Questions tagged [inheritance]
Inheritance is the system in object oriented programming that allows objects to support operations defined by anterior types without having to provide their own definition. It is the major vector for polymorphism in object-oriented programming.
inheritance
7,297
questions with no upvoted or accepted answers
10
votes
5
answers
3k
views
Using interface Class<T> as keys to get concrete instance values?
I have the following test case which fails to retrieve the values from the Map:
package tests;
import java.util.HashMap;
import java.util.Map;
public class ClassTest {
interface A {}
...
9
votes
0
answers
4k
views
Proper use of polymorphism / inheritance in Open API 3
I am missing something in the proper use of polymorphism in Open API 3.
In the specification document (3.0.2), an example uses oneOf, and optionally the Discriminator block :
MyResponseType:
...
9
votes
1
answer
461
views
Entity Framework 'Update Model from Database' recreating associations between base and sub classes
I am trying to implement a number of base/sub classes using Entity Framework, database first. Following some online tutorials, I have decided to attempt TPT inheritance.
On the database, I have a ...
9
votes
0
answers
1k
views
Autosummary: How to control which methods are used in generated docs?
I am using sphinx to generate my documentation and the autosummary extension takes care of generating little stubs for all classes not explicitly written by myself.
Take the class Foo and assume it ...
8
votes
1
answer
2k
views
Doctrine2 - Inheritance mapping, querying sub-classes
I have joined table inheritance (lets call it Action) and I need to get all records of Action that satisfy the condition, but the fields are in sub-classes ? Is there way to access sub-class fields ...
7
votes
0
answers
904
views
How does collections.Iterable work with isinstance()?
I was wondering why the isinstance function works with collections.Iterable for checking whether the object is iterable, if it isn't a subclass of Iterable.
If we have two classes:
class first_class(...
7
votes
2
answers
3k
views
angular material: extend a MatPaginator without creating a dupe paginator
@Component({
selector: 'app-custom-paginator',
template: '<mat-paginator #paginator pageSize="10"></mat-paginator>',
})
export class CustomPaginator extends MatPaginator {
@...
7
votes
0
answers
159
views
Why doesn't the using declaration in a class that derives from a template work as expected in some compilers?
If you derive from a class template, you have to qualify usages of base class members with either Base:: or this->. This is understandable since a member of the base class is a template-dependent ...
7
votes
1
answer
285
views
How come C# can handle this obviously idiotic object promotion during run time?
I like the C# language very much. I'm just playing around, and would never use the code below in production code. Obviously the compiler is fooled by the layout of the struct. But how come, that the ...
7
votes
1
answer
1k
views
Inheriting from Sealed classes in MATLAB
In MATLAB, one of the attributes of a class (defined after classdef) is Sealed, which means that no class can use it as a superclass (or to be more precise, "to indicate that these classes have not ...
7
votes
0
answers
221
views
Grape entities and Single table inheritance
Let's say i have Base class "Attachment < ActiveRecord::Base" and 2 child classes "Attachment::Video < Attachment" , "Attachment::Image < Attachment".
present Attachment.all, with: API::...
7
votes
2
answers
216
views
Defining abstract generic class with List<?> members
Even trying to come up with a clean title for this is a challenge.
The basic idea is to have two superclasses defined: one for "child" items with a member that references its "parent&...
7
votes
3
answers
3k
views
Use @NamedEntityGraph on attribute from @MappedSuperclass
I tried many different things and did loads of research, yet still fail to get the following working: I want to define an @NamedEntityGraph on an entity, but the attribute I refer to is located in the ...
7
votes
0
answers
1k
views
Multi-Level Inheritance in Joined Inheritance strategy using discriminator for each parent in hierarchy
Consider my classes below
Product (Abstract Root class)
@Entity
@Table(name="PRODUCT")
@Inheritance(strategy=InheritanceType.JOINED)
@DiscriminatorColumn(name="PRODUCT_TYPE")
public abstract class ...
7
votes
1
answer
776
views
How to inherit class properties
I have a CFC that is extending another CFC, and I want to inherit the properties from the super CFC. I am using the extends attribute, but my subclass is not inheriting the properties, however it is ...