Re: Best practices for validation (discussion)

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: Sami Vaaraniemi (samivawantsnospam_at_jippii.fi)
Date: 03/10/04


Date: Wed, 10 Mar 2004 13:48:27 -0700

Hi,

Here are some of my experiences, mostly in the context of rich or smart
client applications.

In pretty much every business application I've worked with I've ended up
with some business-like logic on the UI layer (call it UI-centric business
logic). This consists of things like simple validation and also things like
'when users selects value X from combo box C, then I need to populate these
other controls with some values and hide some other controls'. This is
business logic because it reflects directly business rules. In real life, it
simply is not an option to do a server round-trip every time you want to do
a bit of logic like this. Users do appreciate quick response time and the
server roundtrip when doing simple UI centric logic is one of the big
reasons why the UI experience with web apps is poor.

In addition to some UI-centric business logic, you'll want to do the real
business logic on the server side. Further, in addition to UI side
validation, you need to validate everything also on the actual business
logic layer. Otherwise your business logic layer would not be safely
reusable outside the client app. You may end up doing some validation twice,
but again this is how it goes in real life.

So it's a good goal to keep the business logic in its own tier in the
server. Nevertheless some UI centric business logic is unavoidable because
minimizing server round-trips is what keeps your users happy.

Regards,
Sami
www.capehill.net

"richlm" <rich_lm@h0tmai1.com> wrote in message
news:%23nLu80gBEHA.1544@TK2MSFTNGP09.phx.gbl...
> I am looking into "best practices" for implementing validation in a n-tier
> application.
> UI is initially Windows Forms, but there will also be some web UI later.
>
> "Is it sensible to try to encapsulate validation logic in a business
entity,
> in order to keep my UI as thin as possible"
>
>
> e.g. I have a text box on my form to enter a social-security number.
> This has a well defined format, e.g as a regular expression
"^\d{6}-\d{4}$".
> It is easy to put the regex validation in Control.Validating(), a custom
> control or an IExtenderProvider, but this is really business logic.
> I really want my UI to ask the business entity "is this valid" (and the
> entity reply "no" or throw and exception if it is not)
>
> I can envision a fairly generic solution using attributes and/or
reflection,
> along with some standard validation algorithms.
> Then all I need to do is map controls to business entity properties and my
> GUI is pretty much done.
> And if that mapping could be done visually at design time (like data
> binding)...
>
>
> I can think of some technical solutions, but as the subject suggests, I am
> hoping to get some discussion on the subject, to get some opinions and
> experiences.
>
> Richard.
>
>



Relevant Pages

  • Re: SBS2003 Partitioning
    ... sell a server to a customer to maximise billing hours. ... I realise that capacity is all down to the business that you are selling to ... just makes our experiences different. ... If the partition is on the same set of spindles then I could care ...
    (microsoft.public.windows.server.sbs)
  • Re: WGA Questions
    ... >> LOL! ... So say you change your business name, and your customer puts ... > or any other business is not necessary for product validation. ...
    (microsoft.public.windowsxp.general)
  • Re: method signature design question
    ... > to some of the other validation failures I mentioned earlier you can ... that is also why I would model the API to support the business ... > also be provided with the customer service telephone number. ... and the implementation would then have to use exceptions to signal any ...
    (comp.lang.java.programmer)
  • Re: Transfering data between objects
    ... One of the common reasons that UI objects and business of RDB ... The UI shouldn't do that sort of validation because it requires ... fills in the contract type in a control, send that to the business layer ... > the beneficiaries and fail the validation when they click OK. ...
    (comp.object)
  • Re: bad practices in n-tier architecture
    ... scalability you lose in performance. ... pass a scaled down version of your business object rather than a heavy ... than the business object needs to validate it too. ... characteristics of the validation. ...
    (microsoft.public.dotnet.distributed_apps)