Click here to Skip to main content
15,916,463 members
Home / Discussions / C#
   

C#

 
QuestionShamos Pin
msafary6-Nov-11 21:54
msafary6-Nov-11 21:54 
AnswerRe: Shamos Pin
Richard MacCutchan6-Nov-11 22:46
mveRichard MacCutchan6-Nov-11 22:46 
Question"economics" of casting to an interface in a parameter declaration of a method ? Pin
BillWoodruff6-Nov-11 20:41
professionalBillWoodruff6-Nov-11 20:41 
AnswerRe: "economics" of casting to an interface in a parameter declaration of a method ? Pin
harold aptroot6-Nov-11 21:37
harold aptroot6-Nov-11 21:37 
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 
Hi Dave, A most interesting, thoughtful, and much appreciated reply => +5

I have gone through "phases," it seems, in my very humble[1] evolution in programming in C#.

For a while, I seemed focused on 'passing around everything' by raising events, and transmitting data through custom EventArgs.

Then, in my head, I began to feel that there were two "modes" to consider here: one mode was "access:" at times Class/Form/Object A needs to have access to some Field/Property/Data in Class/Form/Object B ... and the principle of "separation of concerns" is the reason why Object A is not designed to be "intimate" with Object B (such as by sharing an Interface, or Inheritance).

And, the other mode, was "raising Events.

I began to think that in terms of this hypothetical "access mode," that the right thing to do was to expose, somehow, in Object B, what Object A "needed to know."

At that point I went into a "phase" where "injection" seemed the right thing to do: plug a reference to the instance of Object B into Object A, and then Object A can "help itself" to everything publicly exposed in Object B.

Then I came to feel that injection was (at least in the broad way I was using it) over-kill, and kind of a violation of separation of concerns. The old security buzz-word "need-to-know" seemed relevant to me here.

Then I entered a phase where I focused on creating static "Manager" classes through which interaction, and exchange of information between Objects/Classes/Forms was handled, in some cases assigning Events to Objects inside the static Manager class, at times just publishing methods in the static Manager class that any Object could invoke, passing in whatever.

And I still like this "static class" Manager idea in a scenario where you may have a whole bunch of run-time created objects of the same type active. For example, a "sticky note" application where you want to modify the content of some, or all, "stickies," based on some action in one particular "sticky."

And, finally, I came to the current phase, which I might call "parsimonious accessibility:" if there's one something in Object B that Object A needs access at times to: then, in Object B, define a Public Property that exposes what Object A needs to know.

Meanwhile, and this may not be a good thing, I seem to have come to rely on Events much less than ever: raising a custom event only when its directly related to asynchronous user behavior at run-time.

So, right now, the use of Interfaces, as a way to "limit exposure" between Objects is kind of the "new dance craze" for me, since I seem to have under-estimated what interfaces can do. And such interesting possibilities as explicit rather than implicit implementation of interfaces tantalize me[^].

My long-range goal here is simple: to have the depth of knowledge to approach solutions to real-world problems involving both algorithms, and asynchronous UI design, and OO application architecture, with a broad "palette" of techniques for inter- and infra- object communication/access tempered by awareness of the usefulness, efficiency, relevance, and cost/benefits of the varying. In other words, to have some sense of "best practice."

My mind is wide-open, and I'm ready to go "cold turkey" to withdraw from addiction(s) to any "phases." Smile | :)

best, Bill

[1] Picking out any one chapter, and reading, in Jon Skeet's "C# in Action" absolutely tops-up my "humility buffer" !
"Last year I went fishing with Salvador Dali. He was using a dotted
line. He caught every other fish." Steven Wright

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 
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 

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.