Hostname: page-component-8448b6f56d-tj2md Total loading time: 0 Render date: 2024-04-24T20:22:01.668Z Has data issue: false hasContentIssue false

Improving Prolog programs: Refactoring for Prolog

Published online by Cambridge University Press:  01 March 2008

ALEXANDER SEREBRENIK
Affiliation:
Laboratory of Quality of Software (LaQuSo), T.U. Eindhoven, HG 5.91, Den Dolech 2, P.O. Box 513, 5600 MB Eindhoven, The Netherlands (e-mail: A.Serebrenik@tue.nl)
TOM SCHRIJVERS
Affiliation:
Department of Computer Science, K.U. Leuven, Celestijnenlaan 200A, B-3001, Heverlee, Belgium (e-mail: Tom.Schrijvers@cs.kuleuven.be)
BART DEMOEN
Affiliation:
Department of Computer Science, K.U. Leuven, Celestijnenlaan 200A, B-3001, Heverlee, Belgium (e-mail: Bart.Demoen@cs.kuleuven.be)

Abstract

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.

Type
Technical Note
Copyright
Copyright © Cambridge University Press 2007

Access options

Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)

References

1995. Information Technology—Programming Languages—Prolog—Part 1: General Core. ISO/IEC. ISO/IEC 13211-1:1995.Google Scholar
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.Google Scholar
Erlikh, L. 2000. Leveraging legacy system dollars for e-business. IT Professional 2, 3 (May), 1723.CrossRefGoogle Scholar
Fowler, M. 2003. Refactorings in alphabetical order. URL: http://www.refactoring.com/catalog/. Accessed April 2, 2007.Google Scholar
Fowler, M., Beck, K., Brant, J., Opdyke, W. and Roberts, D. 1999. Refactoring: Improving the design of existing code. Object Technology Series. Addison-Wesley.Google Scholar
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.Google Scholar
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.Google Scholar
Intelligent Systems Laboratory. 2003a. Quintus Prolog User's Manual. P.O. Box 1263, SE-164 29 Kista, Sweden.Google Scholar
Intelligent Systems Laboratory. 2003b. SICStus Prolog User's Manual. P.O. Box 1263, SE-164 29 Kista, Sweden.Google Scholar
IT Masters. 2000. MasterProLog Programming Environment. URL: http://www.itmasters.com. Accessed September 19, 2006.Google Scholar
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.Google Scholar
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.Google Scholar
Mens, T. and Tourwé, T. 2004. A survey of software refactoring. IEEE Transactions on Software Engineering 30, 2 (February), 126138.CrossRefGoogle Scholar
Moad, J. 1990. Maintaining the competitive edge. Datamation 36, 4 (February), 6166.Google Scholar
Moores, T. T. 1998. Applying complexity measures to rule-based Prolog programs. The {J}ournal of {S}ystems and {S}oftware 44, 4552.Google Scholar
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.CrossRefGoogle Scholar
O'Keefe, R. A. 1994. The {C}raft of {P}rolog. MIT Press, Cambridge, MA.Google Scholar
Opdyke, W. F. 1992. Refactoring Object-Oriented Frameworks. Ph.D. thesis, University of Illinois at Urbana–Champaign.Google Scholar
Parnas, D. L. 1972. On the criteria to be used in decomposing systems into modules. Communications of the {ACM 15, 12 (December), 10531058.CrossRefGoogle Scholar
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.Google Scholar
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.Google Scholar
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.Google Scholar
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.Google Scholar
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/ http://SteinkeDirk-2003.ps.gz. Accessed September 20, 2006.Google Scholar
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.Google Scholar
vanVliet, H. Vliet, H. 2000. Software Engineering: Principles and Practice, 2nd ed. John Wiley & Sons.Google Scholar
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.Google Scholar