
TypeScript 4 Design Patterns and Best Practices: Discover effective techniques and design patterns for every programming task
- Length: 350 pages
- Edition: 1
- Language: English
- Publisher: Packt Publishing
- Publication Date: 2021-09-15
- ISBN-10: 1800563426
- ISBN-13: 9781800563421
- Sales Rank: #148140 (See Top 100 Books)
A detailed and easy-to-follow guide to learning design patterns and modern best practices for improving your TypeScript development skills
Key Features
- Understand, analyze, and develop classical design patterns in TypeScript
- Explore advanced design patterns taken from functional programming and reactive programming
- Discover useful techniques and gotchas when developing large-scale TypeScript applications
Book Description
TypeScript is a superset language on top of JavaScript that introduces type safety and enhanced developer tooling. TypeScript 4 Design Patterns and Best Practices will assist with understanding design patterns and learning best practices for producing scalable TypeScript applications. It will also serve as handy documentation for future maintainers.
This book takes a hands-on approach to helping you get up and running with the implementation of TypeScript design patterns and associated methodologies for writing testable code. You’ll start by exploring the practical aspects of TypeScript 4 and its new features. The book will then take you through traditional gang of four (GOF) design patterns, such as behavioral, creational, and structural in their classic and alternative forms, and show you how you can use them in real-world development projects. Once you’ve got to grips with traditional design patterns, you’ll advance to learning about their functional programming and reactive programming counterparts and how they can be coupled to deliver better and more idiomatic TypeScript code.
By the end of this TypeScript book, you’ll be able to efficiently recognize when and how to use the right design patterns in any practical use case and gain the confidence to work on scalable and maintainable TypeScript projects of any size.
What you will learn
- Understand the role of design patterns and their significance
- Explore all significant design patterns within the context of TypeScript
- Find out how design patterns differ from design concepts
- Understand how to put the principles of design patterns into practice
- Discover additional patterns that stem from functional and reactive programming
- Recognize common gotchas and antipatterns when developing TypeScript applications and understand how to avoid them
Who this book is for
If you’re a developer looking to learn how to apply established design patterns to solve common programming problems instead of reinventing solutions, you’ll find this book useful. You’re not expected to have prior knowledge of design patterns. Basic TypeScript knowledge is all you need to get started with this book.
Table of Contents
- Getting Started With Typescript 4
- Typescript Principles and Use Cases
- Creational Design Patterns
- Structural Design Patterns
- Behavioral Design Patterns
- Functional Programming Design Concepts
- Reactive Design Patterns
- Developing Robust and Modern Typescript Applications
- Anti Patterns and Workarounds
TypeScript 4 Design Patterns and Best Practices Contributors About the author About the reviewer Preface Who this book is for What this book covers To get the most out of this book Download the example code files Download the color images Conventions used Get in touch Share your thoughts Section 1: Getting Started with TypeScript 4 Chapter 1: Getting Started with Typescript 4 Technical requirements Introducing TypeScript 4 Working with input and output Useful TypeScript 4 features Understanding TypeScript and JavaScript's relationship How does JavaScript compare to TypeScript? Transitioning from JavaScript to TypeScript Design patterns in JavaScript Installing and using the code examples Reviewing the libraries included in the code examples Understanding the tsconfig.json file Running the unit tests Using VSCode with TypeScript Using VSCode for this book's code Inspecting types Refactoring with VSCode Introducing Unified Modeling Language (UML) What is UML? Learning UML class diagrams Summary Q & A Further reading Chapter 2: TypeScript Core Principles Technical requirements Working with advanced types Using utility types Using advanced types and assertions OOP with TypeScript Abstraction Inheritance Encapsulation Polymorphism Developing in the browser Understanding the DOM Using TypeScript with webpack Using React Developing in the server Understanding the server environment Using Express with TypeScript Introducing design patterns in TypeScript Why design patterns exist Design patterns in TypeScript Summary Q&A Further reading Section 2: Core Design Patterns and Concepts Chapter 3: Creational Design Patterns Technical requirements Creational design patterns Singleton pattern When do we use the Singleton? UML class diagram Classic implementation Modern implementations Variants Testing Criticisms of the singleton Real-world examples Prototype pattern When do we use the Prototype pattern? UML class diagram Classic implementation Testing Criticisms of the Prototype pattern Real-world examples Builder pattern When do we use Builder? UML class diagram for Builder Classic implementation Testing Modern implementations Criticisms of Builder Real-world examples Factory method pattern When do we use the Factory method? UML class diagram Classic implementation Alternative implementations Testing Real-world examples Abstract Factory pattern When do we use the Abstract Factory? UML class diagram Classic implementation Testing Criticisms of Abstract Factory Real-world example Summary Q&A Further reading Chapter 4: Structural Design Patterns Technical requirements Understanding structural design patterns Adapter pattern When to use Adapter UML class diagram Classic implementation Testing Criticisms of Adapter Real-world use cases Decorator pattern When to use Decorator UML class diagram Classic implementation Modern variants Testing Criticisms of Decorator Real-world use cases Façade pattern When to use Façade UML class diagram Classic implementation Testing Criticisms of Façade Real-world use cases Composite pattern When to use Composite UML class diagram Classic implementation Testing Criticisms of Composite Real-world use cases Proxy pattern When to use Proxy UML class diagram Classic implementation Modern variant Testing Criticisms of Proxy Real-world use cases Bridge pattern When to use Bridge UML class diagram Classic implementation Testing Criticisms of Bridge Real-world use cases Flyweight pattern When to use Flyweight UML class diagram Classic implementation Testing Criticisms of Flyweight Real-world use cases Summary Q&A Further reading Chapter 5: Behavioral Design Patterns Technical requirements Behavioral design patterns The Strategy pattern? When to use the Strategy pattern UML class diagram Classic implementation Testing Criticism of this pattern Real-world use cases Chain of Responsibility When to use Chain of Responsibility? UML class diagram Classic implementation Testing Criticisms of this pattern Real-world use case The Command pattern When to use the Command pattern? UML class diagram Classic implementation Testing Criticism of this pattern Real-world use case The Iterator pattern When to use the Iterator pattern? UML class diagram Classic implementation Testing Criticism of this pattern Real-world use case The Mediator pattern When to use the Meditator pattern? UML class diagram Classic implementation Testing Criticisms of this pattern Real-world use cases The Observer pattern When to use the Observer pattern? UML class diagram Classic implementation Testing Criticisms of this pattern Real-world use case The Memento pattern When to use the Memento pattern? UML class diagram Classic implementation Testing Criticisms of this pattern Real-world use case The State pattern When to use the State pattern? UML class diagram Classic implementation Testing Criticisms of this pattern Real-world use case The Template method pattern When to use the Template method pattern? UML class diagram Classic implementation Testing Criticism of this pattern Real-world use case The Visitor pattern When to use the Visitor pattern? UML class diagram Classic implementation Testing Criticisms of this pattern Real-world use case Summary Q&A Further reading Section 3: Advanced Concepts and Best Practices Chapter 6: Functional Programming with TypeScript Technical requirements Learning key concepts in functional programming Pure functions Recursion Functions as first-class citizens Function composition Referential transparency Immutability Understanding functional lenses Implementation of lenses Use cases of lenses Understanding transducers Understanding monads Summary Q & A Further reading Chapter 7: Reactive Programming with TypeScript Technical requirements Learning Reactive programming concepts The asynchronous propagation of changes The pull pattern The push pattern The push-pull pattern Understanding Promises and Futures Futures Learning observables Getting started with ReactiveX observables Composable operators Cold versus hot observables Summary Q & A Further reading Chapter 8: Developing Modern and Robust TypeScript Applications Technical requirements Combining patterns Singleton Iterator Command Using utility types Using domain-driven design Understanding entities Understanding value objects Understanding domain events Applying the SOLID principles Understanding the single-responsibility principle Understanding the open-closed principle Understanding the Liskov substitution principle Understanding the interface segregation principle Understanding the dependency inversion principle Is using SOLID a best practice? Summary Q&A Further reading Chapter 9: Anti-Patterns and Workarounds Technical requirements Class overuse Not using runtime assertions Permissive or incorrect types Using idiomatic code from other languages From the Java language From the Go language Type inference gotchas Summary Q & A Further reading Why subscribe? Other Books You May Enjoy Packt is searching for authors like you Share your thoughts
How to download source code?
1. Go to: https://github.com/PacktPublishing
2. In the Find a repository… box, search the book title: TypeScript 4 Design Patterns and Best Practices: Discover effective techniques and design patterns for every programming task
, sometime you may not get the results, please search the main title.
3. Click the book title in the search results.
3. Click Code to download.
1. Disable the AdBlock plugin. Otherwise, you may not get any links.
2. Solve the CAPTCHA.
3. Click download link.
4. Lead to download server to download.