DEV Community

Discussion on: What's your favorite software idiom/aphorism?

Collapse
 
bytebodger profile image
Adam Nathaniel Davis

A function (or method) should do one thing, and do it well.

Collapse
 
hadrianhughes profile image
Hadrian Hughes

I like seeing this applied on the macro level too. ie keeping a command line tool specialised to doing one specific task very well.

Collapse
 
louy2 profile image
Yufan Lou • Edited

You'd be surprised at how god-damn much those command line tools actually do.

If you open up a manpage for ls on mac, you’ll see that it starts with

ls [-ABCFGHLOPRSTUW@abcdefghiklmnopqrstuwx1] [file ...]

That is, the one-letter flags to ls include every lowercase letter except for {jvyz}, 14 uppercase letters, plus @ and 1. That’s 22 + 14 + 2 = 38 single-character options alone.

-- The growth of command line options, 1979-Present

Collapse
 
n8chz profile image
Lorraine Lee

Also Google's rule for browser extensions, each extension should do one thing.

Collapse
 
louy2 profile image
Yufan Lou • Edited

This is an idiom which sounds nice but cannot be applied, due to the underspecificity of both "one thing" and "well". It is as meaningless as the following function signature:

f :: a