Many of you (yes you) have the weird notion that the functionality you create is actually the product you deliver to your stakeholder, and that is where you are wrong! Sure the needed functionality and behavior is the reason why you are programming, al do some developers don’t need a reason to code, we call this behavior YAGNI.

So if the functionality and behavior is not the product you deliver, than what is it?

It is your CODE.

And you know what? I need to be able to give your code to any other developer and they should be able to just pick it up and start changing and extending it. This means that by definition it is important that your code is readable and understandable; and no this does not mean readable and understandable to you.

Readable and understandable eh? So I’ll just add comments to the code to explain my intent, that should do it. Wrong again, if you feel the need to add comments to your code to explain what is going on then that is an obvious sign that there is something wrong with the way you wrote it. Make your code explain it self, that way it won’t be out of date when you change it.

Descriptive naming

The first step to make your code readable and understandable is to use descriptive names for all your classes, methods, properties and variables. Don’t shorten your names, make them complete. Yes this means that you will have to type a little bit more, intellisense will be a great help here. This also means that you have to actually think about what it is that this “thing” is representing, which in turn improves your design as well.

Keep it small

Keep your classes and methods small, something small is more easily to understand than something big. A good principle to help you achieve this is the Single Responsibility Principle which dictates that a class or method should only have one responsibility. When something has multiple responsibilities then you should split it up in multiple methods or classes. When correctly applied (with a little help of the Dependency Inversion Principle) this will also help you de-couple your code from each other.

Formatting

Try to format your code as good as possible, don’t put to much on a single line, make your indentation correct, don’t suddenly add many empty lines in your code. Formatting will do a lot to display the flow of your code, use it correctly.

Weird logic

When you have some weird logic like some if else statements and for loops which don’t tell you it’s intend very well, try if you can split these things up into multiple private methods purely to explain in the code why you are doing something. Use the method names to make sense of the weird logic.

In the end this is what separates you from the other mediocre developers, this is something that is more important then knowing the latest new technologies (al do some of these latest new technologies may actually help you make the code more readable and understandable). Good developers write code that functions and behaves correctly, great developers make sure that their code is also easy to be understood by other developers.

Tip: Read clean code from Robert C. Martin
Uncle bob has dedicated a whole book full with tips and tricks (ok tips and tricks sounds demeaning, but really it is a great book that every developer should read).
Ok I did not like how the videos of NDC where listed and created a new list now grouped by speaker and the link points to a almost direct link of the video, now it will open full screen in the browser. The order of the speakers is accidential.

Tim Huckaby

Jump into Windows Presentation Foundation! ...and Become Immediately Effective
Declarative UI Programming with XAML: Windows Presentation Foundation, Silverlight & Surface
Building Data Visualization Applications with the Windows Presentation Foundation
Integrating Windows Presentation Foundation and Windows Communications Foundation into Your Office Business Applications


Scott Hanselman

(comming soon)Deep Tour of .NET 4
Making Your Blog Suck Less: Social Networking and Your Personal Brand Online
The Haacked and Hanselman Show
The magic of "Astoria" - ADO.NET Data Services


Ted Neward

Why the Next Five Years Will Be About Languages
(comming soon)The Busy Developers Guide to ECMA(Java)Script
Rethinking "Enterprise"
XML Messaging in .NET using Windows Communication Foundation
Core Windows Communication Foundation Patterns


Ayende Rahien

Writing Domain Specific Languages in Boo
Building Scalable Systems
Inversion of Control & Dependency Injection: Breaking out from the Dependency Hell
Producing Production Quality Software
Object Relational Mapping + = 2: More than just Data <--> Object


Michael Feathers

Seven Blind Alleys in Software Design
Working Effectively with the Legacy Code: Taming the Wild Code Base
(comming soon)Functional Thinking for Object-Oriented Designers
Design Sense Deep Lessons in Software Design


Jonas Follesø

MVVM Patterns for Silverlight and WPF applications
(comming soon)Building Business Applications in Silverlight 3


