The random utterances of David Arno

Some thoughts on expanding SuccincT to provide richer interface contracts and auto-generated data classes

SuccincT iconRecently I created a very simple framework, SuccincT. At it’s core is the ISuccess<T> interface. As I explained in a previous post though, by itself that interface isn’t much use. C# lacks the ability to define constraints on an implementation of ISuccess<T>, save through comments. The idea behind it was that an implementation should throw an exception if its Value is read when Success is false, but there is no way to guarantee that an implementation will exhibit this behaviour. This bugs me.

Unrelated to SuccincT, I’m a fan of defining data objects via interfaces, rather than concrete types. By “data object”, I mean any object that encapsulates a set of values. These might be used to avoid multiple parameters to a method or constructor, or to return a complex data set from a method. Data objects need not be immutable or serializable; they just need to be simple to use without causing problems when it comes to testing. As I like to encapsulate data, I like the setters of data objects to be internal, which does cause problems with testing. Thus why I like to use interfaces: the test class can define its own implementation, rather than having to fight against encapsulation. However, for every interface I create, I have to create at least one class too. This adds needless code to projects, which also bugs me.

These two things – wanting interfaces to define a more detailed contract and wanting to avoid having to write data object classes that can be 100% inferred from the interface – set me thinking: could I create some way of extending interfaces and avoiding writing data object classes?

Read the rest of the article


Share This Post...
No comments yet, click here to be the first

C# equality in depth. Part 1: Basic == equality

Equality in C# is an odd beast. At first glance, it seems very simple. Value types are compared by by value, objects are compared by reference and the comparison method can be overridden by a class if it wants to. For example, the String class compares the string contents, rather than comparing by reference. There are also sensible “best practice” rules suggested by Microsoft, such as avoiding comparing mutable objects by value, only by reference. All is not as it seems though as the following series of NUnit tests show. All the tests pass and thus demonstrate some aspect of equality in C#.

Read the rest of the article


Share This Post...
No comments yet, click here to be the first

C# equality in depth. Part 2: .Equals() and == are not equal

The two ways of checking for equality in C# – using == and .Equals() – can be modified for individual types. It is important to remember though that override and overload are two very different things in C#: .Equals() can be both overridden and overloaded, whereas == can only be overloaded. This set of tests demonstrate the significant effects this subtle difference can have on equality comparisons.

Read the rest of the article


Share This Post...
No comments yet, click here to be the first

C# equality in depth. Part 3: IEquatable

With .NET 2.0, Microsoft introduced the IEquatable interface. It introduced a typesafe Equals() method that could be used to speed up comparisons in the new generic collections. It speeded up those comparisons by avoiding the need for casting and boxing, which the Object.Equals() suffered from. The IEquatable interface is a dangerous beast though as it can lure the unwary into thinking it rationalised equality in C#. This set of tests sets out to demonstrate how quite the opposite occurred: it simply made things worse.

Read the rest of the article


Share This Post...
No comments yet, click here to be the first

SuccincT – A .NET framework to solve unexceptional exceptions & out parameter annoyances

SuccincT iconThe .NET framework is getting on a bit. Many users of the .NET framework are either resistant to API changes, or are stuck with binary-only 3rd party tools that would break with API changes. As a consequence of these two things, the .NET framework has aspects to it that go against modern thinking, but we are stuck with them. The solution to this is often to encapsulate those features within newer frameworks, which offer “best practice” facades on to those features. SuccincT is one such framework.

Read the rest of the article


Share This Post...
No comments yet, click here to be the first

Is Test Driven Development the only future for software development?

Evolution imageThis blog post was inspired by a brief twitter conversation between myself and Mark Seeman on how, in the future, developers will likely just write tests and how the computer will generate the code to make those tests pass.

Read the rest of the article


Share This Post...
7 comments so far, click here to read them or add another

QCon London 2013 – Day 2

QCon logoQCon is a large conference, with around six parallel tracks, offering talks on a range of subjects. Normally when visiting QCon, I skip between these tracks as the day progresses. That was certainly my plan for day 2 this year, but as the day progressed, I realised one track offered me a great opportunity to take away a good cross-section of ideas; ideas that some might no doubt find controversial: agile can be too process-bound and people are more important than processes.

Read the rest of the article


Share This Post...
1 comment so far, click here to read it or add another

QCon London 2013 – Day 1

QCon logoLast year, I missed QCon due to work commitments, but this year I’m back there again for three exhausting, but fun, days of high quality software education. But being there is only part of the story. The other side to the experience is the bizarre world of the London commuter.

Read the rest of the article


Share This Post...
1 comment so far, click here to read it or add another

How Lapsang avoids two common forms of explicit casting

Lapsang logoI have recently been working on how Lapsang might support both static and dynamic composition. In the process of thinking about these topics though, I’ve come to realise what mammoth topics they are. For example, in OO languages, we take for granted that there is a base class – often Object – that can define things like toString(). Because all classes inherit from that base class, all have access to toString(). However, Lapsang does not allow class inheritance. Thus even simple things like a toString() method have to use composition in order to be universally available. So defining how static composition works is taking longer than I expected, and I haven’t even started thinking about dynamic composition! Whilst working on composition, I started thinking about casting and what the syntax might look like in Lapsang. This led me to question whether Lapsang can avoid explicit casting altogether. The conclusion was yes, it can completely avoid explicit casting, sort of…

Read the rest of the article


Share This Post...
7 comments so far, click here to read them or add another

Why we absolutely should never build software like we build houses

Image of a madly designed houseA few days ago, I read something truly depressing. It was a piece written by Leslie Lamport, “a computer scientist … member of the National Academy of Engineering and the National Academy of Sciences. [with a] Ph.D. and M.A. in mathematics from Brandeis University and B.S. from MIT [and he] works at Microsoft Research.” Yet for all these grandiose accolades, he demonstrates a depressingly clueless understanding of his subject matter: software. In his article, he argues that we should build software like houses. In this article, I’ll detail why attempting to create applications in the same way as building houses is a really bad idea, which held back software development for decades. Further, the reality is that these days, architects are more likely to design houses using techniques pioneered by the latest software development practices.

Read the rest of the article


Share This Post...
7 comments so far, click here to read them or add another

Next Page »