Refactoring

Refactoring in C#


Course Outline Download
Software Installation ArgoUML: IDE:
Reading Material
PowerPoint Slides
Useful References
DayModuleSharing
1
  • What do we mean by refactoring?
  • Refactoring and clean code
  • Misconceptions about refactoring
  • Why you should consider refactoring?
  • Improving the design of your software
  • Maintainability and scalability
  • Understanding, avoiding, and fixing bugs
  • Faster development
  • When should you refactor?
  • The “Rule of Three”
  • Preparatory refactoring for smooth feature implementation
  • Refactoring for bug fixing
  • Comprehension refactoring
  • The “Boy Scout Rule”
  • Planned refactoring
  • Long-term refactoring and “Branch by Abstraction”
  • Refactoring in a code review
  • What should you refactor?
  • Impact analysis
  • Risk assessment
  • Value estimation
  • Prioritization matrix
  • Refactor or rewrite?
What is Refactoring:
2
  • Characteristics of good code
  • Good code is readable
  • Good code is reliable
  • Good code is hard to misuse
  • Good code is modular
  • Good code is reusable
  • Clean Code
  • Why Clean Code?
  • Some principles of Clean Code
  • Write SOLID code
  • Single responsibility principle
  • Open-closed principle
  • Liskov substitution principle
  • Interface segregation principle
  • Dependency inversion principle
  • Side effects and mutability
  • The builder pattern
  • Causes of bad code
  • Deadlines
  • The Broken Window theory
  • No code review process
  • Insufficient domain or technical knowledge
  • Duplicated code
  • Long methods
  • Replace temporary variables with query methods
  • Parameter object
  • Replace a function or method with a command
  • Decompose conditionals
  • Split loops
  • Large classes
  • Switches
  • Primitive Obsession
  • Middle man
  • Message chains
  • Feature envy methods
  • Divergent change
  • Shotgun Surgery
  • God object
Good Coding Habits: Code Smells:
  • Coming soon...
3
  • Why you should test (often)?
  • Identifying and fixing defects
  • Ensuring quality and reliability
  • Customer satisfaction
  • Compliance and standards
  • Security
  • Integration and compatibility
  • Confidence and peace of mind
  • Unit testing
  • Test framework
  • Integration testing
  • Mockito
  • Contract testing
  • Be safe – checking and improving your test coverage
  • What is test coverage?
  • Test-driven development
  • Advantages of TDD
  • Writing better methods
  • Extract Method
  • Inline Method
  • Extract and inline variables
  • Combining a function into a class
  • Moving features between objects
  • Moving a method or field
  • Moving statements into/from methods
  • Hiding delegates
  • Removing dead code
  • Organizing data
  • Field encapsulation
  • Replacing primitives with objects
  • Replacing type code with subclasses
  • Simplifying conditional logic
  • Returning a special case instead of null
  • Using polymorphism instead of conditions
  • Removing duplicated conditions
  • Guard clauses
  • Simplifying method calls
  • Avoiding side effects
  • Removing setter methods
  • Using generalization
  • Pull up field
  • Push down field
  • Pull up method
  • Push down method
  • Template method
  • Using enums instead of constants
  • What is static analysis?
  • Code errors or bad practices
  • Security
  • Cyclomatic complexity
  • Exception (mis)handling
  • Automated static analysis tools
  • What is dynamic analysis?
  • Debugging
  • Profiling
  • Fuzzing
  • Symbolic execution
  • Taint tracking

Recommanded Books
TitleSoftware Development, Design, and Coding:With Patterns, Debugging, Unit Testing, and Refactoring 3rd Edition
ISBN979-8-868-80285-0
AuthorJohn F. Dooley; Vera A. Kazakova
Year2024
Publisher Apress
TitleClean Code Principles And Patterns: A Software Practitioner's Handbook
ISBNB0D1ZDYKMV
AuthorРеtri Silеn
Year2024
Publisher Leanpub
TitleRefactoring with C#:Safely improve .NET applications and pay down technical debt with Visual Studio, .NET 8, and C# 12
ISBN978-1-835-08998-9
AuthorMatt Eland
Year2023
Publisher Packt Publishing Pvt Ltd