如何将 Procedural 项目移植到 OO 项目中
我有一个小型 PHP 项目(大约 3000 行),我需要为其创建一个基本的 UML 模型,从使用图、序列图和状态图的案例开始,可能还有类图,也许还可以用协作图来扩展它。
我是 UML 建模的新手,这是我第一次从实现中创建模型,而不是相反(不是很有用,除非您进行逆向工程,但无论如何,这是一项任务)
现在,我应该如何做解决这个问题?如果我的项目有 OO 实现,一些 UML 工具可以让我的生活变得非常轻松,但事实并非如此,所以我想知道我是否应该将我的项目重写为 OO 以及如何做到这一点(我的意思是,是否有一些标准的基本我应该遵循的准则或程序?),或者我是否应该按原样制作项目模型(在这种情况下哪种建模工具是最好的)。
另外,我的项目是在 Eclipse IDE 上编写的,有人知道有什么插件可以帮助我完成这个 UML 建模任务吗?
I have a small PHP project (about 3000 lines) and I need to make a BASIC UML model of it, starting with cases of use diagram, sequence diagram and states diagram, probably classes diagram, and maybe extend it with collaborations diagram.
I'm new to UML modeling, and this is the first time I make the model out of the implementation instead of the opposite (not very userful unless you're into reverse engineering, but whatever, it's an assigment)
Now, how should I approach this problem? Some UML tools can make my life pretty easy if my project has an OO implementation, but this is not the case so I'm wondering if I should rewrite my project as OO and how to do it (I mean, are there some standard basic guidelines or procedure I should follow?), or if I should just make the model of the project as it is (And in that case which modeling tool would be the best).
Also my project is written on Eclipse IDE, does somebody know any plugin for it to help me with this UML modelling task?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
停止
您以前从事过面向对象编程吗?
您使用过 OO 建模技术吗?
您的 PHP 文件是否使用命名空间或函数前缀 ("("mylib.php", "function mylib_dosomething() { ... }")") ?
不要跳到UML,太快了。 UML就是做一个文档,
你脑子里有什么。
你必须首先思考,你要对网站做什么,
然后,记录并建模您的新网站将如何运作。
UML 是一个很棒的工具,但是,如果你头脑中的设计一团糟,
那么,你的文档就会变得一团糟。
您有一个正在运行的网站,并且想要替换它。
主要有两种方法。
(1) 从头开始:
如果您有 OO 经验,并且您可以忘记您的旧网站,让它继续运行,
并使用面向对象或一些现有的框架从“头”开始创建一个新网站。
(2) 重构
或者,您想维护当前的网站,并迁移到 OO,
步步。 ?它也被称为“重构”。
你可能一开始会认为你的主程序或主php文件是一个大对象(程序)文件,每个库文件也是对象。
示例:
假设您有几个 php 文件。有些文件是页面的主文件。有些文件包含在页面文件中甚至重复出现。其他的是仅具有功能的“库”文件。
并开始将它们变成这样:
目前还没有面向对象。因为,这是一个中间步骤。
(更多内容即将推出)。
STOP
Have you work before with Object Oriented Programming ?
Have you used O.O. modeling techniques ?
Are you using namespaces or functions prefixes ("("mylib.php", "function mylib_dosomething() { ... }")") for your PHP files ?
Don't jump to U.M.L., so fast. U.M.L. is to make a documentation,
of whats in your head.
You have to think first, what are you going to do with website,
and later, document and model how your new website is going to work.
U.M.L. is a wonderful tool, but, if the design in your mind is a mess,
then, you'll have a mess in your documentation.
You have a working website, and want to replace it.
There are two main methods.
(1) Start from Scratch:
If you have experience with O.O., and you can forget about your old site, leave it working,
and start a new web site from "scratch" using O.O., or some of the existing frameworks for this.
(2) Refactor
Or, you want to maintain your current website, and migrate to O.O.,
step by step. ? Its also know as "Refactoring".
You may start by thinking that your main program or main php file is a big object (program) file, and each library file are also objects.
Example:
Lets suppouse you have several php files. Some files are the main files for a page. Some files are included and even repeated in page files. Others, are "library" files with only functions.
And start to turn them into this:
And there is no O.O., yet. Because, its an intermediate step.
(More to come).
要在 Eclipse 中建模 UML,您可能需要查看 Eclipse 建模工具 (MDT) 。
For modelling UML in Eclipse you may want to have a look at the Eclipse Modelling Tools (MDT).