如何识别对象??

phonlee 2003-01-18 11:23:18
分析过程中如何识别对象??
...全文
40 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
sandrowjw 2003-02-08
  • 打赏
  • 举报
回复
照UML里的说法,应该是从use case获得的吧,我也不是很懂,好像要建一个词典来分析吧。
kinogre 2003-02-07
  • 打赏
  • 举报
回复
我想的一种办法,不知道可不可以:
#define REGISTER_CLASS(theClass) (\
public:\
GetClassName() { return #theClass }\
)

class MyClass{
// my class member function
...

REGISTER_CLASS(theClass)
};

SomeFxn()
{
...

MyClass a;
a.GetClassName();

}

行不行我还没试过,因为忽然想起 MFC 里的几个嵌入类里的宏,象消息映射,可串行化等。
allen1981813 2003-02-06
  • 打赏
  • 举报
回复
typeid.name()最ok
natureshuo 2003-02-06
  • 打赏
  • 举报
回复
识别目的是什么?
DaNiao 2003-02-06
  • 打赏
  • 举报
回复
等OO论坛独立了在问吧 否则:cout<<typeid(...).name; :-)

其实我觉得在这个问题上形式化的方法起不了多少作用
就好象我问你在数据建模时如何识别实体?
如果有形式化的解的话计算机就可以自己分析设计了,还要人干什么?

我觉得看看专家的建议(比如前面提到的)
多看写设计模式
然后就全凭直觉了
勉励前行 2003-02-06
  • 打赏
  • 举报
回复
分析过程中如何识别对象?
劃分對象?
對象如何分類?'
'
如何分析對象:

將你要分析的對象歸類,將各對象的屬性再歸類(不要忽視這一步),這樣一個個對象(類)就崩出來了。

再整理這些對象,抽取其共性,這樣一個個新的對象又誕生了,一些多余的對象就死亡了。

反復多次,你的對象模型也就慢慢成熟了。這是一個艱難的過程,過了這一關,後面寫程序就容易了。
superzjx2000 2003-02-01
  • 打赏
  • 举报
回复
cout<<typeid(...).name;
just a try
Lugonix 2003-01-27
  • 打赏
  • 举报
回复
我通常的做法是从关联入手,那么关联的两端就是概念对象,细化整合之后就是分析对象了。
Rocken 2003-01-20
  • 打赏
  • 举报
回复
找出所分析问题域中的概念,这些概念就是你系统的对象的基础。这之中的一些概念作为对象,一些作为对象的属性。有一个原则,就是如果不能确定作为对象还是属性,宁愿将概念作为对象而不是属性。
yeahspyme 2003-01-19
  • 打赏
  • 举报
回复
你如果是模拟设计的话,我觉得模拟的都应该是个对象了,分析的就是它们之间的关系,包括通信和继承。
如果是抽象设计,我觉得至少应该从两个方面来看吧:一是,有一定的独立数据;二是,有一定与数据相关的行为。这才能构成一个对象。当然接下来的依然是关系分析。
个人拙见,请指教。
  • 打赏
  • 举报
回复
你可以在你编写的每一个类中都编写一个返回该类的名字的字符串,如:
class A{
public:
virtual const char* what_am_i() const { return "A"}
//......
};
也可以使用RTTI的typeid运算符:
#include <typeinfo>
typeid(*this);
phonlee 2003-01-18
  • 打赏
  • 举报
回复
指导原则:责任驱动
Responsibility-Driven Design
l The most widely adopted approach to OO analysis.
– Based on “client / server” relationships.
There are 2 common interpretations of “client / server”:
l Used in distributed architectures where the server provides access to shared
resources (such as a database) and the clients provide the user interface.
l Used in the object-oriented vernacular where the server is an object that
provides services; this is the meaning we are using here.
Clients collaborate with servers.
– An object may be a client in one collaboration, and a server in another.
Servers are responsible for providing certain services.
l In general, an object is responsible for behaving in a certain, well-defined way.
phonlee 2003-01-18
  • 打赏
  • 举报
回复
下面是一些资料:

设计流程:
Overview of the Design Process
l Look at a domain and identify the objects and classes
– Objects are often the first to be identified <<<识别对象
– Classes are found by grouping objects
l Identify the relationships between the objects and
between the classes
– Structural relationships
– Collaborative relationships
l Assign responsibilities
– Based on collaborative relationships
l Iterate, iterate, iterate, iterate, iterate, iterate, iterate, iterate, iterate,
l Begin by modeling the domain, not the solution!

phonlee 2003-01-18
  • 打赏
  • 举报
回复

我的问题是系统分析中如何得到对象??

查了一点资料:
传统方法: 识别业务流程中的名字等..
新方法:CRC

请熟悉的朋友发表高见.


seanzh 2003-01-18
  • 打赏
  • 举报
回复
你到底要做什么?说具体点
phonlee 2003-01-18
  • 打赏
  • 举报
回复

系统分析的时候,如何得到对象?

不是说,"如何得到对象类型?"

64,685

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