Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Validate A Class
Message
From
05/04/2010 00:28:37
 
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01458686
Message ID:
01458688
Views:
62
>What's the best way to validate that all required properties on a class are completed correctly? The properties will eventually be
>mapped to UI fields, but the class itself is not visual. It's possible to instantiate the class, set some or all properties, and then call
>methods on it. I want to ensure that all required properties are complete before certain methods are run.
>
>The question is what to do if a required property is not set or is set wrong. Throw an exception?

From my own perception, high level classes should always work without throwing exception. In most of my classes, I have a lError and cError property. Once a method is completed, this can be validated against and see what went wrong, if applicable. Wherever as possible, a method should always return True or False. This is how I am trying to complete all my classes. As far as first level classes, or those included in the client application, I would say it depends on the requirements and how you would like to have it done.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Previous
Reply
Map
View

Click here to load this message in the networking platform