Ways to avoid the needs and the musts of global variables??

Started by
86 comments, last by swiftcoder 13 years, 3 months ago
Quote:Original post by Rubicon
Why do you want to remove global variables? Are the uni professors pushing fixes to non problems again
Quote:Original post by return0
Otherwise, the OP and other new programmers will end up thinking that the complaints against singletons/globals are unjustified scare tactics from ivory tower academic types who have no place in games.
You know, if I knew a single ivory-tower academic type who *had* an opinion on coding practices (beyond documentation), my respect for them would increase threefold.

If you go google for all the "singletons evil" articles from a few years back, you will find that 90% of them are from industry types, not academia. Codebases in academia are generally awful: legacy code mashed together with last year's fad design patterns, in some unpleasant language/API combination that no one has ever heard of [smile]

So before you going blaming good coding practices on academia...

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

Advertisement
I agree, and I think that people who disagree like to attribute what they perceive to be bad advice to some impractical academic strawman. I only mentioned it to cover that base.
That'd be me then. I can't begin to guess what goes on in university as there weren't even relevant courses in this stuff when I was the right age.

All I can comment on is what I see new grads pumped full of when they turn up. It seems to me they have all sorts of priorities, but shipping code is somewhere near the bottom (right below debugging techniques). It's an easy stretch to see that lecturers don't actually ship any code, and then I can join up my own dots.

Maybe they just get terrorised by being told that everyone else on their teams won't be able to code for toffee and they'll have to keep coming in on Saturday to fix other peoples' problems or something.

Dunno really, but people have to get this mentality from somewhere that globals in your code is worse than failing lotcheck, and it's certainly not borne in the workplace, as like I said earlier, it doesn't go on in any of the many workplaces I've seen.

