supporting software development through declaratively
play

Supporting Software Development through Declaratively Codified - PowerPoint PPT Presentation

Supporting Software Development through Declaratively Codified Programming Patterns Kim Mens, Isabel Michiels and Roel Wuyts Vrije Universiteit Brussel (VUB), Belgium SEKE 2001 - 14 June VUB Brussels - Belgium Table of Contents


  1. Supporting Software Development through Declaratively Codified Programming Patterns Kim Mens, Isabel Michiels and Roel Wuyts Vrije Universiteit Brussel (VUB), Belgium SEKE 2001 - 14 June VUB Brussels - Belgium

  2. Table of Contents • Introduction • Our Approach • Declarative Meta-Programming (DMP) • Codifying Programming Patterns Best practice patterns, design patterns, … • Supporting Software Development • Tool Support • Conclusion SEKE 2001 - 14 June VUB Brussels - Belgium

  3. Introduction • Software development – Incremental process – Large development teams • Readability of software is crucial • Use commonly accepted programming patterns to make programmer’s intent clear • However… No explicit support in programming language nor in the environment SEKE 2001 - 14 June VUB Brussels - Belgium

  4. Our Approach • Codify programming patterns in a declarative language • Make explicit link between declarative language and programming language • Use declarative reasoning to: – check & search – detect violations – generate code SEKE 2001 - 14 June VUB Brussels - Belgium

  5. Declarative Meta-Programming (DMP) SEKE 2001 - 14 June VUB Brussels - Belgium

  6. The representational mapping (1) An example: Rule ule class(?Class) if if smalltalk code used as a predication has to return true constant(?Class), or false [ Smalltalk includes: ?Class name ]. Rule Rule class(?Class) if if smalltalk code used in a generate predicate has to return variable(?Class), a collection of results generate(?Class,[ Smalltalk allClasses ]) Query class([Array]). SEKE 2001 - 14 June VUB Brussels - Belgium

  7. The representational mapping (2) Examples of other SOUL predicates: class(?Class) classImplementsMethod(?Class,?MethodName,?Method) methodArguments(?Method,?Arglist) methodClass(?Method,?Class) methodName(?Method,?Name) methodStatements(?Method,?StatementList) instVar(?Class,?InstVarName) isSentTo(?SenderClass,?ReceiverClass,?MesgName,?Arglist) SEKE 2001 - 14 June VUB Brussels - Belgium

  8. Codifying Best Practice Patterns Example: • Getting Method : how do you provide access to an instance variable? • Rule gettingMethod(?Class,?Method,?InstVar) if classImplementsMethod(?Class,_,?Method), instVar(?Class,?InstVar), methodName(?Method,?InstVar), gettingMethodStats(?Stats,?InstVars), methodStatements(?Method,?Stats). SEKE 2001 - 14 June VUB Brussels - Belgium

  9. Codifying Design Patterns Example: Visitor Design Pattern Rule Rule visitor(?Visitor,?El,?AcceptM,?VisitSelector) if if classImplementsMethod(?Visitor,?VisitSelector,_), classImplementsMethod(,?El,?AcceptM,?Meth), methodStatements( ?Meth, <return(send(?V,?VisitSelector,?VisitArgs))>), member(variable([#’self’]),?VisitArgs), methodArguments(?Meth,?AccArgs), member(?V,?AccArgs). SEKE 2001 - 14 June VUB Brussels - Belgium

  10. Codifying Design Patterns (2) SEKE 2001 - 14 June VUB Brussels - Belgium

  11. Codifying other Programming Patterns Example: [Riel’s Design Heuristics] All abstract classes must be base classes and all base classes should be abstract classes. Rule Rule abstractClassHeuristic() if if forall(abstractClass(?Class),baseClass(?Class)), forall(baseClass(?Class),abstractClass(?Class)). SEKE 2001 - 14 June VUB Brussels - Belgium

  12. Supporting Software Development (1) • checking and searching search for Getting Method : Query Query gettingMethod([ApplicationModel],?M,[#’builder’]) Query ry gettingMethod([ApplicationModel],?M,?InstVar) Query ery gettingMethod(?Class,?Method,[#’name’]) SEKE 2001 - 14 June VUB Brussels - Belgium

  13. Supporting Software Development (2) • detecting violations Rule accessingviolator(?Class,?Meth,?InstVar,?ViolMsg) if instVar(?Class,?InstVar), classImplementsMethod(?Class,_,?Meth), not(gettingMethod(?Class,?Meth,?InstVar)), isSentTo(?Class,variable(?InstVar),?ViolMsg,_). Query accessingViolator(?Class,?Meth,?InstVar,?Msg) SEKE 2001 - 14 June VUB Brussels - Belgium

  14. Supporting Software Development (3) • Generating code Rule generateAccessor(?Class,?InstVar) if “ Check whether ?InstVar not instVar(?Class,?InstVar), already exists” not(classImplementsMethod(?Class,?InstVar,_)), gettingMethodStats(?Stats,?InstVar), “Generate code from the method generateMethod( parse tree description” method(?Class,?InstVar,<>,<>,?Stats)). SEKE 2001 - 14 June VUB Brussels - Belgium

  15. Tool Support • well-integrated and user-friendly tools to integrate SOUL in a development environment • Possible (and existing) tools: – synchronization between design and implementation of software (using the synchronization framework) – structural find application – to do application SEKE 2001 - 14 June VUB Brussels - Belgium

  16. Conclusion • Use of programming patterns is crucial for software development support • need for tools to support these patterns • our approach: use DMP as a medium • DMP is ideal for this: – it is declarative – logic language benefits (multi-way reasoning, unification, backtracking) – base-language independent – it is customizable • we reach a higher level of abstraction of code SEKE 2001 - 14 June VUB Brussels - Belgium

  17. References [1] K Beck. Smalltalk Best Practice Patterns . Prentice Hall PTR, 1997. [2] M. Fowler. Refactoring: Improving the Design of Existing Program . Addison Wesley, 1999 [3] R. Wuyts. Declarative Reasoning about the Structure of Object-Oriented Systems. In proceedings of TOOLS USA 1998. IEEE Computer Society Press, 1998. SEKE 2001 - 14 June VUB Brussels - Belgium

Recommend


More recommend