Tagged Questions
2
votes
2answers
103 views
Wrapping constructor arguments
Given a base class with around 25 or so subclasses, I have found that adding an argument to the base constructor is painful.
protected AbstractController(Service1 s1, Service2 s2, Service3 s3){ ... }
...
0
votes
2answers
215 views
Can an object call a method on it's immediate descendant? [closed]
I have an inheritance hierarchy three deep : an abstract base class, from which I derive another abstract class, call it the intermediate class, from which will derive possibly a large variety of ...
1
vote
1answer
160 views
Should I use inheritance or an interface?
So in a nutshell I have an abstract class :
public abstract class Member
{
public string PCode { get; set; }
public string Reference { get; set; }
public DateTime? ElectedDate { get; set; }
}
And ...
1
vote
3answers
455 views
Should utility base classes be avoided
Knowing that C# doesn't support multiple inheritance, is it considered bad form to write a utility base class?
Some initial thoughts:
I could create an interface and a concretion, but then the ...
0
votes
1answer
184 views
Can we say that Java or C# have unified inheritance trees?
Can we say that Java or C# are OO languages with a unified inheritance tree/unified type system?
By unified inheritance tree/unified type system I mean that every class derives implicitly or ...
3
votes
2answers
230 views
Help with inheritance hierarchy design
I'm having trouble designing an inheritance hierarchy.
In the figure:
Base class:
This uses the Template Method.
Contains core logic/algorithm that
calls virtual/abstract methods
Derived ...
33
votes
3answers
1k views
Does Java development typically involve more subclassing than C#/.NET?
I've recently started looking at Android development. This has brought me back into the world of Java software development. The last time I worked with Java, I'll admit, I didn't understand OOP nearly ...
5
votes
9answers
1k views
How can designing for inheritance cause extra cost? [closed]
So I wanted to inherit from a sealed class in csharp and got burned. There is just no way to unseal it unless you have access to the source.
Then it got me thinking "why sealed even exists?". 4 ...
2
votes
1answer
2k views
Adding base-class (inherited) functionality to classes that you don't control
I have a set of classes from a 3rd party library. These classes use an inheritance structure to share logic. I would like to add a layer of abstraction in the middle of their inheritance tree to add ...
1
vote
3answers
325 views
Does non-virtual-by-default lead us to composition-over-inheritance?
There are some design guidelines about testable code in “The Art of Unit Testing”. The first one is “Make methods virtual by default”. I’m curious to know your idea about non-virtual-by-default ...
0
votes
3answers
2k views
What is good practice when inheriting static classes isn't possible/allowed
I am developing a project in C# and due to a design decision it is not possible to have a static class inherit another static class. But I have, in my opinion, a case where this would make sense.
I ...
0
votes
1answer
115 views
Refactoring classes with ref to themselves
How can I refactor this code?
class Node
{
public Node Parent { get; set; }
}
class AVLNode
{
public AVLNode Parent { get; set; }
}
I tried to use inheritance, but then I have to use type ...
1
vote
2answers
369 views
What principle of OOAD is this pattern breaking?
I'm trying to make a case for not putting the structure in the parent BaseModule class I've shown below. I'm more for a Strategy Pattern, and minimizing inheritance in favor of has-a relationships, ...
2
votes
5answers
4k views
How to create a common interface for classes with different subsets of members
Don't know how to put it, But I'll try to be as clear as possible
I have a project in which I am creating lots of classes and those classes have some common properties and methods but those methods ...
4
votes
1answer
474 views
Any valid reason to Nest Master Pages in ASP.Net rather than Inherit?
Currently in a debate at work and I cannot fathom why someone would intentionally avoid Inheritance with Master Pages.
For reference here is the project setup:
BaseProject
...
5
votes
3answers
1k views
When calling a method should we use base.methodname and this.methodname?
In C#, with an inherited class set -- when calling a method should we use keywords 'base.methodname and this.methodname'... irrespective of whether it is a overridden method or not?
The code is ...
17
votes
3answers
13k views
Best design for Windows forms that will share common functionality
In the past, I have used inheritance to allow the extension of Windows forms in my application. If all of my forms would have common controls, artwork, and functionality, I would create a base form ...