西维蜀黍

【Java】macOS下编译JDK8

安装mercurial

brew install mercurial

  ...


【Node.js】Node.js 应用性能监测与分析

监控指标(Metrics to watch)

Tick频率(Tick frequency) - number of ticks per time

Tick周期(Tick Duration) - the time one tick takes

Active Handles and Requests

Garbbage Collection activity

  ...


【Node.js】Node.js中的单线程模型与多线程/进程

JavaScript语言的一大特点就是单线程,也就是说,同一个时间只能做一件事。

那么,为什么JavaScript不能有多个线程呢?这样能提高效率啊。

  ...


【Architectural Pattern】MVVM 与数据绑定

概念

**MVVM (Model - View - ViewModel)**最早由微软提出,它在MVC的基础之上,增加了数据绑定机制。

  ...


【Design Pattern】Structural - Template Method

1 动机

2 定义

在阎宏博士的《Java与模式》一书中开头是这样描述模板方法(Template Method)模式的:

模板方法模式是类的行为模式。准备一个抽象类,将部分逻辑以具体方法以及具体构造函数的形式实现,然后声明一些抽象方法来迫使子类实现剩余的逻辑。不同的子类可以以不同的方式实现这些抽象方法,从而对剩余的逻辑有不同的实现。这就是模板方法模式的用意。

  ...


【Design Pattern】Strctural - Composite

动机

  • 希望表达具有层次结构(部分-整体,part-whole)的实体
  • 对调用者来说,叶子元素和复合元素都是一样的
  ...


【Design Pattern】Structural - Adapter

Adapter Pattern

  • The adapter design pattern solves problems like:

    • How can a class be reused that does not have an interface that a client requires?
    • How can classes that have incompatible interfaces work together?
    • How can an alternative interface be provided for a class?

    Often an (already existing) class can’t be reused only because its interface doesn’t conform to the interface clients require.

  ...


【Design Pattern】Structural - Flyweight/ Object Pool

1 动机

通过尽可能共享对象中的数据来实现对内存的最小化使用,这就是享元模式的动机。

一个典型的例子是:在Word中,对字符的图形化展现。如果每一个显示的字符都对应一个独立的对象,这将会消耗大量的内存。取而代之,位于文档中不同位置的相同字符会共享大部分属性,而只有字符位置这样的属性才需要被单独保存。

  ...


【Design Pattern】Behavioural - Observer

1 定义

观察者模式(Observer Pattern)定义了一种一对多的依赖对象关系,使得当那一个对象状态发生改变时,依赖它的多个对象均能得到通知并自动更新(做出相应反应)。

  ...


【Design Pattern】Behavioural - Chain of Responsibility Pattern

Intent

Chain of Responsibility is a behavioral design pattern that lets you pass requests along a chain of handlers. Upon receiving a request, each handler decides either to process the request or to pass it to the next handler in the chain.

  ...