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 ...
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 ...
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:
...
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: ...
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 ...
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 ...
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.
...
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 ...
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 ...
10
votes
Accepted
If/else produce code duplication
Assuming Update#getMessage() is of type Message and Update#getCallbackQuery() is of type <...
9
votes
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
...
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 ...
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 ...
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 ...
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:
...
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 :
...
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.
...
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 ...
7
votes
Writing PDF files in C#
Given that the PdfWriter holds a reference to an IDisposable resource (the Stream), it's ...
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 ...
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.
...
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 ...
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:
...
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:
...
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 ...
6
votes
Accepted
Reddit Dictionary Bot Python 3
Indentation
The indentation within authenticate is non-standard. Here are two standard alternatives:
...
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:
...
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 ...
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
api × 554python × 121
c# × 100
javascript × 93
php × 75
json × 62
rest × 61
java × 55
python-3.x × 34
node.js × 31
object-oriented × 30
beginner × 27
performance × 26
ruby × 24
c++ × 19
jquery × 15
ruby-on-rails × 15
web-scraping × 15
design-patterns × 13
http × 13
library × 13
express.js × 12
client × 12
error-handling × 11
ajax × 11