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

  • SEARCH
  • Home
  • 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 8124615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T06:30:43+00:00 2026-06-06T06:30:43+00:00

We have a convention to validate all parameters of constructors and public functions/methods. For

  • 0

We have a convention to validate all parameters of constructors and public functions/methods. For mandatory parameters of reference type, we mainly check for non-null and that’s the chief validation in constructors, where we set up mandatory dependencies of the type.

The number one reason why we do this is to catch that error early and not get a null reference exception a few hours down the line without knowing where or when the faulty parameter was introduced. As we start transitioning to more and more TDD, some team members feel the validation is redundant.

Uncle Bob, who is a vocal advocate of TDD, strongly advices against doing parameter validation. His main argument seems to be “I have a suite of unit tests that makes sure everything works”.

But I can for the life of it just not see in what way unit tests can prevent our developers from calling these methods with bad parameters in production code.

Please, unit testers out there, if you could explain this to me in a rational way with concrete examples, I’d be more than happy to seize this parameter validation!

  • 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-06-06T06:30:45+00:00Added an answer on June 6, 2026 at 6:30 am

    My answer is “it can’t.” Basically it sounds like I disagree with Uncle Bob on this (amongst other things).

    It’s all too easy to imagine a situation where you’ve unit tested your library code for non-null arguments, and you’ve unit tested your calling code for a path which happens to provide a null argument to the library without you being aware of it, but which also happens not to cause any problems for that particular path. You can have 100% coverage and actually a pretty good set of tests, and still not notice the problem.

    Is everything fine? No, of course it isn’t – because you’re violating the library contract (don’t give me a non-null value) without being aware of it. Can you be comfortable that the only situations in which you’re providing a null argument are ones where it won’t matter? I don’t think so – especially if you weren’t even aware that the argument was null.

    In my view, public APIs should validate their arguments regardless of whether the calling code and the API itself is unit tested. Problems in calling code should be exposed, and exposed as early as possible.

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

Sidebar

Related Questions

Is there a convention for naming private functions in bash? I have a bash
I have a database schema where the convention for a foreign key's name is:
I have got this code and I am trying to understand the convention followed,
I have many js files, with some naming convention. If there any tool that
In our dev group we have a raging debate regarding the naming convention for
If I have user id variable, what is correct java naming convention for it?
Is there any official/unofficial/informal convention for alt+key namings ? maybe, Microsoft have some internal
I have the a class, CouponAction, with two methods, initCoupon and addCoupon. I only
I have a page that uses an AJAX request (using Prototype's Ajax.Request()) to validate
In Java we have a wonderful tool named CheckStyle that reinforce all our corporate

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.