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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:01:49+00:00 2026-05-20T11:01:49+00:00

Why the assertion is not usually used in deployment ? I studied that asserting

  • 0

Why the assertion is not usually used in deployment ?
I studied that asserting the public method arguments is inappropriate..but asserting private method arguments is appropriate in deployment..why ?

  • 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-20T11:01:50+00:00Added an answer on May 20, 2026 at 11:01 am

    Assertions are not enabled by default, you have to pass the -ea parameter to the JVM to enable them. So in many cases, it may be a simple omission in deployment. Other reasons may be performance (I have no evidence that asserts would noticeably slow down execution though), or proper error handling, i.e. it may be deemed inappropriate for the production system to throw AssertionErrors live.

    Asserting private method arguments is appropriate because you are supposed to be in full control over the arguments passed to them. Public methods OTOH are called from the outside world, so you may have no control over the concrete arguments passed, thus it is better to do explicit argument checks and handle invalid arguments appropriately (e.g. by throwing a suitable runtime exception such as IllegalArgumentException), or for null references, let the JVM throw a NullPointerException.

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

Sidebar

Related Questions

Somewhere in a mass of code that I did not write (but I am
I've a method test that does not have a clear assert expression. The returned
in product mode in GWT the assertion is not available which is good, but
how can I use JUnit to not terminate on assertion failures, but just log
I noticed that static assertions in class templates are not triggered when instantiations are
I'm often creating custom assertion methods for my JUnit tests. eg: public void assertArrays(String[]
d = Deferred() d.callback(Deferred()) # Assertion error saying that a Deferred shouldn't be passed
How do I set up gdb on window so that it does not allow
I usually don't expect help from outside but I need to solve this quickly
I have searched here and found the assertion that no single application may occupy

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.