【读书笔记】《Node.js Design Patterns》前言

##前言

前言内容不多,开篇总述了一下。作者把Node.js比喻成“游戏的改变者”(game-changer),改变了进十年来的web开发模式。这话说的有点儿大,更像是为了吸引读者看下去。我觉得Node.js的出现的确改变了很多东西,让开发变得更有趣,让javascript有了更多的想象空间,不过距离改变世界,应该还有很多路要走,不如说Node.js给我们带来了一个方向,这个方向就是作者在下面阐述的三点:

###第一、javascript的革命

Node.js让javascript向后端迈进,而且这一步迈的还比较成功,面向对象和函数式的混合编程在后端表现不赖,还带来了很多新鲜点,这里提到了两点:单语言应用和前后端共享代码。

在Node.js出现之前,一个程序员想凭借一种语言前后通吃是不行的,即便是王者般的java亦或者宗师般的C++,这就给一个更偏向于做应用的程序员很大的负担,而Node.js的出现,给了大家实现了这个幻想,者也是我最初决定投身这个领域的一个源动力。要知道有些程序员脑子里有极客思维,喜欢单打独斗,如果可以利用更少的工作量创造出更强大的东西,这些人会很高兴。凭借着javascript的大量程序员基础,这些人很快的接受js在后端的应用。当然,js的一些独有特点可以被叫做优点,在某些时候,也会变成缺点。说的哲学一点,我们不会造出来万能的东西,Node.js更不是。

###第二、单线程与异步结构

作者讲到,这两个特点带来了性能与可扩展性的同时,还带来了对并发和并行开发方法的改变。队列代替了互斥锁,回调和事件代替了多线程,因果关系(causality)代替了同步。

对于js的这种异步模式,褒贬不一,一些人觉得这带来了性能的提高,一些人觉得代码难以控制,是啊,世间安得双全法,所以这些东西还要慢慢的探究才能有答案,或者是更好的解决方法。

###第三、npm

这点作者和我想到一块儿去了,npm也是我爱上Node.js的很重要的一个原因,他也将这个东西认为是最重要的一个方面。npm,一个包管理器,他拥有着庞大而快速增长的模块库。它的文化是简洁、实用、极端模块化,事实也是这样的。

我想每一个用过npm的人都会爱上它,它给我带来了一种小时候拼积木的感觉。它的项目目录组织方式很有调理,让你感觉项目就是项目,不存在秘密,是里面有很多小模块的项目,而这些小模块都很有条理的在那里,也许模块里还有模块,不过还是很有调理的在它改在的位置。还有package.json这个文件的出现,是一份很明确的说明书,即使你拿到的是别人的项目,看着这份说明书,也能组装起来。

###关于作者

image

上面那位就是作者,叫做Mario Casciaro,以前在IBM,现在在一家叫做d4h的公司(我也没去深究这个公司是干啥的~)

他的github: https://github.com/mariocasciaro (他最著名的项目叫做scatter,没研究过) 他的twitter: https://twitter.com/mariocasciaro 他的主页:http://www.mariocasciaro.me/ (主页里没啥东西)s

转载于:https://my.oschina.net/mayepythoner/blog/378627

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
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.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值