TypeScript Power-Up: Refactoring and Testing Unleashed in Interactive Workshop
Jorge and Carlos recently led an interactive workshop, “Refactoring and Testing: A TypeScript Deep Dive,” designed to empower developers with practical techniques for improving code quality. The session, emphasizing a playful, hands-on approach, guided participants through identifying and resolving common code smells in TypeScript applications. Attendees actively contributed to discussions, pointing out issues like primitive obsession, tight coupling from hardcoded literals, absent dependency injection, and inappropriate exception handling for domain validation. The presenters highlighted TypeScript’s capabilities for automatic refactoring as a key enabler for these improvements.
The core of the workshop involved a live refactoring demonstration, beginning with a problematic Email Domain Validator and Create Profile Service. The primary focus was on addressing primitive obsession by introducing a robust Email Value Object, encapsulating validation logic and ensuring type safety. Using IDE-assisted refactoring tools, Jorge showcased how to iteratively introduce new parameters, inline variables, and restructure code while maintaining functionality. This practical example underscored the importance of strong naming conventions and the benefits of applying SOLID principles, ultimately leading to more testable, maintainable, and expressive codebases that avoid defensive programming pitfalls and enhance error visibility.