Packt
Writing Clean Code: 20 Code Smells & How to Avoid Them
Packt

Writing Clean Code: 20 Code Smells & How to Avoid Them

Included with Coursera Plus

Gain insight into a topic and learn the fundamentals.
Intermediate level

Recommended experience

12 hours to complete
3 weeks at 4 hours a week
Flexible schedule
Learn at your own pace
Gain insight into a topic and learn the fundamentals.
Intermediate level

Recommended experience

12 hours to complete
3 weeks at 4 hours a week
Flexible schedule
Learn at your own pace

What you'll learn

  • Master strategies for recognizing and refactoring common code smells that affect code readability and scalability

  • Understand the SOLID principles and how they improve software design and maintainability

  • Learn best practices for handling complex data structures, eliminating redundancy, and reducing technical debt

  • Gain the skills to simplify and streamline your codebase, making it more intuitive, flexible, and easier to maintain

Details to know

Shareable certificate

Add to your LinkedIn profile

Recently updated!

May 2025

Assessments

23 assignments

Taught in English

See how employees at top companies are mastering in-demand skills

 logos of Petrobras, TATA, Danone, Capgemini, P&G and L'Oreal
Coursera Career Certificate

Earn a career certificate

Add this credential to your LinkedIn profile, resume, or CV

Share it on social media and in your performance review

Coursera Career Certificate

There are 24 modules in this course

In this module, we will introduce the course and outline its goals. You will learn how identifying and removing code smells can drastically improve the quality and maintainability of your codebase, laying the groundwork for better software design practices.

What's included

1 video1 reading

In this module, we will dive into essential software design principles, focusing on the SOLID principles. You'll explore how these principles can be applied to create cleaner, more maintainable, and scalable software architecture. We’ll also cover techniques for structuring modules effectively to improve code quality.

What's included

7 videos1 assignment

In this module, we will guide you on how to read and comprehend large codebases effectively. You’ll learn techniques for navigating code efficiently and identifying areas where code smells can be improved or refactored for better clarity and maintainability.

What's included

1 video1 assignment

In this module, we will introduce the repeated switch code smell and discuss its negative impact on code readability and maintainability. You will learn how to recognize and refactor repeated switch statements for cleaner, more maintainable code.

What's included

3 videos1 assignment

In this module, we will explore the primitive obsession code smell, focusing on how overusing primitive data types can complicate your code. You will learn how to replace these with domain-specific objects, improving abstraction and readability.

What's included

3 videos1 assignment

In this module, we will address inefficient loop structures, one of the most common code smells, and discuss their impact on both performance and readability. We’ll provide best practices for refactoring loops to make them more efficient and easier to understand.

What's included

3 videos1 assignment

In this module, we will cover the long parameter list code smell and how excessive parameters can complicate function signatures. You will learn strategies for simplifying these lists, such as using objects or default values to enhance readability and maintainability.

What's included

3 videos1 assignment

In this module, we will address the knowledge duplication code smell, explaining how repeated logic across the codebase can lead to inconsistencies and higher maintenance costs. You will learn techniques for refactoring and removing redundancies to improve the maintainability of your software.

What's included

3 videos1 assignment

In this module, we will explore how uninformative comments can clutter your code and reduce clarity. You will learn how to write useful, concise comments and improve code readability by eliminating redundancy.

What's included

3 videos1 assignment

In this module, we will dive into the shotgun surgery code smell, where changes in one part of the system require modifications across multiple classes. You will learn strategies for refactoring to reduce the complexity of these scattered changes and improve maintainability.

What's included

3 videos1 assignment

In this module, we will discuss the problem of alternative classes with inconsistent interfaces, which can lead to confusion and usability issues. You’ll learn how to refactor classes to unify interfaces and improve code consistency.

What's included

3 videos1 assignment

In this module, we will explore the refused bequest code smell, which occurs when a subclass inherits functionality that it does not use. You’ll learn how to refactor your code to reduce misuse of inheritance and prefer composition to improve flexibility and maintainability.

What's included

3 videos1 assignment

In this module, we will address the data clumps code smell, where related data is grouped together inappropriately. You will learn how to refactor these data structures to improve organization and encapsulation for better maintainability.

What's included

3 videos1 assignment

In this module, we will examine the middle-man code smell, where unnecessary classes add complexity by simply delegating functionality. You’ll learn how to refactor your code by removing unnecessary abstraction layers to simplify your codebase.

What's included

3 videos1 assignment

In this module, we will explore mutable data and how uncontrolled changes to state can lead to bugs and inconsistencies. You’ll learn how to refactor your code to manage data immutability effectively for better reliability and predictability.

What's included

3 videos1 assignment

In this module, we will address the feature envy code smell, where methods tend to focus too heavily on data from another class. You’ll learn how to refactor your code to improve object boundaries and move behavior to the class where it logically belongs.

What's included

3 videos1 assignment

In this module, we will explore the divergent change code smell, where a module requires frequent modifications for unrelated reasons. You’ll learn how to refactor your code to minimize the risk of frequent changes causing instability or regressions.

What's included

3 videos1 assignment

In this module, we will explore the issue of large interfaces and how they can make code difficult to maintain and extend. You’ll learn how to refactor large interfaces into smaller, more manageable ones that are easier to maintain and scale.

What's included

3 videos1 assignment

In this module, we will address the multitasker code smell, where classes or methods take on too many responsibilities. You’ll learn how to apply the Single Responsibility Principle to refactor your code and improve its clarity and maintainability.

What's included

3 videos1 assignment

In this module, we will focus on the importance of clear, intuitive naming conventions. You will learn how unclear names can cause confusion and how to adopt best practices for naming variables, functions, and classes for improved readability.

What's included

3 videos1 assignment

In this module, we will discuss speculative generality and how over-engineering can make code unnecessarily complex. You’ll learn how to simplify code by removing premature abstractions and focusing on current requirements.

What's included

3 videos1 assignment

In this module, we will explore the unnecessary exceptions code smell, where the excessive use of exceptions makes error handling more complicated than needed. You will learn how to simplify exception handling for clearer and more robust code.

What's included

3 videos1 assignment

In this module, we will discuss the shallow module code smell, where modules contain little functionality relative to their complexity. You will learn how to refactor these modules to provide more meaningful functionality and enhance reusability.

What's included

3 videos1 assignment

In this final module, we will summarize the key takeaways from the course, reinforce the importance of clean code practices, and offer guidance on how to continue improving your software design skills for better maintainability and scalability.

What's included

1 video1 assignment

Instructor

Packt - Course Instructors
Packt
717 Courses107,704 learners

Offered by

Packt

Why people choose Coursera for their career

Felipe M.
Learner since 2018
"To be able to take courses at my own pace and rhythm has been an amazing experience. I can learn whenever it fits my schedule and mood."
Jennifer J.
Learner since 2020
"I directly applied the concepts and skills I learned from my courses to an exciting new project at work."
Larry W.
Learner since 2021
"When I need courses on topics that my university doesn't offer, Coursera is one of the best places to go."
Chaitanya A.
"Learning isn't just about being better at your job: it's so much more than that. Coursera allows me to learn without limits."

New to Software Development? Start here.

Coursera Plus

Open new doors with Coursera Plus

Unlimited access to 10,000+ world-class courses, hands-on projects, and job-ready certificate programs - all included in your subscription

Advance your career with an online degree

Earn a degree from world-class universities - 100% online

Join over 3,400 global companies that choose Coursera for Business

Upskill your employees to excel in the digital economy

Frequently asked questions