The #1 Rule of Programming
April 22, 2014
There is a lot to learn when it comes to PHP programming … actually, there is a lot to learn when it comes to programming, regardless of the language. Here are my top for programming tips.
Stefan’s #1 Rule of Programming:
You will not remember everything you learn.
All the methods, functions, design patterns and other constructs found in PHP are far too many to for any human to remember. That’s why god invented Google and php.net.
… A good book can help too!
The most important thing to remember when learning PHP, are the basic concepts and practices. So I am talking about things like, function, arrays, classes, recursion, MVC et cetera. Again, it is not important that you remember the specific syntax – that you will forget in time. No, it is only important you understand what these things are and WHY you would use them.
Stefan’s #2 Rule of Programming:
To learn PHP code is to write PHP code.
Yep, the quickest way to understand PHP or any other language, is to actually write it. Start creating mini PHP scripts/projects as soon as you can. If you are already a PHP programmer and are learning something new in PHP, this rule still applies.
… If you want to try recursion, write a recursive function and watch it run.
Stefan’s #3 Rule of Programming:
There are many ways to skin a cat.
That’s one of the cool things about programming; nerds are rebels by nature (geeky rebels but nonetheless …) and so they constantly come up with new ways to do the same things for various reasons.
I mention this because many times, how you do something can impact on the overall performance and quality of the software you are building. Be open to new ideas but at the same time, many times the different ways of doing something won’t mean much in the end. So this is a judgement call on a case-by-case basis.
… These calls often separate the good programmers from the great.
Stefan’s #4 Rule of Programming:
Keep your code simple.
The simpler the code the faster it runs (typically,) the easier it is to update, the easier it is to write, the easier it is to create.
I would rather have a set of classes that have an extra 10% code if the code is much easier to understand.
Hope you find my list useful.