views:

148

answers:

5

Let's say I've made a list of concepts I'll use to draw my Domain Model. Furthermore, I have a couple of Use Cases from which I did a couple of System Sequence Diagrams.

When drawing the Domain Model, I never know where to start from:

  1. Designing the model as I believe the system to be. This is, if I am modelling a the human body, I start by adding the class concepts of Heart, Brain, Bowels, Stomach, Eyes, Head, etc.
  2. Start by designing what the Use Cases need to get done. This is, if I have a Use Case which is about making the human body swallow something, I'd first draw the class concepts for Mouth, Throat, Stomatch, Bowels, etc.

The order in which I do things is irrelevant? I'd say probably it'd be best to try to design from the Use Case concepts, as they are generally what you want to work with, not other kind of concepts that although help describe the whole system well, much of the time might not even be needed for the current project. Is there any other approach that I am not taking in consideration here? How do you usually approach this?

Thanks

+2  A: 

I think the place to start would be whatever feels logical and comfortable. It's probably best to start with the use cases, as they give you clear direction and goals, and help you avoid YAGNI situations. Given that you should be trying to develop a strong domain model, it shouldn't really matter, as the whole picture of the domain is important.

Luke Schafer
So, even if I don't need a heart should I add it to the domain model for completeness sake?
devoured elysium
if it serves no purpose other than completeness, I would say this: add it to the domain model, BUT, this does not mean 'code it'... does that make sense? The domain model is a concept and common language, not a set of classes. Hope I've been a help.
Luke Schafer
Hmmm, I get it.
devoured elysium
this question is as vague as this answer... what is the "domain model"? DDD domain model? business model? analytical class design?
Gabriel Ščerbák
It seemed to me he was implying a DDD-style model. You're right though, I can't really give a concise answer to a vague question... all I can do is try to help.
Luke Schafer
+4  A: 

Whether DDD, or not, I would recommend with determining the ubiquitous language (UL) by interviewing the product owner(s). Establishing communication in a way that will have you and the product owners speaking the same language not only aides in communication, but being able to discuss the project in common terms tends to help the domain model define itself.

So, my answer is basically to discuss, listen, and learn. Software serves a need. Understanding the model from the viewpoint of the experts will lay the solid groundwork for the application.

joseph.ferris
Indeed. Making sure that two people speak the same the language and understand each other is probably the most important step before going into analysis.
James P.
+1  A: 

I'd start by a drawing a class diagram with all the relationships and implement only the classes that are necessary according to the requirements of your application.

You can use an anemic approach (attributes plus getters and setters) to keep things simple and avoid the step of writing business logic in the same step. With an anemic model, the logic would go into a corresponding Service class. That way you can consider Use Cases later on.

I know some people don't appreciate this way of doing things but it does help with maintenance and avoids some dependency issues.

Answer to devoured elysium's question below:

In terms of analysis, starting with Use cases (What) and then proceeding to the class diagram (How) sounds like a good rule of thumb. Personally, I'd do the Sequence diagram (When and Who?) afterwards as you'd need to know between which processes/objects messages need to be sent.

Beyond that my take on things is that UML is simply a way to model a system/projet and not a methodology by itself (unlike Merise, RAD, RUP, Scrum, etc.). There is nothing stopping someone starting off with any diagram as long as they have the sufficient information to complete it. In fact, they should be done simultaneously since each of the diagrams is a different perspective of the same system/projet.

So, all in all it depends on how you go about the analysis. During my studies I was taught the the rigid waterfall approach where you do a complete analysis from start to finish before producing some code. However, things can be different in practise as the imperative might be to produce a working application in the least time possible.

For example, I was introduced to the Scrum methodology recently for an exercise involving the creation of a web site where people can post their fictions (see http://www.tome1.net/). As there was a time constraint and a clear vision of what should be achieved, we started right away with a barebones class diagram to represent the domain model. The Use cases was then deduced from a series of mock screens we'd produced.

From memory, the classes were Story, Chapter, User and Category. This last class was phased out in favour of a more flexible Tag class. As you'd imagine, the complete class diagram of the existing project would be much more complex due to applying domain driven design and the specificities of the Java programming language.

This approach could be viewed as sloppy. However, a web site like this could easily be made in a couple of weeks using an iterative process and still be well designed. The advantage it has over the waterfall approach is that you can continually adjust requirements as you go. Frequent requirements changing is a reality as people will often change their minds and the possibility of producing a working application after each iteration allows one to stay on course so to speak.

Of course, when you're presenting a project to a client a complete analysis with UML diagrams and some mock screens would be preferrable so they have an idea of what you're offering. This is where the UML comes in. Once you've explained some the visual conventions, an individual should be able to understand the diagrams.

To finish off, if you're in the situation where you're trying to determine what a client wants it's probably a good idea to gradually build up a questionnaire you can bring with you. Interviewing a person is the only way you can determine what concepts/features are really needed for an application and you should expect to go back in order to clarify certain aspects. Another tip would be to do some quick research on the web when you're confronted with a subject matter you're unfamiliar with.

In your example, this would be to go through the basics of anatomy. Among other things, this will help you decide what the model should contain and what granularity it should have (What group of organs should be considered? How precise does it need to be? Do only the organs need to modelled or should they be decomposed into their constituents like tissues, cells, chemical composition, etc. ?).

James P.
But isn't the point of the whole analysis and design process doing the domain model to only AFTER do the class diagram? The class diagram should be the result of analysing use cases/system sequence diagrams/id's.
devoured elysium
I added to the answer. It's just a point of view but I hope it'll help you decide what approach you're comfortable with.
James P.
A: 

I would like to share my experience for such type of situations. I usually start with writing tests and code. And try to cover one end to end use case. This gives me fair enough idea about problem and at the end I also have something working with me which I can show case to my client. Most of the time subsequent stories build on top of previous one, but it also happens to me that subsequent stories require changes in the previous model I came up with. But this does not impact me as I already have good test coverage. In this way I came up with the model which fits for the current problem, not the model which maps the real world.

Amit Goyal
A: 

You start with Business Requirements which can be formalized or not. If formalized you would use Use Case Diagrams.

For example here are use case diagrams for an e-commerce app: http://askuml.com/blog/e-commerce/

From these use cases, you can naturally deduce the business entities: product, category of product, shopping cart, ... that is start to prepare class diagrams.

This is best practice in many methodologies but this is also just common sense and natural.

Rebol Tutorial