Supporting Software Development through Declaratively Codified - - PowerPoint PPT Presentation

supporting software development through declaratively
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

SEKE 2001 - 14 June

VUB Brussels - Belgium

Supporting Software Development through Declaratively Codified Programming Patterns

Kim Mens, Isabel Michiels and Roel Wuyts

Vrije Universiteit Brussel (VUB), Belgium

slide-2
SLIDE 2

SEKE 2001 - 14 June

VUB Brussels - Belgium

Table of Contents

  • Introduction
  • Our Approach
  • Declarative Meta-Programming (DMP)
  • Codifying Programming Patterns

Best practice patterns, design patterns, …

  • Supporting Software Development
  • Tool Support
  • Conclusion
slide-3
SLIDE 3

SEKE 2001 - 14 June

VUB Brussels - Belgium

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

slide-4
SLIDE 4

SEKE 2001 - 14 June

VUB Brussels - Belgium

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

slide-5
SLIDE 5

SEKE 2001 - 14 June

VUB Brussels - Belgium

Declarative Meta-Programming (DMP)

slide-6
SLIDE 6

SEKE 2001 - 14 June

VUB Brussels - Belgium

The representational mapping (1)

An example:

Rule ule class(?Class) if if constant(?Class), [Smalltalk includes: ?Class name]. Rule Rule class(?Class) if if variable(?Class), generate(?Class,[Smalltalk allClasses]) Query class([Array]).

smalltalk code used as a predication has to return true

  • r false

smalltalk code used in a generate predicate has to return a collection of results

slide-7
SLIDE 7

SEKE 2001 - 14 June

VUB Brussels - Belgium

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)

slide-8
SLIDE 8

SEKE 2001 - 14 June

VUB Brussels - Belgium

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).

slide-9
SLIDE 9

SEKE 2001 - 14 June

VUB Brussels - Belgium

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).

slide-10
SLIDE 10

SEKE 2001 - 14 June

VUB Brussels - Belgium

Codifying Design Patterns (2)

slide-11
SLIDE 11

SEKE 2001 - 14 June

VUB Brussels - Belgium

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)).

slide-12
SLIDE 12

SEKE 2001 - 14 June

VUB Brussels - Belgium

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’])

slide-13
SLIDE 13

SEKE 2001 - 14 June

VUB Brussels - Belgium

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)

slide-14
SLIDE 14

SEKE 2001 - 14 June

VUB Brussels - Belgium

Supporting Software Development (3)

  • Generating code

Rule generateAccessor(?Class,?InstVar) if instVar(?Class,?InstVar), not(classImplementsMethod(?Class,?InstVar,_)), gettingMethodStats(?Stats,?InstVar), generateMethod( method(?Class,?InstVar,<>,<>,?Stats)).

“Generate code from the method parse tree description”

“Check whether ?InstVar not

already exists”

slide-15
SLIDE 15

SEKE 2001 - 14 June

VUB Brussels - Belgium

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

slide-16
SLIDE 16

SEKE 2001 - 14 June

VUB Brussels - Belgium

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
slide-17
SLIDE 17

SEKE 2001 - 14 June

VUB Brussels - Belgium

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.