Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 394797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T16:23:27+00:00 2026-05-12T16:23:27+00:00

assume i have a huge input form, which of course representing classes. i need

  • 0

assume i have a huge input form, which of course representing classes. i need this input to be loaded into the class’s instances. this input obviously contains (some very complicated validation) checks, obviously the logic layer contains those input validation already. the question is what am i doing with gui.

should i just, in a very ugly way, just rewrite all those validations in the GUI?

or should i write some statics methods in the logic layer, in use those methods in the gui and in the logic layer, but still creating a duplication of the validating it self (first the gui validate itself, then the logic validate what sent to it)

or should i just assume the gui is okay, surround the relevant code that use the logic layer, with a try block, and then, if exception is thrown, inform the user that SOMETHING is not right (without giving him a chance to know what it is)

or should i expose the exception, in which way i expose to him parameters, classes and namespaces names, which he probably won’t understand.

or should i make a special exception class for every single error, and this way inform the user exactly what the problem, but creating maybe hundred of possible exceptions

or should i separate it to general exceptions, which everyone include enum describe the exact content of the error, then catch those exceptions, and by checking the enum inform the user what exactly the problem, but make the app heavier by catching unnecessarily exceptions all the time.

or should i (someone has offered this to me, this isn’t my idea, don’t shout at me :D) to validate the input in the logic layer, and check it only in the gui (seems to be me absolutely horrible solution :D)

and much more important question – where should i learn such things?
usually my instincts are pretty good, but i don’t want to unnecessarily invent the wheel.. (i’m pretty sure there already conventions for such basic things you bombed into every day).

thank you very much!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T16:23:28+00:00Added an answer on May 12, 2026 at 4:23 pm

    Certainly you should be validating user inputs. If the inputs and validation logic are as complex as you say they are, its even more important to validate the input in the GUI, in a way that makes it obvious to the user what the expected values are, and, if there are any errors, what they are. Bonus points if you can suggest how to fix those errors!

    It really doesn’t help the user to be seeing exceptions and exception details — so try to avoid that.

    Also, since you’re dealing with input validation in the GUI, and bad input is an expectation, and isn’t really out of the ordinary, using Exceptions isn’t necessarily a good idea. A simple IsValid() method to check whether something is valid or not is preferable. I always follow the rule that states “Exceptions are for Exceptional circumstances”.

    So if you accept that validation in the GUI is a good thing, then the next question is: How?

    You say that you already have a lot of validation in place, but it doesn’t sound like your validation logic is available separately. A practice that I’ve always found useful is to keep the validation code separated from other business logic. That allows you to re-use the validation logic where appropriate, and in this case, would allow you to share the same validation logic between your business objects and the GUI. There are, obviously, many design approaches and frameworks to do this, but the fundamental principle is a “separation of concerns” – keep the validation logic separate, and make it available for use. You seem to be thinking along the same lines when you say “write some statics methods in the logic layer, in use those methods in the gui and in the logic layer”, and that’s an approach that is proven to work.

    Just for clarity’s sake — I’m not suggesting you put the validation logic in the GUI itself. Rather, make the validation logic available to be used by the GUI. The only part of the validation that should be in the GUI is the part that takes the inputs from the user (to submit to validation) and the part that displays the results of the validation (to the user).

    Edit:

    I don’t want to sound like a shill for a particular design philosophy, but lately I’ve been doing more work using Domain Driven Design principles. I’ve found it works very well, and it addresses many of the questions you’re asking. There are a few questions on SO that give more details on what it is and where some resources are:

    https://stackoverflow.com/questions/1353742/domain-driven-design-ddd-readings
    What is domain driven design?

    Also, have a read here: http://www.lostechies.com/blogs/jimmy_bogard/archive/2009/02/15/validation-in-a-ddd-world.aspx

    Edit 2:

    Also a useful (and related) read: Business Objects, Validation And Exceptions

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Assume I have a function template like this: template<class T> inline void doStuff(T* arr)
Assume I have a form class SampleClass(forms.Form): name = forms.CharField(max_length=30) age = forms.IntegerField() django_hacker
Assume I have a class foo, and wish to use a std::map to store
Assume you have some objects which have several fields they can be compared by:
Assume we have a method like this: public IEnumerable<T> FirstMethod() { var entities =
Lets assume we have this xml: <?xml version=1.0 encoding=UTF-8?> <tns:RegistryResponse status=urn:oasis:names:tc:ebxml-regrep:ResponseStatusType:Failure xmlns:tns=urn:oasis:names:tc:ebxml-regrep:xsd:rs:3.0 xmlns:rim=urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0> <tns:RegistryErrorList
I have some HUGE log files (50Mb; ~500K lines) I need to start filtering
I have a repeater which binds a set of data. Within this repeater is
I have an input form that I have to scroll based on changes of
I have a query which is something like this SELECT t.category, tc.product, tc.sub-product, count(*)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.