随笔分类 - 04 Design&Pattern
摘要:对于软件架构这一概念,有太多的版本,目前在业界由大师级人物或组织提出的对这一概念的阐述就超过十种以上,我个人比较赞同RUP(Rational Unified Process)中对软件架构的定义,即软件架构包含了关于以下问题的重要决策: 软件系统的组织; 选择组成系统的结构元素和它们之间的接口,以及当这些元素相互协作时所体现的行为; 如何组合这些元素,使它们逐渐合成为更大的子系统; 用于指导这个系统组织的架构风格:这些元素以及它们的接口,协作和组合。
阅读全文
摘要:The singleton pattern is one of the best-known patterns in software engineering. Essentially, a singleton is a class which only allows a single instance of itself to be created, and usually gives simple access to that instance. Most commonly, singletons don't allow any parameters to be specified when creating the instance - as otherwise a second request for an instance but with a different parameter could be problematic! (If the same instance should be accessed for all requests with the same par
阅读全文
摘要:在设计模式中,有一种叫Singleton模式的,用它可以实现一次只运行一个实例。就是说在程序运行期间,某个类只能有一个实例在运行。这种模式用途比较广泛,会经常用到,下面是Singleton模式的两种实现方法: 1、饿汉式 public class EagerSingleton { private static readonly EagerSingleton instance = new EagerSingleton(); private EagerSingleton(){} public static EagerSingleton GetInstance() { return instance; } } 2、懒汉式 publ
阅读全文