Wednesday, February 29, 2012

Getting started with DDD when surrounded by Legacy systems, by Eric Evans


Getting started with DDD when surrounded by Legacy systems

STRATEGY 1: BUBBLE CONTEXT(Part 1 of a series by Eric Evans)
  • Why we need the bubble
  • How we form the bubble
  • What becomes of the bubble
WHY WE NEED THE BUBBLE

We say that effectively applying the tactical techniques of domain-driven design (DDD) requires a clean, bounded context (See September 2010 newsletter). This can be a daunting requirement when your work is dominated by legacy systems. These systems are often tangled, and even when they are orderly they are usually not suited to DDD. In a series of articles over the next few months, I'll describe strategies for getting started with DDD when you have a big commitment to legacy systems.

All of these strategies will be ways of establishing a new bounded context. Attempts to employ the DDD tactics in the context of a legacy system almost always disappoint. One of the fundamentals of DDD is that we choose a model (by which we mean a system of abstractions) well suited to the problem at hand, yet a legacy system already has an established model, albeit implicit, and this model can seldom be changed with a reasonable amount of effort. Even if the legacy model could be changed, the new model might not suit the legacy functionality -- the change could undermine what the legacy system was always good at. On the other hand, simply adding objects that express a distinct model without changing the ones already there will lead to conflicting rules and concepts.

Will DDD work for your team? by Eric Evans


Will DDD work for your team?
Four prerequisites for Domain-driven Design


by Eric Evans

While the Strategic Design techniques of DDD can be applied in many situations, development based on subtle domain models has some demanding prerequisites. If you don't have them, it is a waste of effort to leap into application of DDD at the tactical level.

Instead of grinding your gears trying to express elegant models, you'd do better to direct your efforts toward establishing these conditions for success.

This is real life, and nothing is perfect. However, you really must have some form of the following,
  • Access to domain experts
  • An iterative process
  • A clean, bounded context
  • Skills on the team

Wednesday, February 22, 2012

SMTP4DEV

This is a great little tool that will run on your desktop and listen to port 25. Ideal if you are writing code that sends email. That said though. If you have a dependency on smtp and it is preventing you in Test Driven Development then you should probably think about refactoring with dependency injection.


Monday, February 20, 2012

How to use the Yield statement in C#

The Yield is  a very interesting statement. You use it with the Return statement to build a collection.



// Step through the list until we get to the '10' 
void DoSomethingToTheNumbers()
{
foreach (int num in MakeListofNumbers())
{
if (num == 10) return;
}
}


// makes an IEnumerable list of '3', '4'.. 19
IEnumerable MakeListofNumbers()
{
for(int i = 3; i < 20; i++)
{
yield return i;
}
}


 In the method MakeListofNumbers() an IEnumerable of integer values is created. This is built up in a "lazy" manner.

So in the DoSomethingToTheNumbers() method, we can enumerate the MakeListofNumbers() by using a foreach statement. That is we can step through each element in the IEnumerable list.

To see how neat this is it is best to step through it using the debugger. As you step through the foreach statement, the code will magically jump down into the MakeListofNumbers() function and generate the next number in the list.

(To Computer Science nerds this is called a "Continuation")

Why is it called Yield? I think it's because the method yields control to the calling function.

Is it useful?
Well yes but not often. This is really handy if the enumeration generation method is doing something rather computationally expensive. If it is, and if you want to cease the foreach partway through, that is, you want to foreach only the first n elements in the IEnumerable, then you can and you will not have wasted time creating the entire IEnumerable list.


Thursday, February 16, 2012

The Planning Fallacy



Do we all experience the Fallacy on our work:
  • Overoptimistic in the time planning therefore underestimating time taken.
  • Overestimating the benefits
In 1979 a paper by Daniel Kahneman coined the term the Planning Fallacy.

It is a very real and measurable effect. Using a number of different subject areas from origami to tax returns. The tendency is to plan on the light side. Interestingly this only happens when we estimate our own work. When people uninvolved in the work are asked for estimates, they tend to over estimate.
No one really knows why, but vocalism is thought to be a candidate.

One curious observation is that people still tend to underestimate the task even if they have evidence from previous similar tasks.


Wednesday, February 15, 2012

how to stop Windows rebooting after an auto update

