Skip to main content

Questions tagged [inheritance]

One of the four pillars of object-oriented programming (OOP), inheritance establishes a "is-a" relationship between objects. For example, a "Cat" object can be treated in code as any other "Animal" object because a "Cat" is-a "Animal".

Filter by
Sorted by
Tagged with
-1 votes
1 answer
117 views

I have a very class heavy approach to writing C++ code, which I don't think is necessarily wrong. However, I often use classes without knowing if I actually need them, which I feel leads to making ...
user290523's user avatar
0 votes
1 answer
109 views

I was trying to come up with some design to subclass built-in exceptions. For simplest case I used something like this: ...
Jakub's user avatar
  • 11
9 votes
3 answers
630 views

Similar to the class for the RAR file, now a class to extract and store the hashes from SFV files. Though this was considerably easier, there has been some code reorganisation: there is now an ...
viuser's user avatar
  • 629
5 votes
2 answers
341 views

The code below implements a class, CountingOStream, whose job is to count the number of characters written to it while also discarding those characters and ...
Scott McPeak's user avatar
2 votes
0 answers
80 views

I have a spring cloud gateway application with this yml structure for request validation: ...
Q2Dev's user avatar
  • 21
2 votes
0 answers
178 views

I've been looking to have "smarter" or "better" enum functionality in C#. There are a few GitHub/NuGet projects out there, but they seem to target newer versions of .NET and I ...
Jesse C. Slicer's user avatar
1 vote
1 answer
252 views

I'm a newbie python developer who accidentally studied the concept of Abstract classes and I found it pretty much helpful to implement due to the SOLID principles. At the very moment of testing and ...
KhodeNima's user avatar
  • 419
2 votes
1 answer
111 views

Problem Statement From the National Institute of Standards and Technology's Office of Weights and Measures, one can find a handy list of all the metric prefixes: e.g. Purpose Name Symbol Factor Name ...
SumNeuron's user avatar
  • 291
0 votes
1 answer
293 views

I have a small Linked list program which I created for just brushing up the concepts. Following is my Node class ...
Jyothish Bhaskaran's user avatar
1 vote
2 answers
100 views

I need/want to extend created array instance, to add extra methods that i see as useful. class.labels.js ...
Marc's user avatar
  • 153
4 votes
1 answer
433 views

