Cargando…

Clean Code in Python Develop Maintainable and Efficient Code, 2nd Edition.

References -- Chapter 3: General Traits of Good Code -- Design by contract -- Preconditions -- Postconditions -- Pythonic contracts -- Design by contract - conclusions -- Defensive programming -- Error handling -- Value substitution -- Exception handling -- Using assertions in Python -- Separation o...

Descripción completa

Detalles Bibliográficos
Clasificación:Libro Electrónico
Autor principal: Anaya, Mariano
Formato: Electrónico eBook
Idioma:Inglés
Publicado: Birmingham : Packt Publishing, Limited, 2021.
Edición:2nd ed.
Temas:
Acceso en línea:Texto completo
Tabla de Contenidos:
  • Cover
  • Copyright
  • Packt Page
  • Contributors
  • Table of Contents
  • Preface
  • Chapter 1: Introduction, Code Formatting, and Tools
  • Introduction
  • The meaning of clean code
  • The importance of having clean code
  • Some exceptions
  • Code formatting
  • Adhering to a coding style guide on your project
  • Documentation
  • Code comments
  • Docstrings
  • Annotations
  • Do annotations replace docstrings?
  • Tooling
  • Checking type consistency
  • Generic validations in code
  • Automatic formatting
  • Setup for automatic checks
  • Summary
  • References
  • Chapter 2: Pythonic Code
  • Indexes and slices
  • Creating your own sequences
  • Context managers
  • Implementing context managers
  • Comprehensions and assignment expressions
  • Properties, attributes, and different types of methods for objects
  • Underscores in Python
  • Properties
  • Creating classes with a more compact syntax
  • Iterable objects
  • Creating iterable objects
  • Creating sequences
  • Container objects
  • Dynamic attributes for objects
  • Callable objects
  • Summary of magic methods
  • Caveats in Python
  • Mutable default arguments
  • Extending built-in types
  • A brief introduction to asynchronous code
  • Arguments in functions and methods
  • How function arguments work in Python
  • How arguments are copied to functions
  • Variable number of arguments
  • Positional-only parameters
  • Keyword-only arguments
  • The number of arguments in functions
  • Function arguments and coupling
  • Compact function signatures that take too many arguments
  • Final remarks on good practices for software design
  • Orthogonality in software
  • Structuring the code
  • Summary
  • References
  • Chapter 4: The SOLID Principles
  • The single responsibility principle
  • A class with too many responsibilities
  • Distributing responsibilities
  • The open/closed principle
  • Example of maintainability perils for not following the OCP
  • Refactoring the events system for extensibility
  • Extending the events system
  • Final thoughts about the OCP
  • Liskov's substitution principle
  • Detecting LSP issues with tools
  • Using mypy to detect incorrect method signatures
  • Detecting incompatible signatures with pylint
  • More subtle cases of LSP violations
  • Remarks on the LSP
  • Interface segregation
  • An interface that provides too much
  • The smaller the interface, the better