Our functional analysts have designed the 'Life' of a Person as a separate domain object called 'Period'. They did this because -according to them- a person's life is like any other period: it has a start and an end. It also has the same business rules applied to it:
They really would like me to do the technical implementation of the business classes the same way. Something like this:
public class Period
{
private DateTime _start;
private DateTime? _end;
public DateTime Start
{
get { return _start; }
set { _start = value; }
}
public DateTime? End
{
get { return _end; }
set { _end = value; }
}
}
public class Person
{
private Period _life = new Period();
public DateTime DateOfBirth
{
get { return _life.Start; }
set { _life.Start = value; }
}
public DateTime? DateOfDeath
{
get { return _life.End; }
set { _life.End = value; }
}
}
I’m really sceptical about this; because the Life of a person does not exist on itself, it has no Id to identify it and more important: I think it would make things more difficult, because in the UI the validation errors should appear next to the DateOfBirth and DateOfDeath fields of the Person, which means I have to put the validation rules in the Person class also.
My idea is to forget all about the Period class in the technical implementation and add the business logic that applies to the period directly in the Person class.
Do you guys have any advice on this?
Thanks in advance,
Marc
Thanks for your quick reply...
If the design is ok, how do you solve the problem of showing the broken Period rules in the UI then?
I'm seeing 2 possible options:
I'm fairly new to CSLA.NET, so I don't know what are considered the 'best practices' in cases like this... Maybe there is even a third option I didn't think of?
Thanks,
Marc
I've done the same thing with addresses. To me, the whole concept is very powerful if you make the Period a very basic business object in its own right, and then make a self-contained user control that edits Periods. By self-contained I mean it has its own BindingSource and error provider as well as the input controls. The control or form hosting the Period user control just needs to handle setting its BindingSource.
Now you just plunk down that user control on any form or control that edits a business object with a Period property.
Copyright (c) Marimer LLC