Is the meaning of "package" the same in UML as in Java?

736 Views Asked by At

For the purposes of a UML Package Diagram should each package in Java be considered a package? In Java each "package" is essentially a namespace and you can have two different classes (eg A & B) both in the same Java package (eg com.example.my) but in different JARs (eg. API & Domain):

Are Java packages the same thing as packages in UML within the context of a Package Diagram? If not, what is the definition of a package in UML?

2

There are 2 best solutions below

0
Rolf Schorpion On BEST ANSWER

Rahman has given a good answer already. One thing I would like to mention, is that UML is programming-language and platform independent. So both definitions of a package are not the same.

An UML package can contain jar files, (as can be seen your example) but it can also contain devices, execution environments and so on.

0
TR1 On

It depends on the design - I don't believe there is any rule saying that Java packages and UML packages need to be mapped one to one - nor there is any rule that says the opposite.

Both Java packages and an UML packages are intended to group similar objects together. But Java packages are for grouping code while UML packages are for grouping models. And the relation between a model and the code implementation doesn't necessarily have to be one to one and neither do their packages.

Source of info: Software Design courses taken at University.