Naked Objects implemented at the Irish Government

Richard Pawson talks about his experiences implementing a Naked Objects solution for the Irish Government.

They went on to deliver 30+ projects on time and on budget!

We’re closed during December 2011

We’re closed for the month of December, and will be back in January 2012.

It’s been a while since the last post, but there are plans to revamp TrueView – a brand new WPF interface and usability improvements are top of the list

In the meantime, we wish all of our customers and colleagues a very Merry Christmas and a prosperous New Year!

Pitfalls of Domain Driven Design

Someone asked a very important question over at StackOverflow. The answer is also crucially important:

“Probably the most important one: not grokking the central, fundamental principle of the Domain Model and its representation in Ubiquitous Language. With the plethora of technology options around, it’s very easy for your head to fill up with ORMs, MVC frameworks, AJAX, SQL vs NoSql, … So much so there’s little space left for the actual problem you’re trying to solve.

And that’s DDD’s key message: don’t. Instead, explicitly focus on the problem space first and foremost. Build a domain model shorn of architectural clutter that captures, exposes and communicates the domain.”

Of course, I had to give this answer my vote too…

Naked Objects podcast with Scott Hanselman

Scott Hanselman chats with Richard Pawson about the Naked Objects framework.

Find the podcast here.

http://www.hanselman.com/blog/HanselminutesPodcast233InsideTheNakedObjectsFrameworkWithRichardPawson.aspx

Video presentation of Naked Objects

Although TrueView supports Domain Driven Design, it also embraces the Naked Objects Pattern.

This little known architectural pattern is a refreshing (maybe radical?) concept, but complements DDD very well.

Here, Dr Richard Pawson (the originator of the pattern) talks about Naked Objects, why it exists, and why a government department uses Naked Objects to build their key systems.

Compelling viewing for anyone who wants to take Agile and DDD to the next stage.

TrueView V2 Beta, now with POCO support

TrueView V2 has some significant changes since the last version.  You can download the beta and code sample here.

POCO support

TrueView now supports POCO classes, that don’t need to be inherited or marked up with attributes. Now you can re-use your POCO assemblies in other applications, and remove the dependency on the TrueView framework.

To make your POCO classes viewable in the UI, add the following property:

    public Guid ID { get; set; }

To make your classes persistable, add a Version property:

    public long Version { get; set; }

Domain Class enhancements

  • Domain Classes no longer need to be marked with attributes
  • Optional Configuration classes can decouple Domain Objects from the TrueView framework
  • Better support for structs

Infrastructure Class enhancements

  • Infrastructure classes are now decoupled from Domain Classes.
  • IPersistenceInfrastructureService is now exposed, allowing custom Services to be injected at run-time.  TrueView provides FilePersistenceService and NhibernatePersistenceServices out of the box.
  • IExportInfrastructureService replaces the old PrintProvider, and allows you to export data for any Domain Object
  • IPresenterInfrastructureService replaces the old IUiPresenter.  You can control the formatting, and well as providing custom ‘adornments’ to display

UI enhancements

  • Error indicators are now shown next to the property that caused them
  • Custom adornments can be rendered next to an item in the Explorer view
  • Better use of screen estate using multiple columns
  • Improved drag/drop tips now show why certain operations cannot be performed
  • Inline Object and List properties allow users to see more detail without having to drill-down manually.
  • Hyperlinks make it easier to navigate to associated Objects and Lists
  • Additional Enum display options include Slider and Radio-Options.
  • Enum items can be filtered using IQuerySpecification<T>
  • A new Export function replaces the old Print option

Check out the included sample code to learn about the new features.

P.S. There’s a new DomainTypes library available as well.

Update to DomainTypes library

The initial release of DomainTypes was heavily influenced by the existing TrueView framework.  After spending much time working with a current client, it’s clear that a more ‘POCO’ approach has significantly more benefits.

Based on my findings (and questions over at StackOverflow), here are the major changes:

  • Refined and enhanced most of the interfaces
  • Removed the concept of persistent and transient classes
  • Domain Services and Application Services have explicit interfaces
  • Domain Objects no longer implement IDependencyAware
  • Removed the ITrackable interface

I’ve also added more examples to clarify how you might use the interfaces.

You can download the code here.  All comments are welcome.

P.S. Note that this library is NOT compatible with the current TrueView framework.  Watch this space for the new version!

http://evolving-software.co.uk/blog/wp-admin/post-new.php

Merry Christmas and a Happy New Year!

