Skip to main content

Questions tagged [abstract-class]

An abstract class is a class that cannot be instantiated. They are generally meant to be extended/subclasses and generally have "abstract methods" that must be implement by subclasses.

Filter by
Sorted by
Tagged with
4 votes
2 answers
309 views

While developing my application I faced an interesting situation: I have multiple DTO's which are almost identical in terms of methods, only properties are different. For example I have AccountDTO ...
Viacheslav Ravdin's user avatar
1 vote
2 answers
214 views

I'm developing a data pipeline in Python. We receive a variety of different types of data set that we need to process (e.g. xml, json, csv and some Excel workbooks) - where processing involves parsing ...
henryn's user avatar
  • 119
0 votes
1 answer
1k views

At my org we extensively use @Value.Immutable annotation to generate Immutable classes (usually with builders) for our internal data transfer objects (DTOs). In our codebase I've seen both interfaces ...
y2k-shubham's user avatar
3 votes
3 answers
2k views

I have many abstract classes that describe many abstract ideas and objects. These classes have many complex relationships with each other, and I realize that while writing code with some of the ...
nreh's user avatar
  • 161
0 votes
0 answers
70 views

I created an abstract class to represent a vertex in a tree structure. Later, a requirement was introduced where certain types of vertices are not allowed as descendants of certain other vertices. So ...
Cave Johnson's user avatar
2 votes
4 answers
2k views

I think that I've taken the Open-Closed and Single Responsibility principles too far. Previously, I had one huge static class containing every method that has C# talk to stored procedures on my SQL ...
J. Mini's user avatar
  • 1,015
0 votes
1 answer
1k views

In the python docs, I read this about the ABC (abstract base class) meta class: Use this metaclass to create an ABC. An ABC can be subclassed directly, and then acts as a mix-in class. I don't come ...
henryn's user avatar
  • 119
2 votes
2 answers
170 views

Consider the following python3 code: from abc import ABC, abstractmethod class Food(ABC): _food_factory_map = {} _recipes = {} @classmethod def getFood(cls, foodName): return ...
raghavj's user avatar
  • 29
0 votes
3 answers
2k views

Is it code smell to make an abstract child class implement a method, which overrides a parent method, whose only purpose is to call another abstract method? I want to make sure that anyone who ...
Cave Johnson's user avatar
0 votes
0 answers
342 views

I am trying to create a spell casting system for an auto chess game. I find myself not knowing which direction to go in my design. I started out with a Spell as a scriptable object that contains a ...
Jeff's user avatar
  • 1,874
2 votes
3 answers
681 views

I have a doubt about what would be the right OOP approach for implementing classes that do similar stuff with different parameters. To provide a simple example, I would use two polynomial classes, ...
ThePunisher's user avatar
-1 votes
2 answers
194 views

I have the following UML class diagram in a C++ context. I want to make sure that a Customer can have only one role: Can the Customer now only assume one role, and what does <<abstract>> ...
Seonix's user avatar
  • 11
2 votes
1 answer
142 views

I'm reading a book on design patterns. On proxy pattern the code are following: class SensitiveInfo: def __init__(self): self.users = ['nick', 'tom', 'ben', 'mike'] def read(self): ...
Yehui He's user avatar
1 vote
3 answers
720 views

