473,785 Members | 2,738 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Forms Validation - Reusing Business Logic

Hello:

Is it me, or is handling the Validating event for every control on a
form extremely annoying? It is especially annoying when my business
logic repeats most of the validation. Some things you can handle in
the business logic. But other things, like ensuring a textbox
represents a number or null, requires a developer's intervention.

I am asking whether or not there is an easier way of doing validation
for data bound controls.

Really, I am asking how other Forms developer perform validation.
Sep 5 '08 #1
4 2154
<je**********@g mail.comwrote in message
news:60******** *************** ***********@m3g 2000hsc.googleg roups.com...
Hello:

Is it me, or is handling the Validating event for every control on a
form extremely annoying? It is especially annoying when my business
logic repeats most of the validation. Some things you can handle in
the business logic. But other things, like ensuring a textbox
represents a number or null, requires a developer's intervention.

I am asking whether or not there is an easier way of doing validation
for data bound controls.

Really, I am asking how other Forms developer perform validation.
One approach is to split the business object down the middle. Instead of a
three layer approach:-

UI -Business -Persistence

Use:

UI -BusinessClient -BusinessServer -Persistence.

The BusinessClient runs on the same tier that the UI does, IOW its a library
included in the UI app. Hence it can provide rapid feedback to the UI which
would be bound more tightly. You just need to define interfaces that are
understood by the UI and allow the BusinessClient to describe things such as
simple rule breaches.

I might just add though that the example of "must be a number" isn't a good
one. You would expect the UI developer to use a control which simply didn't
allow incorrect input of that nature in the first place. However missing
data would be exactly the sort of thing you would want the BusinessClient to
inform the UI of.

The BusinessServer half would do the things that are best done close to the
data tier.

The BusinessClient and BusinessServer are considered to be the same class in
that each has an intimate understanding of the internal workings of the
other. In a fat client you can have a single class and simply serialise the
object state between tiers. In Web apps I create the BusinessClient is in
JavaScript, BusinessServer is in C# and internal state is held as XML.
--
Anthony Jones - MVP ASP/ASP.NET

Sep 5 '08 #2
On Sep 5, 9:24*am, "Anthony Jones" <AnthonyWJo...@ yadayadayada.co m>
wrote:
<jehugalea...@g mail.comwrote in message

news:60******** *************** ***********@m3g 2000hsc.googleg roups.com...
Hello:
Is it me, or is handling the Validating event for every control on a
form extremely annoying? It is especially annoying when my business
logic repeats most of the validation. Some things you can handle in
the business logic. But other things, like ensuring a textbox
represents a number or null, requires a developer's intervention.
I am asking whether or not there is an easier way of doing validation
for data bound controls.
Really, I am asking how other Forms developer perform validation.

One approach is to split the business object down the middle. * Insteadof a
three layer approach:-

UI -Business -Persistence

Use:

UI -BusinessClient -BusinessServer -Persistence.

The BusinessClient runs on the same tier that the UI does, IOW its a library
included in the UI app. *Hence it can provide rapid feedback to the UI which
would be bound more tightly. *You just need to define interfaces that are
understood by the UI and allow the BusinessClient to describe things suchas
simple rule breaches.

I might just add though that the example of "must be a number" isn't a good
one. *You would expect the UI developer to use a control which simply didn't
allow incorrect input of that nature in the first place. *However missing
data would be exactly the sort of thing you would want the BusinessClientt o
inform the UI of.

The BusinessServer half would do the things that are best done close to the
data tier.

The BusinessClient and BusinessServer are considered to be the same classin
that each has an intimate understanding of the internal workings of the
other. *In a fat client you can have a single class and simply serialise the
object state between tiers. *In Web apps I create the BusinessClient isin
JavaScript, BusinessServer is in C# and internal state is held as XML.

--
Anthony Jones - MVP ASP/ASP.NET
Could you suggest what control you would use for a numeric value?
Obviously an UpDownNumericPi cker is appropriate for simple numbers.
But what about large numbers such as currency or other decimal
numbers? My users don't want to sit there clicking up and down for 12
minutes to get at $1234.56.

As for the MaskedTextBox, I have only ever had trouble with it. It is
weird about letting you click within it. My users hate it. Part of the
problem, as always, is that the user wants to speed of a plain textbox
with perfect validation.
Sep 5 '08 #3
<je**********@g mail.comwrote in message
news:38******** *************** ***********@k7g 2000hsd.googleg roups.com...
On Sep 5, 9:24 am, "Anthony Jones" <AnthonyWJo...@ yadayadayada.co m>
wrote:
<jehugalea...@g mail.comwrote in message

news:60******** *************** ***********@m3g 2000hsc.googleg roups.com...
Hello:
Is it me, or is handling the Validating event for every control on a
form extremely annoying? It is especially annoying when my business
logic repeats most of the validation. Some things you can handle in
the business logic. But other things, like ensuring a textbox
represents a number or null, requires a developer's intervention.
I am asking whether or not there is an easier way of doing validation
for data bound controls.
Really, I am asking how other Forms developer perform validation.

One approach is to split the business object down the middle. Instead of a
three layer approach:-

UI -Business -Persistence

Use:

