Java Server (.JSP) Files in UML Class Diagrams

I am writing a project for a project I am about to start and I am wondering how I should represent the view (jsp files) in the UML class diagrams that I have created. Since jsp files are not classes that they come in? I would not have thought since this is a class diagram, but I'm not sure how else I am supposed to represent them, any ideas?

+3


source to share


3 answers


It all depends on the context in which you are using the UML.

In UML distilled , Martin Fowler outlines three ways to use UML:

  • Blueprint (UML is used in the software development process).
  • Sketch (UML is used for system detailing)
  • Executable UML (using UML where UML is the permanent source of the program, before code)


Most software development processes (drawing mode) will not allow you to include presentation components in a class diagram for logical reasons: UML near OOP . This is also the case in executable UML, in other words, this is what user1556242 is about .

In UML or executable UML scripts, the only UML diagrams that are allowed to represent presentation components are the component diagram and the deployment diagram : this diagram does not display object-specific functionality.

However, if you are in sketch mode, it is your legal right to include JSP pages in the diagram, but it does not have to be a form of the view component. In a class diagram, you have to represent classes. You do not have to be a JSP page nor its object form. JSP is translated into a servlet class at runtime (see Wikipedia article ), in Tomcat this is done via Jasper .

0


source


JSP files are considered view files, they are not actual functions / methods. Thus, they should NOT be included in UML class diagrams.



+2


source


Sorry, but I don't quite agree with the other answers, speaking from a purely UML point of view. From this point of view, the jsp file is an example of an artifact that is a class type. A jsp file instance is an object that has some kind of "manifest" connection to a servlet (borrowing here from bdulac's answer, I'm not an expert on Java Web stuff).

From the UML specification (Superstructure v2.0, page 193):

10.3.1 Artifact (from artifacts, nodes)

An artifact is a specification of a physical piece of information that is used or created by the software development process, or through the deployment and operation of a system. Examples of artifacts include model files, source files, scripts and binaries, a table in a database system, a development version or word processing document, a mailing message.

Further down:

In the metamodel, an Artifact is a classifier that represents a physical object. Artifacts can have properties that represent the functions of the Artifact and Operations that can be performed on its instances. Artifacts can participate in associations with other artifacts (for example, composition associations). Artifacts can be created to represent detailed copy semantics, where different instances of the same artifact can be deployed to different Node instances (and each one can have separate property values, such as for a timestamp property).

AND:

A user-defined artifact represents a specific item in the physical world. A specific instance (or "copy") of the artifact is deployed to a Node instance. Artifacts can have compound associations with other artifacts nested within it. For example, a deployment descriptor artifact for a component might be contained within an artifact that implements that component. Thus, the component and its handle are deployed to a Node instance as a single artifact instance.

Specific profiles are expected to create artifact stereotypes for modeling sets of files (eg, as characterized by "file extension in the file system"). The UML Standard Profile defines several standard stereotypes that apply to artifacts, such as "source" or "executable" (see Appendix C for standard stereotypes). These stereotypes can be further specialized in implementing and platform-specific stereotypes in profiles. For example, an EJB profile might define "jar" as a subclass of "executable" for executable Java archives.

And, the JavaWeb profile can define "jsp" as a stereotype extending "file".

Finally:

Changes to the previous UML

The following changes have been made from UML 1.x: now artifacts can display any PackageableElement (not just components, as in UML 1.x).

While an artifact often exhibits a component, there is no reason to say it cannot render a class (which is also a "PackageableElement"). That's why they removed the limitation that artifacts could only manifest components. So, purely from a UML perspective, the jsp file is a class and therefore can be part of a class diagram.

Whether it makes sense to do this is another problem, but it is not something to be fired without investigation.

+1


source







All Articles