Syndicate

News

My name's Marco De Sanctis and I'm an IT professional from Italy. This is my technical blog, about .NET and related application development and design technologies.

Download my Resume (.doc)

Recent Comments

7/28/2008 at 2:46 PM

Hi...What kind of problem are you experiencing?...
by Marco De Sanctis

Read more...

7/28/2008 at 12:59 PM

Very nice concept and can i expect for list box? ,...
by Sudhir Malireddy

Read more...

7/28/2008 at 9:58 AM

In aggregates the rula is: who is the rool element...
by Tommaso Caldarola

Read more...

7/22/2008 at 7:49 PM

Been there too in a past project! I remember this ...
by Mathias

Read more...

7/14/2008 at 11:50 PM

Sure I am... but if you got batches that last for ...
by Marco De Sanctis

Read more...

Recent Posts

Crunch mode is a pure waste of time, energy and money

7/31/2008 at 5:41 PM

Read more...

Double Click on the .sln file doesn't open Visual Studio on Vista

7/27/2008 at 9:02 AM

Read more...

Domain Model & Aggregates: when do master-detail associations happen?

7/22/2008 at 4:08 PM

Read more...

How I Got Started in Software Development

7/14/2008 at 12:16 AM

Read more...

Unleash the power of VisualStateManager with custom states

6/30/2008 at 12:12 AM

Read more...

July 2008 Entries

Crunch mode, overtimes, weekends spent at the office, are at the very first sight the easiest way to maximize production to meet strict deadlines: my experience is that actually many companies operating in the Italian IT market intensively use this approach. Is the effort worth the gains? Is a tired employee able to work at the same quality level of a fresh one? Obviously not, crunch mode reveals to be counterproductive after a short amount of time. Francesco Carucci, a member of the Italian .NET User Group, recently posted a link to a very interesting article every PM should read.

Here it is, enjoy.

Technorati Tags: ,,

It's a very annoying bug I had to cohabit with for a while. Today I was less patient than usual and I decided to get rid of it :-)

I googled for a minute to find a comment on this post with the solution I needed:

It works when you set both Launcher (C:\Program Files\Common Files\Microsoft Shared\MSEnv\VSLauncher.exe) and IDE (C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\devenv.exe) to run as administrator. (Right click .exe and select Properties -> Compatibility, and choose Run as Administrator)

Oh... obviously a solution could be to directly bind the .sln files to devenv.exe, but I think this is a nicer one.

kick it on DotNetKicks.com

Technorati Tags: ,

During my experience as a consultant, I usually come across domain models in which entities are so interconnected that my head begins to hurt just a minute after I'm trying to figure out where each aggregation symbol leads to, and often the source of all pain is the overuse of master-detail relationship.

An association in a domain model is something etheral, something that apart from its implementation, represent a logical connection between two or more abstract entities. It usually translates itself as a reference in a Object Oriented world and, for example, as a FK relationship between two tables in a relational database.

Now, let's consider a Bill - BillDetail relationship: no one would disagree if I modeled it with the following couple of classes, building a two ways master-detail association:

image

When we project it to a relational database schema, it becomes something like this:

image

Relational representation lacks a lot of the expressivity the object oriented paradigm provides: looking at the classes topology, we can explicitely see that one Bill instance holds a reference to a collection of BillDetails, and thanks to BillDetail.ParentBill property, we can walk that association in both directions while navigating the object graph; all those infos are only implicitely stored in the relational FK association.

In fact, what happens when we consider the Customer the bill belongs to? Let's start from DB schema this time, as most of us are (incorrectly) still used to do while designing a domain model:

image

Now, the inexperienced (but somehow smart) designer should feel that something's different between the two aforementioned examples, even though the relational representation is exactly the same: the association from a bill towards its customer is something we all agree with, but what about the mirrored association? Should we blindly equip our Customer entity with a Bills collection? Or should we simply ignore that side, perhaps providing a GetBillsByCustomer(..) service if we really need to walk from a customer to his bills?

There's a subtle differerence going on between these two examples, something that, once again, is not easy to infer if we're using the database schema as the starting point for our modeling process. A bill detail is something unuseful if taken away from its root; the "Bill" entity with all its details, encompasses the business concept of a real world "Bill". Using a DDD term, they are an Aggregate, whose root is the Bill itself. In that case, implementing a master detail relationship between the two makes a lot of sense, because you're always going to access each bill detail coming from the main Bill entity (you should never access directly each bill detail, according to what Eric Evans states in its Domain Driven Design book).

The relationship between Customer and its Bills now is clearly different! There's nothing bad on directly referencing a Bill, without coming from the Customer, actually a Bill makes a lot of sense (and has a huge business meaning) even though we don't even take care of which customer it belongs to! in other words, Customer and its Bills are not an aggregate.

Why we should avoid master-detail relationship between the two? Because associations are cool, but don't come for free: they have a great cost in terms of complexity and performance, even though we can leverage some ORM to limit the impact on the application. What could be the purpose of a "Bills" property into the Customer class? Even if we suppose to lazy load it, simply accessing it would trigger a query for every bill he has, regardless of the period, of its paying status, and so on. Does it have a business meaning? I don't think so, but that wrong design choice makes us paying its cost anyway.

In other words, a good rule of thumb is: if it's not an aggregate, limit the cohesion and try to avoid master-detail relationships because they are expensive.

I hope many of you agree with that.

kick it on DotNetKicks.com

A couple (perhaps more?) days ago, my friend Simone tagged me with the brand new meme How did you got started in software development? Uhm... ok... here we go ;-)

How old were you when you started programming?

I can't tell it for sure, it must have been when I was 6 or 7 with my father's Pc IBM (who was actually doing it professionally). Anyway... I'm talking about early 80s here.

How did you get started in programming?

My father wanted me to learn how to do it, although I was very young and all that I could do was summing two numbers or playing some notes on the internal beeper. After that very early period, I focused more on videogames for some years, until Visual Basic 1.0 came out. I was so excited that I decided this would have been my life's profession.

What was your first language?

Basic

What was the first real program you wrote?

It was a car taxes calculator I made for a company that hired me during summertime (I was still a student). I made it in Visual Basic for MS-DOS (can anyone remember it?)

What languages have you used since you started programming?

So many... C, C++, Assembler, Basic, Visual Basic, C#, HTML, Javascript, Java... Oh... and VHDL too, as I've been working on digital controlled power supply too.

What was your first professional programming gig?

As I said before, I joined a company to do some work during summer time while I was still a student. Then I re-joined the same company many years later, after my degree in engineering.

If you knew then what you know now, would you have started programming?

Uhm... I think so... I'm actually so happy on what I do every day. However, if I could, I would take some different path on my professional career.

If there is one thing you learned along the way that you would tell new developers, what would it be? 

Try to work with the best, and someday you'll become one of them too.

What's the most fun you've ever had ... programming?

Too easy... having diner with my friends at UGIdotNet after a meeting!!

Who do I tag?

Uhm... what about my friend Alkampfer? :D