A Logic Meta Programming Foundation for Example-Driven Pattern Detection in Object-Oriented Programs

Total Page:16

File Type:pdf, Size:1020Kb

A Logic Meta Programming Foundation for Example-Driven Pattern Detection in Object-Oriented Programs FACULTEIT WETENSCHAPPEN Vakgroep Computerwetenschappen Software Languages Lab A Logic Meta Programming Foundation for Example-Driven Pattern Detection in Object-Oriented Programs Proefschrift ingediend met het oog op het behalen van de graad van Doctor in de Wetenschappen Coen De Roover Academiejaar 2008 - 2009 Promotoren: Prof. Dr. Wolfgang De Meuter en Dr. Johan Brichau ABSTRACT The growing number of tools for detecting user-specified software patterns is testa- ment to their valuable applications throughout the development process. In these ap- plications, user-specified software patterns describe code that exhibits characteristics of interest. For instance, violations of the protocol an API expects to be adhered to. Logic formulas can be used as expressive and descriptive pattern specifications. This merely requires reifying the program under investigation such that variables can range over its elements. Executing a proof procedure will establish whether program elements exhibit the characteristics specified in a formula. However, we have observed that such formulas become convoluted and operational in nature when developers attempt to ensure all instances of a pattern are recalled. As the behavioral characteristics of a pattern can be implemented in different ways, the corresponding formula either has to enumerate each implementation variant or describe the machine-verifiable behavior shared by these variants. The former for- mulas are relatively descriptive, but only recall the implementation variants that are enumerated. The latter formulas recall all implementations of the specified behavior, but do so by quantifying over information about the program’s behavior. This exposes developers to the intricate details of the program analyses that compute this informa- tion. We have reconciled both approaches by embedding source code excerpts in lo- gic formulas. These excerpts exemplify the prototypical implementation of a pattern’s characteristics —thus ensuring the resulting specifications are descriptive. They are specified in the concrete syntax of the base program augmented with logic variables. To ensure that all implementation variants are recalled, these excerpts are matched against behavioral program information according to multiple matching strategies that vary in leniency. Each match is quantified by the extent to which it exhibits the speci- fied characteristics. The smaller this extent, the more likely the match is a false posi- tive. This establishes a ranking which facilitates assessing a large amount of matches. A logic of quantified truth provides the theoretical foundation for this ranking. Unique to our matching process is that it incorporates whole-program analyses in its comparison of individual program elements. A semantic analysis ensures cor- rectness. To compare an unqualified and fully qualified type, for instance, a semantic analysis takes the import declarations into account of the compilation units in which they reside. A points-to analysis increases the amount of implementation variants that are recalled. When expressions are compared, for instance, syntactic deviations are allowed as long as they may evaluate to the same object at run-time. The resulting example-driven approach to pattern detection recalls the implicit im- plementation variants (i.e. those that are implied by the semantics of the programming language) of a machine-verifiable characteristic specified as a code excerpt that exem- plifies its prototypical implementation. iii SAMENVATTING Het groeiend aantal tools voor het detecteren van door ontwikkelaars gespecifi- ceerde software-patronen getuigt van de waardevolle toepassingen van patroondetec- tie doorheen het ontwikkelingsproces. In deze toepassingen beschrijft een software- patroon telkens code die aan bepaalde eigenschappen voldoet. Een patroon kan bij- voorbeeld schendingen beschrijven van het protocol dat gevolgd moet worden bij het aanroepen van een API. Logische formules lenen zich tot descriptieve specificaties van zulke patronen. Hiertoe is slechts een reïficatie van het programma vereist zodat formules over de elementen van het programma kunnen kwantificeren. Het uitvoeren van een bewijs- procedure bepaalt dan of elementen van het programma voldoen aan de geformu- leerde eigenschappen. We hebben echter vastgesteld dat zulke formules eerder ope- rationeel en verre van descriptief dreigen te worden wanneer ontwikkelaars ervoor trachten te zorgen dat alle instanties van het patroon gedetecteerd worden. Aangezien de eigenschappen van een patroon op verschillende manieren ge- ïmplementeerd kunnen worden, moet de corresponderende formule ofwel elke im- plementatievariant opsommen ofwel het gemeenschappelijke gedrag van deze vari- anten beschrijven. De eerstgenoemde formules zijn relatief descriptief, maar kunnen slechts de opgesomde implementatievarianten detecteren. De laatstgenoemde for- mules kunnen verschillende implementaties van het gespecificeerde gedrag detecte- ren, maar moeten hiervoor kwantificeren over informatie die het eigenlijk gedrag van het programma beschrijft. Hierdoor worden ontwikkelaars blootgesteld aan verre van eenvoudige programma-analyses die deze informatie berekenen. Door broncodemallen te integreren in logische formules hebben we beide opties met elkaar verzoend. Deze van logische variabelen voorziene fragmenten broncode fungeren als een voorbeeld van de prototypische implementatie van de eigenschap- pen van een patroon. Als voorbeelden van een implementatie waarborgen zij de de- scriptiviteit van de resulterende patroonspecificaties. Opdat implementatievarianten gedetecteerd zouden worden, vergelijken we zulke broncodemallen met informatie over het gedrag van het programma volgens meerdere strategieën die verschillen in striktheid. Een zogenaamde match bestaat uit bindingen voor de logische variabelen die de broncodemal vervolledigen. Voor elke match kwantificeren we de mate waarin deze aan de gespecificeerde eigenschappen voldoet. Geringe mates zijn indicatoren van valse positieven. De op deze manier verwezenlijkte rangschikking vergemakkelijkt het inspecteren van een groot aantal matchen. Een logica van gekwantificeerde waar- heid ondersteunt deze rangschikking theoretisch. Uniek aan bovenstaand vergelijkingsproces is dat analyses die informatie over het gedrag van het volledige programma berekenen, geconsulteerd worden bij het ver- gelijken van individuele programma-elementen. De correctheid van matches wordt gevrijwaard door een semantische analyse. Bij het vergelijken van een ongekwalifi- iv ceerd type met een volledig gekwalificeerd type, houdt de semantische analyse bij- voorbeeld rekening met de import-declaraties van de compilatie-eenheden waarin beiden zich bevinden. Een points-to analyse verhoogt het aantal implementatie- varianten dat gedetecteerd wordt. Bij het vergelijken van expressies zijn syntactische afwijkingen bijvoorbeeld toegestaan, op voorwaarde dat de expressies kunnen evalu- eren naar eenzelfde object tijdens een uitvoering van het programma. De resulterende voorbeeldgedreven patroondetectietechniek detecteert impliciete implementatievarianten (deze die volgen uit de semantiek van de programmeertaal) van een patrooneigenschap die gespecificeerd is als een fragment broncode dat fun- geert als voorbeeld van de prototypische implementatie van de eigenschap. v ACKNOWLEDGEMENTS I am greatly indebted to my promotor Prof. Wolfgang De Meuter (Vrije Universiteit Brussel) and co-promotor Dr. Johan Brichau (Université catholique de Louvain). Johan has been my partner in crime from the moment I was ready to dive into his implementation of the SOUL interpreter. I have truly enjoyed our joint work on logic meta programming and I am looking forward to continuing this fruitful col- laboration. Despite my stubbornness, Wolfgang never ceased to offer indispens- able advise —from the years that preceded my first keystrokes in “thesis.tex” to mere hours before I was presenting “private_defense.keynote”. Over the years, his interventions have been crucial to my evolution from a student to a researcher. It is impossible to thank both Wolfgang and Johan properly for their tremendous support, patience and the countless hours they have spent proofreading each chap- ter. I have not only come to appreciate them as outstanding advisors, but also as friends. I sincerely thank the members of my jury for their insightful comments and the significant time they have invested: Prof. Michael W. Godfrey (University of Water- loo), Prof. Ralf Lämmel (Universität Koblenz-Landau), Prof. Viviane Jonckers (Vrije Universiteit Brussel), Prof. Dirk Vermeir (Vrije Universiteit Brussel) and Prof. Theo D’Hondt (Vrije Universiteit Brussel). Next time, I will try to be more concise. During my years as an undergraduate student, I had the pleasure of experiencing the inter- nal jury members as gifted teachers who sparked my interests in software engineer- ing, logic programming and language engineering respectively —the confluence of which my research is situated in. I wish to extend my sincerest gratitude to Prof. Theo D’Hondt in particular, for welcoming me in the intellectually stimulating environment he has founded and fostered in his own intriguing style. Working at his laboratory has been an unpar- alleled and extremely gratifying experience. The amounts of trust and freedom to explore that are granted by Theo makes teaching practical sessions for his classes a joy. Moreover, I can only dream of ever mastering all of the clever insights that are delightfully tucked away in the corners
Recommended publications
  • University of Vaasa
    UNIVERSITY OF VAASA FACULTY OF TECHNOLOGY DEPARTMENT OF COMPUTER SCIENCE Arvi Lehesvuo A SOFTWARE FRAMEWORK FOR STORING USER WORKSPACES OF DESKTOP APPLICATIONS Master’s thesis in Technology for the degree of Master of Science in Technology submitted for inspection, Vaasa, June 30, 2012. Supervisor Prof. Jouni Lampinen Instructor M.Sc. Pasi Pelkkikangas 1 TABLE OF CONTENTS page ABBREVIATIONS 3 LIST OF FIGURES 4 TIIVISTELMÄ 5 ABSTRACT 6 1. INTRODUCTION 7 1.1. Company Introduction: Wapice Ltd 8 1.2. Professional Background Statement 9 1.3. The Scope of the Research 9 1.4. Research Questions 10 2. RESEARCH METHODOLOGY 12 2.1. Constructive Research Approach 12 2.2. Research Process as Applied in This Research 13 3. THEORY AND BACKGROUND OF THE STUDY 17 3.1. Introduction to the Subject 17 3.2. History of Object Oriented Programming 17 3.3. Most Central Elements in Object Oriented Programming 19 3.4. More Advanced Features of Object Oriented Programming 25 3.5. Software Design Patterns 27 3.6. Graphical User Interface Programming 34 4. DEVELOPING THE SOLUTION 39 4.1. Identifying the Solution Requirements 39 4.2. Designing Basic Structure for the Solution 43 4.3. Building the Solution as an External Software Component 47 4.4. Storing the User Data 48 4.5. Optimizing Construction for C# 51 2 5. EVALUATING PRACTICAL RELEVANCE OF THE DESIGN 54 5.1. Testing Design by applying it to Different GUI Design Models 54 5.2. Analyzing Results of the User Questionnaire 57 6. CONCLUSIONS AND FUTURE 61 6.1. Practical Contribution 62 6.2.
    [Show full text]
  • A Framework to Support Behavioral Design Pattern Detection from Software Execution Data
    A Framework to Support Behavioral Design Pattern Detection from Software Execution Data Cong Liu1, Boudewijn van Dongen1, Nour Assy1 and Wil M. P. van der Aalst2;1 1Department of Mathematics and Computer Science, Eindhoven University of Technology, 5600MB Eindhoven, The Netherlands 2Department of Computer Science, RWTH Aachen University, 52056 Aachen, Germany Keywords: Pattern Instance Detection, Behavioral Design Pattern, Software Execution Data, General Framework. Abstract: The detection of design patterns provides useful insights to help understanding not only the code but also the design and architecture of the underlying software system. Most existing design pattern detection approaches and tools rely on source code as input. However, if the source code is not available (e.g., in case of legacy software systems) these approaches are not applicable anymore. During the execution of software, tremendous amounts of data can be recorded. This provides rich information on the runtime behavior analysis of software. This paper presents a general framework to detect behavioral design patterns by analyzing sequences of the method calls and interactions of the objects that are collected in software execution data. To demonstrate the applicability, the framework is instantiated for three well-known behavioral design patterns, i.e., observer, state and strategy patterns. Using the open-source process mining toolkit ProM, we have developed a tool that supports the whole detection process. We applied and validated the framework using software execution data containing around 1000.000 method calls generated from both synthetic and open-source software systems. 1 INTRODUCTION latter specifies how classes and objects interact. Many techniques have been proposed to detect design pat- As a common design practice, design patterns have tern instances.
    [Show full text]
  • Active Object
    Active Object an Object Behavioral Pattern for Concurrent Programming R. Greg Lavender Douglas C. Schmidt [email protected] [email protected] ISODE Consortium Inc. Department of Computer Science Austin, TX Washington University, St. Louis An earlier version of this paper appeared in a chapter in the book ªPattern Languages of Program Design 2º ISBN 0-201-89527-7, edited by John Vlissides, Jim Coplien, and Norm Kerth published by Addison-Wesley, 1996. : Output : Input Handler Handler : Routing Table : Message Abstract Queue This paper describes the Active Object pattern, which decou- 3: enqueue(msg) ples method execution from method invocation in order to : Output 2: find_route(msg) simplify synchronized access to a shared resource by meth- Handler ods invoked in different threads of control. The Active Object : Message : Input pattern allows one or more independent threads of execution Queue Handler 1: recv(msg) to interleave their access to data modeled as a single ob- ject. A broad class of producer/consumer and reader/writer OUTGOING OUTGOING MESSAGES GATEWAY problems are well-suited to this model of concurrency. This MESSAGES pattern is commonly used in distributed systems requiring INCOMING INCOMING multi-threaded servers. In addition,client applications (such MESSAGES MESSAGES as windowing systems and network browsers), are increas- DST DST ingly employing active objects to simplify concurrent, asyn- SRC SRC chronous network operations. 1 Intent Figure 1: Connection-Oriented Gateway The Active Object pattern decouples method execution from method invocation in order to simplify synchronized access to a shared resource by methods invoked in different threads [2]. Sources and destinationscommunicate with the Gateway of control.
    [Show full text]
  • Sample Chapter
    SAMPLE CHAPTER C# in Depth by Jon Skeet Chapter 6 Copyright 2008 Manning Publications brief contents PART 1PREPARING FOR THE JOURNEY ......................................1 1 ■ The changing face of C# development 3 2 ■ Core foundations: building on C# 1 32 PART 2C#2: SOLVING THE ISSUES OF C# 1........................... 61 3 ■ Parameterized typing with generics 63 4 ■ Saying nothing with nullable types 112 5 ■ Fast-tracked delegates 137 6 ■ Implementing iterators the easy way 161 7 ■ Concluding C# 2: the final features 183 PART 3C# 3—REVOLUTIONIZING HOW WE CODE ..................205 8 ■ Cutting fluff with a smart compiler 207 9 ■ Lambda expressions and expression trees 230 10 ■ Extension methods 255 11 ■ Query expressions and LINQ to Objects 275 12 ■ LINQ beyond collections 314 13 ■ Elegant code in the new era 352 vii Implementing iterators the easy way This chapter covers ■ Implementing iterators in C# 1 ■ Iterator blocks in C# 2 ■ A simple Range type ■ Iterators as coroutines The iterator pattern is an example of a behavioral pattern—a design pattern that simplifies communication between objects. It’s one of the simplest patterns to understand, and incredibly easy to use. In essence, it allows you to access all the elements in a sequence of items without caring about what kind of sequence it is— an array, a list, a linked list, or none of the above. This can be very effective for building a data pipeline, where an item of data enters the pipeline and goes through a number of different transformations or filters before coming out at the other end. Indeed, this is one of the core patterns of LINQ, as we’ll see in part 3.
    [Show full text]
  • Skin Vs. Guts: Introducing Design Patterns in the MIS Curriculum Elizabeth Towell and John Towell Carroll College, Waukesha, WI, USA
    Journal of Information Technology Education Volume 1 No. 4, 2002 Skin vs. Guts: Introducing Design Patterns in the MIS Curriculum Elizabeth Towell and John Towell Carroll College, Waukesha, WI, USA [email protected] [email protected] Executive Summary Significant evidence suggests that there is increasing demand for information technology oriented stu- dents who have exposure to Object-Oriented (OO) methodologies and who have knowledge of the Uni- fied Modeling Language (UML). Object-oriented development has moved into the mainstream as the value of reusable program modules is becoming more evident. Building blocks such as software com- ponents and application frameworks allow organizations to bring products to market faster and to adapt to changes more quickly. When only one analysis and design course is required, the study of object-oriented analysis and design is often minimal or left out of the Management Information Systems curriculum. This paper argues for an increased emphasis on object-oriented techniques in the introductory Systems Analysis and Design course. Specifically, it provides guidance for faculty who are considering adding object-orientation to a systems analysis and design course where existing content leaves little time for new topics. In particular, the authors recommend the introduction of two successful, generalized design patterns in the context of adaptation of a software development framework. Where time is limited, coverage of such recurring software problems cannot be comprehensive so it is proposed that students explore two design patterns in depth as opposed to a cursory review of more patterns. Students must first learn or review the OO vocabulary including terms such as classes, inheritance, and aggregation so that the ap- propriate term can be used to discuss the UML relationships among the object model components.
    [Show full text]
  • 1. Difference Between Factory Pattern and Abstract Factory Pattern S.No
    1. Difference between Factory Pattern and Abstract Factory Pattern S.No Factory Pattern Abstract Factory Pattern 1 Create object through inheritance Create object through composition 2 Produce only one product Produce families of products 3 Implements code in the abstract creator Concrete factories implements factory that make use of the concrete type that method to create product sub class produces 2.Difference between Abstract Factory Pattern And Builder Pattern S.No Builder Pattern Abstract Factory Pattern 1 In Builder Pattern, there will be one Abstract Factory Pattern will return the Director class which will instruct Builder instance directly. class to build the different parts/properties of our object and finally retrieve the object. 2 It will have reference to the created It does not keep the track of it's created object. object. 3.Difference between Builder Pattern And Composite Pattern S.No Builder Pattern Composite Pattern 1 It is used to create group of objects of It creates Parent - Child relations between predefined types. our objects. 4.Difference between MVC and MVP S.No MVP MVC 1 MVP is a bit more complex to MVC is easier to implement than MVP. implement than MVC .Also, it has additional layer for view interfaces. 2 The request is always received by the The request is received by the controller View and delegated to the presenter which in turn gets the required data and which in turn gets the data does the loads up the appropriate view processing 3 The presentation and view logic an be The controller logic can be unit tested.
    [Show full text]
  • Actors As Channels and Channels As Actors
    Mixing Metaphors: Actors as Channels and Channels as Actors Simon Fowler, Sam Lindley, and Philip Wadler University of Edinburgh [email protected], [email protected], [email protected] Abstract Channel- and actor-based programming languages are both used in practice, but the two are often confused. Languages such as Go provide anonymous processes which communicate using typed buffers—known as channels—while languages such as Erlang provide addressable processes each with a single incoming message queue—known as actors. The lack of a common representation makes it difficult to reason about the translations that exist in the folklore. We define a calculus λch for typed asynchronous channels, and a calculus λact for typed actors. We define translations from λact into λch and λch into λact and prove that both translations are type- and semantics- preserving. We show that our approach accounts for synchronisation and selective receive in actor systems and discuss future extensions to support guarded choice and behavioural types. Digital Object Identifier 10.4230/LIPIcs... 1 Introduction When comparing channels (as used by Go) and actors (as used by Erlang), one runs into an immediate mixing of metaphors. The words themselves do not refer to comparable entities! In languages such as Go, anonymous processes pass messages via named channels, whereas in languages such as Erlang, named processes accept messages from an associated mailbox. A channel is a buffer, whereas an actor is a process. We should really be comparing named processes (actors) with anonymous processes, and buffers tied to a particular process (mailboxes) with buffers that can link any process to any process (channels).
    [Show full text]
  • Chap 5. Patterns
    Chap 5. Patterns 1. Introduction 2. Pattern Description and Application 3. Design Patterns 4. Architectural Patterns 5. Appendix: Other Patterns 1 1. Introduction Motivating Example Problem: You are building a quote application, which contains a class that is responsible for managing all of the quotes in the system. It is important that all quotes interact with one and only one instance of this class. How do you structure your design so that only one instance of this class is accessible within the application? Simple solution: ÷Create a QuoteManager class with a private constructor so that no other class can instantiate it. ÷This class contains a static instance of QuoteManager that is returned with a static method named GetInstance(). public class QuoteManager { //NOTE: For single threaded applications only private static QuoteManager _Instance = null; private QuoteManager() {} public static QuoteManager GetInstance() { if (_Instance==null) { _Instance = new QuoteManager (); } return _Instance; Recurring problems like this kind have } been observed by experienced developers //... functions provided by QuoteManager and a common solution has been distilled,2 } as the Singleton pattern. Pattern Overview - A classical engineering rule of thumb consists of reusing extensively available knowledge base for any kind of problem solving that occurs during system design. Method ÷ When the knowledge doesn't exist for the problem at hand,Theft Intuition then intuition takes the lead. ÷ Architectural styles or patterns define experience-based classes of designs along with their known characteristics. Classical system Method Theft Intuition - A pattern is a solution to a problem in a context •A pattern codifies specific knowledge collected from experience in a domain Unprecedented system •There are three kinds of patterns –Idioms: provide a solution for specific programming issues in given language.
    [Show full text]
  • TIP 57 Trauma-Informed Care in Behavioral Health Services
    A TREATMENT IMPROVEMENT PROTOCOL Trauma-Informed Care in Behavioral Health Services TIP 57 A TREATMENT IMPROVEMENT PROTOCOL Trauma-Informed Care in Behavioral Health Services TIP 57 U.S. DEPARTMENT OF HEALTH AND HUMAN SERVICES Substance Abuse and Mental Health Services Administration Center for Substance Abuse Treatment 1 Choke Cherry Road Rockville, MD 20857 Trauma-Informed Care in Behavioral Health Services Acknowledgments This publication was produced under contract numbers 270-99-7072, 270-04-7049, and 270­ 09-0307 by the Knowledge Application Program (KAP), a Joint Venture of The CDM Group, Inc., and JBS International, Inc., for the Substance Abuse and Mental Health Services Administration (SAMHSA), U.S. Department of Health and Human Services (HHS). Andrea Kopstein, Ph.D., M.P.H., Karl D. White, Ed.D., and Christina Currier served as the Contracting Officer’s Representatives. Disclaimer The views, opinions, and content expressed herein are the views of the consensus panel members and do not necessarily reflect the official position of SAMHSA or HHS. No official support of or endorsement by SAMHSA or HHS for these opinions or for the instruments or resources described are intended or should be inferred. The guidelines presented should not be considered substitutes for individualized client care and treatment decisions. Public Domain Notice All materials appearing in this volume except those taken directly from copyrighted sources are in the public domain and may be reproduced or copied without permission from SAMHSA or the authors. Citation of the source is appreciated. However, this publication may not be reproduced or distributed for a fee without the specific, written authorization of the Office of Communications, SAMHSA, HHS.
    [Show full text]
  • Security Patterns
    Security Patterns Ronald Wassermann and Betty H.C. Cheng¤ Software Engineering and Network Systems Laboratory Department of Computer Science and Engineering Michigan State University East Lansing, Michigan 48824, USA Email: fwasser17,[email protected] Abstract Design patterns propose generic solutions to recurring design problems. Commonly, they present a solution in a well-structured form that facilitates its reuse in a di®erent context. Re- cently, there has been growing interest in identifying pattern-based designs for the domain of system security termed Security Patterns. Currently, those patterns lack comprehensive struc- ture that conveys essential information inherent to security engineering. This paper describes research into investigating an appropriate template for Security Patterns that is tailored to meet the needs of secure system development. In order to maximize comprehensibility, we make use of well-known notations such as the Uni¯ed Modeling Language (UML) to represent structural and behavioral aspects of design. Furthermore, we investigate how veri¯cation can be enabled by adding formal constraints to the patterns. ¤Please contact B. Cheng for all correspondences. i Contents 1 Introduction 1 2 Background 2 2.1 Viega's and McGraw's ten principles . 2 2.1.1 Principle 1: Secure the weakest link. 3 2.1.2 Principle 2: Practice defense in depth. 3 2.1.3 Principle 3: Fail securely. 3 2.1.4 Principle 4: Follow the principle of least privilege. 4 2.1.5 Principle 5: Compartmentalize. 4 2.1.6 Principle 6: Keep it simple. 4 2.1.7 Principle 7: Promote privacy. 5 2.1.8 Principle 8: Remember that hiding secrets is hard.
    [Show full text]
  • Question Bank
    DESIGN PATTERNS UNIT I PART A 1. Define design pattern. 2. List the four elements of design patterns. 3. Distinguish a class and an object. 4. Give an example for class structure. 5. Sketch MVC architecture. 6. State the meaning of a solution. 7. Write the different sections of design patterns. 8. Give the meaning of Intent. PART B 1. List the advantages of design patterns. Write short notes on use of design patterns. 2. Discuss the MVC architecture in small talk. 3. Explain how to describe design patterns. 4. List the different sections of design patterns. Explain about them. 5. Name the patterns along with their intents that are included in the catalog of design patterns. 6. State and explain the classification of design patterns. 7. List the various ways of organizing the design patterns. 8. Compare inheritance verses parameterized types. UNIT II PART A 1. Give the meaning of “WYSIWYG”. 2. Define Lexi. 3. Define an abstract class. 4. Write the meaning of a document. 5. Differentiate compositor and composition. 6. Define formatting. 7. Define an Iterator class. 8. Define creational patterns. 9. List five types of creational patterns. 10. Define abstract factory design pattern. 11. Define builder pattern. 12. Give example of class diagram. 13. Define structure and applicability of abstract factory method. PART B 1. Explain the process of recursive composition in building a document. 2. Explain in detail about the ‘Glyph’ abstract class. 3. Discuss the goals and constraints in choosing an internal representation for a document. 4. Explain partial Glyph class hierarchy with a neat diagram.
    [Show full text]
  • Actors As Channels and Channels As Actors
    Mixing Metaphors: Actors as Channels and Channels as Actors Simon Fowler, Sam Lindley, and Philip Wadler University of Edinburgh, Edinburgh, United Kingdom [email protected], [email protected], [email protected] Abstract Channel- and actor-based programming languages are both used in practice, but the two are often confused. Languages such as Go provide anonymous processes which communicate using buffers or rendezvous points—known as channels—while languages such as Erlang provide addressable processes—known as actors—each with a single incoming message queue. The lack of a common representation makes it difficult to reason about translations that exist in the folklore. We define a calculus λch for typed asynchronous channels, and a calculus λact for typed actors. We define translations from λact into λch and λch into λact and prove that both are type- and semantics- preserving. We show that our approach accounts for synchronisation and selective receive in actor systems and discuss future extensions to support guarded choice and behavioural types. 1998 ACM Subject Classification D.1.3 Concurrent Programming Keywords and phrases Actors, Channels, Communication-centric Programming Languages Digital Object Identifier 10.4230/LIPIcs.ECOOP.2017.90 1 Introduction When comparing channels (as used by Go) and actors (as used by Erlang), one runs into an immediate mixing of metaphors. The words themselves do not refer to comparable entities! In languages such as Go, anonymous processes pass messages via named channels, whereas in languages such as Erlang, named processes accept messages from an associated mailbox. A channel is either a named rendezvous point or buffer, whereas an actor is a process.
    [Show full text]