开发者

Where to find really good code examples [closed]

开发者 https://www.devze.com 2023-01-14 05:55 出处:网络
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references,or expertise, but this question will likely solicit debate, a
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 9 years ago.

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?


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号