Click here to Skip to main content
15,886,919 members
Home / Discussions / Design and Architecture
   

Design and Architecture

 
GeneralRe: Delegates vs. Class Hierarchy Pin
peterchen12-May-08 5:17
peterchen12-May-08 5:17 
GeneralRe: Delegates vs. Class Hierarchy Pin
led mike12-May-08 5:51
led mike12-May-08 5:51 
GeneralRe: Delegates vs. Class Hierarchy Pin
peterchen12-May-08 11:54
peterchen12-May-08 11:54 
GeneralRe: Delegates vs. Class Hierarchy Pin
led mike15-May-08 6:27
led mike15-May-08 6:27 
GeneralRe: Delegates vs. Class Hierarchy Pin
peterchen15-May-08 7:10
peterchen15-May-08 7:10 
GeneralRe: Delegates vs. Class Hierarchy Pin
led mike15-May-08 7:15
led mike15-May-08 7:15 
GeneralRe: Delegates vs. Class Hierarchy [modified] Pin
peterchen15-May-08 7:26
peterchen15-May-08 7:26 
AnswerRe: Delegates vs. Class Hierarchy [modified] Pin
Roger Alsing14-May-08 23:26
Roger Alsing14-May-08 23:26 
I'd say go for the first approach.

By using your "TargetBase" class (or ITarget iface), you can apply extra information on those instances later on if you need.

Eg,

ITarget dt = new DelegateTarget(target);
dt.Status = TargetStatus.New; // Im not saying that these properties applies in this context
dt.TimeToLive = 123; //just that you have the option to add extra info if you need
dict.add(source, dt);

By using the pure delegate approach you can never attach any metadata to your targets.
Except for using more dictionaries that carry the extra info for each delegate.


Maybe you don't need such features, but IMO: an interface approach is always easier to extend than a pure delegate approach.

And I think an interface approach is cleaner when it comes to semantics (this is ofcourse just my own take on it, others may not agree)

Eg, every class that implements "ITarget" (or inherits TargetBase) promises that its purpose is to do what the interface implies.
(ofcourse you can abuse it and implement it differently, but the semantics associated with your interface promises something)

While delegates are more "oh yeah, I just return something of the correct type" , there is not the same kind of promise attached to a delegate type.


modified on Thursday, May 15, 2008 7:24 AM

QuestionException Handling Dilemma Pin
Brady Kelly8-May-08 4:21
Brady Kelly8-May-08 4:21 
AnswerRe: Exception Handling Dilemma Pin
Pete O'Hanlon8-May-08 4:31
mvePete O'Hanlon8-May-08 4:31 
GeneralRe: Exception Handling Dilemma Pin
Brady Kelly8-May-08 4:55
Brady Kelly8-May-08 4:55 
GeneralRe: Exception Handling Dilemma Pin
Pete O'Hanlon8-May-08 4:58
mvePete O'Hanlon8-May-08 4:58 
QuestionInstance vs Static + Option Pin
Brady Kelly7-May-08 2:49
Brady Kelly7-May-08 2:49 
AnswerRe: Instance vs Static + Option Pin
peterchen10-May-08 22:41
peterchen10-May-08 22:41 
AnswerRe: Instance vs Static + Option Pin
Member 9614-May-08 8:37
Member 9614-May-08 8:37 
GeneralRe: Instance vs Static + Option Pin
Brady Kelly14-May-08 10:23
Brady Kelly14-May-08 10:23 
AnswerRe: Instance vs Static + Option Pin
Ed.Poore15-May-08 21:35
Ed.Poore15-May-08 21:35 
AnswerRe: Instance vs Static + Option Pin
Megidolaon11-Jun-08 3:57
Megidolaon11-Jun-08 3:57 
QuestionFunction Extraction \ Refactoring Pin
Ray Cassick30-Apr-08 19:42
Ray Cassick30-Apr-08 19:42 
AnswerRe: Function Extraction \ Refactoring Pin
Zoltan Balazs30-Apr-08 20:15
Zoltan Balazs30-Apr-08 20:15 
GeneralRe: Function Extraction \ Refactoring Pin
Megidolaon11-Jun-08 4:01
Megidolaon11-Jun-08 4:01 
AnswerRe: Function Extraction \ Refactoring Pin
Big Daddy Farang1-May-08 12:19
Big Daddy Farang1-May-08 12:19 
AnswerRe: Function Extraction \ Refactoring Pin
Luc Pattyn1-May-08 12:54
sitebuilderLuc Pattyn1-May-08 12:54 
AnswerRe: Function Extraction \ Refactoring Pin
peterchen10-May-08 23:02
peterchen10-May-08 23:02 
GeneralObject Oriented Data Marshalling Pin
Adam Jasper29-Apr-08 3:37
Adam Jasper29-Apr-08 3:37 

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.