Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.

New answers tagged

4

Winning Bug When the board is at this stage and the user gets the next move: | | X | O | X | | ---------------------- | | | O | | | ---------------------- | | O | X | X | | And the user enters 5, the game bugs ...


4

This code is pretty neat. One major improvement would be the addition of some magic methods, like __iter__, __getitem__, __setitem__ and __str__. iter The magic method you'll use the most wil be __iter__. It will allow you to do for node in linked_list def __iter__(self): current = self.head while current: yield current current = ...


2

The code looks nice! Here are my suggestions. Testing Your code passes your test, but there are quite a few bugs that can be easily caught by testing! Make sure that every functionality is tested so you don't miss some bugs. The compiler flags Right now, you are using this command to compile the code: g++ -std=c++17 -g -Wall main.cpp -o main There ...


5

About the code: List& operator =(const List<T>&)=default; and List(const List<T>&)=default; provide excellent opportunity to get double delete with 100% chance of success. Your linked list required data to be copyable and it copies it on usage. It is bad, since now you cannot store data like std::unique_ptr that are not copyable. ...


1

OK, so what I understand, class MassiveDTO will be instantiated sometimes in your application, but those 3 lists can be static and won't change. So solution is create classes with static hard coded lists (3 classes) and just use static reference them in MassiveDTO: public class MassiveDTO { private List<String> company = CompanyDataHolder....


2

So you need to separate the construction of that class from the class itself? This is the Factory Pattern. Data class Boil down to your DTO to ... well the data. public class MassiveDTO { private final List<String> company; private final List<String> partners; private final List<String> biodata; /** * @see ...


0

There are following issues with such approach: If you call getBiodata() before generateLists() you will get empty list. User of this class should know internal implementation (generateLists() breaks encapsulation). If you use setters after generateLists() you will get the state without filled data. I would suggest following: Create dedicated private ...


0

document/comment your code. In the code. re-checking .next in the second loop is unusually defensive do not have a comment repeat what a statement "does" (reset node to point to head): have it illuminate what is achieved/what-for/why something is done (the way it is) (Eyeballing remove_middle_node, it uses O(1) additional space and Θ(n) time.)


3

Welcome to Code Review! Bugs For every node you insert, next is null. Encapsulation Your code is written almost exclusively using C features. First things first, instead of using a single global variable, use a class to encapsulate the data structure. class Stack { public: Stack() = default; Stack(const Stack&) = delete; Stack& ...


4

Do not cast the result of malloc. If your code does #include <stdlib.h>, the cast is redundant. If it does not, the cast just masks the warning, which may lead to hard to find bugs. Prefer sizeof(object) to sizeof(type). The latter leads to the double maintenance problem, in case the type is changed. I strongly recommend to have a constructor-like ...


Top 50 recent answers are included