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 ...
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 <...
10
votes
Accepted
A String View Library in C
Only include the header files that are required:
#include <stdbool.h>
#include <stddef.h>
#include <stdio.h>
It is useless to include both ...
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 ...
8
votes
A remote trading bot that runs on the CLI - first C++ project
The API class:
There are two things I would change here.
1: Use the command pattern.
2: Don't pass strings around as actions.
The Command pattern
This is basically where you set up a container with a ...
7
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 ...
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 ...
7
votes
A remote trading bot that runs on the CLI - first C++ project
Looking at the "Password" class.
You are using the singleton pattern. But not well.
This:
...
6
votes
Using an API to obtain JSON data and get the date string and determine if data is stale
Just a few quick remarks,
# $opts{t} = 60 unless (defined $opts{t});
$opts{t} //= 60;
(check perldoc perlop for // operator)
...
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 ...
6
votes
Vue 3 audio player
in the method getTracks():
this.tracks =response;
this.tracks=response.data.tracks;
No need to set ...
6
votes
Accepted
Vue 3 audio player
Firstly, just want to say great job in creating your audio player! (I think I may have commented on one of the earlier issues you posted).
Secondly there is nothing "wrong" with your code ...
6
votes
Accepted
A Python-program that makes successive API-calls
Sessions
When you are making repeated requests against a host, you should use requests.Session(). Sessions make it easy to persist cookies, headers etc and improve performance by reusing TCP ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
api × 557python × 123
c# × 100
javascript × 90
php × 75
json × 62
rest × 62
java × 55
python-3.x × 34
object-oriented × 33
node.js × 29
beginner × 28
performance × 27
ruby × 24
c++ × 22
jquery × 15
ruby-on-rails × 15
web-scraping × 15
library × 13
design-patterns × 12
http × 12
error-handling × 11
ajax × 11
express.js × 11
flask × 11