Skip to main content
Filter by
Sorted by
Tagged with
Advice
1 vote
5 replies
31 views

I know we can have: <?php abstract class ExtendMe{ abstract public function implementMe(){} } Can we enforce trait usage? <?php trait MyTrait{} abstract class ExtendMe{ abstract use ...
MonkeyZeus's user avatar
  • 20.8k
9 votes
1 answer
568 views

Let's say I have an abstract class with a public abstract method. If I make that method virtual instead of abstract (i.e. provide a default implementation), is that a breaking change? I think not ...
relatively_random's user avatar
Best practices
0 votes
11 replies
223 views

first I must says that I hate templates.... it makes unreadable complex code.... not speaking about 5000000 lines long error messages, with 10000 possibilities and that takes ages to understand for ...
delab's user avatar
  • 9
10 votes
4 answers
758 views

In C++, there are some widely used zero-size base classes used for the purpose of "tagging" subclasses, for example boost::noncopyable. Is there any that is used to mark a class non-...
Ben Voigt's user avatar
  • 286k
4 votes
2 answers
144 views

I have an abstract base class that used to accept a service via constructor injection: export abstract class BaseEditEventClass<T> extends BaseFormClass { constructor(protected _service: ...
Raphaël Balet's user avatar
-2 votes
2 answers
196 views

I have an abstract Python class with a concrete method: class AbstractFoo(abc.ABC): def append_something(self, text: str) -> str: return text + self.create_something(len(text)) @...
Chriki's user avatar
  • 16.6k
0 votes
1 answer
97 views

This question is likely already asked, but I am not satisfied with the answers. I add the link for reference. Previous Question Now, coming to the point, I have six different abstract classes which ...
Aadhil Ahamed's user avatar
1 vote
1 answer
52 views

I'm working on a Django project where I have an abstract Post model that serves as a base for two concrete models: RentalPost and RoomSeekingPost. Both of these post types need to have multiple images....
Hiệp Trần Hoàng's user avatar
3 votes
1 answer
766 views

I'm having trouble implementing a threaded Binary Search Tree in C++. I have a non-threaded tree completely implemented (see below code). What I'm having difficulty with is setting the threads to ...
Boom's user avatar
  • 514
1 vote
2 answers
139 views

I want to create a class that is called from other methods and change the implementation of that class based on some context (like params): Abstract class: class PdfRenderer(ABC): # Something else ...
Mitrajeet Golsangi's user avatar
1 vote
0 answers
112 views

In my class, I have some methods that can be overridden by subclasses, but do not need to be. I like to test my project and generate a coverage report using coverage.py. Because the method of the ...
502E532E's user avatar
  • 599
3 votes
1 answer
87 views

The ObsoleteAttribute can be used in .NET to indicate that a given member or type is going to be removed in a future version. It will trigger compiler warning 612 or 618 on the code that uses the ...
F-H's user avatar
  • 1,223
3 votes
5 answers
225 views

I have classes ProgramA and ProgramB that derive from abstract class Program. I sum them up into an array std::vector<Program*> and I pick a random one from there that runs for awhile. #include &...
Awed2's user avatar
  • 71
0 votes
0 answers
50 views

I don't understand why this code compiles but it gives execution error: Parameter specified as non-null is null: method kotlin.collections.CollectionsKt___CollectionsKt.minus, parameter at kotlin....
zplot's user avatar
  • 35
1 vote
4 answers
168 views

Let's say I have the following classes: public abstract class Animal { public abstract void talk(); } class Dog extends Animal { @Override public void talk() { System.out.println(&...
montag's user avatar
  • 11
1 vote
1 answer
124 views

I have a number of classes all implementing the same interface. In order to create instances of these classes one should not use the constructor but rather a number of static methods which take a ...
Blue Nebula's user avatar
  • 1,246
1 vote
1 answer
53 views

I implemented the classes UtilityElectricityConsumptionModel and UtilityNaturalGasConsumptionModel from the abstract class UtilityConsumptionModel. The UtilityNaturalGasConsumptionModel just has the ...
Ludovic Wagner's user avatar
0 votes
0 answers
27 views

Best Approach to Handle Varying Parameters in Feature-Specific Implementations of an Abstract Repository in Dart I have an abstract Repository<T> class in Dart that defines several methods, as ...
NemesisXVII's user avatar
-1 votes
2 answers
118 views

In the past life was easy, interfaces could not have implementations, abstract classes could. Nowadays (like for 5+ years already lol), the only difference between abstract class and interface in C# ...
sjanisz's user avatar
  • 162
1 vote
1 answer
105 views

I have implemented a factory pattern but Pyre-check trips over the type-hinting, thinking I want to instantiate the mapping dict type hint: type[MyClassABC] Here is a minimum example, also a pyre-...
Rien's user avatar
  • 478
0 votes
1 answer
62 views

I am a beginner in Python coding and I try to learn abstract classes. I have a problem with implementing two exams which extend abstract class Exam, defining contract for diagnostic test. class Person:...
Mark's user avatar
  • 3
-1 votes
1 answer
70 views

I know that private field are not inherited, and when I am creating an object at line #2, the object is being created for Person and then when I set the fatherName, inside the setFatherName() how is ...
Rishab Negi's user avatar
0 votes
1 answer
89 views

Using c++20, I have the following idea to generalize access to multiple chips in a circuit: An interface should allow reading/writing to all chips with different address bits and register sizes (8, 16,...
DEKKER's user avatar
  • 943
0 votes
1 answer
44 views

I have an abstract class like the one below. export abstract class BaseAPI { static readonly [key: string]: | ApiCall<unknown> // Defines a single API call with a generic response ...
b_it_s's user avatar
  • 724
1 vote
1 answer
71 views

I have a Parent Class Parent class Parent{ public String calculate(String input){ // does lots of external system calls and complex calculations } } Then I have an ...
Rajib Sharma's user avatar
1 vote
1 answer
367 views

I have an abstract method which just includes a pass statement, as the method implementation is in another class that inherits from this abstract class. Here is the method: @abstractmethod def ...
imad97's user avatar
  • 286
-1 votes
1 answer
76 views

I have the following structure: class grandparent(ABC): @abstractmethod def get_obj(self): pass class ParentBase(grandparent): def __init__(self, obj1): self.obj1 = obj1 ...
Rezzy138's user avatar
0 votes
1 answer
68 views

Core question explained via code: Say I have an interface public interface IWorker { void DoWork(); } Now, setup an abstract class implementing this interface. I want this abstract class's DoWork() ...
Avery Ferrante's user avatar
0 votes
0 answers
319 views

I want to force all subclasses of a class to implement a property. As I understand it, I have to use abc methods for this use case. I tried the following: from abc import ABC, abstractmethod class ...
PascalIv's user avatar
  • 625
0 votes
2 answers
86 views

I'm going to explain better what I mean. I think what I desire is not possibile, however I'll try. I have a static class who have this method: public static class BaseTypeID { static ulong _id = 1;...
ProtoTyPus's user avatar
  • 1,324
0 votes
1 answer
93 views

I am trying to develop a routine that will run an sql statement and use the results to populate class objects that are derived from an abstract class, something like the following: public static List&...
Richard B. Sorensen's user avatar
3 votes
2 answers
84 views

I am using an arraylist to hold different shape objects that are a subclass of an abstract superclass. The superclass contains two abstract methods: surface_area and volume respectively. After I add ...
Kaleb Weikel's user avatar
-5 votes
2 answers
123 views

I'm trying to use an abstract class as variable type in C# and getting System.StackOverflowException: 'Exception_WasThrown' error when try to read ResultData.ValuesDescription public abstract class ...
DPZ's user avatar
  • 153
0 votes
0 answers
32 views

This is my first question here, so hopefully I'm doing things right. We have an assignment where we basically have to make a mini weather channel (it's supposed to be teaching us more about ...
Jay's user avatar
  • 1
1 vote
3 answers
169 views

If I create an abstract class in python using abc with an abstractmethod as follows and create a concrete class which doesn't use def to override the abstractmethod but instead attempt to set the ...
Lim Jing's user avatar
1 vote
1 answer
39 views

OptionsAndAnswer is the base class. abstract class OptionsAndAnswer( ..., open val options: List<Option> ){ fun validate() { require(options.map { it.id }.distinct().size == ...
Kun.tito's user avatar
  • 485
2 votes
2 answers
75 views

I'm trying to get abstract properties to work, enforcing property getter & setter definitions in downstream classes. from abc import ABC, abstractmethod class BaseABC(ABC): @property @...
Floriancitt's user avatar
1 vote
2 answers
120 views

I have a base class with an abstract virtual function fv() which is only implemented in derived classes. I want to make sure that the fv() of the derived classes is called in or immediately after the ...
user1479670's user avatar
  • 1,355
0 votes
0 answers
18 views

I want to have something like class Parent { @mustBeOverridden func overrideThis(_ s: Source) -> Target { // does not do anything, i.e. it is "abstract" } } class Child1: ...
CocoaNut's user avatar
0 votes
1 answer
122 views

I am currently creating a small plant caring game (Unity Engine 2022.3.40f1). It's properties (genes) are passed onto it's parts as a genome. These properties can be floats, integers or colors. For ...
Arthur Détaille's user avatar
0 votes
2 answers
154 views

I want my abstract base class to have a templated constructor, but can't get it to work without an extra parameter to deduct the type from. I want to do something like this: class Base { public: ...
UniCode's user avatar
3 votes
1 answer
380 views

I am building an app in PySide6 that will involve dynamic loading of plugins. To facilitate this, I am using ABCMeta to define a custom metaclass for the plugin interface, and I would like this custom ...
KBriggs's user avatar
  • 1,498
0 votes
1 answer
63 views

I have an abstract class, Float, that generates concrete subclasses dynamically. I would like to type-hint the return type so that the IDE knows that it's a concrete subtype of Float. That is, when ...
D. Estes McKnight's user avatar
-1 votes
1 answer
94 views

here is an example of a code where i have a virtual class A, with its child A_2 and other classes/functions that have A as argument/return type. In use i could use instead A_2, A_3 ... #include <...
Zelfior's user avatar
0 votes
1 answer
128 views

Preface: Serialization libraries cannot be used due to restrictions in the development environment, and the latest version usable is C++ 11. I have various struct that need to be serialized and ...
cma0014's user avatar
  • 1,599
1 vote
0 answers
30 views

The OfType part of the query doesn't work as expected, and there’s an error when saving changes in the database. Code: using System; using System.Data.Entity; using System.Data.Entity....
huhmuren heriid's user avatar
0 votes
1 answer
98 views

Let's say we have a game, characters in which have special abilities. All abilities share an abstract base type called AbstractAbility. Each character has a list of said base type (List), elements of ...
Who am I's user avatar
0 votes
0 answers
47 views

I have a couple of classes that need to be serializable using DataContractSerializer, however I am trying to create a generic Class called XMLDocument, that allows for a WeatherData, RSSDocument, and ...
TheLostOne21's user avatar
0 votes
4 answers
145 views

I have an abstract class like this : class Thing { public: Thing(); virtual ~Thing(); static QMutex s_mutex; virtual void load() = 0; virtual void translate() = 0; virtual ...
Charles's user avatar
  • 1,329
0 votes
0 answers
77 views

I receive data entered by the user and I need to initialize a class with it that has an abstract parent class. I can do the check before initializing the class, but in this way the class validation ...
vet etv's user avatar

1
2 3 4 5
107