ID:47884
 
I've been wanting to write this little article for some time now, and today is the day I kinda want to bring Singel and Double loop learning to you attention.

Single loop
Solving a problem in a single loop kind of way can best be compaired to taking a pill to remove your pain. It focusses on taking away the result of a problem. There are many games which use the single loop way to code their game. If something is not working the way they want their game to work they add/change some code to change the result to what they want it to be.
A simple example, which I see ALOT on BYOND, is a HUB with a list of rules. In these rules you can almost certainly find the rule "Don't spam".
Now the single loop way of handeling this is to add code which boots people when they spam.
Sounds like a fix, but is it really the right way to handle things?

Double loop
Instead of fixing the result of a problem a double loop way tries to focus on fixing the cause of the problem. So instead of taking a pill to remove your pain, you try to figure out what causes the pain, and remove this, which in return will take away your pain. As for the coding part of it, it would be better to focus on using a double loop method rather than a single loop.
This would meen you throw away the code that boots people when they spam and create a code which makes sure they can't spam in the first place.

Why, why?
Why would I want everybody to focus on fixing problems the double loop way? Because trying to solve things this way will make you want to understand your code better, and make you see to what other pieces of code it relates. If you keep on fixing errors the single loop way you will eventually end up with many small systems (procs and such). Taking a look at things in the double loop way and you'll soon find yourself having one big main system which does all the work. Generally a big, well coded, main system is easier to use, more reliable and will run much more steady. It will probably be easier to expand, change and maintain.
Having a lot of small systems working together will most likely result in a system which is not stable, is not flexible and will have to be changed alot inorder to make any changes.
Don't get me wrong, a big system does not meen 1 proc to handle everything. It meens having the basic systems running your game the way it's suposed to and doing it right the first time.

I really hope there are people out there who can relate to this way of thinking and find it helpfull while coding.
Just remember, don't fix what a problem results into, fix the cause!

- Fint
Three years to the day I read this, and it's probably some of the best advice I've ever read ;_;