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 354605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T11:56:24+00:00 2026-05-12T11:56:24+00:00

Our application is developed using Spring framework. Is it good practice to check null

  • 0

Our application is developed using Spring framework. Is it good practice to check null condition in all layers (presentation. business, database) ? The flow in our application is

Form submission -> jQuery validator -> Spring validator -> Controller -> Service -> Database

Currently we are checking the parameters for null condition in both Validators, Controller and Service layer. In the controller, service is called only when the parameters are not null, and in the service if the parameters are null we are throwing IllegalArgumentException.

Is the above right design ? Are there any links which suggests such good practices ?

  • 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-12T11:56:24+00:00Added an answer on May 12, 2026 at 11:56 am

    It depends!

    • First, figure out how much error handling you need. Ask yourself how much of a public interface this needs to be. Is this single-use code? The more formal and public APIs need to be more careful about the data they accept and return, and more clearly documented. App-specific code can often just throw an exception– any exception– when something goes wrong. Pick the appropriate level of error checking. (The answers may be different at different layers or in different modules of the app.)

    • You jQuery validator shouldn’t really deal with nulls, but should detect empty strings (obviously).

    • I would recommending making sure the Spring validators are a strong “firewall” to your application. I would do fairly rigorous null checking here, as this removes the burden from your controller code.

    • If you have good validators in place, you can writing thinner controllers, and perhaps do no validation at all. There is really no need to do redundant checks in the controllers that you already have in the validators. These are the same layer architecturally.

    • Although you have checks in the validators, it’s likely the service layer will be called in different ways from different controllers. I think it is worth putting a level of protection into place, to preserve the integrity of your database. It’s very important that this code doesn’t alter the database or silently proceed if called incorrectly; bugs like this are particular nasty to track down. When the caller passes bad (and null) values, the code should throw an exception– any exception. Sure, IllegalArgumentExceptions or NPE is probably correct, in reality any exception will do the trick and allow a developer to track down the problem. Again, if you’re developing a public API you need to be more rigorous.

    • If the database is missing some information, you should define in the service layer interface what should happen. Hibernate returns nulls sometimes, and throws exceptions others, depending on the call. It makes sense to follow the patterns it establishes.

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

Sidebar

Ask A Question

Stats

  • Questions 217k
  • Answers 217k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer BUILT_SOURCES = version.h All files mentioned as BUILT_SOURCES will be… May 12, 2026 at 11:21 pm
  • Editorial Team
    Editorial Team added an answer Sorry for answering my own question. This is what I… May 12, 2026 at 11:21 pm
  • Editorial Team
    Editorial Team added an answer The same is true in VB as in C#. By… May 12, 2026 at 11:21 pm

Related Questions

We are in the process of re-evaluating our usage of JSF (brought in before
I was curious as to what other shops are doing regarding base application frameworks?
We have a asp.net 2.0 web application that is running on IIS7. It is
Part of our java application needs to run javascript that is written by non-developers.

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.