kdocs
GitHub
SC - Software Architecture
SC - Software Architecture
  • About
    • Architectural Requirements (RAs)
    • Architectural Perspectives
  • Software Design
    • Microservices
      • Patterns
    • Monolithic
    • C4 Model
  • Software Architectures
    • Clean Architecture
    • DDD (Domain Driven Design)
      • Strategic Modeling
      • Tactical Modeling
    • Event Driven Architecture
      • CAP Theorem
    • Hexagonal Architecture (Ports and Adapters)
  • Design Patterns
    • Behavioral
    • Creational
    • Data Access
    • Structural
  • Practices
    • Clean Code
    • SOLID
  • Others
    • CQRS
Powered by GitBook
On this page
  • Refactoring
  • Code Smells
  1. Practices

Clean Code

Reinforces the importance of code quality and presents many code smells and refactoring techniques.

Refactoring

Basically rewrite the code to eliminate Code Smells. Ideal to write the tests of the code to be refactored, covering 100%, before refactoring.

Code Smells

A smell is a symptom that occurs in the code and can be an indicator of problems.

  • Strange variable names, methods and classes.

    • Declared names must be clear in relation to its purpose.

  • Excessive comments.

    • Good code is self explanatory.

    • Using good names helps to reduce comments.

  • Dead code.

    • Ex.: Commented code.

  • Empty lines. (Controversy)

  • Duplicated code.

    • Maybe it can be extracted.

  • Long params list.

    • May indicate an anemic object. (It doesn't have self caracteristics, only receives from outside)

  • Variables declared away from its use.

  • Too many nested conditions.

    • Nested ternary conditions also bad.

  • Lack exception treatment.

    • Avoid returning arbitrary values to work as errors. (Like -1, 0, etc)

PreviousStructuralNextSOLID

Last updated 7 months ago