Order of Lines/Elements Is Important
- Be consistent
- > Order of Lines/Elements Is Important
- Balance Planning/Researching With Action
- Sometimes in Order to Understand You Must Do
- When Teaching/Explaining Focus On the Main Topic
- Get Good at Gathering Information From People
- Be lazy (performance tip)
- Do breadth first thinking
- You will always solve it
The order of things in a file is important.
I don’t just mean the ordering/grouping of code constructs (public functions, private attributes, etc) based on some style guide, although that is one (unintersing) reason why ordering is important.
I mean it from a readbility perspective.
Ordering encodes infromation. It can help/hurt readability.
In a function, the statements should be ordered in a “nice way”. Sometimes this means ordering them in a chronological fashion, like you are giving ordered step by step instructions on what needs to be done. Other times it means grouping “similar” statements in blocks. There are many ways in which statements can be “similar”. For example, they can all be related to instatiation, or they can all be related to deletion/clean up.
Sometimes you have to order function statements in a certain way in order to get the proper functional result. If this however is not the case, order your statements in a “nice” way (to make the code read as naturally as possible). This means reading the function statements a few times and making incremental improvements.
Another nice thing to do is to group similar functions together. For example, the functions mapFromParent()
, mapFromScene()
, and mapFromView()
should be grouped, because they all do “mapping”.