Skip to main content
13 votes

Supermarket Product Inventory Management with Polymorphic Product Types

First, a Code Review Anti-pattern Please don't do this: record = new String(); This is (barring compiler heroics), creating a brand new empty string literal, ...
AJNeufeld's user avatar
  • 34k
11 votes

Area calculator for shapes as an OOP interview test

I see some things that may help you improve your code. Don't overcomplicate your code The only thing required of the Shape and ...
Edward's user avatar
  • 66.6k
9 votes

Calculate area and perimeter for shapes: polygon, circle, rectangle and triangle

General In many places, your formatting and alignment are inconsistent. You also have typos in your comments and even a couple of typos in the #endif portion of ...
Cody Gray's user avatar
  • 4,557
8 votes
Accepted

Stopwatch that uses the abstract factory design pattern

Okay, after I worked my way through the original code, a few things have become clearer. Since I have never done programming with ncurses I was eager to try my hand ...
sehe's user avatar
  • 1,322
8 votes

Stopwatch that uses the abstract factory design pattern

A few random notes. I don't like the mix between "object oriented" and "procedural" here. If a Digit is supposed to "have a" position, then in no way should it be incrementing the y of that ...
sehe's user avatar
  • 1,322
8 votes
Accepted

Area calculator for shapes as an OOP interview test

For a junior hire, I may have accepted the answer, but I would have pointed out the short comings while discussing the answer, and see if the candidate could adjust the code accordingly. I agree with ...
jxh's user avatar
  • 440
6 votes
Accepted

Simulating dynamic polymorphism in C

Your approach has at least two unfortunate aspects: Your approach to interface->object uses an extra heap-allocation. Adding a new "method" to ...
Quuxplusone's user avatar
  • 19.4k
6 votes
Accepted

Python solution to Mars Rover

For once it is nice to see code which is properly commented and for the most parts is easy to read and follow. Kudos to you for that. However, there are stuff which I'm wondering on why you've done as ...
holroy's user avatar
  • 11.5k
6 votes
Accepted

Free general e-book downloader

Downloader When I think of an ebook-downloader I see something like this: ...
t3chb0t's user avatar
  • 44.3k
6 votes
Accepted

Simple implementation of signals and slots mechanism using templates

[code] uint64_t It should be std::uint64_t, not uint64_t for key indexes (the latter is the C version). Or better: use ...
user673679's user avatar
  • 11.9k
6 votes
Accepted

Implementing different types of light sources in a Graphics project

Why is LightSource inheriting from IMovable and IRotatable if not every ...
Cornholio's user avatar
  • 911
6 votes

Model animals using inheritance in Java, revised

This is better, but you are still missing a lot of basic ideas. I'm going to continue to approach the code review by looking at concepts and suggesting what you need to consider and what you should ...
Mark Bluemel's user avatar
  • 1,562
5 votes
Accepted

Building a model-view-controller application in PHP

I would consider moving your routing definition logic out of .htaccess and into your PHP code. I think you will find it much easier over the long haul to maintain your logic solely in PHP vs. being ...
Mike Brant's user avatar
  • 9,638
5 votes

Polymorphism and inheritance in C99

First of all, the obvious remark is that this needs to be split in multiple files, with a .h/.c pair for each class. Since you haven't done so, you block the possibility to make this truly OO. It is ...
Lundin's user avatar
  • 4,794
4 votes

99 Bottles of Beer using polymorphism

Your approach: Define duplicate objects that contain information about plural and singular forms and what to do next. Access these from a single conditional (your ...
Ryan Mills's user avatar
  • 1,010
4 votes

A vector-like polymorphic container to store objects from a type hierarchy in contiguous memory

This is some really nifty code. I'd be curious to see the full implementation and whether there were any improvements since this question was posted. :) [code] make_aligned Is there a reason for ...
user673679's user avatar
  • 11.9k
4 votes

Free general e-book downloader

I have some issues with your validation. ...
404's user avatar
  • 2,306
4 votes
Accepted

Polymorphism with overrides and base calls simulating an employee

There is one thing I don't line about Employee: you are leaking memory. Person super; should be a pointer, not the object. You ...
Pablo's user avatar
  • 201
4 votes
Accepted

CUDA/C++ Host/Device Polymorphic Class Implementation

nice! The code is generally rather good. I don’t have a lot to say about the language usage in the individual lines. The idea of using an abstract base to do different implementations selected at ...
JDługosz's user avatar
  • 11.3k
4 votes

Implementing different types of light sources in a Graphics project

Overriding RotateX, RotateY and RotateZ to prevent rotation of your point light source is ...
AJNeufeld's user avatar
  • 34k
4 votes
Accepted

A C++17 std::function implementation

Nice, clean and functional. Still, there are a few things: If you don't have to declare a special member-function, just don't: ...
Deduplicator's user avatar
  • 19.3k
4 votes
Accepted

A polymorphic union in C++

I suggest not codifying the derived types suggested in the type. Only note the ultimate base, size and alignment. Thus you are open to later change. Add a templated alias to get the proper type from ...
Deduplicator's user avatar
  • 19.3k
4 votes

Polymorphic deleter for unique_ptr

This Code Does Not Compile I threw together some boilerplate for Integer and IntegerDeleter. The provided code appears to be ...
Davislor's user avatar
  • 8,344
4 votes

Implementation of tree with different node types and faux-polymorphism in C

Remarks for beginners: Never hide a pointer behind a typedef! Never! It makes the code confusing and very hard to read and maintain. You can't unfortunately use a generic ...
Lundin's user avatar
  • 4,794
4 votes
Accepted

Manage Excel Styles with VBA OOP Approach

Code is generally very clean, although I do have a number of reservations with some of the naming: c prefix for class modules, M ...
Mathieu Guindon's user avatar
4 votes

Supermarket Product Inventory Management with Polymorphic Product Types

Is inheritance really the answer? I think it's been covered that you could dynamically build your product instances, but it's not really clear to me why you'd need to. The object model feels a bit ...
forsvarir's user avatar
  • 11.7k
4 votes
Accepted

Cache for mesh objects

I generally favor readability and maintainability over performance until profiling reveals issues. That's a very good mindset to have. I think the lack of elegance in your code comes from the fact ...
G. Sliepen's user avatar
  • 61.7k
3 votes
Accepted

Document Management Properties and Searching

On first glance this isn't bad, though I hate some of the naming. Let's look at some of it in particular to see what's going on: ...
Der Kommissar's user avatar
3 votes
Accepted

polymorphism with object ArrayList

This is missing the point of polymorphism. Its great strength is that you don't need to know or care about the type. With your code, you still need to check type using the ...
Reinstate Monica's user avatar

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