Skip to main content
1 of 7

Please reconsider the rule: Pseudocode, hypothetical code, or stub code should be replaced by a concrete example?

Related:

My concrete examples usually contain some proprietary things. Even a variable name or package name can convey meaning of something that is not public.

From StackOverflow career I've learnt to simplify, minimize, isolate the problem. (ask specific questions)

Examples of question one may want to ask:

What is the recommended way of passing arguments to the function in JavaScript?

var f1 = function(firstname, lastname) { ... };

var f2 = function(options) { ... };

f1("Michal", "Stefanow");

f2({firstname: "Michal", "lastname": "Stefanow"});

It is a hypothetical code, yet in my opinion it is perfectly valid question about best practices in terms of code structure and readability.

Another one I would like to ask personally but I cannot post it to http://codereview.stackexchange.com/ as it is hypothetical. And I cannot include the actual code because variable names convey some meaning and I want to avoid paying hefty compensation.

What would be the best way to ask the question about following code?

Option 1:

var iammicrowave = /(microwave)/.test(navigator.userAgent);
if (iammicrowave) {
    var settings = { blah : 42 };
    magicFunction(settings);
} else {
    magicFunction();
}

Option 2:

var iammicrowave = /(microwave)/.test(navigator.userAgent);
var settings;
if (iammicrowave) {
    settings = { blah : 42 };
}
magicFunction(settings);

Option 3:

var iammicrowave = /(microwave)/.test(navigator.userAgent);
var settings = imamicrowave ? { blah : 42 } : undefined; // or maybe {} here?
magicFunction(settings);

Shall I:

  • post on CodeReview anyway?
  • post on StackOverflow?
  • read more books?
  • make friends with developers who are better than me?