Interesting -- I usually at least return a bool so I can evaluate the success or failure on a function. The only time I would consider a void would be where a failure is impossible or irrelevant.chuck_starchaser wrote:Well put, denyasis. You've summarized the situation EXACTLY.
As for me, I don't consider myself a developer. There's only two pieces of C++ code I wrote,
in the engine. One was a template messaging system, like an observer pattern; the other
is the code that computes tangents. In both cases, though, I just wrote the code and gave
it to Klauss to integrate into the engine, because I'd have no idea where to put it.
And shaders are something else altogether; not really a part of the engine.
But like you said so clearly, I'd love to become a developer, but I find the code inscrutable;
can't make heads or tails of it ever; even when Hellcat has tried to help me, the amount
of un-figurable stuff is staggering. Among the things you forgot to mention, using special
values in floats, like 0 or -1 to mean special things. This is a NO-NO-NO-NO-NO-NO-NO
in programming. In my coding I rigorously observe command/query separation: A function
is either a query (returns a value but changes no state, and is declared ...() const;) or it is
a command, and MUST return void. To me this is a sacred rule; but VS code doesn't even
seem to be aware of the existence of command/query separation discipline. There's hardly
ever a function returning void, in fact. So one looks at a function and can't even tell if it's a
function to get information or to effect a change, except by looking at the code. Because
even the names tell you nothing about it.
I'd name a query functionand a command functionCode: Select all
bool light_is_on() const;
Makes the meanings and intents clear.Code: Select all
void turn_light_on();
But in the VS engine you might likely find a functionSame thing with naming of variables... A variable named "fuel_is_empty" HAS to be aCode: Select all
float light_off( double );
boolean; can't be anything else; can it? That's how one names variables. Boolean
variables should read like statements that are either true or false. But in the VS engine they
NEVER are so named. Same as "amount_of_fuel_left" is obviously a float, without looking
up the definition. But trying to read VS code you have no way to tell anything from the way
variables or functions are named. You ALWAYS have to look things up, look things up,
look things up... Study functions in detail to even get a glimpse of what they are for.
It just drives me bananas.
We need to get 600 programmers on promises of free sex, and put them to work on a
mother of all rename-athons.
I have also used 0 and -1 in a float to effect a change in behavior. It was to utilize a complicated data stream to effect an unplanned change that would have otherwise required two additional fields in an already complicated data-set.