|
TrinityRaven wrote: I didn't say don't use null . I said don't return null Yes, that's exactly what I pointed out in my loop example: You accept a loop to run until the next element is null unless determining the next element is so complex that it has been pulled out as a function.
If you do that, pull it out as a function, and follow your rule, then the function cannot return the next element the way the simpler inline code (with no function definition) did. The function would have to raise an exception when reaching the end of the list, and the call to the function would have to be wrapped in a try-catch, the exception handler would treat the exception as "ok, so then we set next element to null, so that the while check will terminate the loop", rather than simply accept a the next element as null from the function.
I find that to be an outright silly way of coding - and I don't think that you seriously suggest it. "don't return null" wasn't meant that absolutely; there are cases where communicating a null value to a calling function as something perfectly normal is ... perfectly normal. I say: That happens quite often. You say: OK, in some very special circumstances, like the one with "next object", you could accept it, as an exceptional case. - The question is where to draw the line. But the line is there.
I have seen code that tries to hide nulls by returning pseudo objects: If you ask for, say, a person's spouse, you never receive "null" or "none" or "void", but a person object that has a special identifier member like "no person". Testing for the returned person object being a person with a "no person" identifier is not more convenient by any criteria. You might forget to do that check, too, an reference attributes of this person object, that it doesn't have, because it is a "no person".
Finally: You make an absolute assumption that the called routine remembers to always define the return value to something non-null. I have had cases where the null check on the return value revealed errors in the called function, in a "graceful" way. If my programming style had been "You don't have to check for null returns, because functions do not return null", the error would have been caught much later.
Nowadays, we are using static code analysis tools that do a very thorough check on pointer use. If there is any chance whatsoever that a pointer is null or unassigned when dereferenced, you receive a warning. I have experienced flow paths with 20+ decision points, running through four levels of function calls, telling me that "What you did (or didn't do) there, at the start of the chain, might lead to the pointer you dereference at the end of the chain is null, if this and that and that condition is fulfilled". (And, if I make no use of the returned value, the analyzer is quiet - there is no danger.)
|
|
|
|
|
"Registered Nurse" to remember \r\n
|
|
|
|
|
My Mantra: "I'm too old for this ***t"
|
|
|
|
|
I'd be curious to see an expansion of "this ***t".
It might very well have great overlaps with my list. I know very well the feelings that you are expressing.
|
|
|
|
|
This catchy phrase was uttered by Roger Murtaugh (Danny Glover) in the original Lethal Weapon movie and then carried to the rest of that franchise.
|
|
|
|
|
|
i hear you
Usually it's my code that I want to be in a hurry. =) Go! Compute that LALR(1) table! Factor that grammar!
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
Hmmmm... "Hurry", maybe that's a name I should consider for my new car. "I'm in Hurry, don't hinder me".
(My present one is a red Ford, so I call it Robert.)
|
|
|
|
|
Mostly I just follow the Babylon 5 mantra. I also often catalog the stupidity I'm about to do prior to doing it.
|
|
|
|
|
Write once, read multiple
eg, in SQL - if you're thinking "a" is a valid alias for Account table then think again. Account is not a long word. Make it meaningful. If you have AccountProductMemberElephant table then APME is not a valid alias. These of kind of aliases result in the future readers having to reference back to the table to find what that means. Either don't alias or if you have some meaningless prefix to the table (eg company name) alias to remove that
Just remember you're only writing it once. It'll be read 100s of times!
Or another favourite and one not everybody agrees with
If it's not readable it's wrong!
|
|
|
|
|
|
|
Quote: buy the world's ultimate board-game modification kit I was so impressed I bought two!
- I would love to change the world, but they won’t give me the source code.
|
|
|
|
|
Even that's overpriced. You don't need to write down your cheatinghouse rules at all to play with them.
Did you ever see history portrayed as an old man with a wise brow and pulseless heart, weighing all things in the balance of reason?
Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful?
--Zachris Topelius
Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies.
-- Sarah Hoyt
|
|
|
|
|
Because I want game night to end in political debates with a couple of fights and at least one couple filing for divorce.
And that for a game that's already notorious for sparking fights[^]
|
|
|
|
|
|
not good enough!
equal reward per identity for people with Dissociative Identity Disorder !
Message Signature
(Click to edit ->)
|
|
|
|
|
Quote: ...players in the new board game can jockey for groundbreaking inventions and innovations made possible by women, including ... bulletproof vests ...
Ms. Monopoly is available for pre-order starting Tuesday at Walmart
|
|
|
|
|
|
This is so offensive I am surprised it is legal.
|
|
|
|
|
you're thisclose to getting the point.
|
|
|
|
|
|
Only to end with chocolate-chip cookies
As long as we are different, we will be treated as such. Woman and men should be treated equal, but that doesn't mean erasing all that makes us different, or trying them to become the same thing.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Eddy Vluggen wrote: Woman and men should be treated equal I disagree. I'd open the door or give up my seat for a woman more so than a man (although I do it for both). I also won't be as sarcastic around women because they tend not to get sarcasm as much. I also won't knock a woman around when playing basketball like I would a man. Nor will I flirt with a man.
Eddy Vluggen wrote: but that doesn't mean erasing all that makes us different
Social Media - A platform that makes it easier for the crazies to find each other.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
ZurdoDev wrote: Nor will I flirt with a man. By law, I meant, not a person.
Whom you as a person treat nicely and whom not, is entirely your choice
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|