The Many Benefits of 'Organised Coding'
Author: | Tigerworks
|
Submitted: | 2nd July, 2002
|
Views: | 5612
| Rated: |
|
|
Summary
This is a shorter article about how to make your code safer, easier to read and understand, add to, edit and less likely to be lost or damaged. It explains the many useful benefits of organising your code in groups, commenting, and more.
Organised Coding
These following points are things you should always follow, even in small games! Always follow these rules and you will be amazed at the difference... whether its making your latest game or trying to revive a three-year-old one, these points will always help.
Dealing with long code
Always comment your code. Just a comment at the top of a segment of events saying 'Horizontal movement' can save you a lot of bother when you come back to it next week or next year. In the important main parts of your code, always comment well! You will find otherwise yourself looking at a lot of text, black ticks and icons with red X's next to them which means very little to you. Comments can help you infinitely when it comes to understanding what you have done earlier, or enabling someone else to help with your game.
PUT YOUR CODE INTO GROUPS! Note the emphasis on that. If you only follow one point out of this whole article, make it this one. The absolute, essential, major point of all Click coding. Put your events into groups with relevant headings! For example, in a custom movement racing game, put all events related to the movement under a group called 'Movement Engine'. It may not seem or sound like much, but look at the benefits:
* "I need to change the movement engine to a slightly different speed." You could either wade through hundreds of events in one great list, and after half an hour find the value you think is right, change it and realise its the wrong one. Spend another ten minutes looking for the event you need to change. Or, open up the group of events called 'Movement Engine', and theres the event in front of you, no searching needed. Saves time, energy, bother and money (because time equals money, to the formula Time = Money ).
* "Oh yes, I left the attack engine a little unfinished. I ought to finish it off. What have I already done of it anyway?" Option #1: Sift through hundreds of events looking at the odd sparse event related to attack. Find one or two, have a vague idea, dump the new events at the end of the big list and see what it does. It's not quite right, I can't remember what the other events do. Oh no, big mess time! Option #2: Open 'Attacking' group of events, instantly see what you've already done, instantly add to it in the right place and know whats happening with comments.
* "Yeah where is my attack engine anyway? I need to access all of it quickly and efficiently." Open the group and you've found what you are looking for straight away.
* "Humm, that bullet shooting engine is a bit sketchy. I think I'll redo it all." Again, two choices: 1) Dig out the old code at intermittent intervals in the big long list, delete about half the related events and not find the rest, make your new engine and it doesn't work. Realise the leftovers of the old engine are dragging things down. Oh no, big mes again. 2) Open up Shooting group, delete, restart, nice and clean, no leftovers, simple and easy, and you know what is happening.
* "Argh, something to do with the movement engine is corrupted. What do I do? I have to restart, theres no hope of finding or replacing the corrupt events now!" Whole project down the bin. Or: Open Movement Engine group of events, and delete. Open backup which works, copy Movement Engine events, paste into new version. Tada! Working game.
If you don't do that after reading that, you are insane
Dealing with file problems
If you use MMF, remember to use it's Backup. 5 backups should be enough without flooding your hard drive, but at least 1 (I have had errors that delete your current CCA file and a single backup could have been restored in that situation).
After a big engine change, or every 2 weeks or so, re-save the game as a new name or new date. E.g. Wowgame_v1.cca saved to Wowgame_v2.cca after a big change or 2 weeks, so you always have something to fall back on. Also, if your big new change fails, you can easily return to the old way.
Floppies, CD burners, Zip drives, Secondary hard drives, Networked computers with hard drives CD burners Zip drives etc, Webspace. At least one of those you MUST have, if not, get one of them! Then start backing up your essential games to the new storage perdiodically every week or so. Bad things happen, you have to accept, every once in a while someones hard drive just goes 'Phut' and stops. It could be your hard drive. Save yourself the grief and BACKUP! Note: Local storage is best, most recommended is a secondary hard drive. You have most control over that. Remember your webserver could suddenly cut you off or your network computer is taken away for an upgrade when that critical moment occurs...
Conclusion
Organised code saves you time, money, effort, and makes you a happier person. Comment and sort events into groups, thats all; and behold, Clicking all makes sense.
Thanks for reading, and I hope Clicking is more enjoyable and easier when you follow these points!
|
|
TigerworksKlik Legend Registered 15/01/2002
Points 3882
|