{"id":246568,"date":"2016-10-21T06:08:18","date_gmt":"2016-10-21T13:08:18","guid":{"rendered":"http:\/\/css-tricks.com\/?p=246568"},"modified":"2016-10-22T16:28:00","modified_gmt":"2016-10-22T23:28:00","slug":"on-style-maintenance","status":"publish","type":"post","link":"https:\/\/css-tricks.com\/on-style-maintenance\/","title":{"rendered":"On Style Maintenance"},"content":{"rendered":"

I was talking to a brilliant engineer friend the other day who mentioned they never get to build anything from the ground up. Their entire career has consisted of maintaining other people’s (often quite poor) code.<\/p>\n

In a perfect world, we’d all get to write code from scratch, it would work perfectly, and we would put it into a bin in the sky, never to be looked at by anyone again.<\/p>\n

We all know that’s not how it works. Code need to be maintained<\/em>.<\/p>\n

<\/p>\n

Kyle Simpson often begins his talks explaining that we spend only 30% of our time writing code, and 70% of our time maintaining it. Being a good coworker and programmer is not just about being a skillful problem solver, but being legible. Great developers produce code with maintenance in mind. <\/p>\n

I often joke that I don\u2019t want to hire a code ninja. Ninjas come in the middle of the night and leave a bloody mess.<\/p>\n

I want a code janitor. Someone who walks the hallways of code, cleaning up pieces, dusting up neglected parts, shinning up others, tossing unnecessary bits. I prefer this gentler, more accurate analogy. This is the person you want on your team. This is a person you want in your code reviews. <\/p>\n

Shoutout to JD Cantrell<\/a>, who is an awesome code janitor and code reviewer.<\/p>\n

Let’s think about code maintenance through the lens of two different programming paradigms<\/h3>\n

In programming there are many tools and procedures available to meet the same end. There is no right answer. Here is a succinct definition by Michael Feather of two very popular programming paradigms:<\/p>\n

\n

Object-Oriented Programming makes code understandable by encapsulating moving parts…<\/p>\n

Functional Programming makes code understandable by minimizing moving parts.<\/p>\n<\/blockquote>\n

Let’s consider both in terms of not just understandability but also maintenance.<\/p>\n

Functional Programming<\/h4>\n

I have seen for myself the value of using a functional approach in front-end JavaScript. When we write code, sometimes we want to assume that it will be used forever the way we intended, but most of us have been doing this long enough now to acknowledge that that isn\u2019t always the case. <\/p>\n

Functional programming includes, but is not limited to:<\/p>\n