nearst / laconia

Create well-crafted serverless applications, effortlessly.
http://laconiajs.io
Apache License 2.0
326 stars 30 forks source link

Reorder function definitions #907

Closed ceilfors closed 10 months ago

ceilfors commented 10 months ago

This pull request demonstrates an example application of Reading Order and Cohesion Order

Reading Order: I defined what I expected to see first in this file, then opened it up. I expected to see the most important thing, which is the main logic first, and that logic is defined by the app function. That function is currently buried at the bottom of this file, so I pulled it to the top of the file for ease of reading.

Cohesion Order: I also noticed that the function instances should logically sit together when the IoC container is created, which is when the register method is called. Initially, the instances function was at the top of the file, it's moved to the bottom of the file for cohesion.

ceilfors commented 10 months ago

(I filed this PR to the wrong fork!)