Questions tagged [default-values]

18 questions
7
votes
5 answers

Should an optional boolean function argument rather default to true or false?

In many cases I can formulate some boolean parameter equally well positively as negatively, e.g. isOn or isOff. Which one should I pick then, in case I want the argument to have a default value? Is there a convention that an optional boolean…
DaveFar
  • 1,406
  • 12
  • 19
4
votes
5 answers

The Default State of Unused Memory

In an embedded device, during the initializing of memory locations, is there any convention that are being practiced. I mean, say setting every byte to zero or 0xFF or any other value.
4
votes
3 answers

Is it necessary for a boolean to be "false" by default?

For example, to store whether sound is on, I have a boolean originally named "isSoundOn": private boolean isSoundOn=true; however, the default value of boolean is false, but I want my application to turn on the sound at start. My question is,…
ocomfd
  • 5,652
  • 8
  • 29
  • 37
4
votes
1 answer

Assigning default values from environment variable in Node.js

When attempting to set default values for parameters that may exist in environment variables in JavaScript, I often see this pattern: var lag; try { lag = process.env.THROTTLE_LAG; } catch ( e ) { lag = 100; } I don't like it because,…
msanford
  • 750
  • 1
  • 7
  • 22
4
votes
6 answers

Is it bad practice to resolve null arguments to default static variables?

First, let me show you an example (written in ActionScript 3.0): class GameObject { public static function MakeFromName( pName:String, pAtlas:TextureAtlas = null, …
3
votes
2 answers

Should default configuration for deployed services be set as per production usage?

Today, I and my colleague had a difference of opinion regarding the usage of default values in software configuration. We both agreed that for a consumer software, the default configuration should be determined by the most common usage and user…
Mukul Gupta
  • 149
  • 4
3
votes
1 answer

Miroservices default value for Fallback scenarios

Default values are often suggested to be part of failover mechanism for microservices. At a high level, for any services (say microservices here) the nature of the operation can be broadly classified as Read Or Write. Having default values for…
Divs
  • 187
  • 7
3
votes
3 answers

Can a default value for a business process be set in the database column definition?

The business team in my company has come up with a new field to add to one of our entities. For new instances of this entity, it'll be calculated dynamically, but for previously existing instances, we need to set up a default value of, at the…
user3748908
  • 1,607
  • 2
  • 14
  • 15
3
votes
1 answer

OOP best practice: Optional referenced-type parameter

I know in C#, by default, referenced type variables are passed by reference to a method. I have a function which sometimes I just need its return value and sometimes both return value and the changes on the input object are needed outside of the…
Ahmad
  • 1,806
  • 3
  • 20
  • 32
2
votes
3 answers

Checking at javascript level vs checking in PHP?

Setup: We've got a form with default text values present within the text box itself which "goes away" when I click on them and enter a value (not if I dont enter a value). Currently the 'default' value or the user inputted value gets POSTed to the…
siliconpi
  • 205
  • 2
  • 4
2
votes
1 answer

Does automatic returning affect performance?

There's a bunch of languages that automatically return the last value in a function (mostly functional) like Ruby, Haskell, Lisp, etc. Does this feature (or what do you call it) affect the performance of these languages?
UncleLaz
  • 129
  • 1
1
vote
4 answers

What should be the last entry in a switch/case statement?

When writing a switch statement that only ever has to deal with a known set of values (imagine an implicit enumeration), I find myself wondering what should be the last entry in the construct. I'm always considering the same 3 approaches, but I'd…
1
vote
2 answers

Design Pattern: Algorithm varies according to the input arguments

I will give a simple example to help you understand my question. Suppose we have a rectangle and a Utility class with a method that creates a buffer arround a shape. The .createBuffer method has required and optional arguments: required:…
jorgeb
  • 11
  • 2
0
votes
2 answers

Should default values be explicitly stated in configuration files for libraries or frameworks?

In one of the projects I work for, we have just added karma to run unit tests. When reviewing the MR of a coworker, I noticed the karma.conf.js (the configuration file) has 120 lines, which seems to be a lot for me. While reading each configuration,…
0
votes
1 answer

Is there a normal way to program a CLI script that overrides default parameters in python

If I've got a script that uses a config file (or defaults to a generic config file) that calls another module which needs the config file passed to it as a parameter should I always File 1 (the script): /bin/runner include doer.py ... initializing…
Peter Turner
  • 6,897
  • 1
  • 33
  • 57
1
2