|
void setNeedsUpdate(bool update)
{
if ((update==true))
NeedsUpdate=true;
else
NeedsUpdate=false;
}
This would be better if they returned it too. Nothing like getting back what you put into it.
bool setNeedsUpdate(bool update)
{
if ((update==true))
NeedsUpdate=true;
else
NeedsUpdate=false;
return NeedsUpdate;
}
|
|
|
|
|
The second is better than the first. At least if you're going to set the value in this ridiculous fashion, make sure that it worked.
I wasn't, now I am, then I won't be anymore.
|
|
|
|
|
Excellent, in addition this provides a way to test that assignment succeeded and was correct.
I would even suggest
bool setNeedsUpdate(bool update)
{
if ((update==true))
{
NeedsUpdate=true;
return NeedsUpdate;
}
else
{
NeedsUpdate=false;
return NeedsUpdate;
}
}
so that if the code has a logic flaw, the function never returns !
|
|
|
|
|
How about "if (!(forceSend==true))" ?
|
|
|
|
|
I fully agree. This kind of stuff makes the code SO hard to read. And so many people do this too - just look at all the examples you were able to find! Atrocious.
When will people learn to put spaces around their operators !?!?!
Clive Pottinger
Victoria, BC
|
|
|
|
|
Just ran across this in code I've been asked to maintain (no kidding):
if (((ucGlobalHeaterEnable & (1 << UC_BHOSE_HTR_ON) ) > 0) ? 1 : 0)
{
...
}
Unbelievable!
|
|
|
|
|
Rather indigestible indeed.
I couldn't resist rewriting this piece using bit fields (in my opinion a sadly underused feature in C):
struct tGlobalHeaterEnable
{
bool bHoseHtrOn: 1;
} sGlobalHeaterStatus;
if (sGlobalHeaterEnable.bHoseHtrOn)
{
}
|
|
|
|
|
A true classic. I got thought to not do this first weeks in programming class, before learning stuff like functions.
|
|
|
|
|
I'm with you on this one! Sometimes verbosity improves readability, but there are many cases where it's just dumb.
The first example is terrible:
bool is_queue_empty(void)
{
if (queue_length==0)
{
return true;
}
else
{
return false;
}
}
More code & multiple exit points -- for zero benefit???!!!
This would be better:
bool is_queue_empty(void)
{
return queue_length == 0;
}
|
|
|
|
|
Over 9GB of log files in the log folder of one of our "technology partners"
now - request change in logging behavior or install bigger HD's? What's cheaper?
|
|
|
|
|
Yes, a common pattern. Log every totally uninteresting event, so that the real errors can't be found anymore. And if they are found, they provide little to no information which might give you a hint to what has happened. Who do they think wants to read that stuff?
I had a program that sent a mail with 'An error has occured in application XXX'. No more. No error message, no stack trace, no parameters, no further information. When that thing had a bad day, it flooded your mailbox with those messages.
And from the clouds a mighty voice spoke: "Smile and be happy, for it could come worse!"
And I smiled and was happy And it came worse.
|
|
|
|
|
In a previous job, we had a pretty good logging system. Every message had a location and severity level from 1 for crash bang to 9 for suicidal debug on nearly every step. The code monkeys were reasonably good at putting in logging at the right level.
The clients were pretty bad at setting the logging to catch level 9 for all modules. Figuring they can always filter out the crap later.
Panic, Chaos, Destruction. My work here is done.
Drink. Get drunk. Fall over - P O'H
OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre
I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer
Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett
|
|
|
|
|
Wow... you can always delete the files... can you disable the logging?
|
|
|
|
|
Over 9GB of log fileS? Seems like you did a pretty good job. We got a xml log file that's 9GB. Opening it instantly crashes the server
And seeing what my company logs in other applications I suspect it's 9GB full of crap that wouldn't help any programmer to fix any bug
It's an OO world.
public class Naerling : Lazy<Person>{
public void DoWork(){ throw new NotImplementedException(); }
}
|
|
|
|
|
What makes a happy programmer?
|
|
|
|
|
A happy programmer happens when you see a flabbergasted look from your client, because you delivered something they thought was impossible, in a most amazing way.....
|
|
|
|
|
I bet a happy programmer isn't one who gets their post "Message Automatically Removed"
|
|
|
|
|
When it comes in ahead of schedule, under-budget, bug-free and is accepted by the client who offers you a large bonus for your efforts and a new contract.
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
CCC Link[ ^]
Trolls[ ^]
|
|
|
|
|
Dalek Dave wrote: comes in ahead of schedule, under-budget, bug-free and is accepted by the client
I am sure you must be from a different planet.
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
Wayne Gaylard wrote: I am sure you must be from a different planet.
He's an accountant, so you might be correct.
|
|
|
|
|
Items 1 (ahead of schedule), 2 (under-budget), and 3 (bug-free) are neither necessary nor sufficient. Client/customer acceptance, as signified by the fact they paid you, is the sole criteria for a successful programmer.
None of the criteria, with the possible exception of 'bug-free', are conditions that impact my happiness as a programmer. For me, as bug-free as I can make it is a minimum condition for happiness with a piece of code.
Software Zen: delete this;
|
|
|
|
|
Fata Morgana
Alberto Bar-Noy
---------------
“The city’s central computer told you? R2D2, you know better than to trust a strange computer!”
(C3PO)
|
|
|
|
|
When it comes in ahead of schedule, underover-budget, bug-free and is accepted by the client who offers you a large bonus for your efforts and a new contract.
|
|
|
|
|
Exactly, because doing just one impossible thing a day isn't enough.
Giraffes are not real.
|
|
|
|
|
Didn't your parents explain that to you?
|
|
|
|