Reputation
6,779
Top tag
Next privilege 10,000 Rep.
Access moderator tools
Badges
3 21 30
Newest
 Nice Answer
Impact
~172k people reached

Jun
28
comment ASP.NET user control best practices, programmatically or markup?
+1 I don't know who downvoted you, but I certainly upvoted. Very nice overview! Bookmarked.
May
22
comment Using prefix/postfix increment operator for simple incremental array access rather than actual index numbers
+1, Would add another one for the correct application of DRY principle (avoiding repeat of knowledge, not avoiding repetition per se)
May
22
comment Class design for an app that reads data from Active Directory
Design your app for what it needs to do. Hide the AD details behind wrappers that just expose what your app needs. These wrapper classes will also serve as a perfect "insulation" seam allowing you to unit test all of your app without any dependency on AD (except for the wrappers themselves). In other words: treat AD as you would a database.
May
22
comment Call method in a disposable object at the beginning of a “using” statement
? While I understand the intention of your example, how/where is CollectionUpdateContext<T>.UpdatingCollection being called? Did you perhaps intend UpdatingCollection to be the constructor of CollectionUpdateContext<T>?
May
22
comment C# obtain derived class from base
+1 for the overload approach, but your WidgetToJavaScriptConverter instance could be called from a simple loop without the added indirection of a visitor pattern.
May
22
comment C# obtain derived class from base
You could construct a parallel hierarchy of javascript generating classes and then use a dictionary or other "linking" mechanism to first register and later select the correct javascript generating class for each widget class. ("Is there a way to loop through all the widgets, but determine what type of widget it is?" - TypeOf() method?)
May
19
comment Advantage/Disadvantage of having all variables declared in a JUnit Test
+1 for the case you make. And test code should be production grade code. That said, DRY is not so much about not repeating yourself at all. It is about not repeating knowledge. The DRY principle is stated as “Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.” (en.wikipedia.org/wiki/Don%27t_repeat_yourself). The misunderstandings arise from "repeat" I think, as does: hermanradtke.com/2013/02/06/misunderstanding-dry.html
May
19
comment Advantage/Disadvantage of having all variables declared in a JUnit Test
+1 absolutely, but please bear in mind that DRY is less about avoiding repeating code than it is about not repeating knowledge. See hermanradtke.com/2013/02/06/misunderstanding-dry.html. The Dry principle is stated as "Every piece of knowledge must have a single, unambiguous, authoritative representation within a system." en.wikipedia.org/wiki/Don%27t_repeat_yourself
May
19
comment Advantage/Disadvantage of having all variables declared in a JUnit Test
@CandiedOrange: DRY is less to do with avoiding code duplication than it is about avoiding the duplication of knowledge (facts, rules, etc). See: hermanradtke.com/2013/02/06/misunderstanding-dry.html The Dry principle is stated as "Every piece of knowledge must have a single, unambiguous, authoritative representation within a system." en.wikipedia.org/wiki/Don%27t_repeat_yourself
May
15
answered Unit-testing on higher levels of architecture
May
9
comment Do I need to use an interface when only one class will ever implement it?
Found a perfect use case for an interface implemented by a single class just now, in this thread: programmers.stackexchange.com/questions/281979/…
May
9
comment Is my usage of explicit casting operator reasonable or a bad hack?
You could avoid the copying by using an ISmallObject interface implemented by BigObject and simply return a reference to this in the ToSmallObject implementation.
May
9
comment Is my usage of explicit casting operator reasonable or a bad hack?
This sounds like a perfect use case for an ISmallObject interface which is only implemented by BigObject as a means to provide access to a limited set of its extensive data/behavior. Especially when combined with @Telastyn's idea of a ToSmallObject method.
May
9
answered Application plugin system - interfaces - adding new features
May
9
comment Do I need to use an interface when only one class will ever implement it?
How about the only class implementing that interface does more than just implement that particular interface and you don't want the code needing only the methods of said interface to have access to the rest of the public methods of the class. For eaxmple classes that implement both "immutable" and "mutable" behavior and you want most of your code to have an extra "insulation" layer between them and the methods that change an instance's state (insulation provided by having to "ask" whether the "mutable" interface is supported) so it is easy to spot the code that messes with state.
May
4
comment Web API Design advice
"which seems to be going against RESTful approach or dealing with resources?" you are confusing resources with entities. A resource can consist of many attributes and sub objects containing lists as well. The same way that a view is not restricted to any particular entity. You can structure your resources any way you see fit given the needs of your application. Considering that you plan to use this thing in many places, I would certainly opt for a single resource that pulls everything together for me.
Apr
30
revised Tester/Doer pattern: Assume the caller conforms to the pattern or be defensive and repeat the check?
added an alternative approach
Apr
27
comment Two way communication between Form and plugins
No time to go into any detail now, so comment instead of answer. They way you make every Panel (or UserControl as suggested by CurtisHx) able to receive information from the main form, and/or to add menu items to the main form is to turn it onto its head: make all panels/UserControls implement an interface that allows the mainform to ask each one for any menu items it wants to add and allows the mainform to "broadcast" information from other panels to anyone interested. The latter is the published-subscriber pattern: every panel automatically becomes a subscriber of the mainform.
Apr
17
answered Global / Application settings and testing
Apr
8
comment Should one use Dependency Injection even if the class is used only once?
dependency injection need not be centralized at all (see other answers). And even though this class may be used only once, it still needs to be tested for its behavior. Plus, more importantly, the class using it needs to be tested. And though you could test both classes through the outer one (the one aggregating the other class), your test classes and cases will be much simpler if you focus them on a single class. Which means that the outer class needs to be tested only for its own behavior and its interaction with the inner class. And that automatically is an argument for some form of DI.