A Functional Pattern System for Object-Oriented Design

A Functional Pattern System for Object-Oriented Design

A Functional Pattern System for Object-Oriented Design Thomas Kuhne ¨ ♦ A child does not dis- cover the world by learning abstract rules. Instead it learns by looking at concrete examples. An example contains the rules as well. In contrast to rules, the recognition of examples can be based on tangible reality. The knowledge extracted from an example serves as a Pattern that is used to remember facts and to construct new solutions. When grown-ups are about to learn something or have to apply unknown tools, they are put into a child’s position again. They will favor concrete examples over abstract rules. The rules will happily be gen- erated automatically, for this is how the brain works. ♦ Thesis iii Thesis Design patterns inspired by functional programming concepts can advance object- oriented design. Problem The object-oriented paradigm has undoubtfully raised our ability to design and maintain large complex software systems. However, it does not seem to have meet the high expectations concerning reuse and ease of evolution which have been pro- moted ever since its commercial success. There are many potential reasons for the above observation such as unquali- fied staff, immature languages, inadequate methodologies, inappropriate business processes, etc. The view presented here is that although the object-oriented paradigm is a pow- erful basis, it is incomplete in its inherent concepts and therefore restricts the design space to inappropriate solutions. It is assumed that both software development and language design are restrained from achieving their full potential when restricted to a purely object-oriented world view. Solution Since the complementary paradigm to object-orientation is represented by func- tional programming, I investigate high-level, well-known to work functional con- cepts and examine their suitability to enhance object-oriented design. I explore the software engineering relevance of each concept and present its intent, applicability, implementation, and consequences in the literate form of a design pattern. My approach clearly motivates functional techniques for object-oriented design from a software engineering point of view. This is different to the usual procedure of designing a new language with an “ad-hoc” conglomeration of functional and object-oriented features. The latter case requires excellence in language design and makes it hard to find out and evaluate uses of the new language. In contrast, design patterns are already widely used to improve design. As func- tional concepts constitute a powerful paradigm by themselves, it is more than sug- gestive to assume that design patterns expressing successful functional concepts will enhance the object-oriented paradigm with new capabilities. iv Thesis Contribution Feasibility I demonstrate the feasibility of using functional techniques in object-oriented de- signs which are to be implemented by ordinary object-oriented programming lan- guages. This is done at the level of a calculus comparison and in concrete design pattern implementation descriptions. I demonstrate synergetic effects caused by concept integration, which together with the advantages of functional patterns, thus, show the utility of the approach. Software production Object-oriented practitioners hopefully will use the names of functional design pat- terns as a vocabulary to discuss solutions in a new design space. I present a system of patterns which are connected by relations that describe how individual patterns may interact and collaborate with each other. This system, consisting of state-of- the-art mini-architectures, may allow thinking and designing beyond restrictions imposed by a dogmatic object-oriented approach. As a result, the quality of soft- ware is hoped to improve. Language Design Using functional patterns for object-oriented design can be regarded as dual- paradigm design. In this light, functional design patterns appear as language id- ioms that lift an object-oriented language to a dual paradigm implementation lan- guage. It is very instructive to verify how well an object-oriented language supports the implementation of these idioms, since limiting properties are expected to interfere in other attempts to produce flexible and maintainable software as well. Unless one is restricted to use a certain existing language, it is, however, only natural to consider direct language support in order to avoid the repetitive im- plementation of these idioms. A holistic language that encompasses both object- oriented and functional paradigms should provide more ease of use, increased safety, better initial execution efficiency, and higher optimization potential. I consider each presented design pattern for its contribution to language con- structs that support a dual paradigm language. The software engineering consid- erations, contained in each design pattern description, help to avoid “featurism” in favor of conceptually founded language principles. Ultimately, impulses initiated by the functional pattern system lead to a reeval- uation of the role distribution between a programming language and its associated environment. The result allows transcending the limitations of each paradigm by providing the optimal paradigm view on demand. Preface v Preface Example is the school of mankind, and they will learn at no other. – Edmund Burke A number of people directly or indirectly influenced my work and I am grateful for their contributions. Norbert Ihrig made my early years in school a worthwhile experience and with- out him my way would have been much harder. Gregor Snelting proposed an interesting master thesis to me and, thus, opened up the subsequent opportunity for a research position at the institute for “Praktis- che Informatik” at the Darmstadt University of Technology. I enjoyed his lectures and am thankful for his continued support. Thilo Kielman introduced me to the world of being a scientist. I owe him many hints, paper reviews, and enjoyable hours. Alberto Pardo was my roommate over a long period and shared many stimulat- ing discussions with me. I would like to express my gratitude for his ever present willingness to help and for a lot of advice in the areas of calculi and algebras. He and Nick Dyson helped to improve the chapter on functional programming. John Sargeant invested considerable effort to discuss the Void Value pattern with me and provided useful information on UFO. Dirk Koschorek provided invaluable last minute advice on SMALLTALK. Many scientists, who I had the honor to meet at workshops or conferences, dis- cussed aspects of my work with me and made me reflect about it. Gillian L. Lovegrove and Jurgen ¨ Ebert accepted to be external examiners and I am indebted to their timely efforts. I would like to thank Jurgen ¨ Ebert for his invitation to the “Bad Honnef” workshop series and for his personal interest in my work. Finally, I would like to express my gratitude to my thesis supervisor Wolfgang Henhapl. He gave me all the freedom I could wish for and stimulated my work on several occasions. He asked the question to which function objects present an an- swer and challenged me to conceive the Translator design. Numerous discussions with him created an abundance of insights for me. I am honestly grateful to the nameless cosmic particles that hit me when I had the idea of function objects, to replace Nil with a type specific value, to solve the forces of internal and external iteration with multiple consumable intermediate streams, to express functional ideas by devising a pattern system, and to rethink the roles of languages and their environments based on the notion of tiles. vi Preface Many thanks to Cordon Art for granting permission to use the images by M.C. Escher “Circle Limit IV”, “Space Filling”, and “Day and Night”. 1998, Cordon Art B.V., Nieuwstraat 6, P.O.Box 101, 3740 AC Baarn, Holland. Last but not least, my appreciation goes to to Donald E. Knuth who developed TEX and put it into the public domain, Frank Mittelbach for LATEX2ε, Linus Torvald for LINUX, and all their companions and successors who enabled me to produce this document with copylefted software only. Contents vii Contents Thesis iii Preface v Prologue 1 I Foundation 7 1 Functional programming 9 1.1 Worldview ................................. 9 1.2 Concepts . ................................. 10 1.2.1 Functional decomposition . ................... 10 1.2.2 Reduction Semantics . ................... 11 1.2.3 Higher-Order Functions . ................... 12 1.2.4 Lazy evaluation .......................... 14 1.2.5 Pattern Matching . ................... 16 1.2.6 Type inference . .......................... 17 1.3 Review . ................................. 17 1.3.1 Pro ................................. 17 1.3.1.1 Programming Discipline . ............ 18 1.3.1.2 Concise programs ................... 18 1.3.2 Contra . .......................... 21 1.3.2.1 Functional decomposition . ............ 21 1.3.2.2 Reduction semantics . ............ 21 1.3.2.3 Deceptive Clearness . ............ 26 2 Object-orientation 29 2.1 Worldview ................................. 29 2.2 Concepts . ................................. 31 2.2.1 Object-oriented decomposition . ............ 32 2.2.2 Encapsulation . .......................... 32 2.2.3 Inheritance . .......................... 33 2.2.4 Subtyping . .......................... 34 2.2.5 Dynamic Binding . ................... 35 viii Contents 2.2.6 Identity . .......................... 37 2.3 Review . ................................. 38 2.3.1 Pro ................................

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    346 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us