0% found this document useful (0 votes)
3 views

Clean Code

The document outlines the principles of Clean Code, emphasizing its characteristics such as readability, maintainability, extensibility, and testability. It highlights the importance of meaningful names, effective commenting practices, and the benefits of clean code in improving debugging, team productivity, and reducing technical debt. The agenda covers various aspects including functions, error handling, and the mindset required for writing clean code.

Uploaded by

Abdalla Sakr
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Clean Code

The document outlines the principles of Clean Code, emphasizing its characteristics such as readability, maintainability, extensibility, and testability. It highlights the importance of meaningful names, effective commenting practices, and the benefits of clean code in improving debugging, team productivity, and reducing technical debt. The agenda covers various aspects including functions, error handling, and the mindset required for writing clean code.

Uploaded by

Abdalla Sakr
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Clean Code

Prepared By :
1 - Abdalla Mahmoud
2 - moamen
3 - Sohaila Mohamed
Agenda
1. What is Clean Code?
2. Meaningful Names.
3. Comments.
4. Functions
5. Error Handling
6. Code Formatting and Readability
7. Classes
8. Code Smells and Refactoring
9. Clean Code Mindset and Habits
What is Clean Code ?
• ➢ READABLE

• Readable code is code that can be understood by both a


programming newbie and a professional developer equally.
• ➢ MAINTAINABLE

• Maintainable code is simple, well-organized, and easy to


update or fix. It avoids complexity, making long-term
changes safer and faster.
• ➢ EXTENSIBLE

• Extensible code is flexible and ready for future features or growth.


It's written in a way that allows new changes without breaking
existing code.
• ➢ TESTABLE

• Testable code is designed so that it’s easy to write automated tests


for it . This means using small functions, clear inputs/outputs, and
minimal dependencies.
Why Clean Code Matters ?
1. Easier to debug and fix issues.
2. Improves team productivity faster
onboarding for new developers.
3. Reduces technical debt.
4. Lowers maintenance costs (e.g., 80%
of software cost is maintenance).
5. Makes future changes safer and
easier.
Meaningful Names
• The hardest thing about choosing good
names is that it requires good descriptive
skills.
• This is a teaching issue rather than a
technical.

➢ Use descriptive names


Meaningful Names
➢ USE PRONOUNCEABLE
• Use clear, pronounceable names
like calculateTotalPrice().
• instead of cryptic ones like
calcTP().
Good Naming Practices
•Avoid Disinformation : Use clear names like hitPoints
instead of vague ones like hp to prevent confusion.

•Avoid Mental Mapping : Ensure names are intuitive so


readers don’t need to translate them, prioritizing clarity.

•Class Names: Name classes with noun phrases like


Customer or WikiPage for clear representation.

•Method Names: Use verb phrases for methods like


postPayment or deletePage, and prefix accessors with
get/set per Java standards.
Comments Write Clean Code, Not
Explanations
Avoid Overusing Comments:

Good Practice: Clear Code Over Comments:


Use meaningful names and refactor code.
Avoid using comments to explain bad code.
Comment :
Avoid Complex logic + long comments
Clear code + minimal comments
Best Self-explanatory code (no comment needed)
Good Comments – Legal & Informative
• Legal Comments (Good):
• // Copyright (C) 2003,2004,2005 by Object Mentor, Inc.
// Released under GNU GPL v2 or later
• • Legal comments show code ownership or license.
• Refer to license docs instead of writing full text.
• Informative Comments (Good):
• // Returns an instance of the Responder being tested.
protected abstract Responder responderInstance();
• • Explains purpose or return value.
• Use when the function name alone isn't enough.

You might also like