| « Prev | Page 1 | Page 2 | Page 3 | Next » |
|
static bool first = true;
if (first) { first = false; |
|
"of which the following code is a part of"?
|
Sure - it's from the "Live and let die" school of grammar:
|
Re: self->Static Anti-Pattern
2009-01-19 09:19
•
by
puzzled
(unregistered)
|
|
Sure - it's from the "Live and let die" school of grammar:
[quote user="The Beatles"]But in this ever changing world in which we live in[/quote][/quote] The Wings, not The Beatles |
Whoops |
void Lib::output(Lib* self) or perhaps
|
Re: self->Static Anti-Pattern
2009-01-19 09:24
•
by
Superdude
(unregistered)
|
Surely just Wings (unlessmy sarcasm detector has been unplugged)? |
Yup, that sounds about right to me! An office that doesn't even have a single arcade machine isn't worth going to every day! |
Re: self->Static Anti-Pattern
2009-01-19 09:25
•
by
Voodoo Coder
|
Wings, not The Wings. (just keeping in the nitpicky spirit of TDWTF)... |
That fails to account for the two other cases (when STATUS and self-active share the same status). I don't know if it's right to do so or not, mind you. EDIT: Rectified in my next comment. Why can't I delete my own comments? (I know, Community Server...) |
This won't do: it behaves correctly on the two other cases (when STATUS and self->active share the same state). |
Re: self->Static Anti-Pattern
2009-01-19 09:40
•
by
ingenious
(unregistered)
|
If to nitpick, then I guess the "The" in "The Wings" wasn't meant to be part of the band name, but used as a definite article. |
Re: self->Static Anti-Pattern
2009-01-19 09:41
•
by
Code Dependent
|
Try this: "But if this ever-changing world in which we're living makes you give in and cry--Say 'Live and let die'." |
Re: self->Static Anti-Pattern
2009-01-19 09:42
•
by
Zero
(unregistered)
|
|
I thought the lyric was "...world in which we're livin'". Which makes more sense.
|
Re: self->Static Anti-Pattern
2009-01-19 09:44
•
by
Bert
(unregistered)
|
Saving one redundant boolean assignement is hardly worth all of this... |
|
My head spins after reading this and trying to figure out what it's doing. Or not doing, in a very complicated fashion.
Does this guy (the coder, not the submitter) really not understand how Object-Oriented code works? |
Re: self->Static Anti-Pattern
2009-01-19 09:48
•
by
puzzled
(unregistered)
|
it's But if this ever changin' world In which we live in Makes you give in and cry Say live and let die |
Re: self->Static Anti-Pattern
2009-01-19 09:51
•
by
stanbeard
(unregistered)
|
|
Actually Paul McCartney sings "But if this ever changing world in which we're living"
It's Axl Rose that sang "But if this ever changing world in which we live in"... and he's realised his mistake because he sung it properly at the Gunners concert I went to last year. |
|
There are games companies which try to filter out people who don't know how to code very well at interview. I used to work for one. Unfortunately I now work for a games company which accepts anyone who knows how to write syntactically correct code.
|
Re: self->Static Anti-Pattern
2009-01-19 10:02
•
by
Slash
(unregistered)
|
^ TRWTF ist right there! |
Re: self->Static Anti-Pattern
2009-01-19 10:20
•
by
Code Dependent
|
Not as bad as David Lee Roth singing I don't believe you It must be true No one could look as good as you ...where the actual lyrics are I don't believe you You're not the truth No one could look as good as you |
Re: self->Static Anti-Pattern
2009-01-19 10:31
•
by
Thierry Henry
(unregistered)
|
When did Arsenal start performing gigs. I'm intrigued, who sings; is it Wenger or is he on the drums. |
void Lib::output() //which is a non-static member, as it should be! { STATUS = active; } Would be better. It still doesn't solve the rather scare assignment of 'STATUS' there, but that would probably need a total redesign. Of course, it MIGHT be that 'STATUS' is actually a hardware register, in which case the original complex boolean stuff might be necessary to avoid hardware register writes if data hasn't changed (but I doubt it...) (PS - this is one of the first 'WTF's in a while which has actually had me issue that utterance) |
Re: self->Static Anti-Pattern
2009-01-19 10:40
•
by
configurator
(unregistered)
|
|
But what if self->active was FILE_NOT_FOUND
|
|
May be, just may be, this "programmer"'s first language was Lua (we are talking about game companies here after all) and he didn't grasp the concept of static vs instance methods in C++.
To clarify - Lua doesn't have classes per se, instead there are "tables" - associative containers - that can contain functions as values. There's also some syntactic sugar to implicitly pass the containing table to a "member" function, thus emulating methods with this pointer, but there's no difference between a function declared with explicit this parameter and a function declared with the syntactic sugar/implicit this parameter. Which seems to be related to the WTF at hand. Also, the implicit "this" parameter is called "self". |
Re: self->Static Anti-Pattern
2009-01-19 11:09
•
by
Adrian Cheater
(unregistered)
|
|
I'm surprised that anyone expects video games to somehow magically adhere to a higher standard of code excellence. As an indie developer, I've worked with and written my share of bad code. Hopefully I'm at least trying to improve, but game development seems to get it from all angles.
Goals are unclear: You almost never know what you're making up front, since it's hard to design 'fun' on paper. It's exploratory software, unless you're writing Madden 2K-something. Hardware is non-standard: PC games are a minefield of hardware issues, you often need special cases to handle the wide variety of configurations, or you limit your market appeal. Budgets and time lines are often rigid: As we know, if you can't wiggle on cost and speed, you end up wiggling on quality. Front end quality isn't usually too bad, but keeping all those lofty design goals you had up front start to fall aside when the crunch hits. Since games tend to be throw-away code in the end, maintenance may take a back seat to software stability. Oh, and we have our share of idiots. Guys and girls who 'just like' games, wanted to be a writer instead, have 'a great idea', who may or may not have learned how to code involved in the process. Software is software, and that's why I love coming here, to learn more about what does and doesn't work in other sectors. |
Re: self->Static Anti-Pattern
2009-01-19 11:19
•
by
Code Dependent
|
You just reminded me of an expression I saw years ago framed on some coworker's wall: "When you're up to your ass in alligators, it's difficult to remember that your original purpose was to drain the swamp." |
|
Some people can write Fortran in any language. This guy writes Python.
|
|
Right now I'm in the process of teaching myself C++, and some of the stuff I do looks a lot like this. You know, trying if some expression will compile, and what happens if you write
cout << *&*&*&varname; This does not look like production code that 'does' anything to me. |
Re: self->Static Anti-Pattern
2009-01-19 11:50
•
by
Andrew
(unregistered)
|
Paul McCartney's Wings sang "Live and let die". |
Re: self->Static Anti-Pattern
2009-01-19 11:51
•
by
Xar
(unregistered)
|
This is actually a known C/C++ practice: since first is declared static its value is kept across several calls to the function, so you only do the init the first time the function is called. |
Re: self->Static Anti-Pattern
2009-01-19 11:53
•
by
Voodoo Coder
|
In keeping with the spirit... The noun "Wings" is hardly an indefinite noun (in this context), requiring any kind of article. Furthermore, adding the article could lead to entirely different meaning of the noun (i.e. "Looks like The Wings might be in for another run at the Stanley Cup this year!"). While most who are familiar with Paul McCartney's post-Beatles works and/or James Bond movies featuring Roger Moore would identify either statement in the given context, a man from mars may very well wonder how a hockey team in Detroit could be responsible for such an anthem. </nitpicking> |
Re: self->Static Anti-Pattern
2009-01-19 11:54
•
by
puzzled
(unregistered)
|
I knew what the code was for, it was a comment in reply to the "FIRST" comment (I forgot to click the quote\reply button though) |
Re: self->Static Anti-Pattern
2009-01-19 12:00
•
by
Doc Monster
(unregistered)
|
Even worse is Sammy Hagar singing Only time will tell If our love Will stand the Test of Time (--Van Halen, Why Can't This Be Love?) Sammy needs to read the dictionary page for "tautology". |
Re: self->Static Anti-Pattern
2009-01-19 12:02
•
by
Andrew
(unregistered)
|
No, in this context the first flag is absolutely a bad practice. The IF-statement's body constructs the Lib object. There appears to be only one Lib object. So, why don't they construct it in the main block? |
|
Andy = Nooooooooo!!!!!!
|
I know when I'm not wanted... :^( |
Re: self->Static Anti-Pattern
2009-01-19 12:21
•
by
Cecil
(unregistered)
|
|
Except it's a horrible practice.
Pull everything inside the "if (first)" block and move it into an Init() function. |
Re: self->Static Anti-Pattern
2009-01-19 12:26
•
by
z0ltan
(unregistered)
|
Sir, I would upmod you if I could! ;-) |
|
I thought it was
"If this ever-changing world in which we're living.." At least one online lyrics source agrees with me: http://www.sing365.com/music/lyric.nsf/Live-And-Let-Die-lyrics-Paul-McCartney/8479C51B2F85A57748256A4C0008CAE9 |
|
I'm surprised noone has mentioned "self" up until now. C++ doesn't have "self", it has "this". There must be a macro someplace
#define self this Clearly this programmer didn't feel at home with C++. |
Or Smashing Pumpkins' "what I choose is my choice." Brilliant. |
|
I Googled 'The Beatles' -- wow, just wow -- Paul McCartney was in another band before Wings!
The stuff you learn around here... -Harrow. |
Re: self->Static Anti-Pattern
2009-01-19 13:10
•
by
bob
(unregistered)
|
look again, 'this' is used with the instance methods, the 'self' pointer was passed in to the static methods to make the pseudo-instance methods. |
Re: self->Static Anti-Pattern
2009-01-19 13:10
•
by
Code Dependent
|
Here ya go (reaching way back)--Bob Wills' "Cherokee Maiden": One night when the moon was bright on a moonlit glade |
If you choose not to decide, you still have made a choice. Rush |
Re: self->Static Anti-Pattern
2009-01-19 13:26
•
by
clickey McClicker
(unregistered)
|
Technically it is all the same "Wings." They usually just do the music thing during the day but when they get really really mad they turn all Red(green was already taken), rip off their shirts, put on Hockey uniforms which leads to games and fighting/smashing/clobbering/pummelling. It is admirable how they bring such emotion to all their work even if it isn't always that good. |
Re: self->Static Anti-Pattern
2009-01-19 13:31
•
by
Queex
(unregistered)
|
I think that still makes sense, as long as 'choose' and 'decide' don't reference the same Decision object. If presented with the Decision 'You are either with us or against us' you could choose neither option (presumably by raising a FalseDichotomyException) and still have made a choice (i.e. compile without errors). |
Re: self->Static Anti-Pattern
2009-01-19 13:32
•
by
clickey McClicker
(unregistered)
|
That isn't dumb or redundant. That is deep and full of underlying truth. Like my brother-in-law who quit Wal-mart so he could play games, a lot of people should hear that quote. Inaction is often worse than 'the wrong' action. His inaction is really a choice of shocking stupidity. |
| « Prev | Page 1 | Page 2 | Page 3 | Next » |