我可以在两种不同的环境中使用不同的两类图吗?

时间:2015-12-08 18:13:02

标签: uml software-design class-diagram

我正在处理iOS和Android这两个不同环境的项目,我很想为两个不同的系统设计一个类图,所以我可以使用两个类图,一个用于Android和另一个用于iOS?

我的意思是对于使用两种不同编程语言的两个环境使用相同的类图没有任何意义

2 个答案:

答案 0 :(得分:3)

It doesn't matter how many diagrams you make. In general it is considered a best practice not to overload your diagram with too much classes, so you should have multiple class diagrams for anything but a trivial model.

But I'm guessing the real question is whether or not you want to use the same classes when targeting a different platform.

That depends on the level of abstraction you are modelling on. MDA defines three levels

  • CIM -> Computation Independent Model
  • PIM -> Platform Independent Model
  • PSM -> Platform Specific Model

Which more or less is equivalent to the Conceptual/Logical/Physical layers defined in Zachman or IAF.

So if you are modeling on a CIM or PIM level then you should use the same classes. If you are modeling on a PSM level then should to use different classes for the parts of your system that depend on any of the specifics of your platform.

Look into the Adapter Pattern for a possible way to deal with multiple platforms while still keeping the core business logic of your application platform independent.

答案 1 :(得分:1)

UML图不是针对特定语言或API制作的。如果两种语言都是面向对象的,我不会看到为什么你需要两个不同的类图。

我认为问题是你在UML中加入了“太多”的细节,但情况并非如此。让UML传达类之间交互的结构,行为或性质,而不是nity-gritty细节。

当语言明显不同时,只有javascript是事件驱动的,而LISP才有用,这只会更有意义。