473,320 Members | 1,953 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Handling Properties Limits

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
Nov 17 '05 #1
1 962
This is an area where things get a little bit muddy. Ideally, valiation
rules such as string size limits should be checked in one place, and
one place only. Again, ideally, this place should be the business logic
layer, or the middle tier as you have referred to it, since one should
strive for as much database independence as possible.

However, this is not very practical. The ASP.NET application should
implement simple validation logic, because this would reduce the number
of posbacks required in the case of invalid data.

Again, the middle tier should implement more advanced validation
because not doing so would cause unencessary roundtrips between the
database access layer and the business logic layer.

So, while not very OOP, the most practical implementation is to
implement validation rules on all layers, when possible.

I would highly recommend that you take a look at Rockford Lhotka's
CLSA.NET framework
(http://www.lhotka.net/ArticleIndex.a...a=CSLA%20.NET), and perhaps
get yourself a copy of his book, Expert C# Business Objects. His
framework covers this topic and many others, like O/R mapping, data
binding to Windows and Web cotnrols, etc.

Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Hans-Joachim Widmaier | last post by:
Hi all. Handling files is an extremely frequent task in programming, so most programming languages have an abstraction of the basic files offered by the underlying operating system. This is...
4
by: m96 | last post by:
hi, i'm trying to make a query to a ldap server (version v2 or v3 doen't matter) with c#. the query works just fine but the problem is that i can't read the custom attributes/fields, since .net...
34
by: rawCoder | last post by:
I have read that Exception Handling is expensive performance wise ( other than Throw ) , but exactly how ? Please consider the following example ... ////////////////// Code Block 1...
4
by: James Radke | last post by:
Hello, I am looking for guidance on best practices to incorporate effective and complete error handling in an application written in VB.NET. If I have the following function in a class module...
14
by: Mr Newbie | last post by:
I am often in the situation where I want to act on the result of a function, but a simple boolean is not enough. For example, I may have a function called isAuthorised ( User, Action ) as ?????...
4
by: beatdream | last post by:
I am designing a database to handle different kinds of products ... and these products can have different properties...for example, a trouser can be specified by the width, length, color, and other...
8
by: Grizlyk | last post by:
To continue some ideas of "C++ Archeology: Limits of OO paradigm", i want to ask about C++ development. There are C++ compilers, that has been written in old good C. Are C or pascal perfect...
13
by: Josip | last post by:
I'm trying to limit a value stored by object (either int or float): class Limited(object): def __init__(self, value, min, max): self.min, self.max = min, max self.n = value def...
6
by: Time Waster | last post by:
Java property files are dead simple: key1=val1 some.key2=val2 For simplicity on the Java side, I'd like to use these files from C as well (the C program and Java program must cooperate). ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.