1 of 24

Programming Languages/Software Engineering

Reengineering and Refactoring

Credits: Slide content may contain repurposed material originally by Ian Sommerville.

2 of 24

Inaugural Work on Refactoring

2

Credits: Slide content may contain repurposed material originally by Ian Sommerville.

3 of 24

Type Inference-based Refactoring

3

Credits: Slide content may contain repurposed material originally by Ian Sommerville.

4 of 24

Constraint-based Refactoring

  • Frank Tip, Robert M. Fuhrer, Adam Kieżun, Michael D. Ernst, Ittai Balaban, and Bjorn De Sutter. 2011. Refactoring using type constraints. ACM Trans. Program. Lang. Syst. 33, 3, Article 9 (May 2011), 47 pages.
  • Friedrich Steimann. 2018. Constraint-Based Refactoring. ACM Trans. Program. Lang. Syst. 40, 1, Article 2 (January 2018), 40 pages.
  • Raffi Khatchadourian and Hidehiko Masuhara. 2017. Automated refactoring of legacy Java software to default methods. In Proceedings of the 39th International Conference on Software Engineering (ICSE '17). IEEE Press, Piscataway, NJ, USA, 82-93.

4

Credits: Slide content may contain repurposed material originally by Ian Sommerville.

5 of 24

Software reengineering

  • Restructuring or rewriting part or all of a legacy system without changing its functionality.
  • Applicable where some but not all subsystems of a larger system require frequent maintenance.
  • Reengineering involves adding effort to make them easier to maintain. The system may be re-structured and re-documented.

5

Credits: Slide content may contain repurposed material originally by Ian Sommerville.

6 of 24

Advantages of reengineering

  • Reduced risk
    • There is a high risk in new software development. There may be development problems, staffing problems and specification problems.
  • Reduced cost
    • The cost of reengineering is often significantly less than the costs of developing new software.

6

Credits: Slide content may contain repurposed material originally by Ian Sommerville.

7 of 24

The reengineering process

7

Credits: Slide content may contain repurposed material originally by Ian Sommerville.

8 of 24

Reengineering process activities

  • Source code translation
    • Convert code to a new language.
  • Reverse engineering
    • Analyse the program to understand it;
  • Program structure improvement
    • Restructure automatically for understandability;
  • Program modularisation
    • Reorganise the program structure;

8

Credits: Slide content may contain repurposed material originally by Ian Sommerville.

9 of 24

Reengineering approaches

9

Credits: Slide content may contain repurposed material originally by Ian Sommerville.

10 of 24

Reengineering cost factors

  • The quality of the software to be reengineered.
  • The tool support available for re-engineering.
  • The extent of the data conversion which is required.
  • The availability of expert staff for reengineering.
    • This can be a problem with old systems based on technology that is no longer widely used.

10

Credits: Slide content may contain repurposed material originally by Ian Sommerville.

11 of 24

Refactoring

  • Refactoring is the process of making improvements to a program to slow down degradation through change.
  • You can think of refactoring as ‘preventative maintenance’ that reduces the problems of future change.
  • Refactoring involves modifying a program to improve its structure, reduce its complexity or make it easier to understand.
  • When you refactor a program, you should not add functionality but rather concentrate on program improvement.

11

Credits: Slide content may contain repurposed material originally by Ian Sommerville.

12 of 24

Refactoring and reengineering

  • Re-engineering takes place after a system has been maintained for some time and maintenance costs are increasing. You use automated tools to process and reengineer a legacy system to create a new system that is more maintainable.
  • Refactoring is a continuous process of improvement throughout the development and evolution process. It is intended to avoid the structure and code degradation that increases the costs and difficulties of maintaining a system.

12

Credits: Slide content may contain repurposed material originally by Ian Sommerville.

13 of 24

Research on Refactoring

  • Two parts: Preconditions and Transformations.
  • Preconditions are conditions that must be met in order to likely maintain semantics preservation.
  • Transformation is done after preconditions are met.
  • Preconditions are usually the most challenging but transforming in a way that is similar to what a human would do can also be non-trivial.

13

Credits: Slide content may contain repurposed material originally by Ian Sommerville.

14 of 24

Type Inference-based Refactoring

  • Jens Palsberg and Michael I. Schwartzbach. 1994. Object-Oriented Type Systems. John Wiley and Sons Ltd., Chichester, UK.
  • Use a type-checking approach, which is a form of type inference.

14

Credits: Slide content may contain repurposed material originally by Ian Sommerville.

15 of 24

15

Credits: Slide content may contain repurposed material originally by Ian Sommerville.

16 of 24

16

Credits: Slide content may contain repurposed material originally by Ian Sommerville.

17 of 24

17

Credits: Slide content may contain repurposed material originally by Ian Sommerville.

18 of 24

18

Credits: Slide content may contain repurposed material originally by Ian Sommerville.

19 of 24

19

Credits: Slide content may contain repurposed material originally by Ian Sommerville.

20 of 24

20

Credits: Slide content may contain repurposed material originally by Ian Sommerville.

21 of 24

21

Credits: Slide content may contain repurposed material originally by Ian Sommerville.

22 of 24

22

Credits: Slide content may contain repurposed material originally by Ian Sommerville.

23 of 24

Worklist-based Algorithm

23

Credits: Slide content may contain repurposed material originally by Ian Sommerville.

24 of 24

Constraint-Based Refactoring

  • Use constrain “templates” that encode the semantics of the language in some sense.
  • Type constraints express type relationships between various entities in the program.
  • Generate constraints using templates on an actual program.
  • Receive a system of constraints.
  • Can solve the system for useful information.
  • Can use the constraints to check that a transformation is semantics-preserving (i.e., no violations).

24

Credits: Slide content may contain repurposed material originally by Ian Sommerville.