(And true enough, I've never worked on mission critical server back ends or flight dynamics, just games)
------------------------------Great Little War Game
There's also the odd situation whereby every now and again a holy war starts up over utter trivia. It's globals today. Next week it'll be along the lines of "How can you ship games without even reading the GoF book?". A week later it'll be "How can you ship your game without boost and smart pointers?". We've already skirted along the "How can you ship titles without using agile/scrumm/blah?" and that'll come up again too.

The bottom line is that if someone brainwashed me into adhering to all this crap, I'm willing to concede that my productivity might go up by 1%, maybe. But my productivity is already much higher than anyone elses in most places I've worked at. And massively higher than the kind of guys who want to unit test a particle system. And judging by how little time I spend at other peoples desks, my code seems to be somehow useable also.

The unescapable fact of the matter is that all of us "luddites", the few that oppose the motion in forums, are the ones the producers come running to when the project is in the shit. It really is, I get it a lot. Even right this minute (well, over the holdiday) one guy I worked with in the past is talking to me about sacking his freelance team and getting us to start again from scratch.

"Just get it done" is the most important factor in a programmers make up, but this goes totally unsaid. Well, unsaid by those that don't actually think it's top of the list and are therefore just seat filling drones- and those guys should just do what they're bloody well told.
------------------------------Great Little War Game
Disclaimer: I am stepping into this thread as a community member, and by the unwritten law of GDNet, I hereby forfeit my ability to exercise any moderator power in regards to this thread or any side discussions that may spin off of it. Should things get ugly, though, I will enlist another impartial mod to come clean up as he/she sees fit, so don't take this as permission to get out of line.


I always find it interesting how arrogance tends to manifest in direct proportion to sheer naivete.



Rubicon, please let me be blunt with you for a moment.

You're probably a decent programmer. Maybe. I don't know, I've never worked with you, never seen your code, only read your advice handed out on GDNet - and that I've rarely found to be worth the cost of the paper it isn't printed on. Maybe you're being honest when you say you're so much better than all your colleagues, I don't know that either. But I don't think you should be parading that around as some kind of justification for your opinions.

Suppose Mozart's ghost were to show up here, and start talking about how he's so much better than all his contemporaries, and how in his opinion all this nonsense about playing successive notes in a consistent key is overrated hogwash. We'd probably all roll our eyes at Mozart and move on. Maybe a few of us would feel compelled to point out that he's a bit of a moron for making such statements in a world where musical theory is extremely well understood. Maybe a couple of us more observant folks would realize that he's basically arguing against something he was tremendously good at doing subconsciously, and therefore consider the whole thing an elaborate troll. Whatever.

In any case, if one of history's greatest and most recognized musical geniuses were to show up and start decrying basic music theory as academic bullshit, do you really think anyone but the most naive and ignorant fool would seriously listen to him?



What I'm driving at is this. You're talking as if you are a remarkable programmer. That may or may not be true. But you also talk as if you can thoroughly discount a lot of things that are proven good theory - and not just by theorists, but by those with practice in the trenches who have seen real code and know the real differences between following these guidelines and breaking them.

I have two questions, both rhetorical, which I'd like you to ponder. First: do you really think you are so much smarter than everyone else, that their input is literally worthless? Secondly, do you really think you can be as productive as you claim without at least instinctively doing things right, regardless of how you think you got there?



It's ironic that you keep worshiping this notion of "just ship code" as if it were so holy and superior to all other perspectives. The funny thing is, I also place a huge emphasis on shipping code. But I think there are some subtle differences in our ideas of what it means to ship.

To you, apparently, it means "kick something - anything - out the door and if you can't understand or fix it by yourself later, then fuck you."

To me, shipping code means four things:

  • Producing work which accomplishes the goals that were set forth for the project

  • Accomplishing objectives in a reasonable - often pre-agreed - time frame

  • Writing code that both I and anyone else can maintain and understand far into the future

  • Taking responsibility for the problems that will inevitably arise and working proactively to prevent or at least minimize them prior to shipping - then supporting and reacting to situations as they arise post-ship


Frankly, I think my idea of shipping code is a lot more professional and respectable than yours. And everyone I've worked under in my career is bound to agree.



I also find it interesting that you mention that people come to you to get the job done.

This is true for me as well.

Except there's a key difference: I get it done according to my (very high) standards, and I do so by embracing the advice of people with more intelligence and experience than myself. I get repeat business because I can prove in any environment that I am good and that my skill merits the investment in my time.

You seem, by your words, to get by sheerly on contrast with the alleged incompetence around you.

I could drop into a studio full of far better programmers than myself and still hold my own and do solid work, and still earn a good reputation, still earn repeat business.


Could you?




Also, you expressed some particularly interesting opinions about automated testing and its relationship to games. Have a look around the job postings for the industry for "SDET" positions. I'm sure you have no clue what that means, so look it up. Be educated.

Just because you're so damn sure of yourself doesn't make you right.

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

*deleted*

I did type a long litany addressing every accusation, but defending myself that way looked churlish and I really don't need to.

If you have it in your head that I'm sort of twat and want to read that much bile from between the lines then be my guest.

[Edited by - Rubicon on January 2, 2011 5:55:23 PM]
------------------------------Great Little War Game
Just to summarise:

Yes, I do come across as arrogant at times and I am extremely dismissive of new ideas for the sake of it. Because they're usually shite or address non-problems or are just too damn fiddly to be viable.

However, I've been working in the games industry practically since it started and have never been out of work for a single day. I've shipped about 50 titles over that time. I can think of only two that went out late and one that went out too buggy.

I won't be right all the time, and someone may well have a better opinion on a particular topic than I. But if you think my work record doesn't qualify my opinion on matters as being valid and useful, even if you don't agree with some of them, then what exactly is this board for?

You want the blind leading the blind now?

[Edited by - Rubicon on January 2, 2011 5:14:30 PM]
------------------------------Great Little War Game
Quote:Original post by Rubicon
I am extremely dismissive of new ideas for the sake of it. Because they're usually shite.
The issue I take with your stance is that most of these aren't new ideas just for the 'sake of it'. Some group of people have distilled a sizeable body of experience, and came up with a few principles that they find make life easier.

Now it may well be the case that your own body of experience does not support the same conclusions, but being openly combative to every, single, new, idea, just for the sake of it, doesn't really sound any better than what you are fighting.

Now, I don't entirely disagree with what you are saying. But as far as I can recall, you have only been on this warpath for a couple of weeks - so may I ask why the sudden conviction to swing everyone to your own viewpoint?

edit: new forum bug - can't link to individual replies, because the postbox interprets hash-prefixed numbers as unicode escapes...

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

I think my tolerance capacitor just fills up with certain things and I need to discharge it once in a while.

I'm only dismissive of this stuff (boost, unit tests, design patterns, multi-inheritance etc) because I *am* ignorant of a lot of it! Or have been bitten by it.

Pardon the arrogance again, but I've been put on the spot: The reason I keep harping on about "just get it out" is that I really do have a reputation for getting done in a day what other experienced guys might take two or three over. It's what I do. Don't come to me for a physics engine as I'm not too hot on that stuff, but do come to me if you want standard stuff punting out at a massive rate. And most of game dev is standard stuff. We use a bought in physics engine for example.

So my point is this. If I truly am faster than average to the point of having a rep for it, and I still don't know how to use boost, don't use agile development, don't do unit tests, then what is all that stuff meant to be achieving?

Regarding the advanced coding stuff, again its more down to practicality than some sort of binary racism. A lot of people attacking my stance seem to fall back to comments about solidity and maintainability and self defence, and that's a fair argument.

However, if you strip away templates, multi inheritance, excessive operator overloading, boost, etc then the code becomes so simple to look at that a newbie can fully understand everything I wrote after a quick scan - and that's the best sort of maintainability you can have in my book. Sure the lack of templates can cause extra work, but someone already said that the actual typing isn't a big part of your day and I agree. So it's not much work to just drop them and keep your code readable by anyone then, is it.

And finally, the reason it winds my up when someone says "you're wrong, industry experts have said this..." is because I consider myself to be that soldier too. When we started our own company we made all these things above illegal in our coding practices and still got lots of good work done on time for good profits. And our code is never a problem to port, is always readable and is regularly maintained. So it's a proven, viable operating practice whether that goes against the grain or not.

And that's just not just meant as "bully for me". The point of the above is again purely practical. We get shit done on time and to budget without all the new this and that, so for newbies just starting out I completely advocate bypassing the lot - you can write games without it and learning general game code paradigms is a big enough ask in general. Why complicate matters with side issues?

Hope that helps to explain where I'm coming from a little better than the ridiculous bile version from the previous poster...

(EDIT: PS. I see you linked my comment in the scene graph thread. In that case I was just getting po'd at people not attempting to answer the question, but showing off how new thinking they are instead. My previous couple of comments I thought were more than useful and constructive. But I swear someone at some point will say that integers are old thinking...)

EDIT2: I just checked out all those links and I see they're not to what I assumed they'd be, hence the above wall o' text. I've mentioned the first one, but the other three weren't openly combative at all. I advised against the methods being discussed with described insight of fails, not any latent hatred.

[Edited by - Rubicon on January 2, 2011 7:16:03 PM]
------------------------------Great Little War Game
My opinion is that globalised and static data is an old fashioned practice that actually complicates code. Just pass stuff around as parameters and be happy.

I do enjoy a global logger from time to time however, but that's because I mostly use logging as just another debugging tool - so I don't want to side-track from debugging a problem just to go about engineering the access to a logger, I just want to a grab a logger instance, use it and move on. I'm perfectly willing to accept that I may have to go and pull those logging statements out later; but I find that to be both less time consuming and simpler compared to having engineered the logger in properly to begin with.

This topic is closed to new replies.

Advertisement