thblt / write-yourself-a-git

Learn Git by reimplementing it from scratch

Home Page:https://wyag.thb.lt

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Library, executable seperation

ItsShadowCone opened this issue · comments

It's nice how you put your code in a seperate libwyog.py, but consequently, libwyog.py should only "export" (aka define) functions for like init, add, commit, etc and the wyog executable should do command line parsing etc.

Thanks for the suggestion, but I'm afraid implementing this change would make the tutorial harder to follow with no real gain. The point of having two different files is to make sure that the program is runnable at any point of the tutorial without expecting the user to insert new code at any other place than the bottom of the main file. Since Python is a dynamic language, everything must have been evaluated before the main function runs. The only simple solution to insure a clear separation of concerns would be to add a third file libwyagcliargs.py or something, but I'm not really convinced the gain is worth the increase in complexity.

Suggestion persists, I have the feeling you don't quite understand why one splits code into a library file and an executable, because *adding code at the bottom so it's less complex" isn't the point. I would think it wouldn't add too much in complexity but after all it's your tutorial.