inheritance

Java: Why could base class method call a non-exist method?

class BaseClass { private void f() { System.out.println("Baseclass f()"); } public static void main(String[] args) { BaseClass dc = new DerivedClass(); dc.f(); } } class DerivedClass extends BaseClass { public void f() { System.out.println("DerivedClass f()"); } } In my opinion, the object ...

property inheritance

Public class ClassB : ClassA { } public class GeneralClass { public ClassA test { get{} set{} } } public class specificClass :GeneralClass { public ClassB test { get{} set{} } } As you can see the property test is inherited in specificClass from generalClass but here I want to change the type ...

Why doesn't before_filter work the way I expect with restful-authentication?

My application controller looks like this class ApplicationController < ActionController::Base include AuthenticatedSystem helper :all # include all helpers, all the time protect_from_forgery # :secret => 'sup3rs3cr3t' filter_parameter_logging :password # Here's the interesting bit before_filter :login_required, :except => ...

How do I mimic access modifiers in JavaScript with the Prototype library?

I've been working with the prototype library for some time now and occasionally find myself wishing I had multiple access levels (public, private, and protected). The closest I've come so far is the following: SampleBase = Class.create({ /* virtual public constructor */ initialize: function(arg1, arg2) { // private ...

Strategy Pattern with Different parameters in interface (C#)

I am basically trying to implement a Strategy pattern, but I want to pass different parameters to the "interfaces" implementation (that inherit from the same object) and don't know if this is possible. Maybe I'm choosing the wrong pattern, I get an error similar to 'StrategyA' does not implement inherited abstract member 'void DoSomet...

Inheritance of Interface implementation in Java

I have two questions regarding interfaces in Java. 1) If a class happens to implement all the interface methods of interface I, without declaring itself as implementing them, can it still be used as input into variables of type I? 2) Does a subclass of class A which implements interface I inherits the conformance to that interface, or s...

C# Accessing Inherited members via parent class in a 3D List

Ok this is hard to explain, but here goes. I have a 3D list of objects. The objects type are called CObject, another class CTile inherts CObject. static public List<List <List <CObject>>> CObjList = new List<List<List<CObject>>>(); Ok now lets say that the list is full of information in the correct way. (Can...

Javascript/ExtJS: "Conditional Inheritance"?

We are using ExtJS for a webapplication. In that application, we use the standard Ext.form.ComboBox control when a simple dropdown is required, and the Ext.us.Andrie.Select control when we need a dropdown where you can select multiple values and/or clear the value. Creating either of these always requires a bunch of boilerplate code for ...

Ruby class inheritance of included gems

class Foo require 'somegem' end class Bar < Foo def to_s puts Somegem.somemethod end end Why is this not working/how can I get something like this to work? ...

Problem in the GetDeclaredMethods (java)

hello to all I have a small problem in my code I have 2 classes public class A { public A foo(int a) {return new A();} } public class B extends A{ public B foo(int x){ return new B();} } now in my code I want to print only the method that was declared in class B in this way B b = new B(); Method[] m = b.getClass().ge...

Extension methods on interfaces

I have two interfaces IDto1 and IDto2. IDto2 inherits IDto1. Both interfaces are for DTOs and so I wish to keep "complex" code out of their implementations - I do this by putting a single extension method Initialize in a static class for each interface. So I end up with the following types IDto1, IDto2, IDto1Extensions, IDto2Extensions....

Deeply Nested Inheritance - Bad or Good Practice?

I am in the process of making a PHP web application. I have a situation that I believe would foster a good time for nested inheritance. Anyway, here is my situation: public class RecurringWeeklyEvent extends RecurringEvent { } public class RecurringEvent extends Event { } It does not seem to me that this would be a bad design practic...

how do I get ActionDescriptor from either ActionExecutingContext or AuthorizationContext?

I'm writing a method that just uses the ActionDescriptor property but I can't figure out how to avoid repeating the body of the method so that it can take either an ActionExecutingContext or an AuthorizationContext. Both of these types have an ActionDescriptor property, but they don't inherit it from a common type or interface that I ca...

How to handle generic inheritance

I have this code for example public class BaseClass {} public class DerivedClass1 : BaseClass {} public class DerivedClass2 : BaseClass { } public class DerivedClass3 : BaseClass { } public class GenericBaseClass<T> where T : BaseClass { public List<T> collection { get; set; } } Now I'd like to create a new class which would i...

Descendant non-generic class into Base generic class

Usually I Use interfaces or base classes as paramter types when passing derived objects to a method. For example Method1(ICar car); Method2(BaseClass derivedClass); But what about a Generic base class when the descendant class isn't generic ? public class GenericBaseClass<T> where T : BaseClass {} public class GenericDerivedClass1 :...

How do I specify that an implementing class must contain a particular field?

I would like to write an abstract class (or interface) which either Forces all implementing classes to provide a field (ideally static) of a particular type and name (maybe by throwing a compile-time error if it's missing?), or Automatically provides such fields in implementing classes. An example would be: public abstract class A {...

How relations in UML class diagram inherit?

Hi SO, I was wondering how associations, dependencies and such relations inherit in UML (or let's say, in general). So, in a situation like this: ┌──────────┐ ┌──────────┐ │ ClassA │ │ ClassB │ ├──────────┤ ├──...

Slim version of Large Object/Class

I have a product class which contains 11 public fields. ProductId ShortTitle LongTitle Description Price Length Width Depth Material Img Colors Pattern The number of fields may grow with attributes for more specific product tyes. The description may contain a large amount of data. I want to create a slim version of this product cla...

C++ multiple inheritance off identically named operator

hello Is it possible to inherit identically named operator which only differ in return type, from two different abstract classes. If so, them: what is the syntax for implementing operators what is the syntax for using/resolving operators what is the overhead in general case, same as for any other virtual function? if you can provide...

Why does my class not have a 'keys' function?

class a(object): w='www' def __init__(self): for i in self.keys(): print i def __iter__(self): for k in self.keys(): yield k a() # why is there an error here? Thanks. Edit: The following class also doesn't extend any class; why it can use keys? class DictMixin: # Mi...