Reputation
591
Top tag
Next privilege 1,000 Rep.
See votes, expandable usercard
Badges
1 6 13
Newest
 Teacher
Impact
~18k people reached

Jul
5
awarded  Teacher
Jul
3
answered Reducing boilerplate in class that implements interfaces through composition
Jun
30
accepted Reducing boilerplate in class that implements interfaces through composition
Jun
28
comment Reducing boilerplate in class that implements interfaces through composition
As for the idea of a walk(IWalkable) method, I personally dislike it because then walking services become the responsibility of the caller, and not the Person, and consistency is not guaranteed. Any caller would have to know which service to use to guarantee consistency, whereas keeping it in the Person class means it has to be manually changed for walking behaviour to differ, while still allowing dependency inversion.
Jun
28
comment Reducing boilerplate in class that implements interfaces through composition
In my example the functionality is implemented in separate classes, and I have a class composed of a few of these as a way of grouping the required behaviour. None of the actual implementation exists in my larger class, it's all handled by the smaller components. Perhaps you're right though, and making those helper classes public so they can be directly interacted with is the way to go.
Jun
28
comment Reducing boilerplate in class that implements interfaces through composition
I think my primary reason for preferring A implement IB, IC and ID is it feels more sensible to write Person.Walk() as opposed to Person.WalkHelper.Walk(), for example.
Jun
28
asked Reducing boilerplate in class that implements interfaces through composition
May
14
awarded  Yearling
May
6
comment Should we define types for everything?
Would it not be good design for a type to encapsulate its own validation? Or to create a helper type to validate it?
Mar
12
awarded  Famous Question
Jan
23
comment Should I throw guard exceptions that will be thrown by internal methods anyway?
@DocBrown I would argue that while the answers are voted higher there, none of them are as detailed or as complete as Neil's answer below.
Jan
23
comment Should I throw guard exceptions that will be thrown by internal methods anyway?
@DocBrown That question was asked 13 hours ago. This question was asked months ago.
Nov
28
awarded  Good Question
Nov
27
awarded  Notable Question
Nov
27
accepted Should I accept empty collections in my methods that iterate over them?
Nov
27
awarded  Citizen Patrol
Nov
27
comment Should I accept empty collections in my methods that iterate over them?
It does. My comment was a clarification as Andrzej must have been confused (for why else would they go to the effort of specifying namespaced for a language this question does not reference?).
Nov
27
awarded  Commentator
Nov
27
comment Should I accept empty collections in my methods that iterate over them?
This question is tagged [c#]
Nov
26
awarded  Popular Question