I would like to know if somebody has a good sample about how to organize a UML class diagram when using Domain-Driven Design.
I really don't know how to make fit entities with repositories and services.
The UML diagrams that I end up with for DDD are usually hand drawn, informal and don't strictly adhere to all the guidelines. From the perspective of UML, entities, repositories and services are all simply classes; classes could be marked with a stereotype for clarity.
Furthermore, I don't place too much emphasis on class diagrams alone. It is often more fruitful to consider the model from a behavioral perspective, which is where sequence diagrams can be helpful, though they can quickly become too technical. Class diagrams can help you identify aggregates and entities, but they can also lead you astray by placing too much emphasis of the nouns as opposed to the verbs.
Another important type of diagram in DDD is a context map which can be viewed as a class diagram for bounded contexts. There aren't any explicit UML practices for expressing context maps and as a result an informal approach works best.
Overall, what has worked for me is low friction, low ceremony, and informal. Use boxes to represent concepts and lines between them to represent relationships. Anything beyond that can certainly be helpful but it shouldn't be at the cost of the other aspects.
You should also understand the purpose of the diagram. Are they for facilitating the design and modeling process? Are they for documentation? For sparking conversation? For communication? Each of those reasons may have specific constraints.
my suggestions: build stereotype for each DDD building block (e.g. <>, <, <> e.t.c.), sign each class by one of this stereotypes, use only "use" connection... (composite only for aggregate)
Related
Suppose I draw an UML class diagram representing the class and interface structure of my project. Are there any methods to assess the UML design before actually creating those classes and interfaces?
Example: It is known that the diagram below will lead to diamond problem. And must be changed or handled.
UML is a powerful design language. It is programming language independent (although it has a bias towards class based languages) and thus allows to design things that are not implementable in some languages but trivial in some other languages.
The real question is what you expect from assessment:
syntactic and semantic validity of the model with regard to its compliance with the UML specifications? In your diagram, you use void type, which does not belong to the primitive types of UML. It's a language dependent type.
completeness and accuracy of the model, with an eye on potential ambiguities and missing informations? In your diagram, Animal.eats() may for example be {abstract}. But is the absence of this information an indication that it's not abstract ?
evaluation of the class design, such as for example its complexity, the deepness of the inheritance, the intensity of relations, mutual dependencies, etc... ? But how can this help to spot a bad design, when some domains are just inheriently complex ?
feasibility? UML allows for multiple inheritance, but does not precisely define the semantics behind it. For instance, in C++ you can very well cope with this design with the virtual inheritance of Animal. In Java, multiple inheritance is forbidden and this would not be implementable as such (you would need to alter this model to introduce an interface and use interface realization). Now here, we will not reopen the debate about MI.
A systematic review of of diagrams is done here everyday. The goal of such assessment is to see if the notation is consistent with the UML specification, and eventually with the constraints of the chosen UML profile. There are some research papers that explore the automation of such consistency assessments.
Design is currently not highly automated; There is therefore no systematic method to assess the design as far as I know.
There are some general metrics (e.g. CK metrics) and some of these can be calculated for UML class diagrams (e.g. only 3 out of 6 CK metrics for example). Metrics are not assessments, but they can help an analyst in this task.
I need insight on how much UML to teach. I'm an adjunct for a "2-credit 100-level introductory course" on systems analysis and design (a contradiction in terms to me). The text is written for the typical 300-level 3-credit class. This chapter covers ~7 UML diagrams, it's already extremely simplistic, and I have to strip it down further. I have one week, or two class hours, to cover it.
I've concluded I can either trash the book and cover class diagrams well, which would introduce them to a lot of basic OO concepts, or I can simply aim for basic recognition of these 7 diagrams (not even expecting them to create any). But I feel like basic recognition would so totally skim the surface as to be useless for these brand-new programmers and the diagrams would run together meaninglessly. Advice greatly appreciated.
The 7, by the way, are: object relationship, use case, class, sequence, state transition, activity, and business process modeling.
There are several UML elements that map easily to code and are therefore straightforward to use as design elements.
Package diagram (translates to namespaces).
Class diagram (translates to classes in OO languages).
State machine (translates to any number of state-based implementations).
Sequence diagram (shows chronology of method invocations).
I would say that this is the minimum useful set of UML elements to teach. If you have time, I would also encourage people to learn use case diagrams, although many people find text documents just as effective for that type of analysis.
I would recommend to focus on class diagrams. They are the most useful type of UML diagram for analysing, designing and documenting (the information, or state, structure of) a software system. You could show how class diagrams define
the properties of an object type, both data-valued attributes and object-valued reference properties (representing unidirectional associations).
if a property is single-valued or multi-valued (by its multiplicity)
other property constraints
inheritance relationships in class hierarchies
You could show how classes can be used for conceptual information modeling (also called domain modeling) in the analysis phase, where they define the real-world object types, and for design modeling in the design phase, where they define platform-independent computational constructs to be implemented in some target programming language.
Please help me know as to when it(uml) is necessary. I was told that generally UML are drawn for web based application developement, for desktop based, DFDs and ERDs are used. My university requires all the diagram(uml,dfd,er). please let me know if my information is correct? Thank you
UML Diagram are imporant because it help the person to understand the relationship and dependency between different class present in the code(Class Diagram).
Flow of the program(Sequence Diagram , Activity Diagram).
Help to improve the program architecture etc.
And read about different type of UML diagram you will get more information.
Your needs in using UML depends on your position and your (self)education.
Some companies use UML. So, you would need it to get a job in them. Just now your university requires UML diagrams, so there IS a need in them, isn't it?
If you know UML a bit, you could understand the thoughts of your colleague who wants to share them with you this way.
If you understand the language of a UML diagram, you can use it for improvement of your thinking on the problem. So, you can think into the problem deeper and faster than without a tool. You should be really well acquainted with the tool though, for when inventing something new, you need to think on the domain problem, not on the language problems. But you don't need to know all the rules for this level of use yet.
If you know UML so that you can draw diagrams up to their strict rules, you have two more uses of it.
Translating your knowledge of the problem from one level of abstraction to another and modelling these levels up to the strict rules, you are filtering many misunderstandings in the already accepted model and can practically debug the model before coding. It can save much time and money.
While you are making the diagrams according to strict rules, you can collaborate on the model with your colleagues. It is always better if you can express your ideas more precisely.
As for technology limitations, you can use UML very widely, even out of the IT needs. As for IT, only GUI creation is supported badly. And anonymous classes are almost not supported in class diagrams at all (in behaviour diagrams they work OK).
DFD (datya flow diagram) and ERD (entity relationship diagram) diagram are tools for structural analysis and design, this is way to build structural application (data bases and functions). UML support quite different paradigm: object paradigm - we build application as collaborating objects. DFD and ER (ERD) diagram is not part of UML. We can use ER diagram for data base modeling and join to UML domain model by the ORM (object-relational mapping, implemented e.g. by Hibernate).
I am not sure if this is a good question as I'm unsure if there's any agreement on the subject. However due to the lack of information in the internet I'm compelled to ask anyways.
Let's say I'm making a system that is mainly object-oriented, with its corresponding UML diagrams (use-case, class, colaboration, etc). However, none of the UML diagrams are helpful when dealing with the database, which should be relevant for the developing team so they can know what exists in the database and what does not.
There are two ways to represent a database: Entity-Relationship and Relational (it's unknown to me if there are more, but those two are relevant within the relational database paradigm). ER deals with the representation of the BD in terms of business rules, and Relational deals with the actual, physical implementation. But none are "UML standard" (unless I'm missing something here).
Which modeling should I use, and why? Is ER relevant in terms of UML, or should I stick to relational? Thank you beforehand.
If you want to use UML only, you could use limited class diagrams - without m-n associations and methods. But if you are using some class-table mapping tools, you can use anything, except m-n relationships only.
Nobody had ever said that you can use Class diagram for OOP classes only. You can use them for any more or less formal concepts, if their needs can be covered by the complex of CD elements. I use class diagrams for UI planning and even formal text planning. And tables are very close to classes. So, no problem.
You can use data model diagrams, if you need something that is CALLED data diagram. But they are covered by class diagrams fully. That is the reason they are not supported anymore.
Your task is to make the model understandable for everybody, who can get it in hands. Class diagram is the most widely known UML diagram. A good title and a pair of comments will resolve all possible misunderstandings.
Both are different ER diagrams are relationship of entities and UML diagrams are behaviour of Ojects how they communicate with each other, as per my view point DFD (data flow diagram) is option. It has different levels which is based on number of processes and will better explain about data entities.
I'm currently working on a project for my university and one teacher told me I was wrong to think that there could be classes in a UML class diagram (thinking of it as a design diagram) to which there would be no equivalent in a data model. He then pressured me to provide a counter-example to prove my point but I just couldn't think of one.
I checked a few books I had about UML like "Learning UML 2.0," "Applying UML and Patterns" and UML 2 for dummies, but I couldn't find any information regarding which classes appear on a class diagram. I asked him about implementation classes but he told me that they shouldn't be included in a class diagram. So I'm at a loss here.
I also checked this questions before posting:
Differences between a conceptual UML class diagram and an ERD?
Generate UML from a conceptual data model
how to relate data with function in uml class diagram
But they don't really solve the question I have.
Thanks for any insight you might have.
Both your teacher and you are unnecessarily distracted by the differences between UML and conceptual data modeling (which I take to be tantamount to ER modeling). The real issue you and your teacher are discussing is the difference between analysis and design, regardless of the model used.
A UML model can be created that diagrams the problem as stated or that diagrams the solution as designed. In the first case, implementation classes should be omitted, because they do not pertain to the problem domain. In the second case, they should be included. The first case is analysis. The second case is design.
The same ambiguity exists with regard to ER diagrams. Some people, including myself, use ER models and ER diagrams only to represent the data requirements inherent in the problem itself. This is what is most often meant by "conceptual data modeling". In this framework, the only entities that should appear are entities that have a perceived reality in the subject matter itself, and are not merely constructs inside the database or the application(s). This is analysis.
But there are plenty of other people, perhaps a majority, who use ER diagrams to pictorialize the design of a schema of tables. In this framework, foreign keys are included, and junction tables are elevated to the status of entities, even though they are not subject matter entities. There's nothing inherently wrong in this, so long as the distiction between analysis and design is kept clear.
Unfortunately, the distinction between analysis and design is very often obscured beyond recognition. There are dozens of instances of this right here in SO.
So, if a confusion between analysis and design is allowed to creep into the discussion between you and your teacher, the discussion could end up going in almost any direction.
"one teacher told me I was wrong to think that there could be classes in a UML class diagram (thinking of it as a design diagram) to which there would be no equivalent in a data model. He then pressured me to provide a counter-example to prove my point but I just couldn't think of one."
He is right. In the stage of conceptual analysis/conceptual design, those rectangular boxes in a UML class diagram depict "concepts". And whatever the "concept" happens to be, you can always also draw an E/R diagram around it to illustrate (the nature of) that concept, other concepts that relate to it, and what the nature of those relationships is.
From my understanding of UML, it does NOT define what should be in a diagram. I found this example in the IBM site: (image did'nt lode, so here is the link: http://www.ibm.com/developerworks/webservices/library/ws-RESTservices/)
Surely, a servlet is not part of a domain model.
A UML class diagram us used to model classes, which are entities that have attributes and methods. IMHO, it doesn't matter if they are part of the domain model or are functional classes that support the application. If you need to show them to the customer, they must be there.