views:

62

answers:

2

I am a new web programmer and am always looking to improve my knowledge and skills. As such I have read countless times on stackoverflow that a good way to do this is to read other peoples code.

This is all fine and well but where can i find some good examples of really well written code? Im thinking specifically php here since this is my main language of use and as its server side i can just look at the source?

+2  A: 

Learn how Zend Framework is written. They adopt the best language practices in my opinion.

Yanick Rochon
Yup, ZF was the first thing that came to my mind, too.
Pekka
+1: same here :)
shamittomar
A: 

Now I am not exactly answering your question (at least not directly) but hopefully you will get some ideas that might be helpful to you.

Well written code can be a lot of things. It all depends on what you want to do. Efficient code can not only be code that executes fast but also code that are easy to maintain and/or expand. It all depends on your needs.

A good way to start is to break down your problem into simpler problems first and then decide how to solve it. A good way to learn is to read, modify and above all understand other peoples code.

I've once heard a story about a great programmer. He always had a teddy bear sitting next to him and when the code did not work as expected he took the teddy bear on his lap and explained him every line in the code. You see - he actually explained the code to himself. That can sometimes be the best debugging tool since you risk discovering your own mistakes ;)

Also as an example keep in mind that for fast executing code it is especially important to minimize the amount of variables used in a loop. With some luck all your variables can be stored in the CPU's registers for the duration of the entire loop thus avoiding latency for swapping data on the main memory.

Waxhead