𝔖 Scriptorium
✦   LIBER   ✦

πŸ“

TypeScript 4 Design Patterns and Best Practices: Discover effective techniques and design patterns for every programming task

✍ Scribed by Theo Despoudis


Publisher
Packt Publishing
Year
2021
Tongue
English
Leaves
350
Category
Library

⬇  Acquire This Volume

No coin nor oath required. For personal study only.

✦ Synopsis


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

  1. Getting Started With Typescript 4
  2. Typescript Principles and Use Cases
  3. Creational Design Patterns
  4. Structural Design Patterns
  5. Behavioral Design Patterns
  6. Functional Programming Design Concepts
  7. Reactive Design Patterns
  8. Developing Robust and Modern Typescript Applications
  9. Anti Patterns and Workarounds

✦ Table of Contents


Cover
Title Page
Copyright and Credits
Dedication
Contributors
Table of Contents
Preface
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
About PACKT
Other Books You May Enjoy
Index


πŸ“œ SIMILAR VOLUMES


TypeScript 4 Design Patterns and Best Pr
✍ Theo Despoudis πŸ“‚ Library πŸ“… 2021 πŸ› Packt Publishing 🌐 English

<p><b>A detailed and easy-to-follow guide to learning design patterns and modern best practices for improving your TypeScript development skills</b></p><h4>Key Features</h4><ul><li>Understand, analyze, and develop classical design patterns in TypeScript</li><li>Explore advanced design patterns taken

TypeScript 4 Design Patterns and Best Pr
✍ Theo Despoudis πŸ“‚ Library πŸ› Packt Publishing 🌐 English

<p><span>A detailed and easy-to-follow guide to help you improve your TypeScript development skills and enable you to solve application design problems using modern practices</span></p><h4><span>Key Features</span></h4><ul><li><span><span>Identify common gotchas and antipatterns when developing Type

Scala Design Patterns: Patterns for Prac
✍ John Hunt πŸ“‚ Library πŸ“… 2013 πŸ› Springer 🌐 English

<p>Scala is a new and exciting programming language that is a hybrid between object oriented languages such as Java and functional languages such as Haskell. As such it has its own programming idioms and development styles.</p><p><i>Scala Design Patterns</i> looks at how code reuse can be successful

Scala Design Patterns: Patterns for Prac
✍ John Hunt (auth.) πŸ“‚ Library πŸ“… 2013 πŸ› Springer International Publishing 🌐 English

<p><p>Scala is a new and exciting programming language that is a hybrid between object oriented languages such as Java and functional languages such as Haskell. As such it has its own programming idioms and development styles.</p><p><i>Scala Design Patterns</i> looks at how code reuse can be success

Scala Design Patterns Patterns for Pract
✍ John Hunt πŸ“‚ Library πŸ“… 2013 πŸ› Springer 🌐 English

Scala is a new and exciting programming language that is a hybrid between object oriented languages such as Java and functional languages such as Haskell. As such it has its own programming idioms and development styles.<br><br>Scala Design Patterns looks at how code reuse can be successfully achiev