UI -BusinessClient -BusinessServer -Persistence.

The BusinessClient runs on the same tier that the UI does, IOW its a
library
included in the UI app. Hence it can provide rapid feedback to the UI
which
would be bound more tightly. You just need to define interfaces that are
understood by the UI and allow the BusinessClient to describe things such
as
simple rule breaches.

I might just add though that the example of "must be a number" isn't a
good
one. You would expect the UI developer to use a control which simply
didn't
allow incorrect input of that nature in the first place. However missing
data would be exactly the sort of thing you would want the BusinessClient
to
inform the UI of.

The BusinessServer half would do the things that are best done close to
the
data tier.

The BusinessClient and BusinessServer are considered to be the same class
in
that each has an intimate understanding of the internal workings of the
other. In a fat client you can have a single class and simply serialise
the
object state between tiers. In Web apps I create the BusinessClient is in
JavaScript, BusinessServer is in C# and internal state is held as XML.
Could you suggest what control you would use for a numeric value?
Obviously an UpDownNumericPi cker is appropriate for simple numbers.
But what about large numbers such as currency or other decimal
numbers? My users don't want to sit there clicking up and down for 12
minutes to get at $1234.56.

As for the MaskedTextBox, I have only ever had trouble with it. It is
weird about letting you click within it. My users hate it. Part of the
problem, as always, is that the user wants to speed of a plain textbox
with perfect validation.
>>>>>
MaskTextBox is evilness carried over from the early VB days. I wouldn't
touch it with a barge pole. It's shame we can't just turn off the updown
buttons in the Numericupdown. Sub-class the standard TextBox or TextBoxBase
and take charge yourself.

--
Anthony Jones - MVP ASP/ASP.NET

Sep 5 '08 #4

<je**********@g mail.comwrote in message
news:60******** *************** ***********@m3g 2000hsc.googleg roups.com...
Hello:

Is it me, or is handling the Validating event for every control on a
form extremely annoying? It is especially annoying when my business
logic repeats most of the validation. Some things you can handle in
the business logic. But other things, like ensuring a textbox
represents a number or null, requires a developer's intervention.
Not really. If you use data binding, and if validation in your business
entities take the form of exceptions, then you'll get seamless validation in
your UI. If the textbox is bound to an int property, user will be forced to
enter a number. And if that property will throw ArgumentExcepti on in its
settor for any value smaller than 0, then user won't be able to enter
negative numbers into it, either.

IDataErrorInfo is another interesting thing, and works wonderfully when you
bind through a BindingSource, and then throw ErrorProvider (with DataSource
pointing to that same BindingSource) onto the form. It won't block input,
though, just highlight the errors.

Sep 6 '08 #5

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

Similar topics

19
4109
by: James Fortune | last post by:
I have a lot of respect for David Fenton and Allen Browne, but I don't understand why people who know how to write code to completely replace a front end do not write something that will automate the code that implements managing unbound controls on forms given the superior performance of unbound controls in a client/server environment. I can easily understand a newbie using bound controls or someone with a tight deadline. I guess I need...
7
3102
by: Andy | last post by:
Hi all, This is more of a design question. I'm building an n-tier application, and the question revolves around the buisness layer telling the application that a value is not appropriate for whatever reason. What is the recommended way of doing this? Thrown an exception of a property is assigned a bad value? Throw an exception when a method is called that needs to use that value? Create
3
1727
by: Student | last post by:
Good evening, I create a three tier ASP.NET web application. How can I validate the form input data in the Business Logic Layer? Can anyone give me an example?
0
1522
by: ss | last post by:
Hi, I would like to know like what is the best method of writing validation code in the n-tier application. For example in Business Logic Layer How do I write Data Validation Code, what are all I can write, How do I pass the Messae back to the Presentation Layer if the Value is not correct? In Data Access Layer what are all the things I can write, Any SAMPLE CODE PLEASE?
4
2198
by: ss | last post by:
hi, can anybody gives me a sample code where the sql injection attack is validated. how can i do that in business logic layer and pass the error to the presentation tier I want the sample code
1
1744
by: Robert Bravery | last post by:
HI all, Having a discusion with a colegue. Where is the best place to keep validatations, in the database layer, i on the SQL server via triggers, SP etc; or at the application layer, This being a C# group I gather that the bias would be towards the APL, but what , in you minds are the pro's and con's Thanks Robert
23
3232
by: mosesdinakaran | last post by:
Hi All, I need a small clarification in submitting the forms, Ur suggestions please. In a page I have two form and also two submit butons. (ie)
9
1546
by: WebCM | last post by:
I need a solution for CMS. I would like to edit and create FORMS easily, especially list of settings. Which is better and why? $$ XML or HTML $$ Forms occur in View layer - in presentation file. To simplify editing forms and to improve readability, webmasters use additional tags and attributes, e.g. <checkbox>, <radio>, arrayname... The compiler of templates changes XML code into (X)HTML with conditional expressions in PHP and variables...
8
2738
by: Bryan | last post by:
I want my business objects to be able to do this: class Person(base): def __init__(self): self.name = None @base.validator def validate_name(self): if not self.name: return
0
9643
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10147
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9947
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8971
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6737
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4046
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.