Hacker News new | past | comments | ask | show | jobs | submit login

Null-conditional operators is going to be a real nice thing to have and somethings that's been requested for a long while. Saying that most of the other stuff seems to small nice to haves and cleanup.

I kinda wish they'd put more thought and energy into some tidy way of doing error checking, pre-conditions etc. locating and avoiding bugs is still one of the main concerns in any project and not enough are done to help with that. There are extensions but they are all a little clunky or require too much effort.

If they did that correctly I think it could be a game changer on par with Linq and rx




pre/post conditions can be handled via https://github.com/ghuntley/conditions or via code contracts. Conditions runs on all platforms (mono/windows/xamarin mobile) and does runtime inspection vs Code Contracts which unfortunately runs only on Windows but does have the added advantage of being able to specify behaviour on interfaces and validation being performed at compile time. There was a project w/GSOC back in 2010 that tried to bring Code Contracts across http://monocodecontracts.blogspot.com.au/ which got merged w/ Mono 3.0 but the corresponding tooling in MonoDevelop is missing so it is useless. See http://www.mono-project.com/docs/about-mono/compatibility/ for more information and please bump this ticket https://bugzilla.xamarin.com/show_bug.cgi?id=8400 in support.


The problem with code contracts is that they aren't available across all versions of .NET, even on Windows.

You need at least the Premium edition for the required tools.


Code Contracts were just released under MIT license on GitHub which (I'd think) will probably positively affect their availability https://github.com/CodeContractsDotNet/CodeContracts

Update: On second thought, I think Code Contracts were already available on the free Visual Studio 2013 Community edition: https://visualstudiogallery.msdn.microsoft.com/1ec7db13-3363...


Code Contracts, the library, has always been free. The static checker, the really important piece, was only available in expensive editions for commercial use.


The other problem w/ Code Contracts is inheritance. A call to base.DoStuff(arg); might fail, even though the child class handles it and doesn't need the contract to be satisfied by the parent.


That is not an issue.

Have you read the whole principles behind code contracts?

Derived classes must uphold the same contracts as the base classes, they are only allowed to strengthen them, not to drop conditions.


Is there a difference between design-by-contract and the condition modifications allowed by the Liskov substitution principle? They seem related but I'm not well-enough versed in the differences.

"...the subtype must meet a number of behavioral conditions. These are detailed in a terminology resembling that of design by contract methodology, leading to some restrictions on how contracts can interact with inheritance:

Preconditions cannot be strengthened in a subtype.

Postconditions cannot be weakened in a subtype.

Invariants of the supertype must be preserved in a subtype."

http://en.wikipedia.org/wiki/Liskov_substitution_principle


They are the same.

I was generalizing and though only about pre-conditions.


I see. This is new, it used to be so that although the APIs were available, only Premium, Ultimate and Test had the tooling to generate verifiable builds.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: