background preloader

Development

Facebook Twitter

Redux

Union types in C# - boustrophedonic. This post shows how to easily implement states in C# using a T4 template.

Union types in C# - boustrophedonic

Background I often run into situations where I need an object that has a number of alternate “states” or “choices”. The set of states must be treated as “one thing” for general manipulation, but on the other hand, each state will often have slightly different behavior from the other states. Some examples: A shopping cart might have states Empty, Active and Paid. So given this common situation, what kinds of ways are there to implement these kinds of cases? The inheritance based approach The standard approach in a object-oriented language is to use inheritance. But where should the custom behavior live? For example, in the shopping cart example, should the “RemoveItem” method be available at the interface level? Approach 1: Define all possible actions at the interface level Let’s say the “RemoveItem” method is available at the interface level, then the interface would look like this: Here’s some code to show what I mean:

.net core

Nuget. Debug. Json.Net. .NET samples. Git. IoC, Dependency Injection. XML. Nuget. Portable Class Libraries. Windows Forms. IPC. .NET Reference Source. Cocoa. MvvmCross. Xamarin. Git. Mono. Security. Data. XML. .NET blogs. .NET Framework. Immutability. MEF. Visual Studio Extensions. Web. Transactions. Regular expressions. T4. .NET. Eric Lippert. Expression trees. Security. DLR. WPF, MVVM. Web. Libraries. Learn C#, WPF, Visual Studio 2012, Windows 8, TypeScript, HTML 5, Windows Phone 8, ASP.NET, WCF. The Joel Test: 12 Steps to Better Code. By Joel Spolsky Wednesday, August 09, 2000 Have you ever heard of SEMA?

The Joel Test: 12 Steps to Better Code

It's a fairly esoteric system for measuring how good a software team is. No, wait! Don't follow that link! The neat thing about The Joel Test is that it's easy to get a quick yes or no to each question. A score of 12 is perfect, 11 is tolerable, but 10 or lower and you've got serious problems. Of course, these are not the only factors that determine success or failure: in particular, if you have a great software team working on a product that nobody wants, well, people aren't going to want it. 1. 2. If the process takes any more than one step, it is prone to errors. For this very reason, the last company I worked at switched from WISE to InstallShield: we required that the installation process be able to run, from a script, automatically, overnight, using the NT scheduler, and WISE couldn't run from the scheduler overnight, so we threw it out. 3. 4.

Bug databases can be complicated or simple. 5. 6.

Eclipse

Android. Free Web Development Tools for Windows. MSDN Library. Frameworks. Windows Dev Center: Tools, samples and docs to build Windows apps. We make it easy to get started.

Windows Dev Center: Tools, samples and docs to build Windows apps

All you need to build compelling apps for phones, tablets and PCs is in Visual Studio Express 2013 for Windows (with Update 2 RC). Included are universal app templates, a full-featured code editor, a powerful debugger, emulators, rich language support, and more, all ready to use in production. We have dozens of code samples to get you up and running fast. They’re based on Visual Studio’s new universal app templates, letting you build for both Windows Phone 8.1 and Windows 8.1.

We’ll help you get your Windows Store app ready for a successful launch through one of our worldwide community events or by connecting you with a Windows platform expert. Reliable Software - Creators of the distributed version control system, Code Co-op.

Programming Languages

Asynchrony. Tools. VisualStudio. Agile. Network. Drivers. Patterns. .Net et C# Reactive Programming. WCF. ASP.NET. Media. Functional Programming. Fresh links for developers.