Luca Bolognese

(comming soon)The Future of C#
(comming soon)An Introduction to Microsoft F#


Udi Dahan

(comming soon)Reliability, Availability, and Scalability - How to have your cake, and eat it too
Intentions and Interfaces - Making Patterns Complete
Avoid Failed SOA-business & Autonomous Components to the Rescue


Phil Haack

Black Belt Ninja Tips ASP.NET MVC
(comming soon)ASP.NET MVC + AJAX = meant for each other
The Haacked and Hanselman Show


Robert C. Martin

Clean Code: Functions
Clean Design: SOLID Principles I and II
Clean Design: Components Principles
Clean Practice: Agility and Craftsmanship


Jeremy D. Miller

Lessons Learned from a Long Lived Codebase
Presentation Patterns for Composite Applications
Convention over Configuration applied to .NET
Software Design and Testability


Ian Griffiths

Writing Custom Windows Presentation Foundation Pixel Shader Effects


Richard Campbell

The Scaling IQ Test: When Development and IT Pros Collide


Richard Campbell Carl Franklin

.NET Rocks! Live


Rafal Lukawiecki

Finding Hidden Intelligence with Predictive Analytics of Data Mining
Automatic Recommendation Engine Based on Data Mining
Architectual use of Business Intelligence in Application Design
Microsoft Solutions Framework 4.0 Core for Solution Delivery Projects


Peter Provost

The Butterfly Effect
Extending VSTS 2010 Architect Edition
Code First Analysis and Design with Visual Studio Team System 2010 Arch Ed Microsoft Visual


Roy Osherove

Understanding Test Driven Development
Unit Testing Best Practices
Test Driven Development: Using Mock Objects
Mocking on the Edge - Isolation at the System Level
Unit Testing in Silverlight


Jimmy Nilsson

Is Domain-Driven Design more than Entities and Repositories?


Mike Cohn

Getting Agile with Scrum
User Stories
Agile Estimating
Agile Planning
Leading a Self-Organizing Team
Prioritizing Your Product Backlog


Craig Larman

Agile Architecting
The "Toyota Way House" for Large-Scale Lean Development


Kevlin Henney

Sustainable Software Architecture
Modelling in the Age of Agility
The Uncertainty Principle
Lean Code
A Decent Proposal
Slicing Design over Time
Thomas the Tank Engine I got this analogy after having Scott Hanselman in town, he has a specific ritual whenever he is on a trip. He wants to find a Thomas the Tank Engine to take home for his son Zenzo, but that is not all, it needs to be a wooden model.

I can only imagine how it was when the wooden Thomas model got a successor in the form of a metal model, like anything new it would have been more expensive then the previous model. It was probably the new ‘cool’ thing to have, more features and all that. The next model would be the plastic model, this again would be more superior to the previous one. More expensive as well no doubt. Now the interesting part comes; some people started seeing the craftsmanship that went into creating the wooden Thomas the Tank Engine, they appreciated the effort, they wanted that model instead of the modern mass produced stuff. I guess Scott tought his sons early to recognize quality and craftsmanship :). Now suddenly the old model becomes more in demand and it rises in value, it rises well above the original price and perhaps even above the price of the modern models.

So this is interesting, if you have the choice of buying a new model or a latest version of the old model (of anything, not just Thomas the Tank Engine), what should you do? When you go for the new, it will be the ‘cool’ thing to do, when you go for the old you will be seen as cheap. But you know that eventually this model will become more in demand, the only question is; do you live long enough to benefit from that?

So what does this have to do with Software Development you ask? Well I like to think we need to have the ‘old’ and the ‘new’ together, we want the craftsmanship of the old and we want the features of the new.

The old in Software Development are the Principles and Practices like the SOLID principles they have been around for a very long time; SRP (1979), OCP (1988), LSP (1988), ISP (1995), DIP (1996) (I found these dates in the PrinciplesOfOod by Robert C. Martin). All these principles are still very actual, also think about the Gang of Four book from 1996 where many, still appropriate, patterns are described. And of course Test Driven Development (1999). These form the basis for good design. In other words; “The Really Old Stuff”.

