Click here to Skip to main content
16,012,223 members
Home / Discussions / C#
   

C#

 
AnswerRe: "economics" of casting to an interface in a parameter declaration of a method ? Pin
Luc Pattyn6-Nov-11 22:56
sitebuilderLuc Pattyn6-Nov-11 22:56 
AnswerRe: "economics" of casting to an interface in a parameter declaration of a method ? Pin
PIEBALDconsult7-Nov-11 1:49
mvePIEBALDconsult7-Nov-11 1:49 
AnswerRe: "economics" of casting to an interface in a parameter declaration of a method ? Pin
DaveyM697-Nov-11 11:11
professionalDaveyM697-Nov-11 11:11 
GeneralRe: "economics" of casting to an interface in a parameter declaration of a method ? Pin
BillWoodruff7-Nov-11 19:03
professionalBillWoodruff7-Nov-11 19:03 
GeneralRe: "economics" of casting to an interface in a parameter declaration of a method ? Pin
DaveyM697-Nov-11 21:36
professionalDaveyM697-Nov-11 21:36 
GeneralRe: "economics" of casting to an interface in a parameter declaration of a method ? Pin
Pete O'Hanlon7-Nov-11 23:19
mvePete O'Hanlon7-Nov-11 23:19 
GeneralRe: "economics" of casting to an interface in a parameter declaration of a method ? Pin
DaveyM698-Nov-11 6:45
professionalDaveyM698-Nov-11 6:45 
GeneralRe: "economics" of casting to an interface in a parameter declaration of a method ? Pin
BobJanova8-Nov-11 0:14
BobJanova8-Nov-11 0:14 
This is one of those subjective, grey area questions. There are times when direct linkage is appropriate (generally for things within the same library or application) – for example I think it makes sense for a collision hull to have a direct reference to its host object, as well as vice versa, because it's tightly bound to it (a hull always has a parent object and an object can always have a hull, though some may choose to have a null one). When it crosses library boundaries, you often want to have the linkage in one direction (an 'upward' link in normal layer terminology) to be an interface in order to keep the layers in the right order. And sometimes you want the looser coupling of simply exposing events and allowing someone to hook onto them if they wish.

You can go a step further and have a single central event source which everyone can post messages into and retrieve them out of, as the Unity framework does (IEventAggregator), so you don't have to have a reference to something to hook onto its events. But I find that to be confusing, particularly trying to work out execution paths that have been done like this in other people's code – once you introduce global components like that, everything can depend on it and modularisation is broken.

I only tend to use events for unpredictable, well, events – things caused by user input or other external sources (network, file etc), or asynchronous execution (threads, BackgroundWorkers, etc).
GeneralRe: "economics" of casting to an interface in a parameter declaration of a method ? Pin
DaveyM698-Nov-11 6:57
professionalDaveyM698-Nov-11 6:57 
AnswerNot so simple (Re: "economics" of casting to an interface in a parameter declaration of a method?) Pin
Sergey Alexandrovich Kryukov8-Nov-11 14:58
mvaSergey Alexandrovich Kryukov8-Nov-11 14:58 
QuestionOmar Gameel, Apriori Algorithm Please Help..!!! Pin
Member 78679836-Nov-11 11:29
Member 78679836-Nov-11 11:29 
GeneralRe: Omar Gameel, Apriori Algorithm Please Help..!!! Pin
harold aptroot6-Nov-11 11:41
harold aptroot6-Nov-11 11:41 
AnswerRe: Omar Gameel, Apriori Algorithm Please Help..!!! Pin
Dalek Dave6-Nov-11 12:54
professionalDalek Dave6-Nov-11 12:54 
Questionauto check DataGridViewCheckBoxColumn Pin
Danzy836-Nov-11 10:52
Danzy836-Nov-11 10:52 
AnswerRe: auto check DataGridViewCheckBoxColumn Pin
Dalek Dave6-Nov-11 12:57
professionalDalek Dave6-Nov-11 12:57 
AnswerRe: auto check DataGridViewCheckBoxColumn Pin
Dr.Walt Fair, PE6-Nov-11 16:59
professionalDr.Walt Fair, PE6-Nov-11 16:59 
AnswerRe: auto check DataGridViewCheckBoxColumn Pin
purnananda behera7-Nov-11 19:00
purnananda behera7-Nov-11 19:00 
QuestionHow to read an Autocad file with c# Pin
JUSTLOVE16-Nov-11 10:04
JUSTLOVE16-Nov-11 10:04 
AnswerRe: How to read an Autocad file with c# Pin
Richard MacCutchan6-Nov-11 10:19
mveRichard MacCutchan6-Nov-11 10:19 
GeneralRe: How to read an Autocad file with c# Pin
Dalek Dave6-Nov-11 12:57
professionalDalek Dave6-Nov-11 12:57 
GeneralRe: How to read an Autocad file with c# Pin
Richard MacCutchan6-Nov-11 22:28
mveRichard MacCutchan6-Nov-11 22:28 
AnswerRe: How to read an Autocad file with c# Pin
Luc Pattyn6-Nov-11 22:58
sitebuilderLuc Pattyn6-Nov-11 22:58 
GeneralRe: How to read an Autocad file with c# Pin
Richard MacCutchan6-Nov-11 23:27
mveRichard MacCutchan6-Nov-11 23:27 
GeneralRe: How to read an Autocad file with c# Pin
Luc Pattyn6-Nov-11 23:41
sitebuilderLuc Pattyn6-Nov-11 23:41 
GeneralRe: How to read an Autocad file with c# Pin
Dennis E White7-Nov-11 6:11
professionalDennis E White7-Nov-11 6:11 

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.