Software Design

- Design Principles

  • Open-close, open for extension, close for modification
  • Liskov substitution, any subclass can be in the place where base class is
  • Demeter, least known principle
  • interface segregation, prefer small interface than big one
  • dependency reversion, depends on interface, not implementation
  • composite over inheritance

- Design Patterns

=======================Creation=============================

  • Factory Method
  1. simple factory method, create different implementations of one interface in one method
  2. multiple factory methods, each implementation has one method
  3. static factory methods, no need to create factory instance. methods are static.
  • Abstract Factory, 
  1. to fix problem of Factory Method: need to change the Factory class when want to add more implementations.
  2. add one more layer for Factories, Abstract Factory. 
  3. when want to add more impls, just create concrete factory of Abstract Factory and the concrete factory creates product. no modification to other factories.
  • Single Instance
  1. the double-check way to get single instance has potential issue of uninitialized instance due to non-order between instance initialization and set reference to variable. The typical issue is, one thread gets lock and a = new A(). JVM could assign memory to the instance and set reference to a. then do instance initialization. In between, other threads could see the a without being initialized yet.
  2. Notes: 

private constructor, 

private Object readResolve() {return _instance;} to prevent deserialization


  • Builder, different from Factory Method that builder creates complex object is composed of many parts which are created one by one in builder itself
  • Prototype, Cloneable, private Object clone() throws CloneNotSupportedException

=========================Structure==================================

  • Adapter
  1. class adapter,  Ad extends Source implements Targetable
  2. object adapter, Wrapper(source obj) implements Targetable
  3. interface adapter, Ad1 extends AbstractSource, which implements target interface; Ad2 extends AbstractSource
  • Decorator, Dc(source obj) implements Targetable, source implements the same interface Targetable
  • Proxy, ClassLoader, Interfaces and InvocationHandler
  • Facade, 
  • Bridge, JDBC DriverManager and JDBC Driver (mysql driver, oracle driver)
  • Composite, part and whole
  • Flyweight

==========================Behavior====================================

  • Strategy, a series of algorithms implement same interface.
  • Template Method
  • Observer, listener
  • Iterator
  • Chain of Responsibility, Servlet Filter
  • Command, invoker, command and receiver
  • Memento, original, memento and storage
  • State, operation gets changed when state changes
  • Visitor, decouple data structure and data algorithm
  • Mediator, least known principle
  • Interpreter

- Miscs

  • aggregation/composition, composition has stranger relation than aggregation. parts alone are meaningless in composition
  • dependency/relation, dependency is reflected as method params, static invocation in Java. relation is reflected as fields of class in Java.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
