Skip to main content
Share Your Experience: Take the 2024 Developer Survey
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,822
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
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.3k
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,431
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
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 ...
Harith's user avatar
  • 7,254
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.3k
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,431
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
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
  • 86
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
  • 17k
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.3k
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,131
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) ...
mpapec's user avatar
  • 1,176
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
  • 62.2k
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,356
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
  • 62.2k
6 votes

Vue 3 audio player

in the method getTracks(): this.tracks =response; this.tracks=response.data.tracks; No need to set ...
Chinedu Lawrence's user avatar
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 ...
Daniel Storey's user avatar
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 ...
Kate's user avatar
  • 6,838

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