Trevor Foucher


Chapter 3 - Names That Can't Be Misconstructed

Actively scrutinise your names by asking yourself, “What other meanings could someone interpret from this name?” Example: Filter() Filter is an ambiguous word, it can either mean “to pick out”, or “to remove”. select() is better in the former case and exclude() in the latter. Example: Clip(text, length) Clip() clips the contents of the paragraph. But its unclear whether it: removes length from the end of the paragraph truncates to a maximum length.

Chapter 2 - Packing Information into Names

Packing Information into Names Choose specific words def GetPage(url) doesn’t say much. Maybe FetchPage() or DownloadPage() is more specific? int Size() - is this size the height of an object, numbeer of elements or memory footprint? Maybe Height(), NumNodes() or MemoryBytes() is better. A thesaurus can be useful. send -> deliver, dispatch, announce, distribute, route find -> search, extract, locate, recover start -> launch, create, begin, open make -> create, set up, build, generate, compose, add, new

The Art of Readable Code

“Simple and Practical Techniques for Writting Better Code” by Dustin Boswell and Trevor Foucher.