JavaScript Design Patterns / Шаблоны разработки на JavaScript Год издания: 2024 Автор: Francesco Hugo Di / Франческо Хьюго Ди Издательство: Packt Publishing ISBN: 978-1-80461-227-9 Язык: Английский Формат: PDF, EPUB Качество: Издательский макет или текст (eBook) Интерактивное оглавление: Да Количество страниц: 308 Описание: Step into the world of design patterns through modern JavaScript paradigms to supercharge your applications on the web and beyond Key Features Explore various JavaScript design patterns, delving deep into their intricacies, benefits, and best practices Understand the decision-making process guiding the selection of specific design patterns Build a solid foundation to learn advanced topics in JavaScript and web performance Unlock the potential of JavaScript design patterns, the foundation for development teams seeking structured and reusable solutions to common software development challenges in this guide to improving code maintainability, scalability, and performance. Discover how these patterns equip businesses with cleaner and more maintainable code, promote team collaboration, reduce errors, and save time and costs. This book provides a comprehensive view of design patterns in modern (ES6+) JavaScript with real-world examples of their deployment in professional settings. You’ll start by learning how to use creational, structural, and behavioral design patterns in idiomatic JavaScript, and then shift focus to the architecture and UI patterns. Here, you’ll learn how to apply patterns for libraries such as React and extend them further to general web frontend and micro frontend approaches. The last section of the book introduces and illustrates sets of performance and security patterns, including messaging and events, asset and JavaScript loading strategies, and asynchronous programming performance patterns. Throughout the book, examples featuring React and Next.js, in addition to JavaScript and Web API examples, will help you choose and implement proven design patterns across diverse web ecosystems, transforming the way you approach development. What you will learn Find out how patterns are classified into creational, structural, and behavioral Implement the right set of patterns for different business scenarios Explore diverse frontend architectures and different rendering approaches Identify and address common asynchronous programming performance pitfalls Leverage event-driven programming in the browser to deliver fast and secure applications Boost application performance using asset loading strategies and offloading JavaScript execution Окунитесь в мир шаблонов проектирования с помощью современных парадигм JavaScript, чтобы повысить эффективность ваших приложений в Интернете и за его пределами Ключевые функции Изучите различные шаблоны проектирования JavaScript, вникая в их тонкости, преимущества и рекомендации по использованию Поймите процесс принятия решений, определяющий выбор конкретных шаблонов проектирования Создайте прочную основу для изучения продвинутых тем в области JavaScript и веб-производительности Раскройте потенциал шаблонов проектирования JavaScript, которые являются основой для команд разработчиков, ищущих структурированные и многократно используемые решения распространенных проблем разработки программного обеспечения, в этом руководстве по повышению удобства сопровождения, масштабируемости и производительности кода. Узнайте, как эти шаблоны обеспечивают компании более чистым и удобным в обслуживании кодом, способствуют совместной работе в команде, уменьшают количество ошибок и экономят время и затраты. Эта книга дает исчерпывающее представление о шаблонах проектирования в современном (ES6+) JavaScript с реальными примерами их применения в профессиональных условиях. Вы начнете с изучения того, как использовать креативные, структурные и поведенческие шаблоны проектирования в идиоматическом JavaScript, а затем переключите внимание на архитектуру и шаблоны пользовательского интерфейса. Здесь вы узнаете, как применять шаблоны для таких библиотек, как React, и расширять их до общих подходов к веб-интерфейсу и микро-интерфейсу. В последнем разделе книги представлены и проиллюстрированы наборы шаблонов производительности и безопасности, включая обмен сообщениями и событиями, стратегии загрузки ресурсов и JavaScript, а также шаблоны производительности асинхронного программирования. На протяжении всей книги приводятся примеры с использованием React и Next.js в дополнение к примерам JavaScript и Web API, которые помогут вам выбрать и внедрить проверенные шаблоны проектирования в различных веб-экосистемах, изменяя ваш подход к разработке. Что вы узнаете Узнайте, как шаблоны подразделяются на креативные, структурные и поведенческие. Внедрите правильный набор шаблонов для различных бизнес-сценариев Изучите различные архитектуры интерфейса и различные подходы к рендерингу Выявите и устраните распространенные проблемы с производительностью асинхронного программирования Используйте событийно-ориентированное программирование в браузере для создания быстрых и безопасных приложений Повысьте производительность приложений, используя стратегии загрузки ресурсов и разгрузки выполнения JavaScript.
Примеры страниц (скриншоты)
Оглавление
Preface xiii Part 1: Design Patterns 1 Working with Creational Design Patterns 3 What are creational design patterns? 4 Implementing the prototype pattern in JavaScript 4 Implementation 4 A use case 7 The singleton pattern with eager and lazy initialization in JavaScript 11 Implementation 11 Use cases 15 Improvements with the “class singleton” pattern 16 A singleton without class fields using ES module behavior 18 The factory pattern in JavaScript 20 Implementation 20 Use cases 22 Improvements with modern JavaScript 22 Summary 24 2 Implementing Structural Design Patterns 25 Technical requirements 25 What are structural design patterns? 26 Implementing the Proxy pattern with Proxy and Reflect 26 A redaction proxy implementation 26 Use cases 27 Improving the proxy pattern in JavaScript with the Proxy and Reflect global objects 28 Decorator in JavaScript 33 Implementation 34 Use cases 35 Improvements/limitations 35 Flyweight in JavaScript 37 Implementation 37 Use cases 41 Improvements/limitations 41 Adapter in JavaScript 44 Use cases 48 Improvements/limitations 49 Summary 52 3 Leveraging Behavioral Design Patterns 53 Technical requirements 53 What are behavioral design patterns? 54 The observer pattern in JavaScript 54 Implementation 54 Use cases of the observer pattern 58 Limitations and improvements 58 State and strategy in JavaScript and a simplified approach 61 Implementation 61 Use cases of the state and strategy patterns 69 Limitations and improvements 69 Visitor in JavaScript 75 Implementation 76 Use cases of the visitor pattern 78 Summary 79 Part 2: Architecture and UI Patterns 4 Exploring Reactive View Library Patterns 83 Technical requirements 83 What are reactive view library patterns? 84 The render prop pattern 84 Use cases 85 Implementation/example 89 Limitations 95 The higher-order component pattern 96 Implementation/example 96 Use cases 97 Limitations 97 The hooks pattern 98 An implementation/example 99 Use cases 103 Limitations 103 The provider pattern 103 Use case – the prop drilling problem 103 An implementation/example 104 Limitations 109 Summary 110 5 Rendering Strategies and Page Hydration 111 Technical requirements 111 Client and server rendering with React 112 Client-side rendering in React 113 Server rendering in React 114 Trade-offs between client and server rendering 117 Static rendering with Next.js 118 Automatic static generation 119 Static generation with a third-party data source 121 Static generation with dynamic paths 125 Page hydration strategies 132 Common React rehydration issues 137 React streaming server-side rendering 140 Summary 144 6 Micro Frontends, Zones, and Islands Architectures 145 Technical requirements 145 An overview of micro frontends 146 Key benefits 146 “Classic” micro frontend patterns 147 Other concerns in a micro frontend world 149 Composing applications with Next.js “zones” 150 Root app 151 Adding a /search app 154 Adding /checkout app 157 The benefits/supporting team scaling 162 The drawbacks of Next.js zones 163 Scaling performance-sensitive pages with the “islands” architecture 163 Islands setup with is-land 164 Product island 165 Cart island 168 A related products island 172 Scaling with a team – bundling islands 179 Drawbacks 179 Summary 180 Part 3: Performance and Security Patterns 7 Asynchronous Programming Performance Patterns 183 Technical requirements 183 Controlling sequential asynchronous operations with async/await and Promises 183 Parallel asynchronous operation patterns 189 Asynchronous cancellation and timeouts with AbortController 196 Throttling, debouncing, and batching asynchronous operations 200 Summary 207 8 Event-Driven Programming Patterns 209 Technical requirements 209 Optimizing event listeners through event delegation 210 Patterns for secure frame/native WebView bridge messaging 218 Event listener performance antipatterns 231 Summary 232 9 Maximizing Performance – Lazy Loading and Code Splitting 233 Technical requirements 233 Dynamic imports and code splitting with Vite 233 Route-based code splitting and bundling 237 Loading JavaScript on element visibility and interaction 241 Summary 259 10 Asset Loading Strategies and Executing Code off the Main Thread 261 Technical requirements 261 Asset loading optimization – async, defer, preconnect, preload, and prefetch 262 Using Next.js Script’s strategy option to optimize asset loading 270 Loading and running scripts in a worker thread 272 Summary 276 Index 279 Other Books You May Enjoy 284
Francesco Hugo Di / Франческо Хьюго Ди - JavaScript Design Patterns / Шаблоны разработки на JavaScript [2024, PDF, EPUB, ENG] download torrent for free and without registration
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum