Tuesday, September 22, 2009

Much Ado About Agile 2009 Conference Registration is Open!

This is the line up:

Martin Fowler,
Eric Evans,
Michael Feathers,
Mary Poppendieck,
and others

The conference is going to sell out quickly as it is a small venue.

To register please visit www.agilevancouver.ca

Sunday, September 20, 2009

Event Sourcing and CQS part 1

Lets start by getting the transaction side of the application going. We're going to have a customer class that will have some simple properties at first.

Here is the project setup:


This is a pretty easy start. We have the test project that will exercise anything that we write. The messages project is where all our messages will reside. The Transaction Service will house our coordination of receiving commands to the Domain. We'll worry about the event publishing in a little bit. The Domain project will house our entities.

Time to get some sleep. More on this tomorrow.

Time Machine Example Implementation

A little while ago I wrote about a time machine for your application. This based on Greg Young's infamous Event Sourcing strategy. It's time to get a sample application going with this approach. I'll also take it one step further and apply the same strategy to the reporting side of the application. A lot of this hinges on the Open Closed Principle (OCP) so I'll try and enforce that through GIT hooks.

Here is a recap of the steps I'll be taking:

1. Event Sourcing and CQS to the extreme as prescribed by Greg.
2. Event Sourcing for reporting schema changes.
3. OCP application to the versioning of the dB instead of version scripts.
4. Enforcement of the OCP to the pub/sub of the reporting dB.
5. OCP application to the reporting services side through GIT hooks.

This will be hyperlinked as I complete the blog posts.

Friday, September 18, 2009

The Best Certification

The best "certification" is still community recognition by putting
yourself out there and learning/teaching publicly:

Blogging:

You put up your ideas in front of many eyes. Teach people. They will be better because of you. Learn from people. You will be better because of them.

Twittering:

An optimal conversation is hard to find within your geographical confines. Get the room full of conversations experience on the global scale. What you want to talk about right now is something that others out there want to talk about as well.

Participating in Forums:

To explain something in more than a 140 character-at-a-time conversation, you need a forum. People on forums are there to teach and learn. Participate!

Presenting at User Groups:

Sometimes you just need to talk to people in person and get your ideas out in that manner. Local user groups are great as the attendees are people that you can find common ground with, teach and learn from their critique of what you present.

Presenting at Conferences:

This is an extension of the user group but will connect with a larger group and geographical reach. It will help you develop as a presenter which will make you a better teacher and better learner. The evaluation forms will let you know where you can improve.

Reaching Out to Other User Groups:

Get involved in other user groups. Present there. See what the gap is between the groups. This new dialogue will be very important to learn why the groups exist and why the technologies/methodologies/etc behind each exists.

I resisted that for a long time and only recently bit the bullet to do all of the
above. Your "certification" is the recognition your peers give you.

People right out of school are having a hard time getting work. The
ones that are passionate are the ones that I see getting their career
going in the right direction. They are the ones that are still there
participating in the community. We started an Alt.Net Vancouver group
which is tiny compared to most user groups. But I have a hard time
finding more dedicated people. The inexperienced people are getting
their best "certification".

Hope this will save some people from memorizing index cards and put their time to good use instead!

Thursday, September 17, 2009

Layers Talk

I put together a talk on layers for TechDays. This is part of a new track that Microsoft is piloting in Vancouver and Toronto. Due to the constraints of time, I had to eliminate some of the subjects that I was originally going to cover. One of them was scalability. I've included the original layout at the end here and hopefully I will be going back to this post and adding some links to subsequent posts. Design by Contract was added as the replacement subject.

Thursday, September 10, 2009

Cake Please


I spent the last week and then some preparing a "Layers" presentation. The focus was to try and get away from what's been taught 20 years ago and the 3-tier UI-BL-DL structure.

My first attempt was to concentrate on why software was organized at all. It's to manage growth. You don't need any structure if you have a very simple system. With growth comes a demand that goes beyond the organization of the logic. Most modern architecture topics deal with the growth of data that companies need to manage. On top of that is the other -ilities.

So, scalability and the layers was going to be it. I guess it fell too much on the database at first. The other layers got the raw end of the deal. But wait. That would have been irresponsible.

The truth is that the structure of such companies is really now a system of systems. Each system may be a cake or a few. The trick is now looking at what sits on top of the shards, document dbs, object dbs, etc.

So the presentation really turned into an SOA talk with some Domain Driven Design. By diving deeper, the Domain Driven Design turned out to be a vortex with one idea relying on the other - not unlike mathematics: If you want to learn calculus, you better know basic algebra.

So back to the basics it was: MVP, MVC, MVVM, Transaction Script, Active Record, Domain Model, Data Access and ORM - touching on DbC, DDD and SOA for the second half. I'm happy that I got to use napkin doodles for my diagrams - UML belongs on those things. An MVP diagram looks better next to a coffee cup stain anyway. MS will probably clean all this up :-/

