coding style - The Stepdown Rule in Clean Code -


there stepdown rule (high level function @ top , low level next) in clean code (chapter 3, 1 level of abstraction per function ).
should when use coffeescript since there no function declarations in coffeescript.

example:

 seeamovie = ()->      buytheticket()      watch()   buytheticket = ()->      //some thing   watch = () ->      //some thing 

i want this.

coffeescript doesn't affect rule. rule doesn't have declarations, if did, coffeescript does have declarations anyway. @muistooshort said, here's coffeescript function declaration:

functionname = (arg1, arg2) ->    functionbodyline1   functionbodyline2 

those parenthesis optional in declaration if there no arguments. here's example of step-down rule in coffeescript in action:

highlevel = ->   dosomethingalmostashighlevel1()   dosomethingalmostashighlevel2()  dosomethingalmostashighlevel1 = ->   dosomethingalittlelowerlevel1()  ... 

note edit: that's fine , follows step-down rule. wrong sample?

not mentioned in book, uncle bob clarified me when 2 functions - @ same level of abstraction - use same lower level function, should ordered so:

highlevel1 = -> lowlevel() highlevel2 = -> lowlevel() lowlevel = -> ... 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -