Advertisement

Am I doing it all wrong?

Started by July 06, 2015 12:42 AM
6 comments, last by ApochPiQ 9 years, 6 months ago

Hello there!

Recently I've finished developing my first game for the android platform. It works and I can understand the code perfectly, I used a tutorial to write the core game mechanics then I added a lot more features into it. I understand how the game works and the framework needed for it but can I write it all over again from scratch? I don't think so at all. Should I memorize the code? Should I copycat more tutorials or read books about it? Do expert game developers/programmers memorize the code of their games and/or can they do it without relying on other resources? huh.png

Thanks for any help provided, much respect smile.png

When I use certain algorithms more commonly it isn't about memorizing my code but making a helper class / wrapper that I can take with me to any project I work on and utilize stuff I have already written. If you ever use Unity you will do something similar by making prefabs that will have scripts, textures, etc... Every time you want to write a player controller script you don't rewrite it over and over and over again. You create some sort of source file that you can include in your project.

Advertisement

You should aim for a deep understanding of code and its data and code flow instead of just trying to remember it. Also look at what was good and bad in the code so you don't repeat mistakes. A good understanding of the basics means you will not need to copy/paste as you can build from basics

Also code that you feel is actually reusable should be extracted and made more generic and abstract in nature to allow for reuse in many areas. My current A* path finding code for example has the following signature

Path FindPath(Vector from, Vector to, Func<Vector, bool> isValidLocation);

I have abstracted the code so it has no knowledge of what it will find a path through, instead it is given a function that tests locations to see if valid. I can now reuse it again and again without change.

Programming isn't about memorizing code. It's about understanding your tools and the ability to use them to figure out a solution to a problem. The code isn't "what" you're doing, it's "how" you're doing it. What you generally want to learn is the "what", because the "how" will come naturally if you know your tools.

In practice, you will usually solve each problem once and later go back to reuse or copy from your previous solution. Though it can make sense to force yourself to write it again and again a few times in some cases, until a particularly common algorithm (say quick sort, A*, etc.) isn't just that "mysterious chunk of code I wrote years ago and don't remember how it works".

Copying from tutorials was probably not the point of writing them. Not only because it can be embarrassing to have code that calls "MyFunc" (yes, I've seen that kind of thing in production code), but because the point of that code is to illustrate and focus on a particular point or technique. That means there's usually little to no error handling and room for optimization, because that would obfuscate and distract from the actual subject matter. Also, unless you plan to build your whole program around a tutorial, it will rarely be something you can just drop into the rest of your code without plenty of adjustments. And then there's always the copyright question and what kind of use is permitted by the tutorial code's license.

So I'd move on to the next project. Learning and experience will happen naturally, unless you plan to wipe your memory or drink yourself silly after each programming session. While doing that, you will probably revisit your last project a lot anyway. For practice, resist the urge to copy/paste, if you just want to get it done, reuse away (just try not to copy comments or names that are nonsensical in the context of the new game).

f@dzhttp://festini.device-zero.de

Don't memorize the exact code, memorize the concepts. If you know what the goal is, you should be able to come up with a way to get there. If that involves using code written by someone else (librares/APIs), then it's normal to need a reference manual until you've worked with the same system for a long time.

Tutorials can be used two ways:

1. Copy/paste to get it working.

2. Read to learn the concept, and then try implementing on your own, and only peek at the tutorial code again if you get stuck.

The second way is of course more time consuming, but will teach you how to solve new problems on your own later.


Do expert game developers/programmers memorize the code of their games and/or can they do it without relying on other resources?

No absolutely not. A good programmer will spend time researching the subject a plan their code out before they start trying to bash away at a keyboard. If its a common task that they have done time and time again they may code this from memory but, then if something is used that frequently it may be better to reuse existing code.

Advertisement
Thank you everybody for your tips and guidance, your advices are going to aid me a lot in the projects to come. Much respect and appreciation for giving me some of your time. ^_^
http://two-wrongs.com/how-much-does-an-experienced-programmer-use-google

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

This topic is closed to new replies.

Advertisement