软件构造
梦回礼拜天
这个作者很懒,什么都没留下…
展开
-
monitor模式
设计模式monitor模式monitor模式监视器是一个方法相互排斥的类,因此一次只能有一个线程位于类的实例中.即用ADT自己做lock实现方法: 在所有方法内加上synchronized(this)或者synchronized形如public class XX { private String text; public XX() { text = ""; } ...原创 2019-06-05 13:28:12 · 2636 阅读 · 0 评论 -
Data Type and Type Checking
Abstract Data Type -ADT- and ObjectOriented Programming -OOP-Data Type and Type CheckingJava中的数据类型静态/动态类型检查可变/不变的数据类型可变数据类型的危险性 理解别名使用不变数据类型的优越性 Use immutability to improve correctness, clarity and ch...原创 2019-06-12 15:07:04 · 381 阅读 · 0 评论 -
Designing Specification
Abstract Data Type -ADT- and ObjectOriented Programming -OOP-Designing SpecificationSpecification内容spec中不应出现什么Failing fast写出规约的原因行为等价性优点Designing Specification一个完整的方法包括两个方面方法的规约spec方法的实现体implemen...原创 2019-06-12 17:09:33 · 289 阅读 · 0 评论 -
ADT的四种操作
Classifying the operations of an abstract typeCreators构造器t* -> TProducers生产器T+, t* -> TObservers观察器T+, t* -> tMutators变值器T+, t* -> void | t | T四种方法的区别具体类型分析intStringList (extends Collecti...原创 2019-06-16 00:48:40 · 1012 阅读 · 0 评论 -
如何设计ADT
Designing an Abstract Type——Rules of thumb设计简洁、一致的操作要足以支持client对数据所做的所有操作需要,且用操作满足client需要的难度要低要么抽象、要么具体,不要混合 --- 要么针对抽象设计,要么针对具体应用的设计设计简洁、一致的操作简洁:操作要少而简单,不要多而复杂一致:不应该在List中增加sum操作,如果客户端使用的是List, 会...原创 2019-06-16 20:37:28 · 862 阅读 · 0 评论 -
Java内存管理和垃圾回收
Java内存管理性能指标内存管理三种基本模式Static 静态Stack-based mode 动态,基于栈Heap-based mode(free mode) 动态,基于堆Java内存管理模型Java Virtual Machine (JVM)内存结构垃圾回收可达和不可达对象GC的成本指标四种算法Reference counting 引用计数Mark-Sweep 标记-清除Mark-Compac...原创 2019-06-24 20:20:44 · 590 阅读 · 0 评论 -
面向性能优化的代码调优
面向性能优化的代码调优Common Sources of Inefficiency设计模式Singleton Pattern 单例模式Flyweight Pattern 轻量模式Prototype Pattern 原型模式代码调优不是为了修复bug,而是对正确的代码进行修改以提高其性能(时间空间复杂度)。通常是小规模的变化。Common Sources of InefficiencyO...原创 2019-06-24 21:52:19 · 598 阅读 · 0 评论 -
Exception的类别
Exception的类别Declare exceptions in a specificationDeclare exceptions in a specification“异常”也是方法和client端之间spec的一部分,在post-condition中刻画原创 2019-06-24 23:59:35 · 423 阅读 · 0 评论 -
The Liskov Substitution Principle
liscov替换原则(The Liskov Substitution Principle)子类型必须能够替换其基类型派生类必须能够通过其基类型的接口使用,客户端无需了解二者之间的差异转载 2019-06-25 00:42:45 · 294 阅读 · 0 评论