閱讀筆記:Adaptive Object Oriented Software

作品

書籍

課程

程式集

小說集

論文集

散文集

影片集

編輯雜誌

程式人

電子書

JavaScript

計算語言學

微積分

Blender 動畫

C# 語言

系統程式

高等 C 語言

Java

Android

Verilog

Wikidot

R 統計軟體

機率統計

計算機數學

組合語言

人工智慧

開放原始碼

網路資源運用

計算機結構

相關訊息

常用工具

友站連結

在家教育

RSS

最新修改

網頁列表

簡體版

English

  • Adaptive Object Oriented Software — The Demeter Method with Propagation Patterns — Karl. J. Lieberherr

物件導向的問題

  1. 物件的疆固性 : 物件導向太強調 reuse 了,於是強迫物件必須為所有的 application 設想到所有可能的情況, 但 application 的需求千變萬化,事先的完美設想幾乎是不可能的(即使可能,也使 我們預先做了太多不必要的事情,而降低了效率),因此、black box 的 reuse 實際 上太理想化了,我們必須使用 nonblack box 的 reuse, 讓一個 class 在不同的 application 下可以做不同的事情,擁有不同的功能。
  2. 無法有效率的處理物件之間的 interrelationship : 一個物件不應該事先知道其他合作物件的存在,只要 application 知道即可,應該允許 algorithm 可以貫穿各個 object 以完成工作,但是像 STL 這樣使用與結構非常明確的領域是很少的,我們必須允許 algorithm 可以透過存取 object 之間的 reference 關係(可能是原本就存在物件之間 的或是在 application 確定後才建立的關係)來完成工作,因此、在 object oriented language 上再加上一層 code generator,或是使用 dynamic 式的架構 (Interpreter 或是 object relational database),來完成這件工作,便成為一件相當重要的事。

Class Dictionary Graph

下例是一個有關籃子裝東西(蘋果、柳丁、小籃子)的 class dictionary description.
Basket = <nested NestedBasket.
NestedBasket = <contents SeveralThings.
SeveralThings : None | oneOrMore.
None = .
OneOrMore = <one Thing <more SeveralThings
Thing : NestedBasket | Fruit
Fruit : Apple | Orange *common* <weight DemNumber
Apple = .
Orange = .
Thing_List ~ { Thing }.

Propagation Patterns

下例是一個收集所有裝有蘋果所在地以成為一個 list 的程式.
*operation* Thing_List* all_thing_containing_apples(int &apple_count)
    *init* (@ new Thing_List() @)
  *traverse*
    *from* Basket *via* Thing *to* Apple
  *wrapper* Apple
    *prefix*
      (@ appple_count ++ @)
  *wrapper* Thing
    *prefix* (@ int before_count = apple_count @)
    *suffix* (@ if (apple_count before_count) return_val-append(this); @)
— EC : Edge of construction
=EA : Edge of alternation
— ER : Edge of repetation
==EI : Edge of inheritance
Knowledge path = ((EI*EC)|EA|ER)*
 

Good Idea :

Nonblack-box reuse

Class dictionary Component

Construction Class : class
Construction Edge : has-a
Alternation Class : union of classes
Alternation Edges : is-a
Repetition Class : container

Formal Specification of Demeter method :

Structural specification : class dictionary G
Objects defined by G
Flattened class dictionary F = flatten(G)
Propagation directive d for F
Propagation graph pg = propagate(d, F)
Behavioral specification : propagation pattern pp = (signature, d, wrappers)
Code generation for pp in F.

Parts of adaptive software :

Succinct subgraph specification C : *traverse* *from* class1 *to* class2
Initial behavior specification expressed in terms of C : *init*
Behavior enhancements expressed in terms of C : *wrapper* class *prefix* code *suffix* code

Key Idea for adaptive software :

The detailed design of the individual objects or classes only happens after a system design is in place. Because the interrelationships among objects are complex, it is almost impossible to design them exactly right the first time, as anyone who has built a reasonably large object-oriented program knows from hard-won experience. The design process is iterative, with the interactions among objects being redesigned as problems are unconvered during design or coding of individual objects or classes.
Object-oriented programming doesn't provide comparable support for flexibility in object interrelationship. Often a great deal of code needs to be edited in the face of even a small change to the conceptual interdependence structure.

Inventor's Paradox :

It is often easier to solve a more general problem than the one at hand. — Polya

Stepwise Refinement :

A Complex process where the final solution is achieved by stepwise refinement. In every step certain detail get specified which have been left open in the previous step.
( First get the important parts of your application right and then worry about the accidental details of your data structures. )

Representation / Interface Independence :

A program should be designed so that the i nterfaces of objects can be changed within certain constraints without affecting the program at all.

Data structure shy program :

Written in terms of hooks (ie : important data structure) into a data structure.
Program should be written relatively independent of the hierarchy.
A good adaptive program make minimal assumptions on its class structures.

Pareto-Principle :

For a given task, 80% of the work is done by 20% of the interesting classes.
Propagation patterns allow us to focus on those interesting classes.

Delay-Binding :

Broadly speaking, the history of software development is the history of ever-later binding time.

Bind time \ Language procedural object-oriented adaptive
write time : variables - data structure variables - data structure, functions - data sturcture variables - partial data structures functions - partial data structures
propagate-time : partial data structure - data structure, variables - data structure, functions - data structure
compile time : functions - addresses, variable - address , call-address functions - addresses, variables - addresses functions - address, variable-address
run time : data - addresses data - addresses, call - address data - addresses , calls - addresses

Law of Demeter :

When writing a method, one should not hardwire the details of class structure into that method. You should talk to (1) your self. (2) close relatives. (3) friends who visit you.

Use case :

Use cases are a way to make complex systems understandable without, as a first step, trying to structure the system into … objects .. Such structuring creates very technical descriptions which tend to shift the focus from the problem of understanding the requirement to dealing with implementation-like description.

Unplanned reuse :

If a generic algorithm need to accound for each possible use, then it will be difficult to write and reuse.
Grammer-based programming :
machine code (bit string) — assembly language (symbol) — C (structural symbol) — C++ (concrete datatype) — Demeter Tool (abstract datatype)

Adaptive framework

library of propagation patterns (pps) + class dictionaries (cds) + documentation (purpose, use, design)

(Adaptive framework vs framework = class, genre, species vs. instance, genre, animal)

Decontextualized components :

Compilation decisions are delayed until the context information is available.

Method of assertions :

precondition + postcondition

Intentional programming :

Implementation detail is seperated from computational intent. Domain specific knowledge can be added routinely using program transformations. Trade-offs are simply eliminated by proving great abstraction capabilities.

Requirement for design notation :

Structure shy queries :

Open implementations :

Software Architecture :

Controlling impact of change versus reuse capability.

Hot Pot driven approach :

Important feature of evolving system

  • Adaptability :
    • An element v1 of V1 is formulated in terms of partial information about elements of V2. More Explicitly, view v1 is formulated in term of constraints that specify the set of view in V2 that are compatible with v1.
  • Flexibility
  • Scalability
  • Maintainability
  • Reliability

Facebook

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License