logoalt Hacker News

RivieraKidtoday at 12:37 PM4 repliesview on HN

Not a law but a a design principle that I've found to be one of the most useful ones and also unknown:

Structure code so that in an ideal case, removing a functionality should be as simple as deleting a directory or file.


Replies

layer8today at 1:00 PM

Functionalities aren’t necessarily orthogonal to each other; features tend to interact with one another. “Avoid coupling between unrelated functionalities” would be more realistic.

danparsonsontoday at 12:57 PM

Features arise out of the composition of fundamental units of the system, they're not normally first class units themselves. Can you give an example?

show 1 reply
skydhashtoday at 2:39 PM

Now, I tend towards the C idiom of having few files and not a deep structure and away from the one class, one file of Java. Less files to rename when refactoring and less files to open trying to understand an implementation.

show 1 reply
kijintoday at 12:46 PM

What's the smallest unit of functionality to which your principle applies?

For example, each comment on HN has a line on top that contains buttons like "parent", "prev", "next", "flag", "favorite", etc. depending on context. Suppose I might one day want to remove the "flag" functionality. Should each button be its own file? What about the "comment header" template file that references each of those button files?

show 2 replies