Top-down: Difference between revisions

→‎External links: +Inside-Out Apps <https://www.sicpers.info/2014/03/inside-out-apps/>
(mention that it's hard sometimes even just figuring out where the entry point is in C, and that triple scripts' top-down nature make them kind of like literate programs)
(→‎External links: +Inside-Out Apps <https://www.sicpers.info/2014/03/inside-out-apps/>)
 
(One intermediate revision by the same user not shown)
Line 15:
When implementing a class, we also advocate for keeping the top-down philosophy in mind with respect to class method ordering within the file. If a method <code>collate</code> calls a method <code>seed</code> and <code>collate</code> is <code>seed</code>'s only caller, then the former should appear nearer to the top of the file than the latter. When reading a triple script, it should seem like a picture that gets clearer, or a concept that gets more specific, where it originally starts out as a general outline of all that follows.
 
Program authors can even take advantage of function hoisting to get the same effect. Suppose you wanted to write the <code>collate</code> method but didn't want to create a separate <code>seed</code> method (or even a quasi-private <code>_code_seed</code>). You might instead write:
 
collate(collection) {
Line 36:
== External links ==
 
* [https://www.teamten.com/lawrence/programming/write-code-top-down.html Write code top-down — Lawrence Kesteloot]
* [https://www.sicpers.info/2014/03/inside-out-apps/ Inside-Out Apps]