English 中文(简体)
软件设计基础
  • 时间:2024-12-22

Software Design Basics


Previous Page Next Page  

Software design is a process to transform user requirements into some suitable form, which helps the programmer in software coding and implementation.

For assessing user requirements, an SRS (Software Requirement Specification) document is created whereas for coding and implementation, there is a need of more specific and detailed requirements in software terms. The output of this process can directly be used into implementation in programming languages.

软件设计是软件设计生命周期(SDLC)的第一步,它将重点从问题域转移到解决方案域。它试图指定如何满足SRS中提到的要求。

Software Design Levels

软件设计产生三个层次的结果:

    Architectural Design - The architectural design is the highest abstract version of the system. It identifies the software as a system with many components interacting with each other. At this level, the designers get the idea of proposed solution domain.

    High-level Design- The high-level design breaks the ‘single entity-multiple component’ concept of architectural design into less-abstracted view of sub-systems and modules and depicts their interaction with each other. High-level design focuses on how the system along with all of its components can be implemented in forms of modules. It recognizes modular structure of each sub-system and their relation and interaction among each other.

    Detailed Design- Detailed design deals with the implementation part of what is seen as a system and its sub-systems in the previous two designs. It is more detailed towards modules and their implementations. It defines logical structure of each module and their interfaces to communicate with other modules.

Modularization

模块化是一种将软件系统分为多个离散和独立模块的技术,这些模块应该能够独立地执行任务。这些模块可以作为整个软件的基本构件。设计者倾向于设计模块,使它们可以分别和独立地执行和编译。

模块化设计无意中遵循了“分而治之”问题解决策略的规则,因为软件的模块化设计还附带许多其他的好处。

模块化的优势:

    Smaller components are easier to maintain

    Program can be spanided based on functional aspects

    Desired level of abstraction can be brought in the program

    Components with high cohesion can be re-used again

    Concurrent execution can be made possible

    Desired from security aspect

Concurrency

回到过去,所有软件都被设计成按顺序执行。按顺序执行是指编码的指令将依次执行,这意味着在任何给定时间只有程序的一部分被激活。比如说,一个软件有多个模块,那么在执行时只有其中一个模块处于活动状态。

在软件设计中,并发性是通过将软件拆分为多个独立的执行单元(如模块)并并行执行它们来实现的。换句话说,并发性能够使软件同时执行多个代码部分。

程序员和设计师有必要认识到哪些模块可以进行平行执行。

Example

文字处理软件中的拼写检查功能是软件模块,与文字处理器本身一起运行。

Couppng and Cohesion

当软件程序被模块化时,其任务会基于某些特征分成几个模块。我们知道,模块是一组指令,用于完成某些任务。尽管它们被认为是单个实体,但它们可以相互引用来协同工作。有一些措施可以衡量模块设计及其相互作用的质量。这些措施称为耦合和内聚力。

Cohesion

凝聚力是一个度量,它定义了模块元素内部相互依赖程度的度量。凝聚力越强,程序设计就越好。

有七种凝聚力,即 -

    Co-incidental cohesion - It is unplanned and random cohesion, which might be the result of breaking the program into smaller modules for the sake of modularization. Because it is unplanned, it may serve confusion to the programmers and is generally not-accepted.

    Logical cohesion - When logically categorized elements are put together into a module, it is called logical cohesion.

    Temporal Cohesion - When elements of module are organized such that they are processed at a similar point in time, it is called temporal cohesion.

    Procedural cohesion - When elements of module are grouped together, which are executed sequentially in order to perform a task, it is called procedural cohesion.

    Communicational cohesion - When elements of module are grouped together, which are executed sequentially and work on same data (information), it is called communicational cohesion.

    Sequential cohesion - When elements of module are grouped because the output of one element serves as input to another and so on, it is called sequential cohesion.

    Functional cohesion - It is considered to be the highest degree of cohesion, and it is highly expected. Elements of module in functional cohesion are grouped because they all contribute to a single well-defined function. It can also be reused.

Couppng

耦合是一种衡量程序模块之间相互依赖程度的指标。它描述了模块之间相互干扰和交互的程度。耦合度越低,程序就越好。

有五个耦合级别,即 -

    Content couppng - When a module can directly access or modify or refer to the content of another module, it is called content level couppng.

    Common couppng- When multiple modules have read and write access to some global data, it is called common or global couppng.

    Control couppng- Two modules are called control-coupled if one of them decides the function of the other module or changes its flow of execution.

    Stamp couppng- When multiple modules share common data structure and work on different part of it, it is called stamp couppng.

    Data couppng- Data couppng is when two modules interact with each other by means of passing data (as parameter). If a module passes data structure as parameter, then the receiving module should use all its components.

理想情况下,不耦合被认为是最好的。

Design Verification

软件设计过程的输出包括设计文档、伪代码、详细逻辑图、过程图以及所有功能或非功能要求的详细描述。

下一阶段,即软件实施,取决于上述所有产出。

在进入下一个阶段之前,有必要验证输出。发现错误越早,越好,否则可能要等到产品测试时才会发现。如果设计阶段的输出以正式符号形式呈现,则应使用相应的验证工具,否则可以使用彻底的设计审核进行验证和确认。

通过有结构的验证方法,审查人员可以检测可能由于忽略某些条件而导致的缺陷。良好的设计审查对于良好的软件设计、精确性和质量非常重要。

Advertisements