I have a class which aggregates some temporal data from a database and provides a bunch of methods to query said data. It looks like this: public class InfoProvider { public IEnumerable<...
Bill Tür stands with Ukraine's user avatar
-2 votes
3 answers
1k views

It can be found in many advices on topic that having Singletons is an anti-pattern. Especially for cases of testability. Can someone please advice/critique on this way (please see code below) of ...
psb's user avatar
  • 101
1 vote
1 answer
249 views

I have an Abstract Base Class AbstractModel class AbstractModel { public: struct predictionStructure{}; virtual predictionStructure predict(CompanyLib::Matrix<double> data) = 0; std::...
casey ryan's user avatar
0 votes
1 answer
1k views

Until today I had a static C++ library with no separation between the public interface and internal headers. My other apps just linked to it, included the required headers, and used whatever they ...
user3717741's user avatar
4 votes
4 answers
1k views

I've run into the following situation multiple times, and in every case have struggled with the naming. I want a class to force its children to implement a method, but I want the parent class to be ...
Adam B's user avatar
  • 1,660
0 votes
3 answers
295 views

I have the finance application where we can have different types of transactions, like balance enquiry, funds transfer, and pin change etc. Now the Transaction is a base class, and there are specific ...
rahul sharma's user avatar
2 votes
2 answers
2k views

From what I understand, an abstract data type is basically some data and what we are allowed to do with that data (ex. a list with a set of data and an attribute size and the functions get(), set(), ...
qwerty_99's user avatar
  • 173
9 votes
4 answers
3k views

The question is: interface Animal { void eat(); } class Lion implements Animal{ public void eat(){ //do somethng } } class Test { public static void main(String[] args) { ...
beginner_coder's user avatar
3 votes
1 answer
619 views

I'm working on an app where we need to use different authentication flows depending on how the user is accessing the app. I want to make sure that there is only one instance of the authentication ...
YSA's user avatar
  • 141
1 vote
1 answer
127 views

For teaching purposes, I'm trying to replicate in a more faithful way from this conceptual UML (from wikipedia): In a "so-so" real world example, in my case, families of Loans and Insurances: So, can ...
celsowm's user avatar
  • 253
0 votes
1 answer
523 views

I am reading Domain Driven Design by Eric Evans and there are 2 sub-chapters - Abstract Core & Pluggable Component Framework - that seems to me to refer to the same concept. I believe that there ...
Victor's user avatar
  • 133
1 vote
5 answers
8k views

I'm fairly new to programming. At school I am currently learning to program with Java. I want to build an application where i can store my collection of books, records, boardgames and such. Started ...
Vogel's user avatar
  • 21
24 votes
4 answers
7k views

Back in the 2000s a colleague of mine told me that it is an anti-pattern to make public methods virtual or abstract. For example, he considered a class like this not well designed: public abstract ...
Peter Perot's user avatar
5 votes
1 answer
2k views

I have one interface (let's say in C++) that has been implemented by some derived classes. Let's suppose that the interface is like this: class IBase { virtual bool method_1() = 0; virtual long ...
TonySalimi's user avatar
2 votes
1 answer
271 views

I want to use a physics engine (like bullet or PhysX) in my program, however I want to hide the actual physics engine from it, so I can easily swap it out with another during run-time (e.g. switch ...
user225183's user avatar
3 votes
1 answer
4k views

I'm defining a class structure for persisting to our cassandra database, and I'm unsure about using a combination of an abstract class and an interface. I have two concrete classes, one for persisting ...
Eoin's user avatar
  • 141
3 votes
1 answer
11k views

I want to test an abstract class with: Pure virtual methods that should be overridden in sub-classes Non-pure virtual methods that use the pure virtual methods (as opposed to this question) class Fu { ...
pooya13's user avatar
  • 187
4 votes
2 answers
117 views

Suppose of this question the following: I'm in full control of this project I'm writing a media player Obviously, a media player will allow a user to adjust the volume, so I might have a class that ...
user avatar
17 votes
4 answers
4k views

I currently have two derived classes, A and B, that both have a field in common and I'm trying to determine if it should go up into the base class. It is never referenced from the base class, and say ...
samus's user avatar
  • 475
1 vote
1 answer
103 views

So I have a requirement for something like this: The client shouldn't be aware of how the actual classes are implemented or constructed. The classes implement a common interface So I used Factory ...
Zoso's user avatar
  • 251
3 votes
5 answers
1k views

I have an abstract class Dog and multiple subclasses (Beagle, Labrador, Bulldog...) extendig it. I have a DogHouse that can store a Dog. My problem is that when I put for example a Beagle into a ...
tom's user avatar
  • 149
1 vote
3 answers
5k views

For the past few days I've been researching the relationship of abstract classes and dependency-injected via the constructor classes. It appears that any time that I can have a dependency-injected ...
Liarokapis Alexandros's user avatar
1 vote
3 answers
706 views

I have an abstract base class that is inherited by several different other types. They were all using a type injected into their constructor. So I moved this property in to the abstract base class. ...
DasDave's user avatar
  • 121
13 votes
5 answers
6k views

I have a class with some default/shared functionality. I use abstract class for it: public interface ITypeNameMapper { string Map(TypeDefinition typeDefinition); } public abstract class ...
Konrad's user avatar
  • 1,569
32 votes
2 answers
6k views

Although this isn't mandatory in the C++ standard, it seems the way GCC for example, implements parent classes, including pure abstract ones, is by including a pointer to the v-table for that abstract ...
Clinton's user avatar
  • 1,093
2 votes
1 answer
113 views

So I've got this java assignment for college and was just wondering if anyone here could give me some feedback as to what I've been thinking some of this means. I've got a .csv file with building ...
screencut's user avatar
21 votes
4 answers
4k views

As a C++ developer I'm quite used to C++ header files, and find it beneficial to have some kind of forced "documentation" inside the code. I usually have a bad time when I have to read some C# code ...
Dani Barca Casafont's user avatar
0 votes
3 answers
410 views

I have bunch of keys and values that I want to send to our messaging queue by packing them in one byte array. I will make one byte array of all the keys and values which should always be less than 50K ...
user1950349's user avatar
2 votes
2 answers
976 views

Sometimes i have code along the lines of this: public abstract class A { protected abstract void DoSomething(); }   public abstract class B : A { /// <...
Dbl's user avatar
  • 129
0 votes
1 answer
541 views

I need to design a program in Java which calculates arithmetic expressions (only addition or subtraction). Requirements: 1) abstract class Expression which contains abstract method calculate()...
Yos's user avatar
  • 167
3 votes
1 answer
534 views

I'm doing the exercise 10.1, page 476 from the book Java: How To Program, Early Objects by Paul and Harvey Deitel (10th Edition). Modify the MyLine, MyOval and MyRectangle classes of GUI to create ...
Yos's user avatar
  • 167
2 votes
2 answers
7k views

I've a bunch of classes where one is Abstract class. I draw few derived class from that Abstract base class. For example, class IBase{ public: *register(): bool* *update(): bool* }; class Derived:...
meAbab's user avatar
  • 39
11 votes
6 answers
7k views

I am troubled lately about the use of abstract classes. Sometimes an abstract class is created in advance and work as a template of how the derived classes would work. That means, more or less, that ...
Alexandros Gougousis's user avatar
2 votes
1 answer
2k views

We are using Abstract Factory design pattern in our project, as the project became complex, most of the time the concrete class functionality need to separate to multiple class. As the following code ...
ZijingWu's user avatar
  • 1,077
9 votes
3 answers
6k views

I come from a self taught background and am trying to shore up my weaknesses in OOP, specifically C# and class design. I've been reading Code Complete 2 and it became apparent that I'm not following ...
Brian Ge's user avatar
  • 101
5 votes
1 answer
449 views

I am considering using a strategy pattern for configuration file management, that way I can support some legacy configs. I feel pretty solid on the overall design (as its pretty standard strategy ...
ÁEDÁN's user avatar
  • 153
1 vote
2 answers
642 views

Let's say there are classes D1, D2, etc. describing different types of an abstract class D. Let's say there are SenderReceiver classes describing different ways of communicating for each D1, D2, etc.:...
Mark Lodato's user avatar