inheritance

UI design pattern for true/false/null (for inheritance of values)?

Hi there. I'm trying my best to figure out a succinct, straightforward widget, using standard UI widgets available in any toolkit (e.g., checkboxes, radio buttons, or listboxes), that could model a true/false/null value. Why am I trying to do this? I'm storing a tree in a database (go ahead, criticise me for storing hierarchical informa...

Iterating & containers of smart pointers

I have a container of smart pointers to mutable objects. I have to write two *for_each* loops, one for accessing the objects as read-only data and another for mutable data. The compiler is telling me that std::vector< boost::shared_ptr<Object> > is not the same as std::vector< boost::shared_ptr<const Object> >, note the const. Here ...

Should I establish inheritance at compile-time rather than runtime, and if so why?

AFAIK inheritance in Perl is usually set up like this: package Mule; our @ISA = ("Horse", "Donkey"); Are there any examples where use base (or use parent) is better instead? ...

Where to learn how JavaScript based inheritance works?

Hi, I'm trying to write a software in JavaScript, but I'm having hard time trying to get the idea of all this prototype and other wicked looking inheritance stuff. What I would like to know are the different ways to get inheritance, and the pros and cons of each. ...

Implementing unsafe Java interfaces

I've ran into a problem recently while developing with Spring Security. It has an interface GrantedAuthority with following signature: public interface GrantedAuthority extends Serializable, Comparable And as for Java 1.5 and later, the interface Comparable takes a type parameter T, which is omitted in Spring Security libraries (obvio...

Java: how do you call this multiple inheritance ambiguity?

Here's an example using multiple interface inheritance in Java and there's an issue. Note that I fully know why there's an issue and this is not the point of my question. The question is about how you name this particular multiple interface inheritance ambiguity, if there's a name for it. For example, in C++, the ambiguity that arises...

How to get a constructor function to inherit from a constructor function in Javascript?

Hi all, So I'm learning Javascript and all its' prototype goodness, and I am stumped over the following: Say I have this var Animal = function (a, b, c, d, e, f, g, h, i, j, k , l, m, n){ this.a = a; this.b = b; //...etc... }; var x = new Animal(1,2,3....); Now how do I create a Cat constructor function that inherits from ...

How can I make a user control extend a class that extends UserControl?

I want to attempt an MVC design for my little app. I have a normal Csharp class ViewBase which extends UserControl. It's a single .cs file. I have multiple classes that I want to extend ViewBase. These are actual UserControls so they have a code behind .cs file and a .xaml file. However, CSharp tells me that for these classes, their b...

Overiding Static Classes in C#

I have the following class with static properties and methods which helps manage users on a website. I want to be able to re-use this class among other projects by overriding some properties. public class Account { public static string sessionName = "Account"; public static string tableName = "Accounts"; public static boo...

How to create inheritance based serialization mechanism?

Hey everyone, I whould like to creat a serialization mechanism, to work on a variety of entities, all of which are based on a few base-classes. Now I want to work with DataContractSerializer, so I need to mark all my classes with [DataContract]. but I dont want to do that because that is a big room for error for other members of my tea...

Inheriting from DataSourceControl does not produce an IDataSource

I am trying to create a custom datasource control. I have been following this article to the letter (I think...). I have a skeleton / basic implementation of my datasource, however when I declare it in the markup and try to statically bind it to a gridview, I receive the following error: The DataSourceID of 'grdVw' must be the ID o...

Interface Inheritance: Method does not show up!

I've got an interface inheritance issue that has been vexing me for some time. It doesn't seem to make any sense, and I can only conclude that I'm missing something fundamental. Overview The code below is from part of a fluent interface for our ORM tool. It provides a SQL-like syntax for pulling data from the database. You don't have t...

EF 4.0 Code only assocation from abstract to derived

Using EF 4.0 Code only i want to make an assocation between an abstract and normal class. I have class 'Item', 'ContentBase' and 'Test'. 'ContentBase' is abstract and 'Test' derives from it. 'ContentBase' has a property 'Item' that links to an instance of 'Item'. So that 'Test.Item' or any class that derives from 'ContentBase' has an...

Class Inheritance through Multiple Classes

Hello, I have 3 classes and I run the first class and declare a variable in the second class and want the 3rd class to be able to print out this variable. I have code below to explain this more clearly. from class2 import Class2 class Class1(Class2): def __init__(self): self.value1 = 10 self.value2 = 20 def a...

c# inheriting generic collection and serialization…

Hi Guys with reference to c# inheriting generic collection and serialization… question If you are providing a paged collection it is useful to pass back the total available so the client can set up they paging control. Does anyone know a nice way to achieve? Also why is this "By Design" seems pointless. Cheers. ...

Is there a way to hide the methods partially in child classes?

This question seems weird, but i came across this question in one of the interviews recently. I ve been asked, is there a way in c# to hide the methods partially in a inherited child classes?. Assume the base class A, exposed 4 methods. Class B implements A and it will only have the access to first 2 methods and Class C implements A wi...

Why User model inheritance doesn't work properly?

I'm trying to use a User model inheritance in my django application. Model looks like this: from django.contrib.auth.models import User, UserManager class MyUser(User): ICQ = models.CharField(max_length=9) objects = UserManager() and authentication backend looks like this: import sys from django.db import models from django...

C# Generics - Find correct concrete class depending on object type

I have my domain model with several NewsType's which are subclasses of NewsItem as shown below (simplified): public abstract class NewsItem : Entity { public virtual Account Account { get; set; } public virtual DateTime DateTime { get; set; } } Here are a couple of subclasses of NewsItem: public class NewsItemJoiner : NewsIte...

Difficulty in extending the third party class.

I have the following classes class A{ private String name; private int value; public A(String n, int v){ name = n; value = v; } public void print(){ System.out.println(name + " " + value); } } class B exten...

Creating an object that has all the properties of two other objects?

Consider a sports club situation. A club can have a Club manager and 1 or more Coaches (1 coach per team) So, here is an example of the Manager and Coach classes. Class ClubManager { public void RegisterMember() { // code for registering a member.. } } Class Coach { public void DeviceTeamFormation() { ...