There is a lot out there about business objects and lot that is not. What is out there are endless combinations of code and ideologies. When you are an business and you have to begin to rely on outside coders to enforce the integrity of your data, business rules, and workflow, you have to begin to wonder if it is worth it. There is a likelihood that your developers have chosen a third party to help them do their business objects. That puts you in a conundrum. What happens if they leave? What is the learning curve and how will you continue to support it if you pick an in-depth business object framework like CSLA.Net or nBusiness?
Microsoft seems to be addressing this concern in a circular, almost arbitrary manner. They give you new technologies like LINQ, ASP.Net MVC, Dynamic Data Web Site, Enterprise Library, etc. But none of them answer the question or business need - a simple, manageable business object framework. What is a developer to do?
A business object has to do the following (more could be added):
- Support fields,
- Allow for validation; a.k.a. business rules,
- Have a way to get data,
- Create collections of objects,
- Trap errors,
- Be aware of it's state; dirty, new, old.
- etc.
Why is there no simple way to make this happen?
I am an avid fan of CSLA.Net and highly recommend it. I just discovered nBusiness on codeplex.com/nbusiness.
You can take a look at them and take the time to learn them. There is a lot to be learned and will probably help you solve some of your existing coding problems and give you some new insights to coding.
I have been thinking about this for a long time and I have some initial thoughts about business objects.
I think you should be able to create a class with properties and fields, simple enough. You should be able to decorate your class and properties with attributes that tell a business object framework how to handle them.
An example would be
[Fetch("sp_GetById", "Id")]
[Delete("sp_DeleteById", "Id")]
public class MyObject
{
private int _Id;
[Validation(NotNullable)]
[InitialValue(InFromDatabase)]
[WriteRoles("Admin")]
[ChangeRoles("Admin, Editor")]
[ReadOnlyRoles("?")]
public int Id
{
get { return _Id; }
set { _Id = value; }
}
}
Where is my hero for a business object framework? I think this can be done with less than a dozen custom class files, a data provider framework, and the core .Net framework.