2

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?

NotGaeL
  • 8,344
  • 5
  • 40
  • 70
  • 1
    UML can mean many things. So you want to create a class diagram and turn the implementation into an object oriented one? Also: is your only task to do the UML modelling or the implementation, too? – scravy Dec 03 '11 at 11:27
  • The Assigment is to take a project I made (written in PHP) and make a basic UML model (with cases of use, flowcharts, documentation a so on). Easiest way to do that could be to modify my project's design to be object oriented, use the UML tool to generate a class diagram and start working from that, or start a new project from the model and then do implementation. In any case I need both the model with flowcharts and cases of use and the corresponding implementation. – NotGaeL Dec 03 '11 at 12:42
  • 1
    Maybe you could edit your question and state exactly what you need (sequence diagram, class diagram, use case diagram, ...) Here is a neat introduction to all various aspects of UML diagrams: http://www.ibm.com/developerworks/rational/library/769.html – scravy Dec 03 '11 at 13:31
  • You're right, I should've been more specific. Deployment diagrams are not requested, neither activities, and the states machine and the collaboration diagrams are optional and don't have to be very thorough. I guess my model is centered on the cases of uses diagram and the classes diagram (if OO I guess), also the sequence diagram should be simple and neat, and my question is how much an OO project benefits me as opossed to the procedural I've already implemented... – NotGaeL Dec 03 '11 at 15:46

2 Answers2

5

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.


<?php
// "indexfuncs1.php"

// this is an auxiliary file for "index.php",
// and has some free procedural code.

echo "indexfuncs1.php: dosomething()";

?>

<?php
// "funcslib.php"

// this is an library file,
// and has only functions and constants,

define ("ANYCONST", "Hello World");

function HelloWorld()
{
  echo ANYCONST;
}

?>

<?php
// "index.php"

// only declarations, doesn't do anything, by itself
//include("funcslib.php");
//require("funcslib.php");
//require_once("funcslib.php");
include_once("funcslib.php");

// this code is in other file, and its executed
include("indexfuncs1.php");

echo "index.php: Hello World";
HelloWorld();

// this code is in other file, and its executed
include("indexfuncs1.php");

?>

And start to turn them into this:

<?php
// "indexfuncs1.php"

// this is an auxiliary file for "index.php",
// and has some free procedural code.

function indexfuncs1_dosomething()
{
  echo "indexfuncs1.php: dosomething()";
}

?>

<?php
// "funcslib.php"

// this is an library file,
// and has only functions and constants,

define ("funcslib_ANYCONST", "Hello World");

function funcslib_HelloWorld()
{
  echo funcslib_ANYCONST;
}

?>

<?php
// "index.php"

// only declarations, doesn't do anything, by itself
//include("funcslib.php");
//require("funcslib.php");
//require_once("funcslib.php");
include_once("funcslib.php");

function index_main()
{
  // this code is in other file, and its executed
  indexfuncs1_dosomething();

  echo "index.php: Hello World";

  funcslib_HelloWorld();

  // this code is in other file, and its executed
  indexfuncs1_dosomething();    
}

?>

And there is no O.O., yet. Because, its an intermediate step.

Lets start by transform each web page into a single class, without inheritance, without parent classes.

<?php
// "indexfuncs1.php"

// this is an auxiliary file for "index.php",
// and the free procedural code have become a class.

class indexfuncs1 {
    function dosomething()
    {
        echo "indexfuncs1.php: dosomething()";      
    } // function dosomething()
} // class IndexPage    

?>


<?php
// "index.php"

// only declarations, doesn't do anything, by itself
//include("funcslib.php");
//require("funcslib.php");
//require_once("funcslib.php");
include_once("funcslib.php");

class IndexPage {
    function main()
    {
      $myAux = new indexfuncs1();

      // this code is in other file, and its executed
      $myAux->dosomething();

      echo "index.php: Hello World";

      funcslib_HelloWorld();

      // this code is in other file, and its executed
      $myAux->dosomething();
    } // function main()
} // class IndexPage

function index_main()
{
    $myPage = new IndexPage();
    $myPage->main();
} // function index_main(...)

// --> the only allowed global procedural code:
index_main();

?>

(More to come).

umlcat
  • 4,091
  • 3
  • 19
  • 29
  • well, right now the intermediate step is where I'm at: none of my files contain anything other than functions or constant definitions but the ones who generate a webpage by calling those functions (.phtml files with mostly html content, since the website is not so dynamic, structurally speaking) – NotGaeL Dec 03 '11 at 18:04
  • BTW: Very nice answer, I almost accept it, but it misses something: Now you know where I'm at, should I do the migration or not? (Also, the site is not even online, it's just a project for one of my subjects at the Uni) – NotGaeL Dec 03 '11 at 18:11
  • @elcodedocle: You may want to refresh the page. I have added a class for each code. Its not finished. You may want to continue, since it may help you for future similar (job) projects... – umlcat Dec 03 '11 at 18:48
2

For modelling UML in Eclipse you may want to have a look at the Eclipse Modelling Tools (MDT).

scravy
  • 11,904
  • 14
  • 72
  • 127