Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Any tldr for “deep modules”?


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...

But I highly recommend picking up the book :) It is an enjoyable read.


IIRC, 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.


I 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.


Aha, I’d known some of the superpowers of TCL’s foreach but not all of those.

A ‘deep command’.


This google talk https://youtu.be/bmSAYlu0NcY?si=yHREamFoRG_fZopl is a condensed version of the (already small - 150 pags IIRC) book. I highly recommend both.

To the point made by the GP (and others here) about how useful the book is, I must add that I got a whole lot more from this small book than some other well known and oft suggested titles (like Clean Code, POSA etc).

My most recent peeve about the matter is that Kent Beck"s "Tidy, Fisrt?" was apparently motivated partly in response to this book and yet it falls way too short to matching up. Half of thst book is way too simplistic and almost patronizing and the other is handwavy abstract notions too scared to touch reality lest it spoil the narrative.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: