|
It needs some shift lefts and shift rights thrown in for good measure. It's not obscure enough.
This space for rent
|
|
|
|
|
I would only make a couple of changes
something = Anotherthing - (condition ? someothervalue : (assignment_here = object->method()));
I never liked
condition == 0 I like
!condition much better.
|
|
|
|
|
Currently I am so fortunate that my programming is in a language where (numeric != bool)
In my last plain C project, I happened to set up a "#define ever ;;" so that I could write "for (ever) {..." to make an infinite loop, which is not uncommon in embedded code. (In the CHILL language, made for programming phone switches, "DO FOR EVER ..." is defined in the basic language.) One of the other team members reacted quite fiercly to this, searching through the entire code base for "for (ever)", adding a nasty commit message about "someone" who were trying to make funny jokes in the code, and he changed it to the proper "while (1)". The header project files did define "true" and "false" constants, but he woudn't accept even "while (true)": There is one proper way to make an infinte loop in C, and that is "while (1)".
I was seriously considering to change it to "while (2)", with a commit message that 2 makes it twice as clear that the loop should run for (ever), but I decided not to. My relationship to that guy was bad enough without further provocations.
So, provided "condition" is a bool variable, or an numeric variable that stores nothing but the value of bool expressions, I certainly agree that "!condition" is the proper way. But if "condition" is a numeric value treated as such (e.g. a counter from n down to 0), treating it as a bool for flow control is bad. Then "condition == 0" is far better.
Same with pointers. I detest "if (!nextpointer) { /*leave loop*/" - that should be "if (nextpointer == null)" (or "nil" or "empty" or whatever your favorite language calls is).
Which makes me think of that really nice construction I have encountered in a single language: "FOR currentpointer IN listhead:nextpointer DO..." - "nexpointer" being the name of a pointer member in the class "listhead" (and "currentpointer") points to.
|
|
|
|
|
I only use a ternary operator when it is very clear what is going on. This exceeds my limits on clarity with the assignment in there.
|
|
|
|
|
Anotherthing is inconsistently cased, pure evil indeed!
|
|
|
|
|
That is indeed the real crime here.
"Never attribute to malice that which can be explained by stupidity."
- Hanlon's Razor
|
|
|
|
|
So....
We should both be very grateful that you don't do peer review for me. I would have tucked in an anonymous function just to piss you off.
"Never attribute to malice that which can be explained by stupidity."
- Hanlon's Razor
|
|
|
|
|
den2k88 wrote: but only if the condition of the ternary operator is true.
There's certain elegance to that which I can't help but admire.
Latest Article - A Concise Overview of Threads
Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny
Artificial intelligence is the only remedy for natural stupidity. - CDP1802
|
|
|
|
|
At least it's all on one line.
|
|
|
|
|
There's a lack of prefix and postfix operators, don't you see that? The code should be corrected to:
something = Anotherthing - ((++condition == 0) ? (assignment_here = object->method()) : --someothervalue);
Oh sanctissimi Wilhelmus, Theodorus, et Fredericus!
|
|
|
|
|
There are in other bits of code. This is as of now the single line of code with the most horrors I ever seen.
GCS d--(d+) s-/++ a C++++ U+++ P- L+@ E-- W++ N+ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- r+++ y+++* Weapons extension: ma- k++ F+2 X
|
|
|
|
|
|
Well, object->method() could be a recursive call so it's not that bad.
|
|
|
|
|
Kodi is a home theater video/music player. It's available for Windows, Mac, and Linux. It uses a sqllite database to store video file info. I was cruising their wiki, and at the top of the wiki is this statement:
Warning: The databases are critical components of Kodi. We strongly urge that you do not interfere with
them, unless you have knowledge and experience with database designs.
Imediately following this statement are the schemas for the various tables, which includes the following column names:
c00
c01
c02
...
c23
Maybe they should heed their own warning.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
Well duh! c for 'collumn'. What else you gonna name them?
|
|
|
|
|
All rows start with an "r"?
I.e. Hungurian notation as suggested by Simonyi done right according to Joel Spolsky?
Oh sanctissimi Wilhelmus, Theodorus, et Fredericus!
|
|
|
|
|
So the intersection of a row and a column in a table that uses this naming convention is an "rc", or 'arse"?
I wanna be a eunuchs developer! Pass me a bread knife!
|
|
|
|
|
David O'Neil wrote: collumn
Collumn! Collumn! The Master knowsss where the preciousss design is.
GCS d-- s-/++ a- C++++ U+++ P- L+@ E-- W++ N+ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- ++>+++ y+++* Weapons extension: ma- k++ F+2 X
|
|
|
|
|
Software Zen: delete this;
|
|
|
|
|
Saves them a pain in the I18n.
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
#ifdef ERROR
#undef ERROR
#endif
#define ERROR (-1)
#define OK (0)
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
#ifndef NULL
#define NULL 0
#endif This is in a body of 'C' code I'm stuck with maintaining. This crap was originally written by a Sun UNIX jock who was a zero-order asshat.
Software Zen: delete this;
|
|
|
|
|
Good heavens. That's not only atrocious, it's just plain wrong.
|
|
|
|
|
Yep, I've got over 100 source files chock-full of this kind of stuff. The average identifier length is about 5 characters, and eeeeeverything's global, sports fans! I'd like to kill the mother er who wrote it.
Software Zen: delete this;
|
|
|
|
|
Gary Wheeler wrote: I'd like to kill the mother[mastadon] er who wrote it.
Sounds like you and Marc Clifton need to form a posse and clean house.
|
|
|
|
|
They made a movie[^] about us.
Software Zen: delete this;
|
|
|
|