A new version of TrueView is in the pipeline for next year.  The features on the whiteboard are:

  • Better support for true DDD concepts
  • Allow code models to be reused without TrueView
  • Configuration without using .NET attributes
  • Open architecture, to let consumers develop custom ‘persistence providers’
  • More UI interception points, to allow greater customisation
  • Auto-databinding features, for WPF and possibly Silverlight
  • N-Tier support (finally)

And we’re considering making TrueView FREE for non-commercial use.

We’re going to need beta-testers for the new version, so if you’re interested please email us.

In the meantime, have a very Happy Christmas!

Domain Types – Interfaces

In the last post, I published the DomainTypes library: a set of .NET interfaces & base classes to provide the building blocks for DDD (source code included).

In this post I’ll describe the interfaces and supporting design decisions.

IDomainObject

Represents any type of object within the Domain model. Currently this is simply used as a marker, signalling to developers that the implementation has DDD semantics.

IEntity

Represents a unique Entity within the system.  The ID property is used to identify the instance during it’s lifetime.  Using a GUID allows identity to be established without having to talk to a persistence store (i.e. database).

IValueObject

Represents a non-unique object within the system.  Note that it’s an object, and not a struct.  Structs may seem like a better semantic fit with DDD, but too many instances can cause memory problems (structs – like value types – are created on the stack).

The Clone() method is used to create copies.  The implementing class can decide whether to create new instances, or use the FlyWeight pattern.

IList<T>

Represents a list of Domain Objects.  It’s crucial that the implementing class raises events before items are added or removed from the list.  This allows consumer code to execute any domain rules, and cancel the action if necessary.

IEvent

This is one that Eric Evans mentioned earlier this year.  It is used to record & identify domain events, and must be immutable. For example, a child’s birth should be captured, be identifiable, but never modified.

IAggregateRoot

Most people understand Aggregate Roots as a cluster of closely associated entities.  However, there are 2 additional concerns that an Aggregate Root has:

  1. It knows how to validate the entire aggregate
  2. It is used to lock it’s contents in a multi-user environment

The IsConsistent() method is a placeholder for all rules/invariants that apply to the aggregate.  The locking concerns are handled by IRepository<T> (see below).

IFactory<T>

Used to create Domain Objects/Entities/Aggregate Roots that are complex to build.  Only use factories when the code within your constructors becomes unweildy.

IRepository<T>

Used as a facade to a persistence store.  Strictly speaking, repositories should only deal with Aggregate Roots – to access other entities you would navigate through the Aggregate.

In addition to the typical Load()/Save()/Delete() methods, I’ve also included Lock() and Unlock() methods.  This is a crucial function in a multi-user system, and should be considered when designing your Aggregates.

IService

Currently this is simply used as a marker.  Only consider using Services if :

  1. Try as you might, you can’t decide on which Domain Object to place your logic
  2. The logic requires the use of several unassociated Domain Objects
  3. You’re communicating with another module/tier/component

The remaining interfaces aren’t DDD specific, but are to aid real-world implementations.  I’ll discuss those in the near future.

Download the source code

Free .NET type library for Domain Driven Design + source code

I’ve observed a lot of newcomers to the DDD scene, and typically there’s lots of talk about Entities, Value Objects, Aggregate Roots, Repositories, Factories, IoC, and various technical concerns.

But I’m seeing a lot missing from the discussions.  Like “What about the locking implications around an Aggregate?” or “Must Value Objects be immutable“, or even “How do entities retrieve data if they can’t access a repository?“.

To that end, I’ve created a set of interfaces and base classes that represent the building blocks of DDD.  The idea is to get developers thinking about key concepts early in the design process, and let Intellisense provide some guidance.

You can download the source code here.  It has a Ms-Pl licence, so you can modify and use the code as you wish.

The DDD related interfaces are:

  • IDomainObject
  • IEntity
  • IAggregateRoot
  • IValueObject
  • IList<T>
  • IFactory<T>
  • IRepository<T>
  • IService<T>
  • ISpecification<T>
  • IQuerySpecification<TRequestor, TResult>

Additional interfaces for orthogonal concerns are:

  • IPersistable
  • IPersistableList<T>
  • IAudit
  • IAggregateLock
  • IAssertion
  • IDependencyAware
  • IDependencyLocator
  • ITrackable

Interfaces

This is still a work-in-progress, so feedback would be greatly appreciated.  In the next couple of posts, I’ll describe the interfaces and classes.

Download the C# project

P.S. The next version of TrueView will be based on these interfaces.  So if you code a domain model using the compiled library, TrueView will auto-generate a completely interactive UI (with the appropriate semantics) directly from your model.