Metaprogramming and its relevance in Software Engineering CSC












- Slides: 12
Metaprogramming and its relevance in Software Engineering (CSC 532 Term Paper) By, Sucharitha Rodda
INTRODUCTION ØNeed for an evolution of Abstract Conceptual tools ØMetaprogramming is the art of programming programs that read, transform, or write other programs
Metaprogramming in everyday life Input -> Output Ø 0 -> 0 : Normal program Ø 1 -> 0 : Interpreter Ø 0 -> 1 : Data Pre-Compiler Ø 1 -> 1 : Automatic translator Ø 2 -> 0 : Metainterpreter Ø 2 -> 1 : Code walker Ø 1 -> 2 : Phase splitter
Significance of Metaprogramming in Software Engineering ØEnables Software Reuseability ØEnforces Consistency ØPerforms semi automatic programming ØHelps in inexpensive maintenance of software
Metaprogramming applied to Web Component Deployment «interface» Component +m 1() +m 2() «interface» My. Component My. Impl
Architecture «interface» Component +m 1() +m 2() «interface» My. Component My. Impl My. Stub +handle() «interface» Skeleton My. Skeleton
abstract class A { int i; A a; } interface B { } class C extends A { float f; B b; } class X extends C implements B { X x; } class Y extends X { boolean[] b; } class Z implements B { X x; } XMLSerializer: public static void serialize. Class. Y(XMLSerializer. Stream s, Y o) { if(s. serialize. Reference(o)) return; o. serialize. XML(s); // o may be of type Y or any // subtype thereof }
public void serialize. XML(XMLSerializer. Stream s) { s. opening. Tag("<class. Y>"); serialize. Body. Class. Y(s); s. closing. Tag("</class. Y>"); } protected final void serialize. Body. Class. Y(XMLSerializer. Stream s) { serialize. Body. Class. X(s); // superclass data layout XMLSerializer. serialize. Array. Of. Boolean(s, this. b); // boolean[] b; }
ØImplementation ØAnalysis ØTransformation
Why are metaprogramming techniques not used commonly? ØConsist precisely in not using the studied language, but another language, through metaprograms ØLack of a formal encoding ØLack of a general approach ØLack of a metaprogramming notation
Conclusion ØComputing today has to face two challenges, metaprogramming and the free availability of source code of software. ØPractitioners of computing arts should free themselves from slogans like multimedia, object-oriented, design-pattern, virtual machine, intelligent network, etc, and should rather adopt a scientific attitude.
References: http: //www. erlang. org http: //www. tunes. org http: //java. sun. com/products/ XML 1. 0. http: //www. w 3. org/TR/ Simple Object Access Protocol (SOAP) http: //www. w 3. org/TR/