inheritance

Making Child classes as Non Serializable in java

I have a class which implements Serializable. Now I extends this class and I want this extended class to be non Serializable. So how to do it? For example. I have class A implements Serializable. and i have class B extends A. But I want class B to be Non Serializable. ...

flex binding to a base class property with class inheritance

hi - say that i have a base class called Base, that is Bindable and has a String property like this: [Bindable] public class Base { public var msg:String; } Now, there is a class called Derived: [Bindable] public class Derived extends Base { } i am trying to bind to a mxml component like this: [Bindable] private var d:Derived...

Error when calling the metaclass bases: function() argument 1 must be code, not str

I tried to subclass threading.Condition earlier today but it didn't work out. Here is the output of the Python interpreter when I try to subclass the threading.Condition class: >>> import threading >>> class ThisWontWork(threading.Condition): ... pass ... Traceback (most recent call last): File "<stdin>", line 1, in <module> Type...

java interface extends comparable

Hi all, I want to have an interface A parameterised by T A<T>, and also want every class that implements it to also implement Comparable (with T and its subtypes). It would seem natural to write interface A<T> extends Comparable<? extends T>, but that doesn't work. how should I do it then? ...

Flash MovieClip extend

Question: In Flash ActionScript 3, I extend a MovieClip as show below. But when I create a ToolBar with ToolPictures, and set Xscale and Yscale, then it doesn't resize if I use cMyClip, it works correctly when I use MovieClip. Am I missing something ? Or is extending not the same as inheritance ? package { import flash.display.Sta...

Is there anything composition cannot accomplish that inheritance can?

Composition and inheritance. I am aware that they are both tools to be chosen when appropriate, and context is very important in choosing between composition and inheritance. However, the discussion about the appropriate context for each is usually a little fuzzy; this has me beginning to consider just how distinctly inheritance and po...

Does @AttributeOverride annotation breaks polymorphism?

Hi, I need help with inheritance in JPA I will illustrate my problem with an example: Supose we have an Animal class and a Cat class. @Entity @Table(name = "animal") @DiscriminatorColumn(name="animal_type",columnDefinition="Integer",length=11) public class Animal implements Serializable{ @Id @GeneratedValue (strategy = Generat...

C++ How come I can't assign a base class to a child class?

I have code like this: class Base { public: void operator = (const Base& base_) { } }; class Child : public Base { public: }; void func() { const Base base; Child child; child = base; } My question is: since Child derives from Base (hence it should inherit Base's operator= ), how come when the statement child = base; ...

Should I instantiate a collection or inherit from collection?

I've asked myself this question a number of times when creating classes, particularly those involving collections, but I've never come up with a satisfactory answer. It's a OOP design question. For example, in a checkbook register program say I have a class of BankAccount. BankAccounts contain data involving the Name of the account, the...

inheritance n static variables

Is static variable of superclass avilable to sub-class. i.e i mean static variable of superclass can we access in sub-class without creating object N without using ClassName. ...

Why does overriding a method only occur after I implement an interface?

I've been reading through the book Working Effectively with Legacy Code and I've been playing around with the concept of overriding difficult to test methods in unit tests via the creation of a fake. I put together an example of what I thought would work and it ended up behaving differently than I had been expecting. I think I've just di...

Saving and Retrieving Entities of different types using LINQtoSQL

Disclaimer: Bit of a C# newbie - first Software Dev gig in awhile after being in QA for a couple years. I realize flavors of this question have been asked before (inheritance in LINQtoSQL and the like), but I'm hoping I ask the question differently. In my database, I will have a super-type of "Event" and multiple sub-types: Conferenc...

C# Generics - How do I return a specific type?

Maybe I'm going about this all wrong. I have a bunch of classes that derive from the "Model" class, a base class with a bunch of common properties and methods. I want them all to implement a set of functionality: public abstract void Create(); public abstract T Read<T>(Guid ID); //<--Focus on this one public abstract void Update(); p...

Silverlight custom control inheritance. Reusing the template?

Hi, i have the following scenario: [TemplatePart(Name = GoToEditModeButtonPart, Type = typeof(DoubleClickButton))] public class ValueBoxWithLabel : ContentControl { public const string GoToEditModeButtonPart = "GoToEditModeButtonPart"; #region LabelText Dependency Property ... #region IsInEditMode Dependency Property ... ...

Can I initialize a derived class with an instance of the base class?

Example: public class MyList<T> : List<T> { public MyList(List<T> list) { this = list; // this is basically what I want, but doesn't work base = list; // this also doesn't work } } Any solutions? Or is what I'm trying to achieve simply a bad idea? Motivation: I want to add a custom function to a List object....

Problem inheriting member functions with similar signatures in C++

I have an MFC C++ program that contains two classes, as follows; struct MyStruct { ' ' }; class Class1 { public: virtual MyStruct *MyFunc(LPCTSTR x); virtual void MyFunc(MyStruct *x); ' ' }; class Class2 : public Class1 { public: virtual void MyFunc(MyStruct *x); ' ' }; main() { ' ' CString Str = _T("WTF"); Class2 a; ...

Class Inheritance

Hello, I am trying to get completely to grips with class inheritence in Python. I have created program's with classes but they are all in one file. I have also created scripts with multiple files containing just functions. I have started using class inheritence in scripts with multiple files and I am hitting problems. I have 2 basic sc...

Inheritance and polymorphic-associations in rails

I have a User model, which belongs to Profile (belongs_to polymorphic). One model comes in two subclasses, but the *profile_type* in User always correspond to the parent model. User < ActiveRecord::Base belongs_to :profile, :polymorphic => true SomeProf < ActiveRecord::Base has_one :user, :as => :profile SomeDeepProf1 < SomeProf ...

Where to manage ACL inheritance?

Where should I best manage a hierarchy of ACLs? I see three possibilities to manage a hierarchy of ACLs: 1) The ACLs themselves manage the hierarchy: class Acl { Acl parent; // ... } 2) Constructing a separate tree structure to manage the hierarchy. 3) Using an already existing hierarchy as the implicit hierarchy for ACLs (like...

Inherit Access Control Entries or complet Access Control Lists (ACL)?

I wonder if complete ACLs or only their Access Control Entries (ACE) should be inherited. It would be simple if the children replace the whole ACL, but it would be limitting if only an additional ACE should be added. If ACEs can be inherited, I think I would need negative rights, because otherwise all rights beginning from the root ACL...