The new in Software Development are the languages and the frameworks that are being released by the different providers (OSS included). Think of the .Net Framework that brought us Lambda’s and Generics already, and in version 4 we get the dynamic keyword and parallel execution and many other things. In other words; ”The Really Cool Stuff”.

Separated from each other they are only mediocre powerful, but when you combine “The Really Old Stuff” with ”The Really Cool Stuff” you get an extremely strong and flexible solution on which you can continue to build your feature requirements without much pain. I like to call this; ”The Really Good Stuff”!
I realize that this is a very strong statement, but this years Norwegian Developer Conference does deserve it in full. Let me just take you through the event as I experienced it as well as what happened before and after it, so you can judge for yourself.

15th of June:

I went to the airport in Bergen to pick-up Jeremy D. Miller as we arranged him to first have a talk at NNUG Bergen. It was great to finally meet this great mind behind StructureMap and StoryTeller. He was talking about “Software Design and Testability” and “StoryTeller” where he eagerly shared his knowledge with our community. There were a lot of confirmations about ideas and practices I have/use, it is always good to hear you are on the right track. StoryTeller sounds very interesting, I will definitely give it a go. After that of-course the mandatory Geek Beer where we exchanged war stories. This is as always the most interesting part of the evening.

16th of June:

Jeremy and I flew to Oslo to be one day early for NDC, at the Park Hotel I met-up with Glenn Block for a good conversation about CAB, Prism and MEF later Scott Bellware joined us as well. That evening I was invited to join a dinner with Glenn Block, Luca Bolognese, Rune Grothaug, Phil Haacked, Scott Hanselman, Asbjørn Mikkelsen, Anders Norås and Peter Provost. A very inspiring group of people to say the least. Scott thought me (after making fun of me) how to pronounce “Jalapeño” and I was able to ask some F# questions to Luca. After dinner there was a good discussion going on with Scott Bellware, Udi Dahan, Torbjørn Marø, Jeremy Miller and Jon Torresdal.

17th of June:

The NDC keynotes by Uncle Bob Martin where as always very inspiring and full of wisdom. After that my day looked like this:
- Michael Feathers with “Seven Blind Alleys in Software Design”.
- Michael Feathers with “Working Effectively with Legacy Code”.
- Michael Feathers with “Functional Thinking for Object-Oriented Designers”.
- Luca Bolognese with “An Introduction to Microsoft F#”.
- Udi Dahan with “Intentions and Interfaces - Making Patterns Complete”.
- Jeremy D. Miller with “Presentation Patterns for Composite Applications”.

18th of June:

My second day at NDC was divided as followed:
- Ian Griffiths with “Parallel FX”.
- Udi Dahan with “Asynchronous Systems Architecture for the Web”.
- Jimmy Nilsson with “Is Domain-Driven Design more than Entities and Repositories?”.
- Ayende Rahien with “Object Relational Mapping + = 2: More than just Data <--> Object”.
- Glenn Block with “Building openly extensible applications with .NET Framework 4.0”.

19th of June:

The third day didn’t have that much variation with respect to speakers, but interesting none the less:
- Kevlin Henney with “The Uncertainty Principle”.
- Kevlin Henney with “Lean Code”.
- Kevlin Henney with “A Decent Proposal”.
- Kevlin Henney with “Slicing Design over Time”.

20th of June:

This was back home in Bergen after NDC, we have been lucky enough that Scott Hanselman wanted to do a presentation for NNUG Bergen. We had a quick lunch before hand where Carl Franklin joined us as well. Carl gave us the best speaker introduction we have ever had at NNUG, the crowed was wild! Scott talked with great enthusiasm about “Deep tour of .Net 4”. I have never heard such a loud applause after a presentation!

Recordings:

