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

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

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

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]刪除
最新教學 更多>
  • 極簡設計初學者指南
    極簡設計初學者指南
    我一直是乾淨和簡單的倡導者——這是我的思維最清晰的方式。然而,就像生活中的大多數任務一樣,不同的工作有不同的工具,設計也是如此。在這篇文章中,我將分享我發現的極簡設計實踐,這些實踐有助於創建乾淨簡單的網站、模板和圖形——在有限的空間內傳達必要的內容。 簡單可能比複雜更難:你必須努力讓你的思維清晰,...
    程式設計 發佈於2024-11-03
  • 了解 React 應用程式中的渲染和重新渲染:它們如何運作以及如何優化它們
    了解 React 應用程式中的渲染和重新渲染:它們如何運作以及如何優化它們
    当我们在 React 中创建应用程序时,我们经常会遇到术语渲染和重新渲染组件。虽然乍一看这似乎很简单,但当涉及不同的状态管理系统(如 useState、Redux)或当我们插入生命周期钩子(如 useEffect)时,事情会变得有趣。如果您希望您的应用程序快速高效,那么了解这些流程是关键。 ...
    程式設計 發佈於2024-11-03
  • 如何在 Node.js 中將 JSON 檔案讀入伺服器記憶體?
    如何在 Node.js 中將 JSON 檔案讀入伺服器記憶體?
    在Node.js 中將JSON 檔案讀入伺服器記憶體為了增強伺服器端程式碼效能,您可能需要讀取JSON 對象從文件到記憶體以便快速存取。以下是在Node.js 中實現此目的的方法:同步方法:對於同步檔案讀取,請利用fs(檔案系統)中的readFileSync () 方法模組。此方法將檔案內容作為字串...
    程式設計 發佈於2024-11-03
  • 人工智慧可以提供幫助
    人工智慧可以提供幫助
    我剛剛意識到人工智慧對開發人員有很大幫助。它不會很快接管我們的工作,因為它仍然很愚蠢,但是,如果你像我一樣正在學習編程,可以用作一個很好的工具。 我要求 ChatGpt 為我準備 50 個項目來幫助我掌握 JavaScript,它帶來了令人驚嘆的項目,我相信當我完成這些項目時,這些項目將使我成為 ...
    程式設計 發佈於2024-11-03
  • Shadcn UI 套件 - 管理儀表板和網站模板
    Shadcn UI 套件 - 管理儀表板和網站模板
    Shadcn UI 套件是預先設計的多功能儀表板、網站範本和元件的綜合集合。它超越了 Shadcn 的標準產品,為那些不僅僅需要基礎知識的人提供更先進的設計和功能。 獨特的儀表板模板 Shadcn UI Kit 提供了各種精心製作的儀表板模板。目前,有 7 個儀表板模板可用,隨著時...
    程式設計 發佈於2024-11-03
  • 如何使用正規表示式捕獲多行文字區塊?
    如何使用正規表示式捕獲多行文字區塊?
    符合多行文字區塊的正規表示式符合跨多行的文字可能會為正規表示式建構帶來挑戰。考慮以下範例文本:some Varying TEXT DSJFKDAFJKDAFJDSAKFJADSFLKDLAFKDSAF [more of the above, ending with a newline] [yep, ...
    程式設計 發佈於2024-11-03
  • 軟體開發中結構良好的日誌的力量
    軟體開發中結構良好的日誌的力量
    日誌是了解應用程式底層發生的情況的關鍵。 簡單地使用 console.log 列印所有值並不是最有效的日誌記錄方法。日誌的用途不僅僅是顯示數據,它們還可以幫助您診斷問題、追蹤系統行為以及了解與外部 API 或服務的交互作用。在您的應用程式在沒有使用者介面的情況下運行的情況下,例如在系統之間處理和傳...
    程式設計 發佈於2024-11-03
  • 如何在單一命令列命令中執行多行Python語句?
    如何在單一命令列命令中執行多行Python語句?
    在單一命令列指令中執行多行Python語句Python -c 選項允許單行循環執行,但在指令中匯入模組可能會導致語法錯誤。要解決此問題,請考慮以下解決方案:使用Echo 和管道:echo -e "import sys\nfor r in range(10): print 'rob'&quo...
    程式設計 發佈於2024-11-03
  • 尋找數組/列表中的重複元素
    尋找數組/列表中的重複元素
    給定一個整數數組,找到所有重複的元素。 例子: 輸入:[1,2,3,4,3,2,5] 輸出:[2, 3] 暗示: 您可以使用 HashSet 來追蹤您已經看到的元素。如果某個元素已在集合中,則它是重複的。為了保留順序,請使用 LinkedHashSet 來儲存重複項。 使用 HashSet 的 ...
    程式設計 發佈於2024-11-03
  • JavaScript 回呼何時異步?
    JavaScript 回呼何時異步?
    JavaScript 回呼:是否非同步? JavaScript 回呼並非普遍非同步。在某些場景下,例如您提供的 addOne 和 simpleMap 函數的範例,程式碼會同步執行。 瀏覽器中的非同步 JavaScript基於回呼的 AJAX 函數jQuery 中通常是異步的,因為它們涉及 XHR (...
    程式設計 發佈於2024-11-03
  • 以下是根據您提供的文章內容產生的英文問答類標題:

Why does `char` behave differently from integer types in template instantiation when comparing `char`, `signed char`, and `unsigned char`?
    以下是根據您提供的文章內容產生的英文問答類標題: Why does `char` behave differently from integer types in template instantiation when comparing `char`, `signed char`, and `unsigned char`?
    char、signed char 和unsigned char 之間的行為差異下面的程式碼可以成功編譯,但char 的行為與整數類型不同。 cout << getIsTrue< isX<int8>::ikIsX >() << endl; cout ...
    程式設計 發佈於2024-11-03
  • 如何在動態產生的下拉方塊中設定預設選擇?
    如何在動態產生的下拉方塊中設定預設選擇?
    確定下拉框中選定的項目使用 標籤建立下拉清單時,您可以可能會遇到需要將特定選項設定為預設選擇的情況。這在預先填寫表單或允許使用者編輯其設定時特別有用。 在您呈現的場景中, 標籤是使用 PHP 動態產生的,並且您希望根據值儲存在資料庫中。實現此目的的方法如下:設定選定的屬性要在下拉方塊中設定選定的項目...
    程式設計 發佈於2024-11-03
  • Tailwind CSS:自訂配置
    Tailwind CSS:自訂配置
    介紹 Tailwind CSS 是一種流行的開源 CSS 框架,近年來在 Web 開發人員中廣受歡迎。它提供了一種獨特的可自訂方法來創建美觀且現代的用戶介面。 Tailwind CSS 有別於其他 CSS 框架的關鍵功能之一是它的可定製配置。在這篇文章中,我們將討論 Tailwin...
    程式設計 發佈於2024-11-03
  • 使用 jQuery
    使用 jQuery
    什麼是 jQuery? jQuery 是一個快速的 Javascript 函式庫,其功能齊全,旨在簡化 HTML 文件遍歷、操作、事件處理和動畫等任務。 「少寫多做」 MDN 狀態: jQuery使得編寫多行程式碼和tsk變得更加簡潔,甚至一行程式碼.. 使用 jQuery 處理事件 jQuery...
    程式設計 發佈於2024-11-03
  • CONCAT() 如何增強 MySQL 搜尋功能以實現完整名稱匹配?
    CONCAT() 如何增強 MySQL 搜尋功能以實現完整名稱匹配?
    WHERE 子句中使用 MySQL CONCAT() 函數進行高效搜尋一個常見的資料庫操作是跨多列搜尋資料。然而,當分別使用名字和姓氏欄位搜尋姓名時,可能會存在一些限制,例如捕獲不完整的匹配。 為了克服這個問題,可以使用 MySQL CONCAT() 函數將列組合成一個用於搜尋的單一欄位。這提供了更...
    程式設計 發佈於2024-11-03

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

Copyright© 2022 湘ICP备2022001581号-3