29 votes
Accepted

Python - Tkinter - periodic table of chemical elements

I hope you enjoy this bit of code. I did! Your symbols, keywords and values should have capitalised variable names since they're global constants. However, life would be easier if your symbols were ...
Reinderien's user avatar
27 votes

Python - Tkinter - periodic table of chemical elements

Don't optimize the wrong thing You have an excellent review already, so I'll comment on a narrow topic: cramped code layout. For example: ...
FMc's user avatar
  • 12.7k
15 votes
Accepted

Numerical integration in C++: Newton-Cotes formulas

I wonder whether the #include "NewtonCotesFormulas.cpp" at the end of the NewtonCotesFormulas.h header file could be somehow avoided. I used it because without I'd get linking errors. Yea, ...
JDługosz's user avatar
  • 11.3k
13 votes
Accepted

Creating HTTP proxies for services

Create a strategy to find the mapped implementation of the interface provided: ...
Nkosi's user avatar
  • 3,236
11 votes

Numerical integration in C++: Newton-Cotes formulas

Use an enum to give names to choices Consider using an enum, or even better an enum class, ...
G. Sliepen's user avatar
  • 55.5k
10 votes
Accepted

Building car factory with custom features per car

In 30 min I could only create a draft. It's crazy what they requrie in an interview. It usually takes hours to come up with a resonable design. Anyways this design has one very bad blocker that ...
t3chb0t's user avatar
  • 44.3k
8 votes

Chess move validator

Use Standards Use standard notations and representations whenever possible: see Algebraic Notation for example. Avoid Global Variables Board.CHESS_BOARD is a ...
abuzittin gillifirca's user avatar
7 votes
Accepted

Beep-beep I'm a car factory

1) Which of the moves are actually needed here? Since there are only two moves, let's have a look at them: ...
Zeta's user avatar
  • 19.3k
7 votes

Factory pattern using enum

Using enums in Python The posted code doesn't take advantage of most of the benefits provides by enums in Python. The typical use case of enums is to make decisions depending on a given enum member. ...
janos's user avatar
  • 111k
6 votes
Accepted

Simple factory pattern for cooking a pizza

A few thoughts: As an academic exercise, I generally like what you have done. Your code is clear, concise, understandable, largely documented (though doc blocks are inexplicably missing in some ...
Mike Brant's user avatar
  • 9,608
6 votes

Factory for report handlers

Not sure if that's going to improve the maintainability index, but You're misimplementing Inversion of Control. IoC is when your dependency (namely, IReportHandler)...
guillaume31's user avatar
6 votes
Accepted

Factory design pattern for circles and polygons

Sure. You implemented the basic factory pattern. But factories don't get useful to you start using Abstract Factories. SO you can swap out out factory for another ...
Martin York's user avatar
  • 95.1k
6 votes
Accepted

Shape area calculation

I think your names could be simplified. For instance, the ShapeType enum could be: ...
Rick Davin's user avatar
  • 6,277
6 votes

Chess move validator

Thank you for releasing your code! You have some clever solutions and I would like to add few more points to the previous answers. Naming Piece The class Pawn ...
Roman's user avatar
  • 2,813
5 votes

Building car factory with custom features per car

The list of features is a very flexible solution that follows the "composition over inheritance" rule and allows to add features that are not even known yet. However, the downside of that approach is,...
JanDotNet's user avatar
  • 8,538
5 votes
Accepted

Instantiating shapes using the Factory Design Pattern in Java

You could rewrite getShape as follows: ...
coderodde's user avatar
  • 28.2k
5 votes

Factory for report handlers

Some observations: You shouldn't be creating the factory inside the class that uses it. That defeats its purpose! Instead, you should pass the factory to that class's constructor. You shouldn't be ...
Matthew Watson's user avatar
5 votes
Accepted

Instantiating a C++ class based on an enum value

You are suffering from repetition. Repeatedly, and it's mindmeltingly repetitive. What you have is a list of types, which you repeat all over, and the corresponding enum-values. For the sake of ...
Deduplicator's user avatar
  • 19.1k
5 votes
Accepted

Object-oriented calorie counter

I like your code. It is easy to understand and pretty straight-forward. Regarding your question of the measuring units: yes, every variable should have them since you are not operating exclusively on ...
Roland Illig's user avatar
  • 21.3k
5 votes
Accepted

Abstract Factory Pattern Implementation

This code looks fine, it is indeed an implementation of a factory pattern. However, why would both Audio and Video be in the same factory? Apart from having the same responsibility to export something,...
IEatBagels's user avatar
  • 12.4k
4 votes

Instantiating different kinds of error records for a database operation

There are no established scenarios for deriving from this class. MSDN ErrorRecord Which leads me to believe that there's no reason to derive a child class. Instead, change the name of ...
RubberDuck's user avatar
  • 30.8k
4 votes

Factory to construct a FineTime out of many kinds of objects

Eh, the overloading part doesn't help you much, except adding more methods with more code. More importantly, trying the different date options looks, at the moment, quite horrible. Most of the ...
ferada's user avatar
  • 11.1k
4 votes

Factory to construct a FineTime out of many kinds of objects

Overloading! ...
Pimgd's user avatar
  • 22.3k
4 votes

Beep-beep I'm a car factory

Your factory doesn't really make sense in its current form. You might want to consider using a shared_ptr instead of a unique_ptr. Looking at your code, you check your map to see if there is an ...
forsvarir's user avatar
  • 11.6k
4 votes

Instantiating a C++ class based on an enum value

As far as I'm able to understand you might want to have a look at type erasure: ...
The Techel's user avatar
4 votes

Electricity billing system for home in OOP

Attention to Detail What seem like trivial mistakes can be interpreted as a lack of attention to detail. So whilst your interface has a simple typo ...
forsvarir's user avatar
  • 11.6k
4 votes

Factory method to create two kinds of cars based on an enum

Do not name things with data type prefixes clsAutoFactory. No. Instead: AutoFactory Names should be what they are in the ...
radarbob's user avatar
  • 7,554
4 votes
Accepted

Instantiating View Models using a static factory

That class can still be abstracted public interface IAdSummaryMapper { List<IAdSummary> MapAdSummaries(List<AdResult> esResults); } The search ...
Nkosi's user avatar
  • 3,236
4 votes

C++ Template to implement the Factory Pattern

Seems pretty reasonable. I mean, I definitely wouldn't put this in production code because it relies on parsing a class name out of __PRETTY_FUNCTION__, and that's ...
Quuxplusone's user avatar
  • 19.3k

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