I can’t wait until the recording are published so I can see everything I missed and everything I did see. I hope they make the recordings public it would be a shame if this stayed private to attendees, such great knowledge needs to be shared.

Value:

I believe that the greatest value of this conference (and others a like) is the fact that you can ask questions and discuss issues and thoughts with the speakers. Of course the presentations in itself are great, but just the ability to talk to these great minds in our industry. I really want to thank Anders Norås, Rune Grothaug and Kjersti Sandberg for organizing this great event.

FubuMVC

by Mark Nijhof, in SOLID FubuMVC | Sunday, May 31, 2009 | 0 comments
I held a presentation about FubuMVC for NNUG and decided to write down an abstract of it just like I did for my SOLID presentation "Software Development is not a Jenga game" for those who don’t want to listen my almost 2 hour E-VAN talk (I can’t blame you).

FubuMVC


FubuMVC
The Front Controller Style pattern is a pattern described in Martin Fowlers P of EAA book, read more about it here.

FubuMVC
FubuMVC is not build or based upon ASP.NET MVC, it is inspired by it, but it might actually be even more inspired by Ruby on Rails. The one thing that is shared between ASP.NET MVC and FubuMVC is the System.Web.Routing library, which is used for Url rewriting.

FubuMVC
The guys at Dovetail have been extending ASP.NET MVC Beta 3 since they started using it, changing it more and more. Internally this extended version of ASP.NET MVC Beta 3 was called OpinionatedMVC. After a while Chad Myers thought that the ideas and principles behind OpinionatedMVC would be something others could benefit from as well and he started an Open Source project called OpinionatedMVC. This version of OpinionatedMVC was completely rebuild from the ground up not using ASP.NET MVC at all. OpinionatedMVC was later renamed into FubuMVC and continues to grow into a framework with better ideas and principles behind it.

FubuMVC


FubuMVC
Yeah as you can see this blog is created using FubuMVC you can also see the code which is located in the FubuMVC Contrib project. I created/copied it to learn the FubuMVC framework and is mostly based on an other example AltOxite which is also in the Contrib. After some changes in the framework I will be rebuilding it using proper BDD.

So why would you want to use FubuMVC instead of ASP.NET MVC? Well lets look at how this website is build up. What are the different responsibilities?

FubuMVC
First the main reason for the page to exist, the main content. This is what is important for the user browsing the the web page, if this fails all fails.

FubuMVC
Second is the menu, this can be used to navigate the website, here different options may be visible for different user.

FubuMVC
Third is a list of links to my last ten posts that I have published.

FubuMVC
And fourth we have a second list that contains several blog posts from other people that I have read.

FubuMVC
As you can see on this very simple web page there are already minimal 4 different responsibilities that have nothing to do with each other. So instead of putting these different things in one controller (The C in the MVC pattern, to read more about MVC go here) FubuMVC gives us a different approach to deal with these different responsibilities. Lets take a look at how a request is being handled by FubuMVC.

FubuMVC
After the URL has been processed by the Routing engine of the .Net framework a Action Invoker is being called. Depending on the configuration this can be a One Model In One Model Out (OMIOMO), One Model In Zero Model Out (OMIZMO), Zero Model In One Model Out (ZMIOMO) or a Zero Model In Zero Model Out (ZMIZMO) action invoker. The Model is obviously the M in the MVC pattern.

FubuMVC
Here is some dirty work being done for the user of the framework so you don’t have to worry about it. Here FubuMVC is processing the POST / GET data submitted to the web page. Something that normally involves parsing a dictionary using string keys, FubuMVC uses reflection to map these dictionary keys on provided model properties. This enables type safety for using these variables.

FubuMVC
Here is one of the key features of FubuMVC, Behaviors. Behaviors is a decorator around the Model. It can place data in the model or process data provided by the model, or in some cases do something unrelated to the model.

FubuMVC
But look, multiple Models can be placed inside each other, creating a chain of behaviors that are all wrapping the model and each other. Each behavior can do its own thing, do you see where we are going at with these behaviors?

