Path: csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Cecil Westerhof Newsgroups: comp.lang.java.programmer Subject: Never using booleans as parameters Date: Fri, 20 Nov 2015 09:29:35 +0100 Organization: Decebal Computing Lines: 21 Message-ID: <87lh9tysy8.fsf@Equus.decebal.nl> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="528adfd6ad074c92fdc6a7f8fb9e23d8"; logging-data="15951"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/gNG9uizKVW+psv3sK7Q2xOipMc2yBueU=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) X-Homepage: http://www.decebal.nl/ Cancel-Lock: sha1:9ry65n+j4R0aKB/z5IiCrIU0SM0= sha1:9RNPGWUMOE5xHTLRYxilAYODZKY= Xref: csiph.com comp.lang.java.programmer:33149 Often is said that you should never use booleans as parameters. But I have a function compareObjects that takes two objects and a boolean that signifies if the function is verbose. (Sends logging.) I could of-course define compareObjects and compareObjectsVerbose and instead of writing: compareObjects(a, b, useVerbose); I could write: if (useVerbose) { compareObjectsVerbose(a, b); } else { compareObjects(a, b); } But I do not find that cleaner code. But that could because I am not used to it. Would the second manner be better? -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof