Event, Things and CRC

这篇博客探讨了面向对象设计中类的定义,包括有形与无形的事物、如何寻找和确定类,以及使用名词技术、数据驱动技术和责任驱动技术来识别类。还提到了类的关系、属性、行为以及如何创建CRC卡片来描述类的责任和协作。此外,文章还介绍了分析模型和设计模型中的各种图表,如类图、用例图和序列图在描述系统中的作用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Domain Class 

Definition: Classes are things we want to know about & keep track of within the problem domain. Problem domain is the area of the user's business within the scope of the system or application. e.g. Nationwide -- insurance domain.

 2 types of things

  1. Tangible -- can see and touch
  2. Intangible -- just concept

How to find Classes?

  • Look for objects and things in our system -- e.g. things associated with each Use Case/ User Story
  • Look for nouns in our solutions -- e.g. All nouns associated with actors, Use Case/ User Story, Input/Output

Noun Technique

  • Should I include it?
    • Unique noun
    • Within system scope
    • System needs to remember one or more of the noun items
  • Should I exclude it?
    • Synonym of something already defined
    • Just an output from something already defined
    • Just an input that leads to something already defined
  • Should I research it?

Data-driven Technique

Identify the data in the system and divide it up into classes

  • Start by looking at the database

  •  Then, understand the data and put them into logical groups (classes)

Responsibility-driven Technique

Identify all the responsibilities (methods) in the system

Class Relationship

  • Definition: Naturally occurring associations among specific things
  • Can occur in both directions
  • Optional relationship: multiplicity/cardinality is 0+
  • Mandatory relationship
    1. multiplicity/cardinality is 1 to 1
    2. multiplicity/cardinality is 1+

Attributes

Things have attributes (descriptive information about our things) and values

Things

Things are nouns. All actors and objects in the system are called things.

Actors

Actors can be a external role played by a physical person OR an external system

Object

Objects are the internal artifacts of a computer system.

  • Have attributes and behavior
  • Type of thing is called a class, specific thing is an object
  • Objects belong to classes
  • Behaviors of objects are called methods

Analysis Model

  1. Class diagrams model the problem domain objects and describes the information about things
  2. Use Cases, Activity Diagrams, and System Sequence Diagrams describe the information about the business processes

Design Model

Communication Diagrams, Sequence Diagrams and CRC Cards describe the flow of execution, how user interact with the problem domain objects.

CRC

Class Responsibilities Collaborators 

  • One CRC card for each class (in class diagram)
  • Identify the class and its responsibilities -- i.e. methods
  • Identify collaborator classes -- e.g. include
  • NO universally accepted syntax

Object Speak

  1. Who are you? (class)
  2. What do you know? (attributes)
  3. What can you do? (responsibilities/methods)

Collaboration

Definition: This class has a responsibility to fulfill, but does not have enough information to do it. This is when collaboration comes in -- 2 forms

  1. Request for information
  2. Request to perform a task

 How to create CRC card?

  1. Identify classes with Noun Technique or Data Driven Technique -- Who are you?
  2. Identify responsibilities by Verb Technique or Responsibility Driven Technique -- What do you do?
  3. Identify collaborators by asking "Does the class have the ability to fulfill this responsibility?"
  4. Identify attributes by asking -- What do you know?

  • Structural diagrams describe Things --  Class, statechart etc.
  • Behavioral diagrams describe Events --  Use case, Sequence, Collaboration, etc.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值