软件设计的的一些原则

一、 基本原则

封装变化Encapsulate what varies.

面向接口变成而不是实现 Code to an interface rather than to an implementation.

优先使用组合而非继承 Favor Composition Over Inheritance

二、SRP: The single responsibility principle 单一职责

阅读更多

AS3 依赖注入


一、 AS3 注入基本知识

对于一个写Java的来说注入这个概念再熟悉不过了。Java Spring框架IOC机制被一个蛋疼的东西简单粗暴的借鉴到了actionscript中,这就是Robotlegs。所以就有了形如下面的应用:

1
2
3
4
5
6
//someplace in your application where mapping/configuration occurs
var myClassInstance:MyClass = new MyClass();
injector.mapValue(MyClass, myClassInstance);
//in the class to receive injections
[Inject]
public var myClassInstance:MyClass
阅读更多