不管您喜欢与否,诸如统一建模语言 (UML)类模型和用例模型这样的软件图往往是根据它们的外观来判定其好坏的。看上去整洁的图比看上去杂乱的图更容易受到读者 -- 常常是您的用户或高级经理 -- 的青睐。
我很愿意描述几个重要的经验法则,这些法则将使您比其他建模同仁做得更好。这些虽然简单但很关键的建议主要集中在如何安排组成软件图(包括UML类模型、用例模型,甚至持久模型)的那些框和线条,并因此适用于所有种类的图。
要绘制一个外观整洁的图,您应该避免:
让我们从一个示例开始。在图 1 和 2中,您可以看到两个用两种不同风格绘制的图。第一个复杂,没有章法,而第二个简单,组织良好(虽然有些乏味)。您认为哪个设计更好呢?大多数人都会赞成第二个看上去更好一些,因为虽然这两种设计在功能上是相等的,但第二个的安排更整洁。
避免对角线
图 2 与图 1 的另一个不同之处在于它没有任何对角线。我是通过重新安排框来消除对角线的,就好象它们在一个网格上,使互连的框或者在垂直方向上分离,或者在水平方向上分离。从视觉上说,大多数人对直线更感兴趣。
图 3. 如何在不交叉线的情况下连接 3 和 5?
图 4. 一条线“跳”过另一条
另一个相关的注意事项是对屏幕或页面区域的使用。在我看来,一张占据几页的图比将所有内容蜷缩在一起,使它能在一页上打印出的图要好得多。您应该给图留出足够的空间,使它易于理解。