There is something about the Stepdown Rule (high level function at top and low level next) in clean code (Chapter 3, One Level of Abstraction per Function ).
What should I do when I use coffeescript since there is no function declarations in coffeescript.
seeAMovie = ()->
BuyTheTicket = ()->
watch = () ->
CoffeeScript doesn't really affect this rule. The rule doesn't have anything to do with declarations, but even if it did, CoffeeScript does have declarations anyway. As @muistooshort said, here's a CoffeeScript function declaration:
functionName = (arg1, arg2) -> functionBodyLine1 functionBodyLine2
Those parenthesis are optional in the declaration if there are no arguments. Here's an example of the Step-Down Rule in CoffeeScript in action:
highLevel = -> doSomethingAlmostAsHighLevel1() doSomethingAlmostAsHighLevel2() doSomethingAlmostAsHighLevel1 = -> doSomethingALittleLowerLevel1() ...
Note about your edit: That's perfectly fine and follows the Step-down rule. What is wrong with your sample?
Not mentioned in the book, but Uncle Bob clarified to me that when two functions - at the same level of abstraction - use the same lower level function, they should be ordered like so:
highLevel1 = -> lowLevel() highLevel2 = -> lowLevel() lowLevel = -> ...