inheritance

Class inheritance naming

I want to inherit the DevExpress ComboBoxEdit control, and am wondering if naming my class the same as the DevExpress class is bad practice. Here's the derived class declaration: using System; using System.Collections.Generic; using System.Text; namespace MyApplication.Components { public class ComboBoxEdit : DevExpress.XtraEditor...

How can I best deal with this COM inheritance issue? (C# => VBScript)

[ComVisible(true)] public interface InterfaceA { [DispId(1)] string Name { get; } } [ComVisible(true)] public interface InterfaceB : InterfaceA { [DispId(2)] void SetText(string text); } [ComDefaultInterface(typeof(InterfaceB))] [ComVisible(true)] public class ClassA : InterfaceB { // ... } I'm consuming these objects in VB...

Polymorphism in Django

I have the following models. How do I get access to the unicode of the inheriting tables (Team and Athete) from the Entity table? I'm trying to display a list of all the Entities that displays 'name' if Team and 'firstname' and 'lastname' if Athlete. class Entity(models.Model): entity_type_list = (('T', 'Team'), ('A', 'Athlete')) ty...

C#: new versus override

Wondering what the difference is between the following: Case 1 : Base Class public void DoIt(); Case 1 : Inherited class public new void DoIt(); Case 2 : Base Class public virtual void DoIt(); Case 2 : Inherited class public override void DoIt(); Both case 1 and 2 appear to have the same effect based on the tests I have ra...

Java Multithreading and Inheritance

class A implements Runnable class B extends A Under these circumstances B IS A Runnable. Is it valid to write: class B extends A implements Runnable If it is valid, will the run method in B override that of A? What could be the possible scenarios? I'm uh confused... ...

Is it possible to detect class context in an inherited static method?

OK, that title is a little unclear, but I can't think of a better way of putting it, other than explaining it... Say I have a class Animal, with a static, generic method: public static T Create<T>() where T : Animal { // stuff to create, initialize and return an animal of type T } And I have subclasses Dog, Cat, Hamster etc. In or...

Can I change a private readonly inherited field in C# using reflection?

like in java I have: Class.getSuperClass().getDeclaredFields() how I can know and set private field from a superclass? I know this is strongly not recommended, but I am testing my application and I need simulate a wrong situation where the id is correct and the name not. But this Id is private. ...

Python: List all base classes in a hierarchy

Given a class Foo (whether it is a new-style class or not), how do you generate all the base classes - anywhere in the inheritance hierarchy - it issubclass of? ...

Acceptable to use virtual inheritance to prevent accidentally creating a diamond?

This is a simplification of some real code, and a real mistake I made when I didn't realize someone else had already implemented Foo and derived from it. #include <iostream> struct Base { virtual ~Base() { } virtual void print() = 0; }; struct OtherBase { virtual ~OtherBase() { } }; struct Foo : public Base { // better to us...

HAML Inheritance

I am new to haml and want to do some inheritance, but I don't know whether it is possible with haml or not. I have 2 separate haml files as below === file1.haml %p This is haml1 === file2.haml %h1 This is haml2 *** I want to have a file.haml which inherit from file1.haml and file2.haml. Is it possible to do it with haml? ...

What will be a good minimalistic Javascript inheritance method?

I'm rewriting a JavaScript project, and I want to be able to use object oriented methodologies to organize the mess that the current code is. The main concern is that this JavaScript is supposed to run as a widget inside 3rd party websites and I can't have it conflicting with other JavaScript libraries that other websites may use. So I'...

Should the Applicant class "require 'mad_skills'" or "include 'mad_skills'"?

Also, what does "self.send attr" do? Is attr assumed to be a private instance variable of the ActiveEngineer class? Are there any other issues with this code in terms of Ruby logic? class Applicant < ActiveEngineer require 'ruby' require 'mad_skills' require 'oo_design' require 'mysql' validates :bachelors_degree def qual...

Using log4j with inherited classes

I am instantiating a log4j object inside of a class which inherits most of the methods and attributes from a parent class. Right now I'm getting logging messages from the subclass only. How can I get logging messages to output in both the super class and subclass? EDIT: The way I am do the logging is that I have an instance variable i...

Is it ok to use reflection to get property names and values in a base class?

I am using the following code to save an object and all its properties to a db. It saves me from having to create a save method in every business object. The code in my base class is: public void Save() { List<SqlParameter> Params = new List<SqlParameter>(); foreach (PropertyInfo Property in this.GetType().GetP...

Is there a way to determine what type a class is an instance of in Java?

Say I have 3 classes like so: class A {} class B extends A {} class C extends A {} Would it then be possible to determine whether a particular object was an instance of A, B, or C? I thought that something like this might work: if (myObject.getClass().isInstance(B.class)) { // do something for B } else (myObject.getClass().isIns...

Using boost::shared_ptr within inheritance hierarchy

Imagine the following situation: class IAlarm : public boost::enable_shared_from_this<IAlarm> { boost::shared_ptr<IAlarm> getThisPointerForIAlarm() { return shared_from_this(); } void verifyThis(int); // called by Device }; class Alarm : public IAlarm { Alarm( boost::shared_ptr< Device > attachedDevice){ att...

How can I extend te MembershipUser class w/o multiple inheritance?

At the top level I have a Person class. Next I want .NET's MembershipUser class to inherit from it, because a member is a person. However I want to extend the MembershipUser class which means, I think, I need to create my OWN MembershipUser class which inherits from MembershipUser and then adds my own properties. But once I do that, I ca...

Is it possible to return a derived class from a base class method in C++?

I would like to do this: class Derived; class Base { virtual Derived f() = 0; }; class Derived : public Base { }; Of course this doesn't work since I can't return an incomplete type. But neither can I define Derived before base, since I can't inherit from an incomplete type either. I figure that I could use templates as a workar...

How do you extend the MembershipUser class?

I want the class inheritance to look like this... Person -> MembershipUser -> User Person & User are my own classes. What is the syntax in ASP.NET 2.0 for MembershipUser to inherit my Person class. If I have to create a new class that first inherits MembershipUser, then I have the problem of double inheritance. ...

JPA Inheritance demands ID in subclass

Hello Everyone I have a problem with my jpa domain model. I am just trying to play around with simple inheritance for which I use a simple Person base-class and and a Customer subclass. According to the official documentation (both, JPA and EclipseLink) I only need the ID-attribute/column in the base-class. But when I run my tests, I al...