Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using a Commerical Framework like MM
Message
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Miscellaneous
Thread ID:
00805765
Message ID:
00806691
Views:
24
>Thats my business rule, now, when I introduce the framework:
>
>1. What will this code look like?
>2. Will it be as easy to modify as the existing code?
>(Lets say we change the business rule to return name + firstName != "", does the business rule implemented as an object adapt as easily?)
>3. What do I gain using the new way and not simply coding the rule in a straightforward manner that all C# developers will understand?
>
>I do see why one would want to implement an interface to make business objects more accessible, but still, thats fairly trivial and doesn't require a framework.

When you take away the trappings of his framework the code is almost exactly the same as yours. Here is his code from developer guide
public override bool CheckRulesHook(DataSet ds, string tableName)
{
	DataRow dr = ds.Tables[tableName].Rows[0];

	this.ValidateShipName(dr["ShipName"].ToString());
	this.ValidateShipRegion(dr["ShipRegion"].ToString());

	return this.ErrorProviderBrokenRuleCount == 0;
}

public string ValidateShipName(string shipName)
{
	string message = null;

	if (shipName == "")
	{
		message = "Must specify a ship name";
		this.AddErrorProviderBrokenRule("ShipName",
			message);
	}
	return message;
}
You create a subclass for each business object, override the CheckRulesHook and put in a call to each of your validation routines.

The beauty is that the validation gets checked at the appropriate time and any broken rule messages get displayed automatically as long as you are using his mmBusinessForm. All the infrastructure is in place and you just hook into it using the Template design pattern. Its no different than what you would do and conceptually its the same thing, just easier.

For example, if you set SetRequiredFieldsFromDataSet to true in the business object, the rules object knows how to check for all the columns that do not allow null values.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform