Reputation
673
Top tag
Next privilege 1,000 Rep.
See votes, expandable usercard
Badges
4 5
Newest
 Yearling
Impact
~14k people reached

  • 0 posts edited
  • 0 helpful flags
  • 634 votes cast
Apr
14
comment Principle of least astonishment (POLA) and interfaces
When order matters, you can still satisfy POLA by defining the operations such that performing later steps requires a value returned from prior steps, thereby enforcing order with the type system. FileWriter could then require the value from the last ContentBuilder step in the Write method to ensure all input content is complete, making InvalidContentException unnecessary.
Mar
21
comment Why do you have to specify the data type when declaring variables?
Regarding type inference, many languages, including ML-based languages, use Hindley-Milner. Lambda calculus is magic.
Oct
22
answered TDD - Outside In developemnt
Oct
7
comment Using a private auto-implemented property vs. a private field
As an aside, if you're doing lazy-loading, you should use Lazy<T> rather than if(x == null) x = new T();. It clarifies in the type that the field is lazy and provides better thread safety.
Jul
23
comment How do I handle setters on immutable fields?
@SebastianRedl sadly, primary constructors were removed from the final C#6 release.
Jul
17
awarded  Yearling
Jul
16
answered Control Start Of Program
Jul
10
comment Can you do iterative development in c#?
There is no C# REPL... yet
Jun
26
comment Generic Sorting of Lists<>
Also, if you implement IComparable<T> on each type, you can use List<T>.Sort().
May
14
comment How to measure the potential value of refactoring
There is also a business risk to keeping the VB6: Microsoft dropped full support of VB6 years ago and has been limping along on "It Just Works" support since. The build environment won't run on anything newer than XP, and the runtime could stop working in any future version of Windows. For example, there has yet to be a formal announcement that VB6 is supported on Windows 10.
Mar
30
comment How is CancellationToken.IsCancellationRequested updated?
@RobertHarvey Microsoft now hosts most/all of the .NET source at sourceof.net. It has decent tools for searching around code and you can link directly to types/methods, such as CancellationToken.
Feb
10
answered Best practice to include XSD in C# project
Jan
28
comment Derive from a base class but not include a condition in the base class's method
Also, is there really a need for a separate class? From your description, it sounds like HighDetails is little more than a Details class with includeHighDetails set to true and includeLowDetails set to false.
Nov
26
comment Should I accept empty collections in my methods that iterate over them?
Rather than use yield returns, it might be preferable to extract a method for converting a single Node to a TransformedNode and replace your utility method with LINQ collection.Select(TransformNode) calls.
Nov
21
comment Name/Fix for Production Code Whose Sole Purpose is to Facilitate Testing?
I don't know that I agree the injection constructor is a problem which requires hours of effort to change/test, but I would fix the empty constructor to overload properly: public MyClass() : this(new Something()) { }
Oct
31
comment Is this extension method any better than just casting to an int?
@Snowman you get the type-checking benefits of the GetInt32 call without the extra hit of calling GetOrdinal columns * rows times
Oct
31
answered Is this extension method any better than just casting to an int?
Oct
2
comment Should I denote that a method satisfies an interface?
quite the opposite: StyleCop has a specific rule about avoiding regions
Sep
22
answered Distinct Log and Trace for each object in .NET
Sep
16
comment Static typing vs. dynamic typing
Type inference != dynamic typing. For example, many (most? all?) functional languages use static type systems, but they also mostly use type inference.