+ 7

What is clean code?

Is it a code that is legible with indentation, comments and all or is it a code that works more efficiently?

23rd Nov 2020, 4:23 PM
Logos
Logos - avatar
15 Antworten
+ 25
[Part 1 of 2] Wow! 😱 I am shocked that of all the duplicate questions provided, the one from Tibor Santa in this post is the first to refer to Clean Code and Clean Architecture as we think of these terms in professional environments. This is the problem with having a community where answers are overwhelmingly provided by learners who really have no idea what the context of this question might be referring to. A few key aspects of Clean Code include: - Keep functions short and focused - Use meaningful names - 3 or less function args - Minimal comments... code should be clear enough to understand without comments... most of the time. - DRY - Don't Repeat Yourself - SOLID Principles - 5 character mnemonic acronym for 5 different principles that should be second nature for any senior developer.
23rd Nov 2020, 8:05 PM
David Carroll
David Carroll - avatar
+ 22
[Part 2 of 2] But these are just scratching the surface for what's involved with Clean Code. I'd say that new developers become overly obsessed with the compliance of every aspect of Clean Code, while seasoned developers know how, when, where, and why to strike a balance between the dogma of the concepts vs the practical application of those concepts. To learn more, Google the following and immerse yourself for a while. "Clean Code" "Clean Architecture" "SOLID Principles" "Test Driven Development" "Continuous Integration" "Agile Methodology"
23rd Nov 2020, 8:05 PM
David Carroll
David Carroll - avatar
+ 17
Clean Code is the name of a book, written by Robert C. Martin, one of the most influential authors of software design. The book is about a set of principles and guidelines, to enable developers to write code, that is maintainable and sustainable on the long term. Highly recommended read, and if you ever find any videos or lectures by Robert Martin online, don't miss them, they are a treasure chest of great ideas.
23rd Nov 2020, 5:53 PM
Tibor Santa
Tibor Santa - avatar
+ 8
"Goodbye Clean Code", by a programmer : https://www.sololearn.com/post/223948/?ref=app
23rd Nov 2020, 4:53 PM
Gordon
Gordon - avatar
+ 5
Tibor Santa Thank you so much for the recommendation. I'll definitely give it a read.
23rd Nov 2020, 7:31 PM
Logos
Logos - avatar
+ 5
Clean code is 1. Elegant Straightforward, concise, svelte. It looks like the language was built for the problem. 2. Efficient Performant, effective, reliable. It works. It solves the problem. Exceptions are handled. 3. Intuitive Expressive. Understandable. No gotchas. No antipatterns. Does not need a lot of comments. 4. Maintainable Readable, Scalable, Testable. It should be easy to change or extend. The risk of breaking something should be low. There should be automated tests, low coupling and high cohesiveness. You can give it a mnemonic. R - Reliable I - Intuitive S - Scalable E - Elegant
5th Dec 2020, 4:03 PM
Ore
Ore - avatar
+ 4
David Carroll I know what Clean Code means. It is a book written by Robert C. Martin. I have read that. But that is not what the question is about. I think. I interpreted the question as "what does it mean for code to be considered clean?". That is why I spelt it as "Clean code" not "Clean Code". So yes, it is an Ore original even though much of what I said has already been covered in the book.
5th Dec 2020, 4:39 PM
Ore
Ore - avatar
+ 4
Ore I like the Ore Original 😜👌 Just be aware that Clean Code has become quite ubiquitous in the industry with the points that have emerged from Martin's books. So much so, that we refer to Clean Code as concepts rather than as talking points from a book of the same title. It would be like someone asking what is agile programming and receiving answers about being nimble and flexible and organically changing code along the way. While the above response could be loosely aligned with Agile... it falls short of explaining the formal objectives, methodologies, and practices behind Agile. The responses I posted in the link above speak specifically to Clean Code concepts and disciplines that can be searched upon to further understand the tangible practices and guidelines around achieving Clean Code principles. I'm just trying to minimize any potential for confusion if not clearly stated how these correlate to the formal Clean Code practices and concepts which can be cross referenced with other sources. 👌
5th Dec 2020, 6:39 PM
David Carroll
David Carroll - avatar
+ 3
Ore Is this an Ore original or are you referring to a known mnemonic? I'm not sure you are aware, but Clean Code has a very specific meaning in the industry and this explanation could lead to some confusion.
5th Dec 2020, 4:21 PM
David Carroll
David Carroll - avatar
+ 2
Ore It's all good. 👌 We should start our own movement and call it Dirty Code. 😂🤣
5th Dec 2020, 7:15 PM
David Carroll
David Carroll - avatar
+ 1
Thanks for pointing that out. I did not mean to confuse anyone or to contend with the original ideas of Uncle Bob.
5th Dec 2020, 6:55 PM
Ore
Ore - avatar
0
This is Informative.
24th Nov 2020, 12:31 AM
Daniel Tobi Nyorere
Daniel Tobi Nyorere - avatar
5th Dec 2020, 8:01 PM
Ore
Ore - avatar