Skip to main content Accesibility Help

Improving Prolog programs: Refactoring for Prolog


Refactoring is an established technique from the object-oriented (OO) programming community to restructure code: it aims at improving software readability, maintainability, and extensibility. Although refactoring is not tied to the OO-paradigm in particular, its ideas have not been applied to logic programming until now. This paper applies the ideas of refactoring to Prolog programs. A catalogue is presented listing refactorings classified according to scope. Some of the refactorings have been adapted from the OO-paradigm, while others have been specifically designed for Prolog. The discrepancy between intended and operational semantics in Prolog is also addressed by some of the refactorings. In addition, ViPReSS, a semi-automatic refactoring browser, is discussed and the experience with applying ViPReSS to a large Prolog legacy system is reported. The main conclusion is that refactoring is both a viable technique in Prolog and a rather desirable one.

Hide All
1995. Information Technology—Programming Languages—Prolog—Part 1: General Core. ISO/IEC. ISO/IEC 13211-1:1995.
Crow, D. and Smith, B. 1992. DB_HABITS: Comparing minimal knowledge and knowledge-based approaches to pattern recognition in the domain of user–computer interactions. In Neural Networks and Pattern Recognition in Human–Computer Interaction, Beale, R. and Finley, J., Eds. Horwood, Ellis, 39–63.
Erlikh, L. 2000. Leveraging legacy system dollars for e-business. IT Professional 2, 3 (May), 1723.
Fowler, M. 2003. Refactorings in alphabetical order. URL: Accessed April 2, 2007.
Fowler, M., Beck, K., Brant, J., Opdyke, W. and Roberts, D. 1999. Refactoring: Improving the design of existing code. Object Technology Series. Addison-Wesley.
Garrido, A. and Johnson, R. 2003. Refactoring C with conditional compilation. In 18th IEEE International Conference on Automated Software Engineering, Kirchner, H. & Ringeissen, C., Eds. IEEE, 323–326.
Hermenegildo, M. V. 2000. A documentation generator for (C)LP systems. In Computational Logic – CL 2000, First International Conference, London, UK, July 2000, Proceedings, Lloyd, J., Dahl, V., Furbach, U., Kerber, M., Lau, K.-K., Palamidessi, C., Pereira, L. Moniz, Sagiv, Y., & Stuckey, P. J., Eds. Lecture Notes in Artificial Intelligence, vol. 1861. Springer Verlag, 12551269.
Intelligent Systems Laboratory. 2003a. Quintus Prolog User's Manual. P.O. Box 1263, SE-164 29 Kista, Sweden.
Intelligent Systems Laboratory. 2003b. SICStus Prolog User's Manual. P.O. Box 1263, SE-164 29 Kista, Sweden.
IT Masters. 2000. MasterProLog Programming Environment. URL: Accessed September 19, 2006.
Leuschel, M. & Sφrensen, M. H. 1996. Redundant argument filtering of logic programs. In Proceedings of the 6th International Workshop on Logic Program Synthesis and Transformation, Gallagher, J., Ed. LNCS, vol. 1207. Springer Verlag, 83103.
Li, H., Reinke, C. and Thompson, S. 2003. Tool support for refactoring functional programs. In Haskell Workshop 2003, Jeuring, J., Ed. Association for Computing Machinery.
Mens, T. and Tourwé, T. 2004. A survey of software refactoring. IEEE Transactions on Software Engineering 30, 2 (February), 126138.
Moad, J. 1990. Maintaining the competitive edge. Datamation 36, 4 (February), 6166.
Moores, T. T. 1998. Applying complexity measures to rule-based Prolog programs. The {J}ournal of {S}ystems and {S}oftware 44, 4552.
Nosek, J. T. and Palvia, P. C. 1990. Software maintenance management: Changes in the last decade. Journal of Software Maintenance: Research and Practice 2, 3 (September), 157174.
O'Keefe, R. A. 1994. The {C}raft of {P}rolog. MIT Press, Cambridge, MA.
Opdyke, W. F. 1992. Refactoring Object-Oriented Frameworks. Ph.D. thesis, University of Illinois at Urbana–Champaign.
Parnas, D. L. 1972. On the criteria to be used in decomposing systems into modules. Communications of the {ACM 15, 12 (December), 10531058.
Pitkow, J. and Pirolli, P. 1999. Mining longest repeating subsequences to predict World Wide Web surfing. In 2nd USENIX Symposium on Internet Technologies and Systems, Boulder, CO, 1–12.
Roberts, D., Brant, J. and Johnson, R. 1997. A refactoring tool for {S}malltalk. Theory and {P}ractice of {O}bject{S}ystems ({TAPOS}) 3 (4), 253263.
Schrijvers, T., Serebrenik, A. and Demoen, B. 2003.Refactoring {P}rolog Programs. Tech. Rep. CW 373, Department of Computer Science, Katholieke Universiteit Leuven, Leuven, Belgium.
Seipel, D., Hopfner, M. and Heumesser, B. 2003. Analysing and visualizing {P}rolog programs based on {XML} representations. In Proceedings of the 13th International Workshop on Logic Programming Environments, Mesnard, F. & Serebrenik, A., Eds. 31–45. Published as technical report {CW}371 of {K}atholieke {U}niversiteit {L}euven.
Steinke, D. 2003. Refactoring von Logischen {P}rogrammen. M.S. thesis, Universität Rostock. URL: http://e-lib.informatik.uni-rostock. http://de/fulltext/2003/diploma/ Accessed September 20, 2006.
Tourwé, T. and Mens, T. 2003. Identifying refactoring opportunities using logic meta programming. In 7th European Conference on Software Maintenance and Reengineering, Proceedings. IEEE Computer Society, 91–100.
vanVliet, H. Vliet, H. 2000. Software Engineering: Principles and Practice, 2nd ed. John Wiley & Sons.
Vanhoof, W. 2004. Searching semantically equivalent code fragments in logic programs. In Logic-based Program Synthesis and Transformation. 14th International Workshop, LOPSTR 2004, Verona, Italy, August 26–28, 2004, Pre-Proceedings, Etalle, S., Ed. 1–18.
Recommend this journal

Email your librarian or administrator to recommend adding this journal to your organisation's collection.

Theory and Practice of Logic Programming
  • ISSN: 1471-0684
  • EISSN: 1475-3081
  • URL: /core/journals/theory-and-practice-of-logic-programming
Please enter your name
Please enter a valid email address
Who would you like to send this to? *



Full text views

Total number of HTML views: 0
Total number of PDF views: 0 *
Loading metrics...

Abstract views

Total abstract views: 0 *
Loading metrics...

* Views captured on Cambridge Core between <date>. This data will be updated every 24 hours.

Usage data cannot currently be displayed