Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I use UML when designing new code and algorithms? [closed]

Tags:

uml

I'm designing a new system and finding that I am struggling with the structure of what I want to do. A symptom is that every time I re-approach the problem I have to try to draw the relationships of the components on paper. (It is not yet clear in my mind as to what these components are precisely or what the relationship is - for example I managed to delete one that wasn't doing anything).

Is UML a useful way forward? I used to be very sceptical and tried early versions where the production version cost way too much money. Now I see there is a plugin in Netbeans which inter alia has a good selection of Patterns (this alone might make it worth the while).

I've read most of the top-level posts on SO and there doesn't seem to be a very clear consensus. My context is that this is related to research rather than coding for a client so the main purpose is not to document a final product but to help clear my mind (and possibly write some simple structures).

If any answers support UML it would be useful to suggest how long it will take to get productive and how often it will be used. (As a reference I use tests, loggers, and debuggers every day).

SUPPLEMENTARY Is there anything in UML software that enforces consistency (at any level) between the code and the diagram. I assume that when, say, a StrategyPattern, is created then it can generate stub code. But can that code be included in such a way that if the Pattern is broken the UML tool detects this?

like image 990
peter.murray.rust Avatar asked Sep 12 '09 10:09

peter.murray.rust


2 Answers

Martin Fowler is IMHO right when he says there are three ways to use UML:

  • as a sketch of what you are going to do
  • as a blueprint for what you are going to do
  • as the thing you are going to do in itself

It sounds like you are mostly leaning towards the first, with a side order of the second. It definitely helps to pick one and set your expectations correspondingly - you can't expect to execute a sketch, or produce an executable blueprint in 3 minutes.

Whether it works for you depends on a bunch of things like:

  • how visual you are as a thinker: people vary very strongly in this.
  • whether you can get an effective tool for free, or from your budget.
  • whether you need to communicate the design to other people
  • if you are effectively using some other means of design (e.g. test driven design).
like image 122
soru Avatar answered Oct 05 '22 11:10

soru


UML is not going to make your code any better, but can improve you vision about what you are doing.

It is not about whether UML is useful or not for writing code, but about UML's REAL purpose, to enable you to picture what you want to do, what the system looks like.

You need a metaphor, a story to communicate your work. Developers who join the project later on will need this to better understand your code, to have the right context when looking at the details and to ultimately not break stuff.

Don't let yourself be fooled by tools. UML is not a solution per se, it is just one formalized way to tackle a common problem: writing sound systems.

like image 39
raoulsson Avatar answered Oct 05 '22 12:10

raoulsson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!