Modelling Legacy Code with UML Sequence ... - Semantic Scholar

4 downloads 0 Views 500KB Size Report
[7] Thompson, John B, Structured Programming with COBOL and JSP, John Barrie Thompsom and Chartwell-Bratt Ltd,. 1989. [8] Yang, H; Luker, P and Chu, W, ...
Appeared in Proceedings of IADIS Virtual Multi Conference on Computer Science and Information Systems (MCCSIS'05), International Association for Development of the Information Society, 2005. (Preprinted-Version)

MODELLING WEB-BASED SYSTEM WITH UML SEQUENCE DIAGRAMS Jianjun Pu, Zhuopeng Zhang, Richard Millham, Yang Xu, Hongji Yang Software Technology Research Laboratory De Montfort University, Leicester, LE1 9BH, England {jjpu, zpzhang, yangxu, [email protected] and [email protected]}

ABSTRACT The research in this paper focuses on the approach to modelling web-based system with UML sequence diagrams in order to comprehend web-based systems. The actors of web-based system are achieved from the outside of web-based system. Human beings that utilise web-based system, hardware that executes it, and other systems that interact with it are served as the actors. All the parameters of web-based system are gathered together and classified into some groups. Each group is refined as one object. Based on the time and sequence, operations of web-based system are collected. Messages of web-based system are distilled from those operations and then the sequence diagrams of web-based system are realised. The key to modelling dynamic aspect of web-based system is to represent the messages of web-based system from those operations. KEY WORDS Unified Modelling Language (UML), Sequence Diagram, Web-Based System, Actor, Object, Message.

1. INTRODUCTION UML sequence diagrams describe interactions of web-based system among objects, which show scenarios of the system behaviour. A simple UML sequence diagram describes exactly one scenario. For describing multiple scenarios and specifying real-time systems, it is necessary to consider the compositions of UML sequence diagrams. The research in this paper concentrates on the approach to modelling dynamic aspect of web-based system with UML sequence diagrams. The actors are achieved from the outside of system. Human beings that utilise system, hardware that execute it and other systems that interact with it are served as the actors. All the parameters of web-based system are gathered together and classified into some groups. Each group is refined as one object. Based on the time and sequence, operations of web-based system are collected. Messages are distilled from those operations and then sequence diagrams realised. The key to modelling dynamic aspect is to represent the messages from those operations.

2. ACHIEVING UML SEQUENCE DIAGRAMS FROM WEB-BASED SYSTEM 2.1. Finding out the Actors The domain of a system is the set of demands allocated to it. It is essential to analyse where the problem is located. Because the software implies business data and rules, the problem analysis is to understand business problems. This is closely related to the business domain. Initial solution boundaries and constraints of software code are defined from both technical and business perspectives, which constitute the program boundary. This boundary is decided by the domain in which place the code performs its tasks. Practically, the same program is used in different software solutions, and the different software solutions are used in different domains. The mapping of the domain to the program results in software programming corresponding to objective reality. The

domain knowledge permeates all of the software including the name of the parameters, the attributes of the procedure and parameters, the operational constrains of execution, and the associations between the elements. The stakeholders that are closely related to the software system serve as the candidates of web-based systems. Different stakeholders means end users, analysts, developers, system integrators, testers, technical writers, and project managers—each brings different agendas to a project, and each looks at that system in different ways at different times over the project’s life. When the web-based system is executed, it may exchange messages with other systems. It may send data to and receive data from other systems, send signals to control other systems, receive signals to be controlled, or be executed by other hardware systems. All these systems are regarded as the candidates of the actors of web-based system. Because the humans are generally the most important users of the web-based system, it is important to take into account the users of the web-based system as the most important candidates of the actors [1]. It is essential to regard one of those interactors as one actor. If there are more than two actors, humans should be considered as the most important actor candidate. Because only the humans can utilise the software directly for their special purposes, it would be better to take into account all the users, the maintainers, the managers of the company, or even the business organisations using the Internet. However, different candidates may be of different importance to the web-based system. The direct end users are the most important among all the candidates of the actors of the web-based system. In most cases, they would utilise the web-based system and determine when it is executed. The operational results are reported directly to them. Then they decide on what should be done next. The next may be the company managers because they not only use the web-based system indirectly but also manage the direct end users of the web-based system in the company. They maybe make some decisions of the web-based business based on the output of the web-based system. Both the direct end user of the web-based system and the company managers use the web-based system for the commercial purposes and in some cases may be the same. The next may be the indirect users and the maintainers. In most cases, they do not use the web-based system for the business purposes in the Internet. Other interactors, except human beings, are considered and chosen as the actors, including the hardware that executes web-based system and other systems that interact with it. These interactors describe the interacting effect and the process of how the web-based system is executed in the hardware and what messages are exchanged with other systems. Any systems that invoke the web-based system are regarded as the candidates of the actors.

2.2. Extracting Objects All the parameters and their corresponding operations of the web-based system are classified into several groups. Each group has one nucleus. Each group is related closely to each other to describe the common core in that group. Although that core is not always obvious, every parameter and related operations are part of the specifications of that nucleus in that group. In every group, each parameter depicts one piece of the characteristics of that nucleus, such as its name, its age, its weight, its height, and its ID; and every operation is the change, assessment, assurance or detection of those pieces of characteristics of that nucleus, such as the reaction of increasing or decreasing its weight, confirming whether it is at a specified age, and determining whether it has another name [9]. It is possible that one operation may be involved in different groups. The best way to dealing with that problem is to separate that operation into different ones, each of which concentrates on only one group [10]. It is important to note that the name of the object, its attributes, and its operations are domain-related [6]. The domain is the place in which the problem is allocated. All the definitions and extractions must be based on the domain knowledge of the Internet and networking. The object model will initially include too many associations if all associations that are identified after examining verb phrases are included. Adding unnecessary associations complicates the model leading to incomprehensible models and redundant information. Most entity objects have an identifying characteristic used to access them. Once the analysis model includes most objects and associations, it is necessary to go through each object and check how it is identified and in which context. This approach can be formalised by examining each individual object and identifying the sequence of associations that need to be traversed to access a specific instance of that object. For identifying attributes, attributes are properties of an individual object. When identifying properties of objects, only the attributes relevant to the system should be considered. It is important to note those properties that are represented by objects are not attributes. An attribute has a name that identifies it within an object; a

brief description; and a type used to describe the legal values it can take. In the case of entity objects, any property that needs to be stored by the system is a candidate attribute. It is important to note that attributes represent the least stable part of the object model. Unless the added attributes are associated with additional functionality, the added attributes do not entail major changes in the object and system structure. It is vital to check the validity of the objects and corresponding operations and attributes. The objects should not overlap. If it happens, the groups are redefined. If one operation on one object contains operation on other object, it is necessary to divide that operation into different parts, each of which focuses on only one object [1] [8]. If the inconsistence occurs in the code where the objects are accessed, it is necessary to restructure the code at a high level and correct those types of logical flaws [2].

2.3. Classifying Calls The call stands for the procedure or function call in the web-based system. The starting point in analysing the structure of the web-based system is to develop a call graph. Examining the calling structure of the web-based system can be used to identify program elements with minimal dependencies that could be migrated easily. Four different kinds of program elements in the web-based system are distinguished: root program elements that call other program elements but are not called by any other program elements; leaf program elements that are called by other program elements but do not call any other program elements; node program elements that both call and are called by other program elements; and isolated program elements that neither call nor are called by other program elements. Leaf program elements are the best candidates for the start point of comprehending the web-based system. They do not call back to web-based source code, and it is possible to minimise the number of these elements by transferring entire subsystem in a single iteration.

2.4. Refining Messages from Web-based System Understanding the operations of the web-based system means to obtain the equivalent but different design from the original code using an intermediate language or representation that has clearer and simpler semantics than the original programming language. It is the essential preparation for the whole process to translate web-based source code into a more understandable style. The representations are structured by the way to organize the data in order that each line of the source code is a meaningful fragment of a program. The isolated program elements are understood at the structural level at first. This will lead to the decline of the complexity and size of web-based system. Then the operations of leaf and node program elements are understood. At last, the root program elements are taken into account. The web-based system is understood over a series of increments, making functionality available. The goal is to break up the migration to the web-based system into small manageable steps, where the objectives of each increment are well defined [5]. Incremental plans are driven foremost by complexity and technical feasibility. It is critical to ensure that the functionality, reliability, and performance of the web-based system are not diminished [7]. When refining the operations of web-based system, the preconditions and post-conditions of each operation are necessary to understand. A message, which goes from one object to another, goes from one object's lifeline to the other object's lifeline. An object can send a message to itself - that is, from its lifeline back to its own lifeline. It is necessary to realise that the timing sequence of operations is used in web-based system [4] [5]. The operations of web-based system are classified into different layers, especially in a web-based system containing node and leaf program elements. They are described in sequence diagrams of that web-based system. Those operations that are similar and work sequentially and together are collected and presented as one message. For example, those three operations to the date “sending the value of the day”, “sending the value of the month” and “sending the value of the year” are extracted into one message that is named as “sending the date”. In web-based system, some kinds of complex computations, especially many mathematical formulas, are represented by the messages in that application domain of Internet. For instance, the formula S=Length1*Length2, is achieved as the message “computing the rectangle area”. Meanwhile, it is fundamental to order the messages of web-based system in sequence diagrams according to the time and sequence they are executed by. The objects from which and to which the message is sent are recorded. It is important to concentrate on the critical operations to refine the messages of web-based system. Not all the operations are treated as messages nor does one operation correspond to one message.

2.5. Realising Sequence Diagram Sequence diagrams are organized according to time. These diagrams show the time flow of messages and present a detailed view of relationships between the objects and message passage. A sequence diagram has two dimensions: the vertical dimension representing time, and the horizontal dimension representing object interaction. A message is shown as a horizontal solid arrow from the lifeline of the sender to the lifetime of the receiver [3]. Layering is a common approach to organizing the web-based systems. As a result it makes sense to layer sequence diagrams of web-based system in a similar manner. That is done based on the layers of the program calls in web-based system. The root program element is regarded as the first and the most important sequence diagram. Other program elements are included in that diagram. The node program elements are presented before the leaf and isolated program elements. The primary actor of web-based system is allocated at the top at the left side of sequence diagram. Other actors follow it according to time and importance. In a sequence diagram, an object receives messages and invokes the operation of time ordering. Only if one message has been executed, the next message can then be performed in a time dimension. Consequently, the time periods of executing the messages by objects are clearly shown on sequence diagrams.

3. A CASE STUDY 3.1. Actor of Message Application Program The sample of a web-based system, which is used in this paper, is called Message Application Program. This program prints the messages from a specified queue. It processes the first 80 bytes only of each message. It produces a report showing all the messages in a specified queue with a specified queue manager. It uses the systematic call to ensure that data is not lost. If the return value is 0, it shows the successful completion; if 4, it indicates parameter errors; if 8, then it indicates error in call. Message Application Program is utilized as the specified message application in bank systems and other commercial areas. The interactors include human beings that utilise that web-based system, the hardware that executes it, and other systems that have interaction with it. The interactor of the Message Application Program is the company employee. The actor of the Message Application Program is the company employee.

3.2. Objects of Message Application Program All the parameters of Message Application Program are classified into following groups. It is not necessary to list all the parameters for the upper layers. For example, the parameters YY, MM, and DD are represented with one parameter DATE. Each group is extracted into one object. The following objects are achieved from those groups. Some of groups are presented as the same objects. For instance, Group 12 and 14 are regarded as the same object DataLine. Group No. 1 2 3 4 5 6

Object Name printing file input data page header a OK message a warning message

Group No. 7 8 9 10 11 12

Object Name a error message message queue manager reason date data line

Group No. 13 14 15 16

Object Name return code data line queue queue

3.3. Operations of Message Application Program Program elements invoke other program elements using the call statement of programming language. The call statement transfers control to another program in the executable image. Message Application Program has its

root program element MAIN SECTION, leaf program elements PRINT-LINE SECTION, PRINT-HEADER-1 SECTION, and PRINT-HEADER-2 SECTION. Part of Operations of Message Application Program is distilled from that system in Appendix A. The achievements of operations are not necessary to use all the work of source code. It is not necessary to utilise all the objects in the operations. For example, that OK message is not presented in the operations because it continues to work if every precondition is fulfilled. When refining the operations of web-based system, the preconditions and post-conditions of each operation are necessary to understand.

3.4. Sequence Diagrams of Message Application Program Messages of Message Application Program are refined from the operations. Sequence diagrams of Message Application Program are realized in Appendix B.

4. CONCLUSIONS The description of a web-based system is complicated. The research in this paper concentrates on the approach to modelling web-based system with UML sequence diagrams. The key to modelling the dynamic aspect of web-based system is to represent the messages of web-based system from those operations. The operations of the web-based system are classified into different layers, especially in a web-based system containing node and leaf program elements. The operations are described in sequence diagrams of that web-based system. Those operations that are similar and work sequentially together are collected and presented as one message. In web-based system, some kinds of complex computations, especially many mathematical formulas, are represented by the messages in that application domain. Meanwhile, it is fundamental to order the messages of web-based system in sequence diagrams according to the time and sequence they are executed by. The objects from which and to which the message is sent are recorded. It is important to concentrate on the critical operations to refine the messages of web-based system. Not all the operations are treated as the messages and one operation to one message.

REFERENCE [1] Booch, G, Rumbaugh, J, and Jacobson, I, The Unified Modeling Language User Guide, Addison-Wesley-Longman, Inc, 1999. [2] D’Souza, D F and Wills, A C., Objects, Components, and Frameworks with UML, Addison-Wesley, 1999. [3] Fowler, M, UML Distilled. Second Edition, Addison-Wesley, 2000. [4] Haajanen, J., Pesonius, M., Sutinen, E., Tarhio, J., Ter¨avirta, T. and Vanninen, P., “Animation of User Algorithms on the Web”, Proc. of the 1997 IEEE Symposium on Visual Languages, pp. 360-367, Sept, 1997. [5] Jacobson, I; Booch, G and Rumbaugh, J, The Unified Software Development Process, Addison Wesley Longman, 1999. [6] Pu, J., Millham, R., and Yang, H., “Acquiring Domain Knowledge in Reverse Engineering The Web-based system into UML”, Conference of IASTED Software Engineering and Application, 2003. [7] Thompson, John B, Structured Programming with COBOL and JSP, John Barrie Thompsom and Chartwell-Bratt Ltd, 1989. [8] Yang, H; Luker, P and Chu, W, “Code Understanding Through Program Transformation for Reusable Component Identification”, 5th International Workshop on Program Comprehension (IEEE IWPC 97), pp. 148-157, 1997. [9] Yang, Hongji et al, “Acquisition of Entity Relationship Models for Maintenance - Dealing with Data Intensive Programs in A Transformation System”, Journal of Information Science and Engineering, Vol. 15(2), p. 173-198, 1999. [10] Zahavi, R, Enterprise Application Integration with CORBA Component and Web-Based Solutions, John Wiley & Sons, Inc, 2000.

Appendix A. Part of Operations of Message Application Program Open the queue If an error occurs

Build an error message and move it into data line Print the line

End-if Get the first message Do while no error Add 1 to relative message number

Move message into print line (max 80 bytes) Print the line (Perform PRINT-LINE) Get next message End-do

Appendix B. Sequence Diagrams of Message Application Program

Suggest Documents