Ensuring that some logic is always being run before the user's overriding methods. I'm writing a library and I have some abstract classes that can be binary serialized (and users can subclass them and ...
Saturn's user avatar
  • 409
2 votes
1 answer
542 views

I want to have some classes that would contain arrays of different sizes. I want this to be statically allocated because it is intended for an embedded system. The only good solution I can think of is ...
hellothere's user avatar
2 votes
1 answer
98 views

The objective is to implement the reversed version of StringToDoubleConverter but without writing too many redundancies. I love DRY (Don't Repeat Yourself) design ...
D G's user avatar
  • 135
0 votes
1 answer
514 views

I'd love some feedback on the C++ base class shown below. It's basically a toy problem for a fake video game where the monsters that you have to avoid will all be sub-classed from the class shown ...
tarstevs's user avatar
2 votes
0 answers
130 views

I'm working on a repo the purpose of which is to create and manage a local PostGIS server. (PostGIS is a bit niche, but it boils down to a few extra spatial data types and built-in SQL function. With ...
Tom Hosker's user avatar
6 votes
2 answers
1k views

How can I improve this code or make it tidier? ...
user366312's user avatar
0 votes
1 answer
246 views

The context is a library to represent numbers (in this case integers) by wheighted position by radix powers for every radix R, passed as template argument. These derived types are digits of radix R, ...
Earendil's user avatar
2 votes
1 answer
1k views

We were tasked to do this assignment where there is the base class employee and two derived class part-time and full-time employees. Here is what I came up with: ...
kairodesu's user avatar
3 votes
0 answers
137 views

This code builds the environment for the standard Mountain Car Problem of reinforcement learning. I'm using Python 3.9 with PyCharm and I'm wishing to use type annotations throughout. I'm trying to ...
Robin Carter's user avatar
2 votes
1 answer
104 views

Please review my code and give some improvement suggestions. I wrote code but not to the best standards. I think this site gives some valuable suggestions. This code is for extracting ...
Mohanraj M's user avatar
4 votes
4 answers
3k views

Yesterday I posted my first solution to an interview problem here. I am now aware that I have many weak spots in Java and need to do extensive review before tackling any more interviews. Having said ...
apex2022's user avatar
  • 161
1 vote
1 answer
504 views

I was assigned the following problem: You've gone back in time to 500BC Athens and Socrates wants you to build him an app to help classify animals. Build the classes ...
apex2022's user avatar
  • 161
-1 votes
2 answers
106 views

This code models two vehicle types, with a method to accept a string representing a boost to change speed. How can I optimize performance in inheritance child class? How can I reduce the code inside ...
manas's user avatar
  • 9
1 vote
1 answer
2k views

I saw this post and tried to do my attempt. This is the requirement of task: Design a coffee machine which makes different beverages based on set ingredients. The initialization of the recipes for ...
Learner's user avatar
  • 143
1 vote
1 answer
525 views

I have class structure to read the data from resource bundle (property files). ...
Gaurav Jeswani's user avatar
3 votes
2 answers
221 views

I had a problem at my work that we have some tasks that need to be executed as fast as possible. To do this we implemented them so they are multi-threaded in an ExecutorService. Originally we had for ...
Skrelp's user avatar
  • 73
0 votes
1 answer
60 views

I have the following working code: person.h ...
user avatar
3 votes
2 answers
471 views

I have these two classes and they should remain separate classes, but I have a feeling that this could be implemented more efficiently and with less duplicate code. After googling around I still didn'...
LostHat's user avatar
  • 33
1 vote
2 answers
3k views

I have implemented the below _get_schema method to ensure that schema attribute is always present on the ...
barciewicz's user avatar
5 votes
2 answers
519 views

I have a requirement to fetch data for different types of Users (Customers, Publishers etc) for three different timelines (retro, current, and past), all have different URLs. There is a scheduler ...
Pankaj's user avatar
  • 151
2 votes
0 answers
105 views

My first component ...
Dewanshu's user avatar
  • 129
2 votes
3 answers
331 views

After reading that Data Classes can be considered a code smell, I am shifting from a pattern with many data classes and a single manager class that handles all the instantiation of the classes, to a ...
user avatar
2 votes
1 answer
238 views

I've made a major update to my Noughts & Crosses program, this ISN'T a duplicate! I know it's not good to use system("pause") and system("cls"), however, I just wanted to make ...
George Austin Bradley's user avatar
6 votes
2 answers
193 views

I made this FizzBuzz game for my college class and it's kind of ridiculous, but is suppose to demonstrate chain of command so writing it in a little forloop was out of the question. In case you don't ...
Soco's user avatar
  • 153
3 votes
1 answer
87 views

I want to implement color space logic. So I started with creating some structs: ...
Hrant Nurijanyan's user avatar
4 votes
0 answers
2k views

UPDATE: After getting "a kind of" affirmation from various platforms( my discussions on twitter, reddit, other stack overflow posts,etc) I have written an article on this style of view ...
ansh sachdeva's user avatar
4 votes
1 answer
2k views

I am working on a finite element (FE) code and want to provide multiple material models (20+). In FE applications, the computational domain is subdivided into a set of geometrically simple elements, e....
StefanKssmr's user avatar
4 votes
2 answers
428 views

I'm quite new to object-oriented C#. I wanted to test my knowledge by creating a Dog/Animal classes. I also tried to implement ...
tommy99's user avatar
  • 103
2 votes
1 answer
328 views

Here is a custom class I use to handle different types of orders in Laravel. This question includes the code regarding Order Type A. I want to know whether I can simplify the code. I have different ...
camille's user avatar
  • 147
32 votes
5 answers
5k views

I teach programming, and I currently teach my class about inheritance, abstract classes, and mixins. I wrote this code as an example, and I want to be sure it is as good as possible before I release ...
Infinity's user avatar
  • 525
4 votes
1 answer
3k views

I've written a simple mesh class. The purpose of it is to build a mesh, draw it to the screen, and provide some means by which the mesh can be transformed/scaled, etc. This was done with GLAD, GLFW, ...
Featherball's user avatar
-2 votes
2 answers
120 views

I have a class Main that uses fn(cls, ...) methods from several modules; they're used exclusively by ...
OverLordGoldDragon's user avatar
2 votes
2 answers
134 views

I am working on this project where I like to PreserveIds once inserted into the database. The id are auto incrementing and I return them once the data in inserted. I like to know if there is a better ...
Jefferson's user avatar
  • 423
0 votes
1 answer
120 views

The problem / background I have a project, BusinessProject, that currently stores some static data in memory using the Singleton pattern - we'll call this class ...
laventnc's user avatar
  • 113
1 vote
4 answers
2k views

Exercise: Design a Stack A Stack is a data structure for storing a list of elements in a LIFO (last in, first out) fashion. Design a class called Stack with three methods. ...
Milliorn's user avatar
  • 610
5 votes
1 answer
809 views

I'm studying design patterns from Head First Design Patterns and, in order to get confident, I plan to implement the each pattern in C++ after studying the corresponding chapter. As regards the ...
Enlico's user avatar
  • 531
2 votes
1 answer
117 views

I have two python libraries, let's call them lib and extended_lib, that provide a very similar public API. To be more specific, <...
Patrick Trentin's user avatar
2 votes
1 answer
207 views

Suggestions to better understand when and how is convenient to use OPP. This question is a follow-up question on this post. I have a script that reads an input file. In time, the script may be ...
Stefano's user avatar
  • 55
1 vote
1 answer
194 views

I am a novice of Python and I am trying to understand how to use OOP paradigm to improve my scripts. My scripts usually read some data from a formatted csv file and perform some numerical analysis. ...
Stefano's user avatar
  • 55
-1 votes
1 answer
390 views

Background Apologies for "burying the lead." The questions are in the next section. In my application, the purpose of inheritance is to abstract away complicated logic in the base class template, so ...
Taylor's user avatar
  • 303

1
2 3 4 5
7