Some Best Practices & Refactoring Techniques

Published on
Embed video
Share video
Ask about this video

Scene 1 (0s)

Some Best Practices & Refactoring Techniques. SE3070 - Case Studies in Software Engineering Semester 2, 2025 SLIIT.

Scene 2 (8s)

Learning Outcomes. After completing this topic, you will be able to, Explain the relationship between coding standards, best practices, and code quality. Apply best practices to improve maintainability and readability. Identify code smells in a given codebase and propose appropriate refactoring techniques. Use refactoring to improve cohesion, reduce coupling, and align with SOLID principles..

Scene 3 (26s)

Contents. Coding Standards and Best Practices Why Best Practices & Coding Standards Aren’t Enough From Code Smells to Refactoring Refactoring Fundamentals Some examples When Not to Refactor Summary.

Scene 4 (37s)

Poor code quality leads to technical debt. Design quality ≠ Implementation quality Even great designs can be ruined by bad code. Good code is easier to understand, modify, and extend without breaking existing features..

Scene 5 (54s)

Coding Standards. A collage of a person with clown makeup AI-generated content may be incorrect..

Scene 6 (1m 9s)

Consistent naming conventions for classes, methods, variables, constants etc. Package/module structuring that matches system architecture. Consistent formatting indentation, braces, whitespace, line wrapping etc. Documentation & comments Explain “why”, not just “what”.

Scene 7 (1m 23s)

Google C++ Style Guide Google Java Style Guide Google Python Style Guide.

Scene 8 (1m 34s)

Logging Use appropriate log levels, include context. Exception Handling Don’t swallow exceptions, use meaningful messages. Use of Constants & Configuration Replace magic numbers Store in properties/env variables. Avoid Deprecated APIs Always prefer supported alternatives Organize Code Effectively.

Scene 9 (1m 52s)

Logging: Use appropriate log levels, include context. Why? Structured, levelled, timestamped records for troubleshooting configurable per environment supports aggregation/monitoring (E.g. ELK Stack).

Scene 10 (2m 7s)

Best Practices for Implementation.

Scene 11 (2m 15s)

Exception Handling: Don’t just throw exceptions, handle them properly..

Scene 12 (2m 29s)

Use of Constants & Configuration This is bad because, Magic Numbers – arbitrary numbers with no meaning ("0.12") scatters configuration across code makes updates error‑prone prevents environment‑specific overrides.

Scene 13 (2m 43s)

A math equation with numbers and symbols AI-generated content may be incorrect..

Scene 14 (3m 4s)

Avoid Deprecated APIs Always prefer supported alternatives.

Scene 15 (3m 23s)

Create Utility/ Helper classes for reusable logic Read this: Java Helper vs. Utility Classes Follow Single Responsibility Principle One class, one responsibility Group related functionality logically in packages/modules. Aim for High Cohesion, Low Coupling Avoid bloated Utilities A code smell – God Class Keep utility classes focused..

Scene 16 (3m 43s)

Requirements evolve (features, scale, compliance) The original design no longer is adequate Problem Domain Understanding improves models, names, and boundaries must be reshaped to match the domain. Software entropy many small clean changes still create coupling and duplication over time. Style ≠ architecture conventions ensure readability, not good architecture. Delivery trade-offs create technical debt (due to code smells) Refactoring is how you address these problems safely..

Scene 17 (4m 7s)

Code smells are indicators of deeper problems not bugs, but warnings. Smells make code harder to maintain and extend. Refactoring removes smells and restores design integrity. Examples: Long Method → Extract Method Large Class → Extract Class Switch Chains → Replace with Polymorphism.

Scene 18 (4m 24s)

Refactoring is “a change made to the internal structure of software to make it easier to understand and cheaper to modify without changing its observable behavior.” – Martin Fowler..

Scene 19 (4m 39s)

Goals Improve design make code easier to understand help find bugs enable faster development Small Steps Principle Incremental changes reduce risk.