|
-
December 8th, 2008, 07:52 PM
#5
Re: Object Validation
FirstName / LastName combinatorial, as I showed in my previous reply.
More imporaantly you need to re-factor (heavily)...look at how much duplication you have..
I any real application you will end up with thousands of
Code:
if ((....))
{
OnValidationMessage("Message to user");
return;
}
type constructs.
Develop a good validation object model!!!!!
Other problems... You are tieing business logic (your classes) to UI presentation (Showing Messages). These should be separated by (typically) TWO layers.
A starting point...
Code:
class Verify<DATA_TYPE, HANDLER_TYPE>
{
public Verify(object owner) {}
public DATA_TYPE Value { get; set; }
}
class Person
{
public Person()
{
InstanceValidator(this);
}
public readonly Verify<string, Validator> FirstName(this);
public readonly Verify<string, Validator> LastNameName(this);
public ObjectValidator IsValid(this);
}
NOTE: Shortcust were taken, and this will NOT compile, it is for conceptual purposes only......
TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
2008, 2009,2010
In theory, there is no difference between theory and practice; in practice there is.
* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions 
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|