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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:50:10+00:00 2026-06-14T00:50:10+00:00

I was just discussing a method with colleague, the usage looks a little like

  • 0

I was just discussing a method with colleague, the usage looks a little like this:

String myString = getString(fields[10], true);

Now here’s my question, what does true do?

The obvious answer is to look at the method definition and see what it does with that boolean, but why do I need to do that? Is there a better coding style that will explain the purpose of the boolean right there in the method call?

I thought initially to change the method to accept a specific string, but that’s far too loose.

The best idea I can come up with is to create a local boolean, like this:

boolean thisShouldBeUpperCased = true;

String myString = getString(fields[10], thisShouldBeUpperCased);

Has anyone come across this before, is there a better way?

  • 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-14T00:50:11+00:00Added an answer on June 14, 2026 at 12:50 am

    Typically in a C-like language you might use consts or enums to improve readability, e.g.

    const bool kConvertToUpperCase = true;
    const bool kDoNotConvertToUpperCase = false;
    

    or

    enum {
        kDoNotConvertToUpperCase,
        kConvertToUpperCase
    };
    

    The above methods also allow for extensibility, e.g. if a design initially calls for two possible options for a particular parameter, which might then be implemented as a boolean, but later this becomes three (or more) options, requiring an int or an enum – you don’t then need to switch form explicit true/false literals everywhere to their equivalent values.

    E.g.

    const int kConvertToLowerCase = 2;
    const int kConvertToUpperCase = 1;
    const int kDoNotConvertToUpperCase = 0;
    

    or

    enum {
        kDoNotConvertToUpperCase,
        kConvertToUpperCase,
        kConvertToLowerCase
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a static method like this public static string DoSomethingToString(string UntrustedString) { //parse
Just learning the world of jquery, and all my googling gives examples like this:
I got this question from this discussion . A method call like object.m does
A colleague and I are discussing best practices regarding ordering method parameters. The goal
(I just posted this in the NUnit discussion group on groups.google.com) Under VS 2008,
This is going to be a quick discussion, but I just wanted some feedback
Just a knowledge question which I would like to ask: For example, I have
I was just discussing about calling static methods using class name with my friend
The idea behind this code is that it uses an extension method to instantiate
New to rails, so if this is discussed somewhere, just link me off: I

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.