I'm a snob and I am unbearable company because I'm a fully paid up member of the Mac brigade. Every day there is at least one moment of pleasurable reflection when I appreciate something on one of my Mac devices where I'm glad they paid a great deal of attention to the detail.
Windows on the other hand...
No actually I'm not dead against Microsoft or Windows as it's definitely horses for courses and no giant corporation can be right all the time. But I do have my pet hates. Here is one.

You leave your windows machine for a coffee break. The Visual Studio windows are arranged. Source files open at specific points as you struggle your way through more diagnostics.

You come back and Windows has rebooted!
Who in the name of ... thought that would be a neat thing to do.

Yes I'm sure from an OS perspective, a Microsoft perspective, from a Paternalistic systems perspective they're doing it for our own good.

I hear that Windows 8 will require fewer reboots. That makes me smile.

So, how to disable this patronising annoyance:

Step 1
Go to the Start button, or whatever it's called these days, and in the search box type
gpedit.msc
this opens the Group Policy editor.

Step 2
In the tree view,  navigate to:

Computer Configuration -> Administrative Templates -> Windows Components -> Windows Updates

Step 3
In the right hand pane:
Double-click on:
 "No auto-restart with logged on users for scheduled automatic updates installations"

Step 4
Set this to Enabled.
Click OK to go on your merry way.

Wednesday, February 8, 2012

Papua New Guinea Fairtrade coffee beans









Mrs Non-Gorilla Morning Mrs Gorilla.
Mrs Gorilla Morning Mrs Non-Gorilla.
Mrs Non-Gorilla Have you been shopping?
Mrs Gorilla No...been shopping.
Mrs Non-Gorilla Did you buy anything?
Mrs Gorilla A piston engine.
She reveals a six-cylinder car engine on a white tray, on a trolley.
Mrs Non-Gorilla What d'you buy that for??
Mrs Gorilla Oooh! It was a bargain.

Monday, February 6, 2012

espresso

The more espresso I drink, the slower everybody else talks.    

Development on the iPad - Pixie Scheme

Quite interestingly, you can actually develop on the iPad if you felt so inclined. I know there is a rather cool editor with brace matching and keyword colouring etc - Textastic. I  But I didn't know you could actually code and run. One that I found is Pixie Scheme. Link to Pixie Scheme


I can't criticise this at all: It's worthy. It's free (or is it £0.69). It works. It's fun. It's useful if you want to do little bits of Lisp/Scheme whilst slouched in front of the telly, or on the train. But, why can't developers get a sense of colour and visual design? I include myself in that group so I say that with a smile.


Saturday, February 4, 2012

vsClojure - .cljproj is not supported by this version.

For a .NET developer, when starting out with Clojure it seems obvious to try to get it to work in Visual Studio rather than struggle with Emacs and Slime. So you visit the the Extension Manager, search for Clojure, and instal the extension.

If you then create a New Project, and select a Clojure project, this message can appear:


'<somestuff>\VisualStudio\10.0\Extensions\vsClojure\2.0.0\Templates\Projects\Clojure\Clojure.cljproj' cannot be opened because its project type (.cljproj) is not supported by this version of the application.
To open it, please use a version that supports this type of project.

So it seems that Visual Studio didn't know about the project type, the .cljproj. 

First attempt to fix vsClojure Failed
I tried something that was suggested in a posting somewhere.

Reset the Skip Package flags. 
This didn't work for me, but may work for you.
You locate Devenv.exe and run in the command line.
Devenv can usually be found at: C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE
run Devenv.exe /ResetSkipPkgs


The Workaround
I noticed that the DLL was at:
C:\Users\John\AppData\Local\Microsoft\VisualStudio\10.0\Extensions\vsClojure\vsClojure\2.0.0\Runtimes\\1.3.0\Clojure.dll
but the problem wasn't the loading of the DLL, it was the loading of the project with a name. cljpro.

So I thought of starting the REPL to see if that did something. Probably written in C# so it might register something somewhere.

So I ran:
 Clojure.Main.exe


This was found in the same folder as the Clojure dll.
C:\Users\John\AppData\Local\Microsoft\VisualStudio\10.0\Extensions\vsClojure\vsClojure\2.0.0\Runtimes\\1.3.0\Clojure.Main.exe
I then tried to create the Clojure project in Visual Studio and it worked.