Decompose system into modules
2022-01-28 02:35:19 1 举报
AI智能生成
software design and specific
作者其他创作
大纲/内容
Modularization
Module is a responsibility assignment rather than a sub-program. (each task forms a separate, distinct and small program module.)
Each module has its own input & output, well-defined interface with others, test indepedently, easily to change without reassemble ot-her modules or the whole system
Improves the flexibility, managable and comprehensibility of a system
A effective modularization is dependent on the criteria that divides system into modules
Preparation
Write design decisions, definitive document, including UML with pointer conventions, calling conventions etc.
Specify the interface between modules before work
modularization 1&2
decompose a system into modules on the basis of a flowchart.
decomposes a system into modules on the basis of a hierarchical structure.
Difference between 1&2
Main differences: the way of devision work & interfaces
Changeability
e.g. input format; 按需加载 to save memeory; different formats to pack input;
1: it shares implemantation detail of input data(e.g. the table organization等) with other modules, which causes that any change in inp-ut module affects the remaining modules. (暴露太多实现的细节,导致牵一发而动全身)
2: line storage module hiddens the implementation of line from other modules. and its change will not affect other modules. (它变,其他modules可以保持不变)
Independent development
1 has complex interfaces. modules are not really independent.
2 has more abstract interfaces with function names, # and types of paramaters. easier to work. Developer can specify any shift in the s-ame software structure.
Comprehensibility
1 modules之间耦合性太强, difficult to understand
2 easy to understand
Criteria
General criteria: each module hides its design decision from the rest of the system.
1: makes each major step in the processing a module. works like flowchart.
2: uses information hiding as criteria. The modules no longer correspond to steps in the processing.
Decomposition tips
A data structure, its internal linkings, accessing producers and modifying procedures are not shared by other modules.
The sequence of instructions necessary to call a given routine and the routine itself are part of the same module.
The formats of control blocks used in queues in OS and similar programs must be hidden within a "control block module", because de-sign evolution forces frequent changes on control block formats such a decision is often extremely costly.
Character codes, alphabetic orderings and similar data should be hidden in a module for greatest flexibility.
The sequence in which certain items will be processed should be hidden within a single module. Various change rangign from equipm-ent additions to unavailability or resources in an OS make sequencing extremely variable.
Efficiency implementation
背景: Even in 2nd decomposition, If each of function is implemented as a procedure with an elaborate calling sequence, lots of calling are created due to the repeataed switching between modules.
In many cases, the routines will be the best inserted into the code by an assemble. In other cases, highly specialized and efficient trans-fers would be inserted.
总结: The several representations of the program must be maintained in the machine together with a program performing map-ping between them.
Hierarchical structure
It assures us to "prune off" the upper level of the tree and start a new tree on the old trunk.
Hierarchcal structure and "clean" decomposition are two desirable but independent properties of a system structure.
Summary
To achieve an efficient implementation, we must abandon the assumption that a module is one or more subrountine(子程序), an-d instead allow subroutines(可看做function) and programs to be assembled(集合) collections of code from various modules.
0 条评论
下一页