English 中文(简体)
物体在被点击时表现不同的设计模式,视全球国家而定[封闭]
原标题:Design pattern for an object behaving differently when clicked, depending on a global state [closed]

我们不准许对书籍、工具、软件图书馆以及更多的图书馆征求建议的问题。 你可以ed问这个问题,以便用事实和引言回答。

Closed 6 years ago.

我正在就这一问题使用“团结3D”,但这是一个一般软件工程问题。

团结3D的实体(活性物体)是用部件或行为建立的。 通过将行为合在一起,你确定了物体的确切行为。

我正在考虑如何在被点击时,以一个全球国家为基础,对不同的物体作出不同的反应。 例如,我有一个工具,只针对现场的圈子;如果我选择这一工具,点击物体,如果它是一个圈子,我将将其改为平方。 如果它不是一个圈子,我就只会忽视它。

采用基于构成部分的实体设计,我将界定一种称为“IsCircle”的行为,当被点击时,我将检查一下究竟应该发生什么情况。 然而,它获得整个申请的全球状况的最佳途径是什么? 请允许我说,我想避免任何开关,如果开车,希望解决办法脱钩。

(问题是,OnMouseDown()活动手在任何参数中没有通过)。

如果答案考虑到我所利用的环境,我将执行综合模式。

最佳回答
问题回答

我不敢肯定你能利用这一解决办法,但我想到国家设计模式,我被用来改变基于国家物体的行为,例如,你必须把这个国家移至你们的物体。 你们也可以考虑访客设计模式,可能采取某种多方法。





相关问题
Choosing the right subclass to instantiate programmatically

Ok, the context is some serialization / deserialization code that will parse a byte stream into an object representation that s easier to work with (and vice-versa). Here s a simplified example ...

Design pattern for managing queues and stacks?

Is there a design pattern for managing a queue or a stack? For example, we are looking to manage a list of tasks. These tasks will be added to a group queue, users will then be able to pull off the ...

Organizing classes using the repository design pattern

I have started upgrading one of our internal software applications, written in ASP.NET Web Forms, and moving to ASP.NET MVC. I am trying to leverage the Repository design pattern for my classes, ...

Misuse of Observer Pattern?

I have a Car object which contains a latitude field and a longitude field. I use the observer pattern so that any time either of these fields change in my application, my car object is notified. I ...

How are Models (in MVC) and DAOs supposed to interact?

How are models and DAOs supposed to interact? I m in the process of putting together a simple login module and I m unsure where to put the "business logic." If I put the logic with the data in the ...

热门标签