IEditableObject capability for your POCO

July 14, 2009

How would you go about implementing this kind of functionality:

After changing a domain property, a system function is called. If it triggers another property, other system functions are called, if there are any.

A domain property is just any property, that has a business meaning, for example a person has a Name and Surname, a task object has a collection of ResponsibleUsers, and Status, and FinishDate, etc.

A system function is a custom business logic, that can be implemented either by a programmer, compiled and loaded during system start up, or it might be defined via “Administration” menu in your application.  In any case, this system function is registered for a concrete business type, and some exact property.

An example might look like this:

[OnPropertyChanged(typeof(Task), “Status”)]

public void OnStatusChange(Task task)


if (task.Status.Name.Equals(“Finished”))

task.FinishDate = DateTime.Now;


[OnPropertyChanged(typeof(Task), “FinishDate”)]

public void OnFinishDateChange(Task task)


// do something with FinishDate property

Manually implementing INotifyPropertyChange for each of our domain object is not a solution. What i would go with is an automatic solution.

One nice source of ideas is FabioMaulio and José F. Romaniello blogs.

Here are the blog posts that are very very interesting:

All these posts together tell how to dynamically inject necessary functionality into your POCO via interceptors, and how to wire everything with NHibernate.

As a side result, it also tells how to programme even without POCO, that is only with interfaces of your domain entities.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: