Suppose one had inherited a complex codebase (in Visual C++, assume 2003 or perhaps later) with a large and complex inheritance graph. Suppose it's deep, and there's lots of virtual functions and possibly even multiple inheritance as well. (Yes, a bit of a maintenance nightmare). Any attempt to refactor this class hierarchy into somethin...
            
           
          
            
            I've had this problem many times before, and I've never had a solution I felt good about. 
Let's say I have a Transaction base class and two derived classes AdjustmentTransaction and IssueTransaction.
I have a list of transactions in the UI, and each transaction is of the concrete type AdjustmentTransaction or IssueTransaction.
When I...
            
           
          
            
            Hi,
I need to grab a value from the HttpCOntext.Items request cache, where should I do this?
Is there a particular event or contsructor I should override?
...
            
           
          
            
            Hi
When reviewing our codebase, I found an inheritance structure that resembles the following pattern:
interface IBase
{
    void Method1();
    void Method2();
}
interface IInterface2 : IBase
{
    void Method3();
}
class Class1 : IInterface2
{
    ...
}
class Class2 : IInterface2
{
    ...
}
class Class3 : IInterface2
{ 
    ...
...
            
           
          
            
            I have the following code that creates two objects (ProfileManager and EmployerManager) where the object EmployerManager is supposed to inherit from the object ProfileManager. 
However, when I do alert(pm instanceof ProfileManager); it returns false.
function ProfileFactory(profileType) {
    switch(profileType)
    {
     case 'employe...
            
           
          
            
            Hi,
I read about this ages ago but never tried it now I can't remember if this is possible or not. Is it possible to extend a class from two parents on php5 e.g.
class_d extends class_c and class_b
moreover can you do this if class_c and class_b are themselves extended from class_a ... so you get something like this
                 ...
            
           
          
            
            Let's say we have a concrete class Apple. (Apple objects can be instantiated.)
Now, someone comes and derives an abstract class Peach from Apple. It's abstract because it introduces a new pure virtual function. The user of Peach is now forced to derive from it and define this new function. Is this a common pattern? Is this correct to do?...
            
           
          
            
            My C++ framework has Buttons. A Button derives from Control. So a function accepting a Control can take a Button as its argument. So far so good.
I also have List<T>. However, List<Button> doesn't derive from List<Control>, which means a function accepting a list of Controls can't take a list of Buttons as its argument. This is unfortun...
            
           
          
            
            How do I setup a class that represents an interface?  Is this just an abstract base class?
...
            
           
          
            
            As we all know, when we derive a class and use polymorphism, someone, somewhere needs to know what class to instanciate. We can use factories, a big switch statement, if-else-if, etc. I just learnt from Bill K this is called Dependency Injection.
My Question: Is it good practice to use reflection and attributes as the dependency injecti...
            
           
          
            
            public enum myEnum {    
VAL1(10), VAL2(20), VAL3("hai") {
     public Object getValue() {
      return this.strVal;
     }
     public String showMsg() {
      return "This is your msg!";
     }
    };
    String strVal;
    Integer intVal;
    public Object getValue() {
     return this.intVal;
    }
    private myEnum(int i) {
     th...
            
           
          
            
            Yesterday I had a two-hour technical phone interview (which I passed, woohoo!), but I completely muffed up the following question regarding dynamic binding in Java.  And it's doubly puzzling because I use to teach this concept to undergraduates when I was a TA a few years ago, so the prospect that I gave them misinformation is a little d...
            
           
          
            
            Here's another problem with qt:
I extend a QAbstractTableModel, but I get a compiling error ( I'm using cmake)
// file.h
#ifndef TABLEMODEL_H
#define TABLEMODEL_H
#include <QAbstractTableModel>
class TableModel : public QAbstractTableModel
{
Q_OBJECT
public:
TableModel(QObject *parent = 0);
int rowCount(const QModelIndex &parent = QM...
            
           
          
            
            currently i am forcing my WPF app to use the luna theme no matter what, with this XAML code
<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="Styles.xaml" />
            <ResourceDictionary Source="NavigationCommands.xaml" />
            <ResourceDict...
            
           
          
            
            I was discussing multiple inheritance vs. single inheritance with a friend of mine, and discovered that plainly, my conception of Object-Oriented design is completely different than his. I am mostly an Obj-C programmer, so Multiple Inheritance is not something I use daily. He is mostly a C++  programmer under Windows/PSP, so we probably ...
            
           
          
            
            I have an abstract base class and derived class:
type TInterfaceMethod = class
  public
    destructor Destroy; virtual; abstract;
    procedure Calculate; virtual; abstract;
    procedure PrepareForWork; virtual; abstract;
end;
type ConcreteMethod = class(TInterfaceMethod)
  private
    matrix: TMinMatrix;
  public
    constructor Crea...
            
           
          
            
            Just came across this quote in a book on OOP that I'm reading,
  A child is only allowed to augment
  functionality and add functionality. 
  A child is never allowed to remove
  functionality.  If you do find that a
  child need to remove functionality,
  this is an indication that the child
  should appear before the parent in the
  ...
            
           
          
            
            I have an abstract class:
type
  TInterfaceMethod = class abstract
  public
    destructor Destroy;         virtual; abstract;
    function GetBasePlan: Word; virtual; abstract;
    procedure CountBasePlan;    virtual; abstract;
    procedure Calculate;        virtual; abstract;
    procedure PrepareForWork;   virtual; abstract;
  end;
...
            
           
          
            
            I have, for my game, a Packet class, which represents network packet and consists basically of an array of data, and some pure virtual functions
I would then like to have classes deriving from Packet, for example: StatePacket, PauseRequestPacket, etc. Each one of these sub-classes would implement the virtual functions, Handle(), which w...
            
           
          
            
            In java, there's three levels of access:
Public - Open to the world
Private - Open only to the class 
Protected - Open only to the class and its subclasses (inheritance).
So why does the java compiler allow this to happen?
TestBlah.java:
public class TestBlah {
    public static void main(String[] args) {
        Blah a = new Blah...