[閱讀筆記] Clean Code — Chapter5 Formatting

Vertical Formatting

  • Vertical Openness Between Concepts
    blanks between different functions, class
  • Vertical Density — close association
  • Vertical Distance
    closely related concepts should be kept vertically close to each other
    closely related concepts should not be separated into different files
  • Variable Declarations
    declared as close to their usage as possible
  • Instance Variables
    declared at the top of the class because been used in many places
    (instance variables to be declared in one well-known place)
  • Dependent Functions
    put them together following the calling order from top to bottom
  • Conceptual Affinity
    The stronger that affinity, the less vertical distance
  • Vertical Ordering
    function call dependencies to point in the downward direction

Horizontal Formatting

  • Horizontal Openness and Density
    whitespace → related/disassociate
    return b*b - 4*a*c;
  • Horizontal Alignment
    Aligning variables and assignments is not good → split them up
  • Indentation
  • Dummy Scopes
    while (dis.read(buf, 0, readBufferSize) != -1;Bad
    the semicolon is hard to see
  • Team Rules

--

--

--

An interactive engineer based in Tokyo. CG/Unity/Coding/Book Review

Love podcasts or audiobooks? Learn on the go with our new app.

The Java Condundrum

Spawn Doctor: Part One

Google Summer of Code 2021 — Community Bonding Period @ Hydra Ecosystem

From Java Development to C++ Development. Does programming language matters?

Bewekoof customer Care number/8584892730//8584892730/Bewekoof customer Care…

We’re shutting down Lisn

Use Docker to run Postgres locally

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Question Kid

Question Kid

An interactive engineer based in Tokyo. CG/Unity/Coding/Book Review

More from Medium

GitHub vs GitLab; which code repository should you choose

Linux: Software libraries in C

How I Learned To Write SOLID Code

Clean Code by Robert C. Martin [Book Review]

clean room