DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
The Latest "Software Integration: The Intersection of APIs, Microservices, and Cloud-Based Systems" Trend Report
Get the report

Code Must Be Clean. And Clear.

Clear code might be just as important as clean code. Find out why other developers still can't understand your clean code in this post.

Yegor Bugayenko user avatar by
Yegor Bugayenko
·
Sep. 13, 18 · Opinion
Like (15)
Save
Tweet
Share
5.18K Views

Join the DZone community and get the full member experience.

Join For Free

There is a famous book by Robert Martin called Clean Code. The title is an obvious call to all of us: the code must be clean. Clean, like a kitchen, I suppose — there are no dirty dishes, no garbage on the floor, no smelly towels. Dirt to be cleaned in a code base, according to Martin, includes large methods, non-descriptive variable names, tight coupling, lack of SOLID and SRP compliance, and many other things. Read the book, it's worth it. However, there is yet another aspect of source code. How clear is it?

The Rum Diary (2011) by Bruce Robinson


The kitchen is clean when there is no dirt in the oven. But if it's electric panel speaks French, I can't use the kitchen. Even if it's perfectly clean, it's not clear how to use it — that's why it's useless.

The metaphor applies to source code. Making it clean is the first and very important step, which will remove all those coding anti-patterns so many books speak about, including my favorites, Code Complete by Steve McConnell, Working Effectively With Legacy Code by Michael Feathers, and Clean Code. A very important step, but not the most important one. A dirty kitchen that is useful is better than a clean one that I can't use, isn't it?

Making code clean but leaving it difficult to understand by others is the pitfall most of us fall for. By "others" I mean everybody, from our fellow in-project co-developers sitting next to us at the same desk, to imaginative junior contributors who will join the project in five years after we're all hired by Google. All of them, across this very large timeframe, must be able to use the kitchen source code without any additional help. The oven has to speak their language. Not the language of its designer.

How do you do that? How do you make sure the code is clear, not just clean?

Well, test it. Ask someone who is outside of the project to take a look at your code and tell you how clear it is. Not how beautiful your classes and code constructs are — that's what makes it clean. Instead, ask someone to fix a bug in just 30 minutes and see how they react. You will realize how clear the code is and whether it speaks the language a stranger can understand.

This is the definition of maintainability. If a stranger can modify your code and fix a bug in less than an hour, it is maintainable. Obviously, cleanliness will help. But it's not enough. There has to be something else, which I don't really know how to describe. The only way to achieve it is to let strangers regularly see your code, attempt to make a contribution, and report bugs when something is not clear.

Making your code open and encouraging programmers to report bugs when something is not only broken but unclear — are the best two ways to achieve high maintainability.

Clear (Unix)

Published at DZone with permission of Yegor Bugayenko. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • The Power of Docker Images: A Comprehensive Guide to Building From Scratch
  • Implementing PEG in Java
  • 11 Observability Tools You Should Know
  • How To Choose the Right Streaming Database

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: