loading...

Discussion on: Building minicli: Implementing Command Controllers

Collapse
ppetermann profile image
ppetermann

Quick suggestion: you are using App like a service locator, it would be better to inject the printer into the controller.

(And generally when injecting, it's a good practice to type hint interfaces rather than implementations).

Also, when you register your command you already instantiat it, that, when having multiple commands will lead to unnecessary code being instantiated - a better practice would be to wrap the instantiation in a closure that's used to get the implementation when actually needed, rather than on registration.

Collapse
erikaheidi profile image
Erika Heidi Author

Oh, thank you so much for sharing these suggestions! I'll work on at least some of these ideas for the next release. :thumbs_up: