Hot answers tagged

22 votes
Accepted

REST API to list books, where null means "everything"

I personally think it's fine, but it helps to turn your thinking around from a "selector" to a "filter". Then, the default is to return all books, and you selectively filter down the set you're going ...
Jon Raphaelson's user avatar
22 votes

Player data collection program

Classes Why do you need a separate class for each game whose data you request? This is very inflexible, should you need to request the data for more or fewer games. Just use one class to represent a ...
ShokoN's user avatar
  • 465
15 votes

If/else produce code duplication

Keep it like that. It is perfectly readable, easy to understand, everything is fine. Naturally you could do some lambda trickery along the lines of: ...
mtj's user avatar
  • 4,792
13 votes
Accepted

Current ISS latitude / longitude position

Currently your code is not re-useable. To make it re-useable you should move the logic inside a function. To do this the function we will have two functions here: ...
Ashwini Chaudhary's user avatar
13 votes

League of Legends Summoner Analysis

find_game_ids is far more complicated than it needs to be. You have essentially two "counters", Idgame and ...
Carcigenicate's user avatar
12 votes

Player data collection program

Abstracting classes In your question you asked how to abstract classes so I thought I would show a concrete example of how this is done. Here is a minimal example of how you could abstract your game ...
akozi's user avatar
  • 221
11 votes

API method to validate Facebook OAuth token

You have a lot of null checks (well, two at least), which I think leads to less readable code. Also, it shouldn't really be necessary to have them. ...
tim's user avatar
  • 25.1k
10 votes

Current ISS latitude / longitude position

The code is clean and understandable. There are only minor improvements that we can apply. use more descriptive variable names: latitude_direction and ...
alecxe's user avatar
  • 17.2k
10 votes
Accepted

General purpose replacement for enum with FlagsAttribute

int NextFlag(string category) I'd expect this to throw when it runs out of flags. I really really don't like that the first flag just happens to be ...
VisualMelon's user avatar
  • 7,421
10 votes
Accepted

If/else produce code duplication

Assuming Update#getMessage() is of type Message and Update#getCallbackQuery() is of type <...
Mario Ishac's user avatar
9 votes

Clean call api from client, with good practice

Design ...
Nick Udell's user avatar
  • 5,197
9 votes

General purpose replacement for enum with FlagsAttribute

Is this as extendable as I think it is? Does it work for multi-bit flags? For instance ...
dfhwze's user avatar
  • 13.9k
8 votes
Accepted

Simple yet Hackable WhatsApp API [UNOFFICIAL]

Here is a collection of things to improve. Code Style Notes Overall, there is a number of PEP8 Code Style violations, like lack of spaces around operators, blank lines, spaces before the ...
alecxe's user avatar
  • 17.2k
8 votes
Accepted

Normalize whitespace and describe string

I don't have much to say, but this stuff does look useful. The types are designed to be exposed to the world, so it's transparent to the consumer and could make the intentions clear. There is one ...
VisualMelon's user avatar
  • 7,421
8 votes

Player data collection program

The other reviewers have already explained how you should re-organize your classes, but I want to expand a bit on how you create them and how it can save you a lot of typing. So we assume that you use ...
Ivo Merchiers's user avatar
7 votes

API method to validate Facebook OAuth token

I am mainly a C# .NET developer, but Java code seems quite clear for me. Your code seems fine, but it might be slightly improved: Here: ...
Alexei's user avatar
  • 1,786
7 votes

Clean call api from client, with good practice

@Nick already has covered some important stuff, so I'd add my two cents. Nick pointed out that : ...
IEatBagels's user avatar
  • 12.4k
7 votes

API method to validate Facebook OAuth token

Is better to write two private (or protected if you want override in future) methods to get a valid auth token and a valid user. ...
Michele d'Amico's user avatar
7 votes
Accepted

A PHP API which has an endpoint for processing a user's facebook login details

A lot of times people post PHP here and it's often very ugly, this is not one of those times. Your classes and design are beautiful, and it's very obvious what your intentions are. You've built a ...
Der Kommissar's user avatar
7 votes

Writing PDF files in C#

Given that the PdfWriter holds a reference to an IDisposable resource (the Stream), it's ...
RobH's user avatar
  • 16.9k
7 votes

HttpClient reusable instance for simple calls on another methods

Dispose Strategy It seems your class doesn't even need to implement IDisposable. Should dispose HttpClient? Single Responsibility I would extract configuration ...
dfhwze's user avatar
  • 13.9k
7 votes

Build a set of REST interfaces using Symfony framework

I'll try to cover the response part. SingleProduct and BundleProduct should be polymorphic. ...
alx's user avatar
  • 486
7 votes
Accepted

Python script to get and save data from a web API

This is pretty good! For the purpose of your job, I would suggest leaving this alone unless or until you decide it's broken in some way. It's certainly "good enough". As a learning ...
ShapeOfMatter's user avatar
6 votes

Responding to API requests with much complexity

Serialization Where there's a switch there is usually an indication of a missing interface. In your case you could perfectly define a serializer interface: ...
t3chb0t's user avatar
  • 44.2k
6 votes

Basic API wrapper around a Restful service

I would personally prefer to use HttpClient directly as it provides full control and perfect testability - see here. We can define our REST API as: ...
Dmitry Nogin's user avatar
  • 6,133
6 votes
Accepted

Using an API to obtain JSON data and get the date string and determine if data is stale

You may also want to look at the Nagios::Plugin module or it's successor, Monitoring::Plugin. In these plugins, the OK, WARNING, CRITICAL and UNKNOWN exit statuses are exported by default, so you do ...
Tim B's user avatar
  • 76
6 votes
Accepted

Reddit Dictionary Bot Python 3

Indentation The indentation within authenticate is non-standard. Here are two standard alternatives: ...
Reinderien's user avatar
6 votes

Player data collection program

One of the more costly bits nobody has mentioned: Cache the result of response.json(). Cache other frequently used things. I.e. write: ...
David G.'s user avatar
  • 1,248
6 votes
Accepted

Using Node.js, Express, and Express Router to implement a very simple REST API

After I examine the codes you have written, I could see some things that are not rightly done. Below are the few things I highlighted: The structuring of the codebase is not okay hence it can be ...
Kater Akeren's user avatar
6 votes
Accepted

Efficiently parsing JSON response data in python

If this were for a job, I'd say you need to potentially translate the JSON soup into well-typed, well-defined models, but it's probably not. In that case, you should still break your logic up into ...
Reinderien's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible