Case Study: Simulation of a LAN.
- SourceAvailable from: Reiko HeckelElectronic Notes in Theoretical Computer Science 03/2003; 72(4):1-5.
Conference Paper: Extending Graph Rewriting for Refactoring.[Show abstract] [Hide abstract]
ABSTRACT: Refactorings are transformations that change the structure of a program, while preserving the behavior. The topic has attracted a lot of attention recently, since it is a promising approach towards the problem of program erosion. Nevertheless a solid theoretical foundation is still lacking. In this paper we focus on improving the expressive power of graph rewriting rules, so that more refactorings can be expressed by single rules. Two new mechanisms are introduced: a notion of refinement of graphs, enabling one to treat specific substructures (e.g. syntax trees of expressions) as a whole, and a notion of duplication, enabling one to use parts of rewriting rules as prototypes that can be instantiated several times. Both mechanisms can be viewed as ways to specify large or infinite sets of rules in a concise way. It is shown that the refactorings PushdownMethod, ExtractMethod and InlineMethod can be expressed using the proposed techniques.Graph Transformations, Second International Conference, ICGT 2004, Rome, Italy, September 28 - October 2, 2004, Proceedings; 01/2004
- [Show abstract] [Hide abstract]
ABSTRACT: This article proposes a case study to evaluate the suitability of graph transformation tools for program refac- toring. In order to qualify for this purpose, a graph transfor- mation system must be able to (i) import a graph-based rep- resentation of models of Java programs , (ii) allow these mod- els to be transformed interactively with well-known program refactorings, and (iii) export the resulting models in the same graph-based format used as input. The case study aims to en- able comparison of various features of graph transformation tools, such as their expressiveness and their ability to interact with the user. The model of Java programs is presented and some examples for translating Java source code into the model are provided. The refactorings selected for the case study are specified in detail.International Journal on Software Tools for Technology Transfer 01/2010; 12:183-199.
URL: http://www.elsevier.nl/locate/entcs/volume72.html 3 pages
Case Study: Simulation of a LAN1
Dirk Janssens and Serge Demeyer2,3
Department of Mathematics and Computer Science
Universitaire Instelling Antwerpen
Programming Technology Lab
Vrije Universiteit Brussel
The aim of this contribution is to present a case study - the simulation of a
Local Area Network - that has been used at Vrije Universiteit Brussel (VUB)
and the University of Bern to illustrate various aspects of the evolution of
Object-Oriented programs. We believe that it can be useful as a common test
case for the further investigation of this subject. The basic version of the case,
as presented here, is rather simple, but the core features of OO languages are
used in it, and it seems obvious that it can be extended to more complex
versions in a smooth way.
The case is mainly intended to illustrate modeling support for software evo-
lution, and in particular refactoring. It might also be relevant for the domain
of network design. From a programming point of view, the domain is object-
oriented programming. The interplay between incremental development and
refactoring has been explored, using this example, in a number of lectures at
VUB and at the University of Bern.
The case consists of an initial version of the simulation program, and a
series of changes in the specification that require it to evolve. Straightforward
1Partially supported by the EC TMR Network SegraVis (Syntactic and Semantic Integra-
tion of Visual Modeling Techniques) through Universitaire Instelling Antwerpen.
c ?2003 Published by Elsevier Science B. V.
adaptations of the program undermine the original design, and hence refac-
torings are used to improve the structure. As diagrammatic representations
have become a useful element in OO design, it seems natural to extend this
kind of visualization to the topic of refactoring. As demonstrated in our con-
tribution to ICGT , at least some of the refactorings used in the case can
be adequately described by graph grammar productions.
The case requires knowledge of a standard OO programming language,
such as JAVA or Smalltalk. It uses only basic OO programming concepts
such as late binding, dynamic invocation, inheritance, super calls. Concerning
semantic concepts, the case study focuses on behaviour-preserving properties,
which are crucial for refactoring. The relevant meta-level objectives from Seg-
raVis are in the first place M4 (modularity, refinement and transformation of
models), but it may also serve as an example for M5 (integration of visual
modeling techniques) and M6 (integrated meta CASE support). The devel-
opment of suitable graph representations of OO programs may be relevant for
M1 (static and dynamic semantics). The sample code is available at
3 The case study
A simulation of a Local Area Network in a standard OO language is considered.
So far, Java and Smalltalk have been used. Starting from a simple network
(a ring of nodes where a single type of message is transmitted), more complex
versions are developed in an incremental style: extra functionality is stepwise
added, but for each step a straightforward adaptation leads to a program that
can be improved by refactoring.
In the initial version of the program, the simulated LAN is very simple, and
its simulation is straightforward: the network consists of nodes, organized in
a ring. There are two types of nodes (workstations and printservers). Packets
are sent around the ring, and these packets must travel from the worksta-
tion where they originate to their destination (Fig. 1). The simulation pro-
Fig. 1. A simple LAN.
gram consists of the obvious four classes (node, workstation, printserver
and packet), where workstation and printserver are subclasses of node
(Fig. 2). The evolution of the program corresponds to a series of four consec-
utive requirements at the level of the LAN, which must be incorporated into
Fig. 2. The simulation program.
the simulation program. For each of them, a number of refactorings are used.
(i) Provide a logging facility: each time a packet is sent from a node, a
message identifying the node and the packet is printed. (Refactorings:
(ii) Extend the LAN so that documents of different types (Postscript, ASCII)
can be printed on a corresponding printer. (Refactorings: Extract-Superclass,
Pull-up-Field, Pull-up-Method, Extract-Method, Form-Template-Method)
(iii) Printservers need to register the author and the title of the document that
is being printed. (Refactorings: Extract-Superclass, Replace-Conditional-
(iv) Extend the LAN so that messages can be broadcast.
Extract-Method, Move-Method, Inline-Method)
4 Closing remark
We propose a LAN simulation as a case study for the evolution of Object
Oriented programs. In its current form, the case study is too small to serve
as a full-scale experimental basis. However, there are various obvious ways in
which the test case can be improved and extended. To mention but a few,
it would be desirable to use more relevant parts of the UML to express the
specification of the program as well as the new requirements to which it has
to be adapted. Also, if one restricts attention to the refactoring aspect, one
may try to find changes that require, or at least enable one to illustrate, a
wider range of refactoring operations.
 T. Mens, S. Demeyer and D. Janssens, Formalizing Behaviour Preserving
Program Transformations, technical report 02-03, Dept of Math. and Computer
Science, University of Antwerp - UIA, 2002. Also Proceedings of ICGT 2002.