All Questions
Tagged with inheritance design-patterns
690
questions
0
votes
0
answers
16
views
Efficient design solution for handling dynamic marking schemes with multiple levels and subjects
We're developing a grading system for a school with multiple levels (e.g., elementary, middle school, high school) and various subjects within each level (n subjects < 200). The challenge is that:
...
1
vote
0
answers
54
views
Implementing a NON-implementation (example from "Head First Design Patterns")?
In "Head First Design Patterns," there is an example involving flying behavior of ducks that gets refactored because there is a combination of flying ducks (eg Mallards) and non-flying ducks ...
0
votes
0
answers
51
views
What design pattern would this be, and is it a good idea for run-time selection?
We have a very common calculation Compute that can be done multiple ways. These inherit from some IFoo interface. We'll call them FooRed and FooBlue.
class FooRed : public IFoo
{
public:
FooRed() = ...
1
vote
1
answer
31
views
Good structure for cases where only some classes in the inheritance hierarchy need certain fields or functions
I want to know a good structure for cases where only some classes in the inheritance hierarchy need certain fields or functions.
I'm creating a program with the following structure:
class Singleton
{
...
0
votes
2
answers
82
views
Singleton Inheritance - Which object is created?
I've created two classes - a base class and derived class where the base class is a singleton.
When I call the derived class constructor, which object is being created as the static instance? Is it a ...
0
votes
1
answer
89
views
Class inheritance design with protected methods and run time base handlers
Using C#, I got a class called BaseConfigurations which handles CRUD operations. This class also contains a protected method which is used inside the CRUD handling methods:
public class ...
-1
votes
1
answer
85
views
Java : generics, inheritance and best design
I have a basic processing interface :
public interface Processing<T> {
void appendTo(T t);
}
And this inheritance tree :
public class Animal {
}
public class Dog extends Animal {
...
0
votes
0
answers
91
views
Architecture of C++ matrix classes: inheritance or specialisation?
I would like to define a class :
template <class T, std::size_t M, std::size_t N> class Matrix
with simple and classic methods applied to any matrix (std::array<std::array<T, N>, M> ...
0
votes
1
answer
121
views
Code for both static and dynamic polymorphism in C++?
Is there a way so that I can write code as the follows:
IConnection<Socket> s{Socket{...}}; // statically
Connection* c = new Socket{...}; //dynamically
// a heterogeneous list that ...
0
votes
0
answers
45
views
Is it good practice to define a inner memeber accessor operator overload for CRTP template?
This occurs to me that I can add
template<typename T>
class ISock {
public:
Message Recv() {
return static_cast<T*>(this)->Recv();
};
~ISock(){
...
-1
votes
2
answers
68
views
How to create a polymorphic behavior when sub-classes have extra fields, compared with base-class?
Let us assume we have the following hierarchy:
(It's worth mentioning that the example uses Person-Student case just for the sake of simplicity)
class Person
{
public string Name;
public int Age;...
2
votes
0
answers
55
views
How can we reduce a multi-functional class with conditional logic into fundamental classes with specific logic - C# ASP.NET Core
In an ASP.NET Core EF application, I have a CentralDesignObject with many types of related data, and a significant amount of derived / calculated values based on the information applied to the ...
1
vote
1
answer
82
views
Design pattern for handling different sets of inherited variables?
I have a base class that stores all columns of a record of a database. I want to have three child classes that send different fields of that record to different recepients using the Run() method.
But, ...
0
votes
2
answers
108
views
How to make use of a fixed hierarchy of classes for various similar entities, like employee-Manager for company 1,2,3
I have a class say Employee and a subclass (of Employee) say Manager.
There are various methods (and data member) in Employee class related to payroll, employee details, appraisal, etc. Similarly for ...
1
vote
1
answer
47
views
Dynamic Inheritance, some piece of code... could you look and help me to improve my code?
So I have built this piece of code, but it looks like something is wrong in it. Is it not bad practice to creates function which creates class like below?
Should I build some subclasses?
base file
...