Years ago, I began tinkering with programming. I found that I had a knack for it. I could make my code do some pretty amazing things!
Then, I started hanging out with “real programmers”, who all had little mini-heart attacks whenever they looked at my code. I soon learned the “proper” way to program. I basically caught on, but it didn’t feel as natural to me. Besides, I was working with “real programmers” now, so I didn’t have to worry about it. I just let them to the programming.
Now, I often find that, while these guys are programming, I don’t have a lot to do. So, I open up mini-projects on the side, and tinker (currently a classic (J)RPG). The problem is, I now SUCK at programming.
I try putting everything into neat little classes, only make variables public that need to be public, etc, but I’m constantly tripping over myself and flooding my console with error messages. I then get angry and depressed, and I feel like an unproductive shmuck.
So, I decided, “to hell with this”. Why am I killing myself over this? If I’m the only one working on this thing, and I can get it to work, then who cares if it’s done “properly”.
Any thoughts on this? Is there any reason I can’t do things this way (aside from making other programmers cry)?
Just that you dont do it the common way doesnt mean that it is bad in general. There are a thousand ways to do the same. The “proper” way comes in handy where you need the optimal code because of performance reasons. Or when you work with other people together. But you can also optimize yourself to death.
One of the common advices of programming is “first make it work, then make it work good”. Mix that with “only optimize when you have to”, and you have your golden way
You guys are making me feel much better about this.
I spent too much time with programmers from the “enterprise” part of the industry. They’re very rigid, and don’t seem to enjoy their work very much. It becomes very easy to lose sight of why I’m doing this.
I actually made some decent progress tonight, and feel pretty good about myself for the first time in a long time.
Sorry to break the tap on the back mood guys, but … if by “proper code” you mean efficient, clean, and elegant, then except for pure decoration, “coding properly” does have a reason to exist. It’s never meaningless.
It prevents from further bugs that you can’t see yet (and believe me, in videogames, there will be ones)
It will give better performance (unless it’s indentation and decoration stuff)
It reduces the number of files, the number of lines, and more globally it “makes more sense”, which itself boosts your logical engineering abilities (essential in videogame dev).
It boosts code maintainability, reducing bug solving work time. (remember, there will be bugs ^^)
And most importantly : even if you’re alone, the cleaner your code will be, the less you’ll have those “get angry and depressed, feel unproductive” moments. In a word, you’ll do yourself a favor, and coding will not feel like a chore anymore.
To me there are no such things as “premature optimization”, “overmerging”, etc… Any form of optimization and cleansing is never lost time because it will always serve you in the future.
I proved it to myself several times with Unity. Latest example being that I had to litterally re-code all my game logics for network rollback compatibility. And because over the years I took care to have no logic redundancy, to separate each logic dealing business into different classes, to read 10 times each new class I wrote before validating it, etc, merging all businesses I could merge, etc …
because of all those (exhausting) efforts, I was able to rewrite all my game logics in 1 week. Would have taken ages otherwise. (aka maintainability).
Plus if you’re into profit : thanks to those efforts, now I got a complete, flexible fighting game engine that I could even license.
And if I didn’t have those proper 80000 lines of code, never would I be able to know exactly where X and Y are, etc. I wouldn’t enjoy to work. Actually even in an enterprise environment, having to work with a crappy framework is a valid reason for me to resign. Because yes, when your environment is bad, you will have those “get angry and depressed, feel like an unproductive shmuck” moments
At the end of the day, the only thing that matters is that it works. Any definition of ‘efficiency’ that’s worth listening to is directly related to getting it to ‘work’.
So on one hand, any efficiency that degrades your ability to get it to ‘work’ is bad. On the other hand if you ignore a standard ‘efficiency’ you may be damaging your ability to work - even if you don’t notice it at the time.
Then of course, not all efficiencies work, or should be applied in your situation
You`re of course right. Optimized and clean written code is a good thing. It helps alot with performance issues and debugging. But professional programmers tend to make a holy grail out of this. For most of them there is usually only one valid way do do things, only one valid language, only one valid solution allowed. Other solutions may work but they are soo slow, unefficient, uncommon, whatelse. They are not OPTIMAL.
And when doing the things that way without an important reason you end in a very slow and cumbersome workflow. A workflow that you learn to hate because you always try to optimize and optimize instead of writing working code instead. You trap yourself that way. And that is what happened to khanstruct. He didn´t write working code anymore. But highly optimized codebits instead.
Usually writing clean and good readable, means proper code is something that happens automatically the more experience you get. Bit by bit. That`s something that grows. And it better grows by fun
I totally agree with that
There’s nothing more irritating than a coder who thinks his way of coding is the holy grail. Who tells you that if you don’t know what the latest “XMvPVP rev.4a 2013 edition” coding pattern is, you’re basically worthless. But fortunately, as a matter of fact, such pedant behaviours are often a way to cover a lack of lower-level knowledge (or lack of recognition they wish they had). Bleh. As others said, let’s code in the way we want, as long as it’s efficient, proper and elegant
Round 1
First just build it , then try and apply it to more than one scenario/prototype game idea , normally this also entails trying to scale certain areas of the code with more features.
Round 2
Normally after the first round has matured enough and also depending on experience you will have a good idea of what works great and what is a bit shaky - then its time for refactoring or even complete rewrite.
here after its a rinse and repeat of each round but the time frame in between each cycle is larger and the need to repeat the cycle will cease with a great working code base one day.
You get better at it with time and by constantly learning about programming in general. Take what you want , leave what you hate , develop your style and have fun. That been said - after time it will be apparent that certain structures and principles of programming shine through ( programming towards an interface and not an implementation is one) and you will pick them up in the end because of the need for better productivity.
its ok to have down moments here and there … and bug squashing is a huge part of coding don’t feel bad.
When you’re going solo, It’s really a matter of what you’re trying to achieve. If you care about the end results only, you just throw crap code all over the place. If you take pride in your work, you don’t let yourself do that. It’s as simple as that.
Sense you are on your own and working on your own programs only, I would say do it however you want. Just remember that after you haven’t touched the code for 6 months and have to come back to it, the code will look like someone else wrote it (no matter how well written). If you just have a big pile of spaghetti code you will get a lot more frustrated and depressed then if you had taken the time to write it properly. Also once you have been programming a while it gets tiring to rewrite the same functionality over and over again which is why we use classes and keep them loosely coupled. The bottom line is sense you are not programming as a profession or in a group, you don’t need to strain yourself to greatly optimize your code but you should try to keep it structured and neat (with lots of comments).
You want to make your code robust and reusable so you can put it in other projects, but usually I only code as much as I need it to do. I was working on a simple powerbar for example and had options for horizontal/vertical, pixel or precent but I only needed precent and pixel so I didnt bother writing the rest of the code.
Theres really only one proper response to this. Are the people playing your game going to look at your code? Of course not. So if it works, and works well, there is no problem.
Who are these people who criticise you? what makes them right?
A few million people have enjoyed my (as far as I can tell) bug free code. So, whatever language I use, whatever technique, is irrelevant.
The same applies to everyone. The only exception is when you are part of a large team of programmers, this is when it becomes very important to obey a house style or conventions.
What is an easier thinking pattern for one person isn’t for another. Do what you want to do, providing it achieves your goals.
My take on this is if the guys you work with work in a way that is less efficient than yours even when the project grows larger, they need to change their ways.
Enterprise programmers aren’t “good programmers”, they’re just programmers, good or bad depends on each individual one, usually average people in any trade go by the book, and then it just depends on how good the book is, IMHO in programming the “standard ways” to program are pretty horrible and inefficient, if you program well make the right decisions, you should end up with so little code that the architecture around it becomes much less important, because a single person will be able to have the whole thing in their mind at a single time.
So my take on good code is usually make the same thing in 1/10 of the lines of code (without uglyfying it) and then it will architecture itself properly almomst by itself.