指导我的 UML 图的 OO 设计 [英] guidance with OO design of my UML diagram

查看:29
本文介绍了指导我的 UML 图的 OO 设计的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我能得到一些关于这个 UML 图的反馈吗?这是一个简化图,仅显示了类的布局和互连,此时有意省略了实例变量、构造函数和方法.

Could I please get some feedback on this UML diagram? It's a simplified diagram only showing the layout and interconnectivity of the classes with instance variables, constructors and methods intentionally left out at this point in time.

库存项目简化 UML 图

我需要指导的主要内容是面向对象的设计.我是否有正确的类实现接口,或者我应该将接口移动到子类/超类,我是否有正确的关联、组合、聚合关系......那些事情.由于我对 UML 还是个新手,我希望我已经使用了正确的约定来按照我希望的方式描绘关系.

The main thing I need guidance with is the object-oriented design. Do I have the right classes implementing interfaces or should I move the interface(s) to subclass(es)/superclass(es), do I have the association, composition, aggregation relationships correct...those kinds of things. As I'm still new to UML I hope that I have used the proper conventions to portray relationships the way I intend them to be.

基本上,我正在做一个 Java 项目,在该项目中我模拟了一个用于商店库存的数据库.该项目的范围只需要几个类,但我正在添加接口和其他 OO 技术以更好地学习面向对象设计,因为这本质上是我第一个合适的 OO 项目(我已经将一个具体类扩展到另一个具体类在这里和那里,但到目前为止就是这样).

Basically I'm doing a Java project where I mimic a database for an inventory of a store. The scope of the project only requires a few classes, but I'm adding interfaces and other OO techniques to learn object-oriented design better, as this is essentially my first proper OO project (I've extended a concrete class to another concrete class here and there but that's about it so far).

几天前我做了一个类似的帖子,但后来又添加了一些东西,改变了一些东西,等等.另外,我对 OO 设计的掌握仍然太不稳定,我需要进一步的反馈来帮助我获得更好的掌握并更加自信地利用面向对象的设计.

I made a similar thread a few days ago but have since added a few things, changed a few things around, etc. Also, my command of OO design is still too shaky and I need further feedback to help me gain a better grasp of - and more confidence utilizing - object oriented design.

零售产品,顺便说一句,应该是抽象的;拍完照片才发现自己忽略了斜体.

RetailProduct, btw, should be abstract; I realized I neglected to italicize after I took the picture.

推荐答案

看起来不错,但是我没有看到持久化相关类的重点.你可以有一个 PersistenceManager 类和方法 saverestore 来处理序列化.

Looks good, but I don't see the point of the persistence related classes. You just can have a PersistenceManager class with the methods save and restore to deal with serialization.

如果你想要额外的 OO 点,PersistenceManager 应该是一个接口,然后你会实现 FilePersistenceManager.所以很容易实现其他类型的后端,例如 DbPersistenceManager...

And if you want extra OO points, PersistenceManager should be an interface and then you'd implement FilePersistenceManager. So it would be easily to implements other types of back-ends such as DbPersistenceManager...

这篇关于指导我的 UML 图的 OO 设计的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