Questions tagged [inheritance]
Inheritance is a way to reuse code of existing objects, or to establish a subtype from an existing object, or both, depending upon programming language support.
585 questions
0 votes
2 answers
335 views
C# - Entity handler correct use clean code
I have a question about setting up my service. My main concern is if the design is clean and in order. Whether it meets the SOLID principles and does not spill out on me. I have entities like order ...
2 votes
3 answers
324 views
How do I model this scenario so that it adheres to OOP principles?
I have a Slide class with subclasses referring to the different types of slides (IntroSlide, SummarySlide, etc.): abstract class Slide { String slideType; final String title; final String ...
2 votes
3 answers
271 views
"use auto" and "declare most abstract type", which guideline has higher priority?
According to Why define a Java object using interface (e.g. Map) rather than implementation (HashMap), I know I should declare most abstract type when possible, for example, suppose I'm using an UI ...
5 votes
2 answers
765 views
Is "using active record pattern" a reason to inherit from standard container (eg:vector)?
According to Is it bad practice to use Inheritance to associate methods with a basic container?, I know it is bad to inherit form std containers, mainly because std containers are not designed to be ...
5 votes
4 answers
2k views
If class B extends A, can we say that B depends on A?
Let's say we have 2 (Java) classes: class A {} class B extends A {} To me, saying B extends A and B is dependent on A are both true (but not equivalent) in this situation. My colleague, OTOH, says ...
2 votes
1 answer
398 views
Inheriting a logger
When you define a class, is inheriting a logger such as log4cxx a good design? Assume I am defining a class called MyClass. When I want a logger, I use a pointer to an abstract logger class as a ...
1 vote
4 answers
1k views
What's the alternative to trying to inherit static methods?
I know you can't inherit static methods, and it seems the consensus is that if you feel like you need to, you're doing something wrong. However, I don't know what the alternative is in my case. Please ...
0 votes
5 answers
2k views
Comparing Java objects with different member variables
I have a base class "People" which two other classes inherit from: Employee and Student. The Student class includes a GPA (type double) and the Employee class does not. I have an ArrayList ...