FubuMVC
Then finally after all the behaviors we get to the Controller, you can see there is a prepare input and modify output on each behavior, so you can do something before and after the controller. And for that matter any inline behavior as well.

FubuMVC
Then when the whole behavior chain including the controller have been executed the output is generated. Well generating the output is a behavior in itself.

FubuMVC
But hey the chain is in control of the whole request pipeline so if certain conditions apply a behavior can decide not to continue executing the chain but instead render a different result to the browser.

FubuMVC
But why should I use behaviors, well they are our answer to the previously proposed problem of having to many responsibilities in the controller. Each behavior will have one and only one responsibility and because you can chain them all together you are able to provide the same functionality and still adhere to the Single Responsibility Principle. This also makes re-use much more feasable.

FubuMVC
Here is a very common behavior, this one loads the latest ten blog posts and puts the results in the model. As you can see the behavior is very compact and easy to understand. The behavior_base_for_convenience is a convenience base class that provides the prepare input and modify output functionality.

FubuMVC
This behavior has a different structure as the previous one. This is one of those cool features of a behavior chain, because of how behaviors are all wrapping each other they give you the ability to wrap a whole request in a try catch statement. In this example I am showing you an UnitOfWork implementation. When something in the chain throws an error the whole transaction is reverted. This together with StructureMap makes for a very powerful implementation. StructureMap has the ability to cache an object for the duration of a web request so anywhere where the UnitOfWork is needed you will get the same one. Thus basically ensuring that the whole request is running in the same transaction.

FubuMVC
Convention over Configuration is an other very good reason why you may want to try FubuMVC, it means that whenever there is something that will be repeated you want to tell the framework how to deal with these situation. You don’t want to specify everything, you just want to specify the rule.

FubuMVC
The top example is a rule where FubuMVC can find the controllers in your system, and also how to discover the action methods. Below that is specified what default behaviors should be attached for each discovered action method.

FubuMVC
The top example shows us how we tell FubuMVC where to find the views and partial views when it needs them. And below that we define how FubuMVC will create the URL’s for the action methods it discovered.

FubuMVC
As you can see FubuMVC wants to limit repetition as much as possible, whenever there is something that should be able to be configured using a convention you can trust the framework to try to do so. But what is important is to know that these will be your conventions, not ours. So you can work with the framework how you like to work.

FubuMVC
We don’t want you to burn yourself when dealing with all kinds of magic strings, so we strive to have everything benefit from compiler checking. As I mentioned before processing POST / GET variables is done in such a way, but this comes back everywhere else as well.

FubuMVC
Just take a look at the view displayed above you may notice that there are no magic strings involved. Below is the model that will be provided to the view, as you can see Model.Body is mapped straight from in the view, but take a look at RenderPartial().Using()...ForEachOf(Model.Tags) this will render a partial view of type TagLink for each item in the Model.Tags collection. There is some more pretty stuff in there which I am sure you can figure out as well.

FubuMVC
Well you may have noticed it already but FubuMVC is build keeping in mind all the proper principles like SOLID and DRY. Especially the Single Responsibility Principle, Interface Segregation Principle and the Dependency Inversion Principle are found everywhere in the code. For example an IoC container is used to make DIP easier, by default this is StructureMap, but internally everything uses the Common Service Locator so you can use other IoC containers as well.

FubuMVC
Testability is an important topic as well and a very welcome side affect of adhering all the proper principles is that your code becomes very testable. You have seen the examples and all of them are easily testable, this goes for everything you would create using the framework. And also the FubuMVC code is properly tested.

FubuMVC
But we couldn’t test it all. Yes Chad is also working on an implementation of Spark for FubuMVC so you don’t have to use the ASP.NET render anymore.

FubuMVC
Yes if you have questions or comments, please let me know, I will be happy to hear them, especially the confronting ones.
Navigate to next page »

Mark is reading