Hot answers tagged class-diagram
10
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 ...
6
In a class diagram, you don't show the act of instantiation. That is something that a sequence or communication diagram would show. Class diagrams show the static structure of a system.
If a class A "depends on" a class B, then you could look at the association and dependency relationships. Dependency is the weaker of the two and is usually used if the ...
4
I annotate the line with "*..*". For 1-to-many it would be "1..*". It's a standard way of denoting multiplicity.
http://en.wikipedia.org/wiki/Cardinality_%28data_modeling%29
http://www.agilemodeling.com/artifacts/classDiagram.htm
3
Normally, you have two classes in your diagram: Order and Product.
As an order usually means that the customer has ordered 1 or more (1..*) products, you model this by creating an association from the class Order to the class Product.
This coincides with adding a collection of Product instances to your Order instances, i.e. most code generators will give ...
3
You can draw an UML sequence diagram out of this easily, but a class diagramm won't tell you much, except for some logical errors.
Let's draw up a sequence diagram first:
Now, let's remove Factory for a moment, what do we have?
Hmm, are we sure we're missing something?
Basically all your Factory module does is, it shortens a namespace into its last ...
3
Isn't using an interface for this type correct?
Using an interface in this case would work, but you would have to duplicate behavior between Directory and File (like having a maximum of 256 chars for the name). You would be better off making FileSystemElement an abstract class (assuming your language of choice supports it) Which also answers your second ...
3
First point: this is fairly non-trivial. Second point: the fact that the Java environment makes the Java compiler directly available will help a lot in implementing this. I believe you should be able to collect most (all?) the information you need by walking the AST with the compiler tree API. At least from the looks of things, the part you'll care the most ...
2
If it's a case of just UML homework, Yannis and Emmad are spot on with regards to technical aspects and you just re-model it with their input.
Coming to the functional part, my suggestion would be
Visit Barnes and Noble and follow the links to get a better understanding of how book sites function. You got to know it to model your system
You cannot have ...
2
In order to better discuss the image, I annotated your image with some numbers. Hopefully this will help me be more clear in my writing.
There are really three types of lines used here - association (1), composition (4->2), and inheritance (3).
A solid line connecting two classes, such as between Client and BookComponent is simply an association ...
2
Your picture shows several different relationships.
The relationship between the Client and BookComponent classes is a Containment relationship. I.e. the Client Contains an instance of BookComponent.
BookComposite and BookComponent has two relationships the open arrowhead is a Generalization relationship (i.e BookComponent generalizes BookComposite or in ...
2
You can use an association class as depicted e.g. here: http://www.agilemodeling.com/style/classDiagram.htm
Using a new class and two associations inbetween like user1598390 described is valid as well. It depends how you would like to see the relationship between your entities. UML-wise association classes are probably more concise. Regarding the ...
2
Often times many to many associations indicate the need for a third entity.
You need InvoiceDetail entity.
Anyway "count of each good" should be a method in class Invoice.
public int getCountOfGood(Good good);
there can also be a method that returns a data structure with the count of each distinct Good in the Invoice
public ...
1
An association links one class to another to indicate a relation between them. For example, you have an association between Customer and Order which (with no further information) indicates that:
A customer can have an order or maybe several orders,
An order can belong to a customer or maybe shared by several customers.
The diagram in your question gives ...
1
First of all, you are not limited to one class diagram. You can have as many diagrams as you want! the purpose of the class diagrams is to help you (or someone else) understand the system better, so it is mostly a problem of taste. Some people need to see all of the details to understand the structure of the system and so they need one big class diagram. But ...
1
Your company has products it sells to customers. It does this through line-item records on invoices which associate a product and a quantity to the invoice. A typical schema might look something like this:
1
You should include all classes in your program, as a class diagram is suppose to describe the entire structure of your program/application.
However, in many applications this process could turn quite complex, so try to isolate the main components (Data Access Layer, Service Layer, Business Layer, etc.) and graph them independently, with proper ...
1
The one-to-many relationship between Order and Product translates as a list of Products. For example in Java Order would have a member of type List<Product>.
But I recommend having an OrderDetail class instead because you will soon find that you have to have and amount or quantity of the product, and it doesn't belong in either Order or Product.
...
1
I do not know how it would handle the Products
Assuming that you are modeling this to generate RDBMS tables, you would generally use 2 separate classes. The 'child' class would have the Product attributes plus the Product_Id acting as a 'foreign key'. The other class is your Order class.
The diagram in the answer of @Esther Fan - MSFT in ...
1
"I am drawing a class diagram ... Should I show the table created supplier_product ? "
The many-to-many relationship is part of your class design. The join table is not; it is created incidentally by the OR mapping framework. Include the relationship. Do not include the table, or any other generated artifact.
1
It depends on the business. On our business you can get the same spare part from multiple suppliers and each and every one has its own internal item code. So we have our own product item master which holds our code with the relative data.
Then there is the supplier master table with the suppliers.
Finally a Cross reference table exists where you bind one ...
1
In contrast to Emmad, I see a lot of things you don't need. There's no point in developing any kind of UML model until you have specific use cases to drive the modelling. If you just need to do inventory management, then you don't need information about price, or genre, or even author. You need some identifier (ISBN?), the reorder policy, and the source.
...
1
I am not sure if this is a homework or a real system. Anyway, I see that it is missing a lot of things. Models for real applications must be comprehensive and complete.
The purpose of the system must be identified so that it can be judged. Any way, several things are not correct with this model. I will list some of them only:
The classes: Authors, ...
1
I have some experience with code generation, significantly less with diagramming. I have a few suggestions:
I notice you use human readable text. I suggest googling for Inflector.java and choosing an appropriate implementation. This will also help with variable names for unlabelled relationships between classes (pluralization gives you List<Foo> foos ...
1
An option would be to show a subset of Package2 on the diagram for Package1. In this case, you would show Package2 and ClassE, but not at full detail. Don't include any private or protected members, and consider not even showing public members for ClassE on the diagram for Package1. Depending on how they are structured, include a note or reference to the ...
1
I agree with @Thomas Owens that class diagrams in UML are not meant to show instances in general. However, I must add that UML does provide mechanisms to depict instantiation:
the InstanceSpecification element provides a way to model instances, such as alpha in your example.
the dependency notation (a dashed arrow with plain arrowhead), flowing from the ...
Only top voted, non community-wiki answers of a minimum length are eligible