」工欲善其事,必先利其器。「—孔子《論語.錄靈公》
首頁 > 程式設計 > 物件導向設計注意事項|部分-

物件導向設計注意事項|部分-

發佈於2024-07-31
瀏覽:661

Part 1 - Object-Oriented Analysis and Design

1. Object-Oriented Thinking

Object-oriented thinking is fundamental for object-oriented modelling, which is a core aspect of this post. It involves understanding problems and concepts by decomposing them into component parts and considering these parts as objects.

  • Definition: Object-oriented thinking means viewing various elements as discrete objects. For example, in a software system, a tweet, a user, or a product can be viewed as objects.
  • Attributes and Behaviours:
    • Attributes: Properties or characteristics of an object (e.g., a person's name, age, height).
    • Behaviours: Actions that an object can perform (e.g., a device powering on or off, a user logging in).
  • Benefits:
    • Organization: Objects encapsulate both data and behaviour, keeping related details and functions together.
    • Flexibility: Changes to an object’s attributes or behaviours can be made independently of other objects.
    • Reusability: Objects can be reused across different parts of a program or even in different programs, reducing the amount of code that needs to be written and maintained.

2. Design in the Software Process

The design phase is critical in the software development lifecycle. It ensures that the final product meets user requirements and functions as intended.

  • Software Development Process: The software development process is iterative and involves several key stages:
    1. Requirements Gathering: Understanding what the client or user needs from the software.
    2. Conceptual Design: Developing high-level design outlines and mock-ups.
    3. Technical Design: Creating detailed specifications for each component.
    4. Implementation: Writing the actual code based on the designs.
    5. Testing: Verifying that the software works correctly and meets requirements.
    6. Deployment: Releasing the software for use.
    7. Maintenance: Ongoing updates and bug fixes.
  • Importance of Design: Skipping or inadequately addressing design phases can lead to project failure. A solid design foundation ensures that the software development starts on the right track and reduces the risk of costly changes later on.

3. Requirements

Requirements gathering is the foundation of a successful project. It involves understanding what the client or user needs from the software.

  • Definition: Requirements are the conditions or capabilities that the software must satisfy.
  • Elicitation:
    • Client Interviews: Direct discussions with the client to understand their vision and needs.
    • Questionnaires and Surveys: Collecting structured information from potential users or stakeholders.
    • Observation: Watching how users interact with current systems to identify needs and pain points.
    • Workshops: Collaborative sessions with stakeholders to gather and prioritize requirements.
  • Trade-offs: Clients may need to balance different needs and constraints. For instance, they might need to choose between more features or faster delivery.

Example: When designing a house, the architect gathers requirements by asking detailed questions about the homeowner’s preferences for room sizes, placements, and specific features. This helps prevent costly changes during construction.

4. Design

Design in software development involves creating both conceptual and technical blueprints that guide the implementation phase.

  • Conceptual Design:
    • Definition: High-level outline of the software’s major components and their responsibilities.
    • Mock-ups and Wireframes: Visual representations that help stakeholders understand and approve the design before detailed work begins.
    • Responsibilities: Defining what each component of the software is supposed to do.
    • Examples:
    • Mock-ups: Visual layouts of user interfaces showing how screens will look and function.
    • Wireframes: Simple sketches or diagrams showing the layout of components without detailed design elements.
    • Importance: Ensures all stakeholders have a clear understanding and agreement on the high-level structure of the software.

Example: In building a house, the conceptual design outlines the general layout of rooms and their connections but does not yet detail the plumbing or wiring.

  • Technical Design:
    • Definition: Detailed specifications of each component, including how they will be built and interact.
    • Technical Diagrams: Detailed drawings showing how components fit together and how data flows between them.
    • Breakdown of Components: Further decomposing high-level components into smaller, manageable parts until each can be implemented.
    • Examples:
    • Class Diagrams: Show the structure of classes, their attributes, methods, and relationships.
    • Sequence Diagrams: Illustrate how objects interact in a particular sequence of events.
    • Component Diagrams: Depict the organization and dependencies among components.
    • Importance: Provides developers with the detailed information they need to write code effectively and ensures consistency across the development team.

Example: In house construction, the technical design specifies the exact materials for walls, floors, and roofs, as well as the detailed plans for plumbing and electrical systems.

5. Compromise in Requirements and Design

Throughout the design process, compromises are often necessary to balance client needs and project constraints.

  • Communication: Constant feedback loops with clients are essential to ensure the design remains aligned with their vision and constraints.
    • Iterative Reviews: Regularly reviewing and refining designs with client input.
    • Prototyping: Building early versions of components to test and validate ideas with clients.
  • Reworking: Both conceptual and technical designs may need to be revised if they do not meet requirements or prove unfeasible.
    • Flexibility: Being open to changes and adjustments as new information emerges or as requirements evolve.
    • Impact Analysis: Evaluating the potential impact of changes on the overall project to make informed decisions.

Example: If a client wants an open kitchen but structural needs require a supporting beam, the architect and client must find a compromise that maintains structural integrity while satisfying the client’s aesthetic preferences.

6. Design for Quality Attributes

Designing software involves balancing various quality attributes to meet both functional and non-functional requirements.

  • Quality Attributes: Characteristics that affect the performance, usability, and maintainability of software.
    • Performance: How fast and efficiently the software performs its tasks.
    • Security: Measures taken to protect the software from threats and vulnerabilities.
    • Scalability: The ability of the software to handle increased load or usage.
    • Maintainability: How easily the software can be updated or modified.
    • Usability: The ease with which users can learn and use the software.
  • Trade-offs: Balancing these attributes often involves trade-offs, as optimizing for one attribute can affect others.
    • Performance vs. Security: Enhancing security measures can sometimes slow down performance.
    • Scalability vs. Usability: Adding features to improve scalability might complicate the user interface.
  • Context: The specific context of the software influences how these attributes are balanced.
    • Critical Systems: Prioritize reliability and security over other attributes.
    • Consumer Applications: Emphasize usability and performance to enhance user satisfaction.

Example: When designing a front door, balancing security (sturdy locks) with convenience (ease of access) is crucial. Too many locks make the door secure but inconvenient, while too few locks make it convenient but less secure.

7. Class Responsibility Collaborator (CRC) Cards

CRC card

CRC cards are a tool used to identify and organize classes, their responsibilities, and collaborators in the design process.

  • Definition: CRC cards help in visualizing and organizing the responsibilities of different classes and how they interact with each other.
    • Class: Represents an object or concept in the system.
    • Responsibility: Defines what the class knows and does.
    • Collaborator: Other classes with which the class interacts.
  • Usage:
    • Brainstorming: Helps teams brainstorm and identify necessary classes and their roles.
    • Design Sessions: Facilitates discussions about class responsibilities and interactions.
    • Documentation: Serves as a documentation tool to capture design decisions.
  • Process:
    • Identify Classes: List all potential classes involved in the system.
    • Define Responsibilities: Write down the main responsibilities of each class.
    • Identify Collaborators: Determine which classes each class needs to interact with to fulfil its responsibilities.
  • Benefits:
    • Clarity: Provides a clear and concise way to organize and communicate design ideas.
    • Flexibility: Easy to update and modify as the design evolves.
    • Collaboration: Enhances team collaboration by making it easy to discuss and refine design decisions.

Example: In a banking application, a CRC card for the "Account" class might list responsibilities like "manage balance" and "track transactions," with collaborators like "Customer" and "Transaction" classes.

8. Prototyping and Simulation

Prototyping and simulation techniques are used to test and refine designs early in the process, helping to identify and fix issues before full-scale development.

  • Prototyping:
    • Low-Fidelity Prototypes: Simple, rough versions of the software or specific components, often created with paper or basic digital tools.
    • High-Fidelity Prototypes: More detailed and interactive versions that closely resemble the final product.
    • Purpose: Validate design concepts, gather user feedback, and identify usability issues.
    • Methods:
    • Paper Prototyping: Creating hand-drawn sketches of user interfaces and interactions.
    • Digital Prototyping: Using software tools to create interactive mock-ups and simulations.
  • Simulation:
    • Definition: Running models to test the behaviour and performance of a design under various conditions.
    • Use Cases: Evaluating system performance, load testing, and validating design decisions.
    • Benefits:
    • Early Validation: Identifies potential issues before full-scale development.
    • Cost-Effective: Reduces the risk of costly changes by addressing issues early.
    • User Feedback: Allows users to interact with the prototype and provide feedback on functionality and usability.
    • Tools: Various software tools and platforms are available for creating prototypes and running simulations.

Example: Before finalizing the design of a house, an architect might build a small-scale model or use software simulations to visualize the layout and identify potential issues with space utilization and design.

版本聲明 本文轉載於:https://dev.to/anshulanand/object-oriented-design-part-13-4nb1?1如有侵犯,請聯絡[email protected]刪除
最新教學 更多>
  • 哪種在JavaScript中聲明多個變量的方法更可維護?
    哪種在JavaScript中聲明多個變量的方法更可維護?
    在JavaScript中聲明多個變量:探索兩個方法在JavaScript中,開發人員經常遇到需要聲明多個變量的需要。對此的兩種常見方法是:在單獨的行上聲明每個變量: 當涉及性能時,這兩種方法本質上都是等效的。但是,可維護性可能會有所不同。 第一個方法被認為更易於維護。每個聲明都是其自己的語句,使...
    程式設計 發佈於2025-03-25
  • 如何限制動態大小的父元素中元素的滾動範圍?
    如何限制動態大小的父元素中元素的滾動範圍?
    在交互式接口中實現垂直滾動元素的CSS高度限制問題:考慮一個佈局,其中我們具有與用戶垂直滾動一起移動的可滾動地圖div,同時與固定的固定sidebar保持一致。但是,地圖的滾動無限期擴展,超過了視口的高度,阻止用戶訪問頁面頁腳。 $("#map").css({ margin...
    程式設計 發佈於2025-03-25
  • 版本5.6.5之前,使用current_timestamp與時間戳列的current_timestamp與時間戳列有什麼限制?
    版本5.6.5之前,使用current_timestamp與時間戳列的current_timestamp與時間戳列有什麼限制?
    在時間戳列上使用current_timestamp或MySQL版本中的current_timestamp或在5.6.5 此限制源於遺留實現的關注,這些限制需要對當前的_timestamp功能進行特定的實現。 創建表`foo`( `Productid` int(10)unsigned not ...
    程式設計 發佈於2025-03-25
  • 如何使用不同數量列的聯合數據庫表?
    如何使用不同數量列的聯合數據庫表?
    合併列數不同的表 當嘗試合併列數不同的數據庫表時,可能會遇到挑戰。一種直接的方法是在列數較少的表中,為缺失的列追加空值。 例如,考慮兩個表,表 A 和表 B,其中表 A 的列數多於表 B。為了合併這些表,同時處理表 B 中缺失的列,請按照以下步驟操作: 確定表 B 中缺失的列,並將它們添加到表的...
    程式設計 發佈於2025-03-25
  • 如何從Google API中檢索最新的jQuery庫?
    如何從Google API中檢索最新的jQuery庫?
    從Google APIS 問題中提供的jQuery URL是版本1.2.6。對於檢索最新版本,以前有一種使用特定版本編號的替代方法,它是使用以下語法:獲取最新版本:未壓縮)While these legacy URLs still remain in use, it is recommended ...
    程式設計 發佈於2025-03-25
  • 拆分數組的數量
    拆分數組的數量
    您得到了一個 0- indexed integer arnay長度n。 nums在索引i上包含一個 第一個i 1元素的總和比的最後一個n -i -i -1元素的總和。 至少有一個元素在i的右邊。也就是說,0 = -1,i = 1是一個有效的分裂。 在索引2處拆分nums。然後,第一部分是[1...
    程式設計 發佈於2025-03-25
  • 如何為PostgreSQL中的每個唯一標識符有效地檢索最後一行?
    如何為PostgreSQL中的每個唯一標識符有效地檢索最後一行?
    postgresql:為每個唯一標識符在postgresql中提取最後一行,您可能需要遇到與數據集合中每個不同標識的信息相關的信息。考慮以下數據:[ 1 2014-02-01 kjkj 在數據集中的每個唯一ID中檢索最後一行的信息,您可以在操作員上使用Postgres的有效效率: id dat...
    程式設計 發佈於2025-03-25
  • 如何在JavaScript對像中動態設置鍵?
    如何在JavaScript對像中動態設置鍵?
    在嘗試為JavaScript對象創建動態鍵時,如何使用此Syntax jsObj['key' i] = 'example' 1;不工作。正確的方法採用方括號: jsobj ['key''i] ='example'1; 在JavaScript中,數組是一...
    程式設計 發佈於2025-03-25
  • 如何在Java中正確顯示“ DD/MM/YYYY HH:MM:SS.SS”格式的當前日期和時間?
    如何在Java中正確顯示“ DD/MM/YYYY HH:MM:SS.SS”格式的當前日期和時間?
    如何在“ dd/mm/yyyy hh:mm:mm:ss.ss”格式“ gormat 解決方案: args)拋出異常{ 日曆cal = calendar.getInstance(); SimpleDateFormat SDF =新的SimpleDateFormat(“...
    程式設計 發佈於2025-03-25
  • Java是否允許多種返回類型:仔細研究通用方法?
    Java是否允許多種返回類型:仔細研究通用方法?
    在Java中的多個返回類型:一種誤解類型:在Java編程中揭示,在Java編程中,Peculiar方法簽名可能會出現,可能會出現,使開發人員陷入困境,使開發人員陷入困境。 getResult(string s); ,其中foo是自定義類。該方法聲明似乎擁有兩種返回類型:列表和E。但這確實是如此嗎...
    程式設計 發佈於2025-03-25
  • 如何使用Regex在PHP中有效地提取括號內的文本
    如何使用Regex在PHP中有效地提取括號內的文本
    php:在括號內提取文本在處理括號內的文本時,找到最有效的解決方案是必不可少的。一種方法是利用PHP的字符串操作函數,如下所示: 作為替代 $ text ='忽略除此之外的一切(text)'; preg_match('#((。 &&& [Regex使用模式來搜索特...
    程式設計 發佈於2025-03-25
  • 如何從PHP中的數組中提取隨機元素?
    如何從PHP中的數組中提取隨機元素?
    從陣列中的隨機選擇,可以輕鬆從數組中獲取隨機項目。考慮以下數組:; 從此數組中檢索一個隨機項目,利用array_rand( array_rand()函數從數組返回一個隨機鍵。通過將$項目數組索引使用此鍵,我們可以從數組中訪問一個隨機元素。這種方法為選擇隨機項目提供了一種直接且可靠的方法。
    程式設計 發佈於2025-03-25
  • ``STD :: LANEDER'如何解決工會中的const成員的編譯器優化問題?
    ``STD :: LANEDER'如何解決工會中的const成員的編譯器優化問題?
    Unveiling the Essence of Memory Laundering: A Deeper Dive into std::launderIn the realm of C standardization, P0137 introduces std::launder, a funct...
    程式設計 發佈於2025-03-25
  • 如何處理PHP文件系統功能中的UTF-8文件名?
    如何處理PHP文件系統功能中的UTF-8文件名?
    在PHP的Filesystem functions中處理UTF-8 FileNames 在使用PHP的MKDIR函數中含有UTF-8字符的文件很多flusf-8字符時,您可能會在Windows Explorer中遇到comploreer grounder grounder grounder gro...
    程式設計 發佈於2025-03-25
  • 在細胞編輯後,如何維護自定義的JTable細胞渲染?
    在細胞編輯後,如何維護自定義的JTable細胞渲染?
    在JTable中維護jtable單元格渲染後,在JTable中,在JTable中實現自定義單元格渲染和編輯功能可以增強用戶體驗。但是,至關重要的是要確保即使在編輯操作後也保留所需的格式。 在設置用於格式化“價格”列的“價格”列,用戶遇到的數字格式丟失的“價格”列的“價格”之後,問題在設置自定義單元...
    程式設計 發佈於2025-03-25

免責聲明: 提供的所有資源部分來自互聯網,如果有侵犯您的版權或其他權益,請說明詳細緣由並提供版權或權益證明然後發到郵箱:[email protected] 我們會在第一時間內為您處理。

Copyright© 2022 湘ICP备2022001581号-3