I don't know. Maybe I'm too tired at this point in the night. I didn't manage to work GIT in to the presentation. Next time.

Monday, September 7, 2009

A Rewind Button For Your Application Without the Temporal Object Pattern

In Ayende's style, I will blog as soon as a thought comes to me.

In the last year or so, I have been working on applying the Event Sourcing pattern. This led to some interesting thoughts. With the fact that the state of any object will be "rewindable", you can do a true audit. Audit logs don't cut it as Greg Young has put forth in his presentations.

That's great for the state of each of the objects. With a bit of work, you can work out anything that might have happened on any reporting that you may need or needed. This may be quite a task to merge your structure and lookup data changes in the reporting db and the actual events that update that data.

To add, the more difficult task is to have the reporting service changes merged as well. This would not be so bad if the Open Closed Principle (OCP) was adhered to - but only for when new events were added. If the reporting service started to act differently as of some arbitrary version, a careful replay of the system through time would be needed with binaries ready for each timespan that they were around for to receive those events.

There is the very explicit Temporal Object Pattern that seems tempting to use. However unless the domain is clearly responsible for knowing it's own contracts, this looks like a very complex solution to put forth as we will want all our objects to be temporal - and our reporting data as well. This is just a wish to have a rewind button on my app to have a truly representative audit.

So now that we've described the problem, let's take a look at a possible solution: Event Sourcing. As stated earlier, this allows us to capture events that the domain publishes and add the ability to reconstruct an objects state using just what has been published in the past. A very good implementation of this pattern was thought up by Greg Young. Martin Fowler writes about it here.

That solves the problem of the rewind button working on the objects themselves. How can we do the same for the rest: reporting services and the reporting schema? The trick is that the state of the objects is write-only via the events they have published so far. To have the same effect for the Reporting Service, we need to adhere to the OCP and publish an event called "CustomerReportService2 will now listen to all CustomerEvents from now on". We keep both versions of the service alive. We can also say that another message is now going to be consumed by the second version from now on at a later point in time.

This simple fact that we are closing the old service functionality from that point on in the event stream is key. It also gives us the same thing for the dB schema. When we add a table or column or lookup item, etc., we publish the schema change as an event. When rewinding the clock, we drop all the tables from the dB and simply replay all events from the beginning of time through the latest binaries. This may take some time, so some snap shot concept can be introduced as is with Greg's Aggregate Root object snapshot idea.

If we adhered to the OCP, the reporting service and schema will have been used as it has before. The slight overhead is the management of which version of the reporting logic is used when. It listens for when to switch directing of the messages to a particular version of the service. Sounds like a job for an Inversion of Control (IoC) Contianer?!

So.. It always comes back to this: GIT hooks that prevent you from changing certain files in certain ways! The db script can only be added to! The reporting service cannot be changed - just ammended! OCP insurance from your source code management is a cool concept.

That's the best accounting system for software I can think of.

Looking forward to critiques of this and questions for clarification since I offered no diagrams. I probably will update this with that info later.

Wednesday, September 2, 2009

GIT for fun and profit presentation application

Tired of unreliable source code management? Do you save your source code in 6 different places and put a hard copy of the work you did today under your mattress when you get home? ... then you need to see how GIT's design will allow you to throw off those shackles and become a free person again!

... but wait..

Are you scared of switching to a different source code management tool because the last time it took 3 developers, 2 project managers and all of Accenture's employees in western Canada to deploy your barely functional current one? Well not this time! If you are better at copying a file than your technically challenged mother, you can deploy a git repository! You will be shown how.

and then...

Did you avoid work today because you feared missing your lunch hour break? Because getting the latest version of your solution would take so much time over your 14.4 kB modem? Thinking of switching to AOL? GIT will compress and send only the changes that you need. Take a look at why even on your beautiful dial-up connection, GIT will enable you to contribute to that open source z-modem implementation you're working on.

.. but what about this:

Constantly forgetting to check things in because you're preoccupied by those Britney Spears albums in your iPod? Did your last checkin encapsulate the project from beginning to end? Well wait! With GIT it's not too late to save yourself the horrible embarrassment of this gigantic checkin! Come discover how!

... if you're not convinced yet:

But my mom keeps tripping on and unplugging the interweb cord out of the wall when I'm working on my Dungeons and Dragons program - so I can't checkin my changes! ... And I need the new elf package to be implemented before my D&D Saturday night party! Well, don't fret my nerdy friend. GIT works without a connection too! Find out what else is possible!

.. I'll try to convince you with just one more..

The evil developer from across the office is committing changes to the files I'm working on! He types way faster than me because he uses a Dvorak keyboard and beats me in the check-in race! He gets work done and I spend my day resolving conflicts. GIT, can you help me here as well? Of course GIT can. With 9 different merging strategies to help you, your evil foe will quickly fall to the wayside and you can laugh at him when he's layed off.