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, ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
6
votes
Accepted
Free general e-book downloader
Downloader
When I think of an ebook-downloader I see something like this:
...
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 ...
6
votes
Accepted
Implementing different types of light sources in a Graphics project
Why is LightSource inheriting from IMovable and IRotatable if not every ...
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 ...
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 ...
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 ...
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 ...
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 ...
4
votes
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 ...
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 ...
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 ...
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:
...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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:
...
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
polymorphism × 117c++ × 50
object-oriented × 37
c# × 23
inheritance × 22
java × 15
beginner × 13
c++11 × 12
interface × 10
design-patterns × 9
.net × 9
c × 7
c++17 × 7
template × 7
c++14 × 6
python × 5
javascript × 5
php × 4
array × 4
template-meta-programming × 4
generics × 3
event-handling × 3
classes × 3
pointers × 3
dependency-injection × 3