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

Why can't we use assertion for public methods? I have read somewhere An assert
In some regex flavors, [negative] zero-width assertions (look-ahead/look-behind) are not supported. This makes it
Executive Summary: When assertion errors are thrown in the threads, the unit test doesn't
If I use assert() and the assertion fails then assert() will call abort() ,
What are opinions on the design of a performance assertion checking system? The idea
Are there any situations when you would use assertion instead of exceptions-handling inside domain
When testing in any language, how does everybody phrase their assertion messages ? I
By that I mean, what do I need to do to have useful assertions
My table definition is: CREATE TABLE Product (ProID INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
In C++11, should the operation of static_assert within a template depend on whether that

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.