I am developing the middle tier of an application. The middle tier will
return custom classes that represent the data in the database. So then let me
illustrate my problem:
Database has a table called Person. In the Person table is a job description
field called JobDescription and it is a Varchar (50). Therefore it is limited
to 50 characters by the database.
In my middle tier I have a class called Person and it has a property called
JobDescription and is coded as shown below:
public string JobDescription{get{return
mJobDescription;}set{mJobDescription= value;}}
The presentation layer (asp.net web application) never talks to the database
and totally rely's on the middle tier to handle data processing. The web
application should not assign a job description that is more than 50
characters.
This begs the question from me: What is the proper (OOP) way to handle this?
Should I test and throw an exception in the set clause if the value being
assigned exceeds 50 characters or allow the exception to get thrown by
ADO.Net in the middle tier? I feel that it would be faulty to rely on the web
application to test for it.
Any thoughts?
--
-Demetri