4 ms·
Deep module - simple interface, complex functionality Shallow module - interface is relatively complex to the small functionality it provides. Shallow modules
by zakirullin 2y ago
Deep module - simple interface, complex functionality
Shallow module - interface is relatively complex to the small functionality it provides. Shallow modules don't hide as much complexity.
https://github.com/zakirullin/cognitive-load?#too-many-small-methods-classes-or-modules https://github.com/zakirullin/cognitive-load?#too-many-small...
But I highly recommend picking up the book :) It is an enjoyable read.
- Scarblac 2y agoIIRC, the deep/shallow thing is anout how much functionality there is, and he used wide/narrow for the size of the API? So that the goal is to have deep, narrow modules: modules that have a lot of functionality hidden behibd a small API.
- v9v 2y agoI think a good example of this concept is the foreach command in Tcl: It's quite flexible compared to list iteration constructs found in most languages. This is normal usage: foreach x {1 2} {puts $x} => 1 2 You can iterate over two lists at once: foreach x {1 2} y {3 4} {puts $x $y} => 1 3 2 4 Instead of reading one element from the list, you can read multiple: foreach {x1 x2} {1 2 3 4} y {5 6} {puts $x1 $x2 $y} => 1 2 5 3 4 6 If any of the lists happen to run out before the others, instead of complaining it just returns empty elements. Many commands in Tcl give the impression that they can be used in many different ways, so writing a program in Tcl feels like building a structure by creatively assembling a limited set of legos.
- runlaszlorun 2y agoAha, I’d known some of the superpowers of TCL’s foreach but not all of those. A ‘deep command’.
- deleted 2y ago[deleted]