Questions tagged [subclassing]
The subclassing tag has no usage guidance.
16
questions
6
votes
4answers
4k views
Which is preferred: subclass double or create extension methods to test (relative) equality due to floating point differences?
I am writing numerical calculation software using .NET C#, which needs to be blazingly fast. There is a lot of fractional math. So using decimal type is pretty much out of the question, given its poor ...
2
votes
2answers
202 views
C++: Achieving a decoupled “Definition is Registration” paradigm for derived classes?
I'm trying to engineer this:
200 subclasses [ Derived Classes ]
After a subclass is defined, I wont need to edit any other file. [ Decoupled ]
Subclass Definition registers itself. [ Definition is ...
1
vote
2answers
94 views
Modeling Class hierarchy that may change during runtime
I've been building an application that processes documents through different filters.
I have a class (or better as an interface for creating test-doubles?) called Document. The Document class ...
0
votes
2answers
145 views
Make a group of classes visible only by a single class
I have a group of classes (let's say B,C,D,E) that basically represent specific operations a user can execute. I would like to have a single point of access for creating these object and launch their ...
0
votes
0answers
38 views
Classification of methods that are only accessible by a child class and its parent
I'm trying to document some of my JavaScript according to this JavaScript Documentation guide and came across member access (private, public, protected). I was wondering what the classification would ...
0
votes
1answer
73 views
Inheritance or composition for a more advanced implementation of a class?
So i have a class called VirtualMouse, it is used to perform mouse actions such as moving and clicking.
public class VirtualMouse
{
public VirtualMouse()
{
}
public void ...
2
votes
2answers
120 views
Object that can set its own subclass/amend its methods with subclass?
I have a database that stores client data. All data is in one table. For each client, there is one row per day. Clients have different kinds of contracts, their data format remains the same, however, ...
0
votes
3answers
2k views
Why do the following enum fields extend their base class or base enum?
Regarding enums in java how I understood is
Sample enum
public enum Strategy {
STRATEGY_A {
@Override
void execute(){
System.out.print("Executing strategy A");
...
0
votes
1answer
60 views
How to organise tree of sub-classes which should interact?
I'm writing a trading framework in MQL and I'm confused how I should organise my class hierarchy.
|-- Terminal (Log)
| |-- Market
| | |-- Chart
| | | |-- Draw
| |-- Account
| | | |...
7
votes
4answers
381 views
Subtyping without adding state or behavior - Bad Practice?
Observation
There are many Exception subtypes that don't have any added state or behavior. For example, ClosedByInterruptException code.
Question
Why is subtyping without adding state or behavior "...
2
votes
2answers
545 views
How to change this implementation to cover drawbacks of Mediator Design Pattern here
I am new to design patterns, here is a classic example of basic mediator pattern that has 3 problems with it, first of all take a look at the application image, diagram, code and description:
We use ...
4
votes
2answers
155 views
Would you use object proxy, extend the class, if else conditions or make a duplicate class for supporting two different API's?
This is not an easy one but here goes. I'm working on adapting a JavaScript project (ACE Editor) to support two different targets but maybe more. Any way I look at it, it looks like a large task and ...
48
votes
6answers
7k views
What would be the disadvantage to defining a class as a subclass of a list of itself?
In a recent project of mine, I defined a class with the following header:
public class Node extends ArrayList<Node> {
...
}
However, after discussing with my CS professor, he stated that ...
5
votes
1answer
16k views
Is calling the superclass constructor in a subclass really important?
The following piece of Python code uses a superclass solely as the repository of functions that one of more subclasses may draw from:
class Class(object):
''' A trivial repository for functions ...
7
votes
1answer
296 views
Is the complexity needed to prevent downcasting from constructor to overridden method worth it?
Invoking non-final instance methods in constructors risks downcasting from a constructor to an overridden method as such:
public class Start {
public static void main(String[] args) {
try ...
1
vote
2answers
239 views
Parameterization vs subclassing
Example taken from : Agile software development : principles, patterns and practices
A new employee is added by the receipt of an AddEmp transaction. This transaction contains the employee's
name, ...