Click here to Skip to main content
15,896,154 members
Home / Discussions / Design and Architecture
   

Design and Architecture

 
AnswerRe: Inheritance - what's your take on this? Pin
Mycroft Holmes6-Dec-11 0:09
professionalMycroft Holmes6-Dec-11 0:09 
AnswerRe: Inheritance - what's your take on this? Pin
Eddy Vluggen6-Dec-11 8:15
professionalEddy Vluggen6-Dec-11 8:15 
AnswerRe: Inheritance - what's your take on this? Pin
Chris Meech6-Dec-11 8:33
Chris Meech6-Dec-11 8:33 
GeneralRe: Inheritance - what's your take on this? Pin
Eddy Vluggen6-Dec-11 8:51
professionalEddy Vluggen6-Dec-11 8:51 
GeneralRe: Inheritance - what's your take on this? Pin
lclarsen8-Dec-11 2:53
lclarsen8-Dec-11 2:53 
AnswerRe: Inheritance - what's your take on this? Pin
Shameel7-Dec-11 2:54
professionalShameel7-Dec-11 2:54 
AnswerRe: Inheritance - what's your take on this? Pin
jschell9-Dec-11 11:37
jschell9-Dec-11 11:37 
AnswerRe: Inheritance - what's your take on this? Pin
Stefan_Lang13-Dec-11 4:13
Stefan_Lang13-Dec-11 4:13 
The question I always ask myself to find out what kind of relationship two objects really have, is whether it's a 'is a' or 'has a' relationship. E. g. a Mercedes 'is a' car, so it inherits all methods and properties of a generic car. And it 'has a' three-pointed star. You wouldn't inherit a 'Mercedes' from a three-pointed star, would you? Wink | ;)

Your case sounds more like a 'has a' relation ship, in that all the other classes 'have' an ID, title, etc.. The obvious way would be to just let every class have these members, but if all classes are going to have the same 3 or 4 member variables, then chances are these belong together in a class of it's own. or maybe just a struct:
C++
struct ID {
   int id;
   std::string title;
};

class MyDialog {
   ID id;
   // ...
};

class MyButton {
   ID id;
   // ...
};

Now you need to decide if that is sufficient for the operations you want for these classes. You will get a bit of redundance this way: e. g. accessors for each class that uses ID. But I see no reason to have virtual methods or inheritance.
AnswerRe: Inheritance - what's your take on this? Pin
gentlegod00125-Dec-11 4:36
gentlegod00125-Dec-11 4:36 
QuestionConflict between Delete and global Reset in a tree view Pin
Ambe15-Nov-11 20:33
Ambe15-Nov-11 20:33 
AnswerRe: Conflict between Delete and global Reset in a tree view Pin
Mycroft Holmes15-Nov-11 21:13
professionalMycroft Holmes15-Nov-11 21:13 
GeneralRe: Conflict between Delete and global Reset in a tree view Pin
GateKeeper2218-Nov-11 6:26
GateKeeper2218-Nov-11 6:26 
AnswerRe: Conflict between Delete and global Reset in a tree view Pin
Eddy Vluggen26-Nov-11 6:39
professionalEddy Vluggen26-Nov-11 6:39 
QuestionEmployee Portal Pin
Sunil Kokkiligadda15-Nov-11 9:44
Sunil Kokkiligadda15-Nov-11 9:44 
AnswerRe: Employee Portal Pin
Mycroft Holmes15-Nov-11 21:19
professionalMycroft Holmes15-Nov-11 21:19 
AnswerRe: Employee Portal Pin
R. Giskard Reventlov15-Nov-11 21:49
R. Giskard Reventlov15-Nov-11 21:49 
QuestionRe: Employee Portal Pin
Sunil Kokkiligadda16-Nov-11 12:30
Sunil Kokkiligadda16-Nov-11 12:30 
AnswerRe: Employee Portal Pin
R. Giskard Reventlov14-Dec-11 3:25
R. Giskard Reventlov14-Dec-11 3:25 
GeneralRe: Employee Portal Pin
Mycroft Holmes20-Nov-11 19:35
professionalMycroft Holmes20-Nov-11 19:35 
GeneralRe: Employee Portal Pin
dawmail3337-Dec-11 1:57
dawmail3337-Dec-11 1:57 
AnswerRe: Employee Portal Pin
srinivas vadepally20-Nov-11 19:00
srinivas vadepally20-Nov-11 19:00 
QuestionHow far is to far for separation of concerns? Pin
GateKeeper2214-Nov-11 6:57
GateKeeper2214-Nov-11 6:57 
GeneralRe: How far is to far for separation of concerns? Pin
GateKeeper2214-Nov-11 8:19
GateKeeper2214-Nov-11 8:19 
AnswerRe: How far is to far for separation of concerns? Pin
jschell14-Nov-11 8:24
jschell14-Nov-11 8:24 
GeneralRe: How far is to far for separation of concerns? Pin
GateKeeper2214-Nov-11 8:28
GateKeeper2214-Nov-11 8:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.