Clean Code: The Bible, The Dogma, and The Dirt
Because perfection is the enemy of shipped.
If you've been a software engineer for more than 5 minutes, someone has probably told you to read Clean Code by "Uncle Bob" (Robert C. Martin). For a long time, this book was considered the absolute bible of software engineering.
But what actually is it? Is it still relevant today in the era of AI-generated code and serverless functions? And is there ever a time where writing "dirty" code is actually... better?
What Exactly IS Clean Code? (The Breakdown)
Uncle Bob's core philosophy is that code isn't just for computers to execute—it's for humans to read. He argues that the ratio of reading code to writing code is well over 10:1. Here are the core commandments:
- Meaningful Names: No more
let d = 10; // d is days. Use elapsedDays. Variables, functions, and classes should reveal their exact intent.
- Small Functions: A function should do exactly one thing, and it should be small. Like, 5-10 lines small. If it bends your screen, it's too long.
- Comments are Failures: Good code documents itself. If you have to write a comment explaining what a block of code does, your code isn't clear enough. Refactor it!
- Formatting Matters: Your codebase should look like an elegant newspaper article—most important stuff at the top, details at the bottom.
Name variables like you'll forget them tomorrow.
Is It Still Relevant Today?
Yes and No. The core philosophy—writing readable, maintainable software—is timeless. However, the exact prescriptions of the book have aged a bit awkwardly.
For example, Uncle Bob is heavily biased towards early 2000s Java Object-Oriented paradigms. Today, with functional programming, Go, Rust, and React paradigms, chopping a function into 10 microscopic one-liner files can actually make your codebase a nightmare to navigate. Sometimes, long procedural functions are much easier to read than jumping across 15 different files for a single API call.
Why Sometimes, "Dirty" is Good
In Indonesia, there's a famous detergent commercial with a legendary slogan: "Berani kotor itu baik" (Don't be afraid to get dirty / Being dirty is good). And honestly? That's incredible advice for software engineering.
Startups and businesses survive on speed, not mathematical perfection. If you spend three weeks polishing a feature into perfectly abstracted Clean Code, and a competitor ships a messy, "dirty" working version in three days... the competitor captures the market, gets the funding, and you get laid off with a perfectly clean codebase.
Berani kotor itu baik! ✨
Here are times when you should actively choose the dirty route:
- Prototyping & MVPs: Just write the spaghetti code. Prove the business value first! You can't refactor code for a product nobody wants to buy.
- Highly Performant Loops: Sometimes readability costs CPU cycles. In game dev or high-frequency trading, you write ugly, bit-shifting, heavily nested code because it's fast.
- One-off Scripts: Writing a data-migration script you will run literally once? Keep it entirely in one massive 500-line
main() function.
The Verdict
Learn Clean Code. Master the rules. Know how to write beautifully structured software. And then, once you've mastered the rules, you earn the right to break them. Be pragmatic. Just like playing outside when you were a kid: Berani kotor itu baik!
Clean Code: Kitab Suci, Realita, dan Kotor yang Haqiqi
Perfeksionis itu nyusahin rilis.
Kalo lo udah jadi software engineer lebih dari 5 menit, pasti ada aja senior atau orang random di internet yang nyuruh lo baca buku Clean Code karangan "Uncle Bob" (Robert C. Martin). Udah bertahun-tahun buku ini disembah sebagai kitab sucinya anak IT.
Tapi sebenernya apa sih itu? Apa iya masih relevan di zaman serba AI dan serverless ini? Terus pertanyaannya... ada nggak sih momen di mana nulis kode "kotor" itu malah nguntungin?
Bedah Tuntas Clean Code ala Uncle Bob
Filosofi intinya Uncle Bob tuh simpel: Kode itu ditulis bukan cuma buat dibaca sama komputer, tapi buat dibaca sama manusia. Rasio kita ngebaca kode dibandingin nulis kode itu minimal 10 banding 1. Makanya, ini dia "fatwa"-nya:
- Penamaan Kudu Jelas: Nggak ada lagi tuh nulis
let d = 10; // d itu hari. Langsung aja tulis elapsedDays. Nama variabel, fungsi, atau class harus jelas maksudnya apa tanpa perlu ditebak-tebak.
- Fungsi Kudu Pendek: Satu fungsi cuma boleh ngerjain SATU hal aja, dan ukurannya harus kecil. Kalo bisa 5-10 baris doang. Kalo fungsi lo panjangnya sampe ngalahin skripsi, berarti kepanjangan.
- Komentar = Kegagalan: Kode yang bagus itu ngejelasin dirinya sendiri. Kalo lo sampe harus nulis komentar panjang buat ngejelasin blok kode lo ngapain, berarti kode lo belum cukup sakti. Refactor!
- Format itu Penting: Codebase lo harus elegan kayak artikel koran—inti ceritanya di atas, detail pelaksanaannya ngumpet di bawah.
Namain variabel sejelas mungkin bos!
Masih Relevan Nggak Sih Zaman Now?
Iya dan Enggak. Filosofi dasarnya untuk nulis software yang gampang dimaintain dan dibaca itu emang timeless abis. Tapi sayangnya, aturan-aturan spesifiknya udah agak usang.
Secara historis, Uncle Bob nulis buku itu dengan bias ke arah arsitektur Java awal 2000-an yang serba Object-Oriented. Hari ini? Kita pake Functional Programming, Go, Rust, sama React. Kalo lo mecah satu fungsi panjang jadi 10 file kecil-kecil kayak doktrinnya, malah bikin codebase lo pusing buat di-trace. Kadang, baca kode prosedural panjang di satu file itu jauh lebih gampang dipahamin daripada harus muter-muter nyari 15 file berbeda cuma buat nyari tau API call ini nembak ke mana.
Kenapa Kadang Nulis Kode "Kotor" Itu Baik
Kita semua orang Indonesia pasti pernah denger slogan iklan deterjen legendaris ini: "Berani kotor itu baik." Dan jujur aja? Itu adalah advice software engineering paling goated yang pernah gue denger.
Startup dan bisnis itu idup dari speed, bukan dari seberapa indah kode lo. Kalo lo ngabisin waktu tiga minggu buat mijit-mijit dan nge-polish fitur lo biar jadi 100% Clean Code, sementara saingan lo ngerilis versi "kotor" dan acak-acakan tapi jalan di hari ketiga... si saingan bakal narik semua user, dapet funding gede, dan perusahaan lo gulung tikar ninggalin codebase super bersih di dalem kuburan.
Iklan Rinso relate banget di IT! ✨
Ini dia momen-momen sakral di mana lo HARUS nulis kode kotor:
- Bikin Prototype & MVP: Gass aja bikin kode spaghetti. Buktiin dulu idenya laku! Lo nggak bisa nge-refactor kode dari produk yang nggak ada user-nya.
- Looping Super Ngebut: Kadang "readability" itu ngorbanin CPU cyles. Di game dev atau high-frequency trading, lo mending nulis kode jelek dan bersarang asalkan eksekusinya kilat.
- Script Sekali Buang: Lo mau bikin script buat migrasiin data yang cuma bakal dijalanin sekali seumur idup? Nggak usah sok Clean Code. Tumpuk aja semua logikanya di dalem
main() sepanjang 500 baris. Kelar.
Kesimpulannya
Pelajarin Clean Code. Pahami aturannya, khatamin cara nulis software yang terstruktur rapi. Terus, pas lo udah jago, lo punya hak veto buat ngelanggar aturan-aturan itu sesuai kebutuhan bisnis. Jadilah pragmatis. Kayak anak kecil main di lapangan habis ujan: Berani kotor itu baik!