非常好的一个设计文档,可以作为模板 TABLE OF CONTENTS 1 INTRODUCTION ............................................................................................................................................................... 10 2 APPLICABLE AND REFERENCE DOCUMENTS .............................................................................................................. 11 3 TERMS, DEFINITION AND ABBREVIATIONS TERMS ....................................................................................................... 13 4 SOFTWARE DESIGN OVERVIEW .................................................................................................................................... 15 4.1 Software static architecture ................................................................................................................................. 15 4.1.1 Components Overview .............................................................................................................................. 15 4.1.2 Relationship with other systems ................................................................................................................ 16 4.1.3 Information Model Overview .................................................................................................................... 17 4.1.3.1 Order Options Model .................................................................................................................. 17 4.1.3.2 Order Model ................................................................................................................................. 19 4.1.3.3 User Profile Overview ................................................................................................................... 21 4.2 Software dynamic architecture .......................................................................................................................... 21 4.3 Interfaces Context ................................................................................................................................................. 22 4.3.1 OPGW vs. HMA Client (Input Interfaces) ................................................................................................ 24 4.3.1.1 HMA Ordering::GetCapabilities [Discrete flow] ..................................................................... 24 4.3.1.2 HMA Ordering::GetOptions [Discrete flow] ............................................................................. 25 4.3.1.3 HMA Ordering::Submit [Discrete flow]...................................................................................... 25 4.3.1.4 HMA Ordering::GetStatus [Discrete flow] ................................................................................ 25 4.3.1.5 HMA Ordering::Cancel [Discrete flow] .................................................................................... 26 4.3.1.6 HMA Ordering::GetQuotation [Discrete flow] ........................................................................ 26 4.3.1.7 HMA Ordering::DescribeResultAccess [Discrete flow] .......................................................... 26 4.3.1.8 key exchange [Control flow] ..................................................................................................... 27 4.3.2 OPGW vs. HMA Client (Output Interfaces)............................................................................................. 27 4.3.2.1 HMA Ordering::SubmitResponse [Discrete flow] .................................................................... 27 4.3.2.2 HMA Ordering::CancelResponse [Discrete flow] ................................................................... 28 4.3.2.3 HMA Ordering::GetQuotationResponse [Discrete flow] ....................................................... 28 4.3.3 OPGW vs. EOLI XML Catalogue (Input Interfaces) ............................................................................... 28 4.3.4 OPGW vs. EOLI XML Catalogue (Output Interfaces) ............................................................................ 28 4.3.4.1 EOLI XML Catalogue::processPresentationRequest [Discrete flow] ................................... 28 4.3.5 OPGW vs. EOLI XML Order Server (Input Interfaces)............................................................................. 29 4.3.6 OPGW vs. EOLI XML Order Server (Output Interfaces) ......................................................................... 29 4.3.6.1 EOLI XML Order::processProductOrderRequest [Discrete flow] .......................................... 29 4.3.6.2 EOLI XML Order::processOrderMonitorRequest [Discrete flow] ........................................... 29 4.3.7 OPGW vs. OPGW Operator (Input Interfaces) ...................................................................................... 29 UNCLASSIFIED P50638/DSASGT-0083-10/00 OPGW – Software Design Document for HMA Follow On Task4 - Order Page 4 of 71 Elsag Datamat spa Copyright as reported on the cover page 4.3.7.1 ServiceDirectory.xml [Discrete flow] ......................................................................................... 29 4.3.7.2 Users_YYYYMMDD_HHMMSS.xml [Discrete flow] ..................................................................... 30 4.4 Long lifetime software ........................................................................................................................................... 30 4.5 Memory and CPU budget .................................................................................................................................... 30 4.6 Design Standards, conventions and procedures ............................................................................................. 31 4.6.1 UML Notations .............................................................................................................................................. 31 4.6.1.1 Deployment Diagrams Notations.............................................................................................. 31 4.6.1.2 Component Diagrams Notations .............................................................................................. 32 4.6.1.3 Class Diagrams Notations ........................................................................................................... 33 4.6.1.4 Sequence Diagrams Notations ................................................................................................. 37 4.6.2 Data Flow Diagrams Notations ................................................................................................................. 37 4.6.3 Database Schema Notations ................................................................................................................... 38 5 SOFTWARE DESIGN ......................................................................................................................................................... 39 5.1 General .................................................................................................................................................................... 39 5.2 Overall architecture............................................................................................................................................... 39 5.2.1 Components overview .............................................................................................................................. 39 5.3 Software components design - General ........................................................................................................... 41 5.4 Software components design – Aspect of each component ....................................................................... 42 5.4.1 OPGW - HMA Skeleton [RD-02] ................................................................................................................. 42 5.4.1.1 Type ................................................................................................................................................ 42 5.4.1.2 Purpose .......................................................................................................................................... 42 5.4.1.3 Function ......................................................................................................................................... 42 5.4.1.4 Subordinates ................................................................................................................................. 43 5.4.1.5 Dependencies .............................................................................................................................. 43 5.4.1.6 Interfaces ....................................................................................................................................... 43 5.4.1.7 Resources ...................................................................................................................................... 43 5.4.1.8 References .................................................................................................................................... 43 5.4.1.9 Processing...................................................................................................................................... 43 5.4.1.10 Data ............................................................................................................................................... 43 5.4.2 OPGW - Order Service ............................................................................................................................... 44 5.4.2.1 Type ................................................................................................................................................ 48 5.4.2.2 Purpose .......................................................................................................................................... 48 5.4.2.3 Function ......................................................................................................................................... 48 5.4.2.4 Subordinates ................................................................................................................................. 49 5.4.2.5 Dependencies .............................................................................................................................. 49 5.4.2.6 Interfaces ....................................................................................................................................... 49 UNCLASSIFIED P50638/DSASGT-0083-10/00 OPGW – Software Design Document for HMA Follow On Task4 - Order Page 5 of 71 Elsag Datamat spa Copyright as reported on the cover page 5.4.2.7 Resources ...................................................................................................................................... 49 5.4.2.8 References .................................................................................................................................... 49 5.4.2.9 Processing...................................................................................................................................... 50 5.4.2.10 Data ............................................................................................................................................... 50 5.4.3 OPGW - Support Tools ................................................................................................................................ 51 5.4.3.1 Type ................................................................................................................................................ 52 5.4.3.2 Purpose .......................................................................................................................................... 52 5.4.3.3 Function ......................................................................................................................................... 52 5.4.3.4 Subordinates ................................................................................................................................. 52 5.4.3.5 Dependencies .............................................................................................................................. 53 5.4.3.6 Interfaces ....................................................................................................................................... 53 5.4.3.7 Resources ...................................................................................................................................... 53 5.4.3.8 References .................................................................................................................................... 53 5.4.3.9 Processing...................................................................................................................................... 53 5.4.3.10 Data ............................................................................................................................................... 53 5.4.4 OPGW - Database ...................................................................................................................................... 54 5.4.4.1 Type ................................................................................................................................................ 55 5.4.4.2 Purpose .......................................................................................................................................... 55 5.4.4.3 Function ......................................................................................................................................... 55 5.4.4.4 Subordinates ................................................................................................................................. 55 5.4.4.5 Dependencies .............................................................................................................................. 55 5.4.4.6 Interfaces ....................................................................................................................................... 55 5.4.4.7 Resources ...................................................................................................................................... 56 5.4.4.8 References .................................................................................................................................... 56 5.4.4.9 Processing...................................................................................................................................... 56 5.4.4.10 Data ............................................................................................................................................... 56 5.4.5 Security Layer ............................................................................................................................................... 57 5.4.5.1 Type ................................................................................................................................................ 58 5.4.5.2 Purpose .......................................................................................................................................... 58 5.4.5.3 Function ......................................................................................................................................... 58 5.4.5.4 Subordinates ................................................................................................................................. 58 5.4.5.5 Dependencies .............................................................................................................................. 58 5.4.5.6 Interfaces ....................................................................................................................................... 58 5.4.5.7 Resources ...................................................................................................................................... 58 5.4.5.8 References .................................................................................................................................... 58 5.4.5.9 Processing...................................................................................................................................... 58 UNCLASSIFIED P50638/DSASGT-0083-10/00 OPGW – Software Design Document for HMA Follow On Task4 - Order Page 6 of 71 Elsag Datamat spa Copyright as reported on the cover page 5.4.5.10 Data ............................................................................................................................................... 59 5.5 Dynamical Model ................................................................................................................................................... 59 5.5.1 Identity Management Scenario ............................................................................................................... 59 5.5.2 Product Ordering Scenario ....................................................................................................................... 60 5.5.3 Configuration Scenario .............................................................................................................................. 62 5.5.4 Asynchronous operations .......................................................................................................................... 62 5.6 Internal Interfaces design ..................................................................................................................................... 63 5.6.1 activate Ordering Class ............................................................................................................................. 63 5.6.1.1 Type ................................................................................................................................................ 63 5.6.1.2 Description .................................................................................................................................... 63 5.6.2 key ................................................................................................................................................................. 63 5.6.2.1 Type ................................................................................................................................................ 63 5.6.2.2 Description .................................................................................................................................... 63 5.6.3 decrypt SAML Token ................................................................................................................................... 63 5.6.3.1 Type ................................................................................................................................................ 63 5.6.3.2 Description .................................................................................................................................... 63 5.6.4 encrypt SAML Token ................................................................................................................................... 64 5.6.4.1 Type ................................................................................................................................................ 64 5.6.4.2 Description .................................................................................................................................... 64 5.6.5 create signature .......................................................................................................................................... 64 5.6.5.1 Type ................................................................................................................................................ 64 5.6.5.2 Description .................................................................................................................................... 64 5.6.6 verify signature ............................................................................................................................................ 64 5.6.6.1 Type ................................................................................................................................................ 64 5.6.6.2 Description .................................................................................................................................... 64 5.6.7 Database Files ............................................................................................................................................. 64 5.6.7.1 Type ................................................................................................................................................ 64 5.6.7.2 Description .................................................................................................................................... 64 5.6.8 HMA Ordering ICD Interface .................................................................................................................... 64 5.6.8.1 Type ................................................................................................................................................ 64 5.6.8.2 Description .................................................................................................................................... 64 5.6.9 JDBC access ................................................................................................................................................ 65 5.6.9.1 Type ................................................................................................................................................ 65 5.6.9.2 Description .................................................................................................................................... 65 5.6.10 Order Capabilities File ................................................................................................................................ 65 5.6.10.1 Type ................................................................................................................................................ 65 UNCLASSIFIED P50638/DSASGT-0083-10/00 OPGW – Software Design Document for HMA Follow On Task4 - Order Page 7 of 71 Elsag Datamat spa Copyright as reported on the cover page
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值