??? 01/17/11 08:37 Read: times |
#180641 - Always good to read code Responding to: ???'s previous message |
Andy Neil said:
David Good said:
Jack Ganssle once observed that while students in most professions spend an appreciable amount of time studying quality examples of their craft I think the key thing is that this happens under the guidance of a "mentor" - who can provide a commentary on what the "apprentice" is seeing. The trouble with just looking at existing designs (whether hardware or software) is that it just shows you what the designers did - not why they did it. Even without a mentor, it's meaningful to read lots of code. You soon learn to like or dislike different code. But you need to know enough to understand the code in the first place, so that a reasonable amount of brain capacity can be spent on looking at details of the code. How things are declared. How timing issues are handled etc. Even without a mentor, it will soon be obvious if a design pattern results in "clumsy" code. A big trap for a reader who doesn't know the quality of the code is to spot potential timing issues - code that may look elegant, but ignores what happens when an 8-bit processor have non-atomic updates of multi-byte variable from ISR and main loop without protection etc. Such issues are almost impossible to spot until you do know about them and know what to look for. In many situations, it may be enough to read code and have access to a web forum where it is possible to ask questions about specific things seen in code - with publicly available code it is easy to post a link to the source. |