A sort of follow up/related question to this.
I'm trying to get a grip on a large code base that has hundreds and hundreds of classes and a large inheritance hierarchy. I want to be able to see the "main veins" of the inheritance hierarchy at a glance - not all the "peripheral" classes that only do some very specific / specialized thin...
One very common mistake with class hierarchies is to specify a method in a base class as being virtual, in order for all overrides in the inheritance chain to do some work, and forgetting to propagate the call on to base implementations.
Example scenario
class Container
{
public:
virtual void PrepareForInsertion(ObjectToInsert* pObje...
I didn't realize at the time I create this particular application that I'd need to reuse some of the components - some Windows forms and a class or two.
Now that I've already created the fairly complex forms inside one project, what's the easiest way to transform those forms into inheritable forms that I can reuse in other projects? On...
I have a class that is generated by some tool, therefore I can't change it. The generated class is very simple (no interface, no virtual methods):
class GeneratedFoo
{
public void Write(string p) { /* do something */ }
}
In the C# project, we want to provide a way so that we can plug in a different implementation of MyFoo. So I'm th...
Hello,
I have two forms,one is main and other is inherited form main.Lets say I have a function on the main form:
procedure FormMain.CreateButton;
begin
with TsButton.Create(Self) do begin
Width := 31;
Height := 31;
Left := 31;
Top := 31;
Visible := true;
Parent := Self;
end;
end;
Usually everything on the...
I have an interesting stack of assemblies I want to put together:
Common Assembly (C# or C++)
public class MyBase
{
public void MethodA()
{ ... }
private void MethodB()
{ ... }
protected virtual MethodC()
{ ... }
}
Test Code Assemblies (all C++)
public class MySpecific : public MyBase{
protected: override MethodC();
};
Test Simulat...
Hi,
In C++, what's the overhead (memory/cpu) associated with inheriting a base class that has no virtual functions? Is it as good as a straight up copy+paste of class members?
class a
{
public:
void get();
protected:
int _px;
}
class b : public a
{
}
compared with
class a
{
public:
void get();
protected:
int _px;
}...
I am designing a new laboratory database with MANY types of my main entities.
The table for each entity will hold fields common to ALL types of that entity (entity_id, created_on, created_by, etc). I will then use concrete inheritance (separate table for each unique set of attributes) to store all remaining fields.
I believe that this...
In Ruby, since you can include multiple mixins but only extend one class, it seems like mixins would be preferred over inheritance.
My question: if you're writing code which must be extended/included to be useful, why would you ever make it a class? Or put another way, why wouldn't you always make it a module?
I can only think of one r...
I would inheritance for a particular object to be dynamic and set via an extra setting of some type like the app.config file.
Here is an example:
//PROGRAM A
public class MySuperClass : OldIneritanceObjectVersion
{
........Stuff Goes Here
}
//PROGRAM B
public class MySuperClass : OldIneritanceObjectVersion
{
........S...
I have a project with a large codebase (>200,000 lines of code) I maintain ("The core").
Currently, this core has a scripting engine that consists of hooks and a script manager class that calls all hooked functions (that registered via DLL) as they occur. To be quite honest I don't know how exactly it works, since the core is mostly und...
I've run into a bit of a problem with my class hierarchy, in a WPF application. It's one of those issues where you have two inheritance trees merging together, and you can't find any logical way to make your inheritance work smoothly without multiple inheritance. I'm wondering if anyone has any bright ideas for getting this kind of syste...
public class BaseFoo
{
private string param;
public BaseFoo(string param)
{
this.param = param;
}
}
public sealed class SingletonFoo : BaseFoo
{
static readonly SingletonFoo instance = new SingletonFoo();
static SingletonFoo()
{
}
public static SingletonFoo Instance
{
get
...
The Setup
I have a WCF service that exposes a base type (e.g. Animal) as well as a few derived types (e.g. Lion, Tiger, and Bear). Another type (e.g. Zoo) includes a property that is a collection of the base type. The base type is concrete, not abstract, so it is perfectly acceptable for the collection to contain instances of the base t...
At work I've been tasked with turning a bunch of HTML files into a simple JSP project. It's really all static, no serverside logic to program. I should mention I'm completely new to Java. JSP files seem to make it easy to work with common includes and variables, much like PHP, but I'd like to know a simple way to get something like templ...
I have a class hierarchy that looks like this. These classes contain a lot of other details which I have excluded. This is a simplification to focus on the serialization aspect of these classes.
[ProtoInclude(1, typeof(Query<bool>))]
[ProtoInclude(2, typeof(Query<string>))]
[ProtoInclude(3, typeof(Query<int>))]
[ProtoInclude(4, typeof...
How can you specify a common base class in .xaml files for seperate Silverlight Page classes? I have a few common properties that I would like to share across pages, but I don't know how to do this without manually changing the base class in the .g.cs files each time they are generated.
Is this possible? I assume it is possible, since t...
Hi all
I'm wondering if it's possible to encapsulate the methods of a class, but then expose them within a consuming class. For example (JFTR, I know this code is wrong)
class Consumer{
public function __construct($obj){
$this->obj = $obj;
}
public function doCommand(){
$this->obj->co...
I'm writing some library code, and classes that use that code are required to have two attributes specified (one custom attribute and one from .NET).
It's a bit of a hassle to document this requirement and copy-and-paste both of those attributes onto every class that uses my library, so I thought it might be better to have my custom att...
I have a need for specialized collection classes. Let's call them FooItems and BarItems.
I basically need all the functionality of a List, but I need to do some extra work when new items are added or removed from the collection.
My first stab at this was to simply derive from List and List, then create my own Add and Remove methods....