33

The three links Association, Aggregation and Composition form a kind of scale on how closely two classes are related to each other. On the one end of the scale, there is Association, where objects of the two classes can know about each other, but they do not affect each others lifetime. The objects can exist independently and which class A object knows ...


21

These functions both have to do with collisions, but what they do is very different, so giving them names that more clearly describe what they actually do will make it easier for future developers to understand the difference without having to look at the logic inside. The method that checks if the object is colliding with another object could be called ...


12

Exactly those classes which are necessary to understand the aspect of the system which that particular class diagram depicts. It could be the entire domain model, or all classes that make up the external API of a particular layer or subsystem, or whatever you think is important. But note that class diagrams are not the only type of diagram, nor the most ...


11

Composition is when an object A contains object B and the object A is also responsible for creating the object B. Composition relationship We have a class A which will be used by class B. final class A { } There are multiple options as how the composition may look. Direct initialization composition: final class B { private $a = new A(); } ...


10

UML is just a language to draw pretty pictures with some chance that others understand what the shapes mean without an extensive explanation from you. UML does not tell you which diagrams to use in your analysis and design of a system, nor in which order diagrams should, or even can, be used. Which diagrams to use depends mostly on the information you want ...


9

It makes no sense to say that a class can implement an interface. Either it does or it doesn't, and that's determined as the code is written. Specific instances (users) can't make that decision for themselves, although they can set an IsAdministrator flag instead. If the IsAdministrator flag is insufficient, then (as @superM said) the design you want is ...


9

No, it's much faster to write code than to draw diagrams on a computer. To generate a Java class from a diagram you would have to draw the diagram, and then type in most of the code anyway. Sure, you might not have to type get/set methods, but Lombok does a better job of solving that problem. For example, it's much easier to simply type "class X ...


8

A server or database doesn't go into a class diagram. A class diagram, at the highest level, shows the classes and their relationships with each other. Adding more detail would first indicate public members, and even more detail would indicate private members of the class. You may show classes that interact with the database (your data model, as an example), ...


8

You're partially right: the problem exists in the case of the multiple inheritance too, but can easily be solved in some languages; diamond, on the other hand, cannot be solved that easily. In C#, multiple inheritance is forbidden, but a class can implement multiple interfaces. Imagine that the class Example implements IModifiable and ITransformable. Those ...


7

I think the last few years have shown a preference for using class diagrams to document existing code as opposed to generating code. Diagrams give the reader of the code a quick look at the overall structure of the systems in terms of its classes and relationships. Of course, the successful use of diagrams is dependent on the diagrams being kept in sync ...


7

You can add an open arrow head to the composition or aggregation line, pointing toward the child to indicate directionality in the relationship. If the child knows about the parent, then simply don't include an arrow at all. I believe this works, because composition is a stronger form of an association link. The diamond indicates a composition or aggregation ...


7

[Disclaimer: I'm not a UML jockey, so don't take my word for it.] I think, it would look like this. Some details omitted for brevity.


7

System architecture describes the components of the system. For example you might have an order entry system that consists of: Web Front End, Business Layer Service, and Data Store. So, you should a high level diagram showing this. Software application architecture describes the architecture of a particular component. For example, one of the ...


7

In a class diagram, you don't typically show the functionality of a particular method. That's not the purpose of a class diagram. You're right that you can use Object Constraint Language or pseudocode in a note, but I don't think this is done often. Consider the mode in which you are using UML. If you are using UML as a blueprint, you're going to want the ...


6

UML is not one of these mathematical computation models that try to achieve completeness with a minimal set of rules(like Turning machines or lambda calculus). UML is a visualization of software architecture and flow. It is not used for proving - it is used for understanding. Yes, using 1..* forces a child to exist for the duration of it's parent's lifetime(...


6

Can a class inherited an implementation of interface ? The interface realization expresses that a class X implements a an interface I. Class X can then, like any other class be specialized further by letting other classes inherit from it. Your UML diagram You could therefore have an interface Contract, and have several implementation such as ...


6

The only principle which is not respected here is the Interface Segregation Principle: E-book inherits stock and replenishStock() which are absolutely useless for an electronic book. If you want to have a proper segregation of interfaces, you'd need something like the following, where Book describes a content, and PaperBook and e-Book correspond to ...


6

Bart van Ingen Schenau's answer is right in that UML is just a language and not a methodology. However, there are some methodologies that are built around tools (including UML), such as the Rational Unified Process. Different UML diagrams are used throughout the different phases of RUP. It's not really possible to specifically say how you can fit graphical ...


5

Show them if and only if they help understanding whatever aspect of the system that diagram is supposed to show. UML is a tool for communication. If you can't say what a diagram communicates, you shouldn't have that diagram.


5

What you want is a Decorator. An Administrator would be a subclass of User, and its primary member attribute would be a User object. Thus a Student Adminstrator would be an Administrator containing a Student (which is a subclass of User, right? The Administrator-specific attributes are set in the Adminstrator class, with the User methods passed through ...


5

The level of abstraction provided by Entity Relationship Diagrams created with modeling tools, the entity model provided by EF, and UML class diagrams is almost the same. When I create my POCO entities I generally put them in my Model project with my other domain classes, and so a class diagram of the domain model contains the same POCO entities found in the ...


5

Your external API (the connection to the content management system) is not a class, it's an interface. As illustrated in this Stack Overflow question, it would look something like this:


5

I am doubting what I should name my association. Should it be "a flight has * stewards"? Or should it be "a steward works on many flights"? Usually, the more specific you can name your association, the better, because a more specific name conveys more information. On the other hand, if you are using a directional association (you put an arrowhead on one ...


5

You could represent the annotation as a stereotype, and then apply the stereotype to the class. +----------------------+ | <<SuperSpecial>> | | MyClass | +----------------------+ If your annotation has attributes, you can represent them as tagged values on the class. Tagged attributes have different syntax in ...


5

I'm sorry, but I have to inform you that there is no "correct" or "wrong" in class designs. You can do "wrong" UML by drawing strange unicorns into the diagram, but whether your design is good enough depends on a large amount of different factors. It's not as easy as simply telling us one requirement and expect to be able to derive a design from that. The ...


5

However, I am still unsure how or where I am supposed to describe the functionality that a method of a class offers. This is a valid concern. I should be able to look at your UML diagram and have a fairly good idea what the methods do. In code, I would simply put a docblock above a method in which I describe that method's purpose. Where would I put that ...


5

Navigability means according to the UML specifications: that instances participating in links at runtime (instances of an Association) can be accessed efficiently from instances at the other ends of the Association. The precise mechanism by which such efficient access is achieved is implementation specific. If an end is not navigable, access ...


5

A use case diagram in UML shows two things the actors that interact with the system the reason why each actor interacts with the system (i.e. the use case) Most importantly, a use case diagram does not show what an interaction looks like or what steps might be involved. For the vending machine you described, there are two actors and two use cases: The ...


5

Use case diagrams describe the whole systems behavior of how it interacts with the outside actors. These are documents1 made during the requirement analysis phase, and done independently (and before) any architectural and technical descisions are made about the concrete implementation. Modules and classes are architectural and technical aspects of an ...


5

The only UML diagram this is likely to apply to is the Class Diagram. In a class diagram, the constructor is treated as merely another method. It is sometimes prefixed with <<create>>, or the return type omitted, to indicate that it is a constructor; but it is a method like any other nevertheless. In a typical UML class diagram, methods are ...


Only top voted, non community-wiki answers of a minimum length are eligible