精通Node.js设计模式:第二版

需积分: 10 5 下载量 115 浏览量 更新于2024-07-18 收藏 12.69MB PDF 举报
"Node.js Design Patterns - Second Edition" 是一本关于使用Node.js构建模块化、可扩展服务器端web应用的专业指南。这本书详细介绍了如何利用Node.js的新特性来创建可复用的模式和模块,理解其异步单线程设计,并掌握各种功能。适合具备基本JavaScript知识,希望深入学习企业级Node.js应用设计和开发的开发者和软件架构师阅读。 书中内容涵盖设计和实现一系列服务器端JavaScript模式,以便了解在不同场景下何时何地应用这些模式。读者将通过使用回调、Promise、生成器和async/await语法来熟悉异步编程。此外,还会学习如何解决模块间的耦合问题,组织和连接模块,以及运用已知技巧解决常见的设计和编码问题。本书还探讨了Universal JavaScript的最新趋势,教你编写能在Node.js和浏览器上运行的代码,并利用React生态系统实现通用应用。 书中首先介绍了Node.js的基础知识,如其异步单线程架构和主要设计模式,然后深入到异步控制流模式和流组件。接着,详细列出了Node.js实现的常见设计模式,以及一些专属于Node.js世界的设计模式。最后,讲解了高级概念,如Universal JavaScript、可扩展性和架构模式,以及消息传递和集成模式,为构建企业级Node.js应用提供了全面的概念和技术。 本书的风格是全面解释,通过实例让你创建可扩展和高效的实时服务器端应用。章节包括:Node.js平台简介、Node.js核心模式、使用ES2015的异步控制流模式、流编程、设计模式、模块连接、Web应用程序的Universal JavaScript、高级异步解决方案、可扩展性和架构模式、以及消息和集成模式。 这本书对于想要提升Node.js技能,深入理解如何构建高性能、可维护的Node.js应用的开发者来说,是一本宝贵的资源。
2017-11-25 上传
By reading this book, you will learn the following: The "Node way": How to use the right point of view when approaching a Node.js design problem. You will learn, for example, how different traditional design patterns look in Node.js, or how to design modules that do only one thing. A set of patterns to solve common Node.js design and coding problems: You will be presented with a "Swiss army knife" of patterns, ready-to-use in order to efficiently solve your everyday development and design problems. How to write modular and efficient Node.js applications: You will gain an understanding of the basic building blocks and principles of writing large and well-organized Node.js applications and you will be able to apply these principles to novel problems that don't fall within the scope of existing patterns. Throughout the book, you will be presented with several real-life libraries and technologies, such as LevelDb, Redis, RabbitMQ, ZMQ, Express, and many others. They will be used to demonstrate a pattern or technique, and besides making the example more useful, these will also give you great exposure to the Node.js ecosystem and its set of solutions. Whether you use or plan to use Node.js for your work, your side project, or for an open source project, recognizing and using well-known patterns and techniques will allow you to use a common language when sharing your code and design, and on top of that, it will help you get a better understanding of the future of Node.js and how to make your own contributions a part of it. What this book covers Chapter 1, Welcome to the Node.js Platform, serves as an introduction to the world of Node.js application design by showing the patterns at the core of the platform itself. It covers the Node.js ecosystem and its philosophy, a short introduction to Node.js version 6, ES2015, and the reactor pattern. Chapter 2, Node.js Essential Patterns, introduces the first steps towards asynchronous coding and design patterns with Node.js discussing and comparing callbacks and the event emitter (observer pattern). This chapter also introduces the Node.js module system and the related module pattern. Chapter 3, Asynchronous Control Flow Patterns with Callbacks, introduces a set of patterns and techniques for efficiently handling asynchronous control flow in Node.js. This chapter teaches you how to mitigate the "callback hell" problem using plain JavaScript and the async library. Chapter 4, Asynchronous Control Flow Patterns with ES2015 and Beyond, progresses with the exploration of asynchronous control flows introducing Promises, Generators, and Async- Await. Chapter 5, Coding with Streams, dives deep into one of the most important patterns in Node.js: streams. It shows you how to process data with transform streams and how to combine them into different layouts. Chapter 6, Design Patterns, deals with a controversial topic: traditional design patterns in Node.js. It covers the most popular conventional design patterns and shows you how unconventional they might look in Node.js. It also introduces the reader to some emerging design patterns that are specific only to JavaScript and Node.js. Chapter 7, Wiring Modules, analyzes the different solutions for linking the modules of an application together. In this chapter, you will learn design patterns such as Dependency Injection and service locator. Chapter 8, Universal JavaScript for Web Applications, explores one of the most interesting capabilities of modern JavaScript web applications: being able to share application code between the frontend and the backend. Across this chapter we learn the basic principles of Universal JavaScript by building a simple web application with React, Webpack, and Babel. Chapter 9, Advanced Asynchronous Recipes, takes a problem-solution approach to show you how some common coding and design challenges can be solved with ready-to-use solutions. Chapter 10, Scalability and Architectural Patterns, teaches you the basic techniques and patterns for scaling a Node.js application. Chapter 11, Messaging and Integration Patterns, presents the most important messaging patterns, teaching you how to build and integrate complex distributed systems using ZMQ and AMQP.