430 likes | 722 Views
Application Generators. Advanced Seminars in Software Reuse Leandro Marques do Nascimento. “Every minute spent on infrastructure programming is a wasted minute.” Juval Lowy, .NET Software Legend, April 2003. “Code generation is a formalized version of copy-and-paste programming.” (CGN, 2005).
E N D
Application Generators Advanced Seminars in Software Reuse Leandro Marques do Nascimento
“Every minute spent on infrastructure programming is a wasted minute.” Juval Lowy, .NET Software Legend, April 2003 “Code generation is a formalized version of copy-and-paste programming.” (CGN, 2005)
(McIlroy, 1968) “Mass Produced Software Components” • Felt that component libraries could be effectively used for numerical computation, I/0 conversion, text processing, and dynamic storage allocation.
(Freeman, 1983) • Not only source code can be reused • “Different types of artifacts which are not limited to source code fragments can be reused including: design structures, module-level implementation structures, specifications, documentation, transformations, and so on.”
(Biggerstaff and Perlis, 1989a) (Biggerstaff and Perlis, 1989b) • Commonality among the software reuse techniques used: • Abstraction: essencial feature in any reuse activity • Selection: selects the appropriate artifacts to the specific domain. • Specialization: specialize the artifacts through transformations, constraints, parameters or other refinement • Integration: combine a collection of selected and specialized artifacts into a complete software system
(Krueger, 1992) • “Software reuse is the process of creating software systems from existing software rather than building software systems from scratch.” • “Application generators operate like programming language compilers—input specifications are automatically translated into executable programs.” • Using Generators the code expansion (input/output) may reach 2000 lines of code per day. System specification Generators what to do System implementation how to do
(Krueger, 1992) System Architecture (Domain Dependent) • Abstraction: Textual Specifcation Languages (4th generation languages) Graphical Diagrams Templates Interactive menu driven dialogs Structure-oriented interface
(Krueger, 1992) • Selection: • Depends on domain covarage • Application generators are often highly specialized, limiting their domain coverage • Specialization: • Primary task of a software developer, by providing an input specification • “Conventional” generators: business-oriented, data intensive applications. Report generation, data processing and displaying • “Expert” generators: expert knowledge to solve problems in a particular domain • Parser and compilers generators: the most known examples of application generators, such as Lex (Lesk and Schmidt, 1979) and Yacc (Johnson, 1979) • Integration: • Generators that produce a complete executable system do not need integration
(Krueger, 1992) Automated Automated • Software life-cycle using application generators (ideally): System specification (requirements) Architectural design Detailed design Testing Coding Unnecessary Automated
(Sametinger, 1997) • Reuse techniques: • Compositional Reuse: mounting systems from unmodified components (ideally) Component repositories Component composition Code and design Scavenging Code Design Blocks of code copied from other system Large blocks of code. Details deleted. Design retained.
(Sametinger, 1997) • Reuse techniques: • Generative Reuse: reuse of a generation process instead of reuse of components. Examples: lexical analysers, parsers and compilers. Application Generators Transformation Systems Language based generators Programming Languages
(Sametinger, 1997) • Generation vs. Composition
“Domain Engineering is the activity of collecting, organizing, and storing past experience in building systems or parts of systems in a particular domain in the form of reusable assets…” • Vertical X Horizontal Domains • It encompasses: (Czarnecki and Eisenecker, 2000)
(Czarnecki and Eisenecker, 2000) • “Generative Programming (GP) is about automating of intermediate and end-products (i.e., components and applications)” • Domain Engineering helps in GP: System Families Model Problem Space Find Components Model the Config. Knowledge
(Czarnecki and Eisenecker, 2000) Feature and Concept Modeling Design Common Architec. Identify Components Specify DSLs Domain Scoping • Steps in GP: Implement Using Generators Implement DSLs Implement Components Specify Config. Knowledge
(Neighbors, 1980) • DRACO • First system to support the transformation of high-level domain-specific programs to executable code • DE based • Idea: organize software construction knowledge into a number of related domains • DRACO domain encapsulates: DSLs Optimization Transformations Transformational Components Domain-Specific Procedures Transformation Strategies Parse Tree Rules Refinements When a set of transformations can be performed algorithmically Domain Dependant
DRACO – Practical Example (Neighbors, 1980)
(Batory, 1996) • GenVoca • “...building software generators based on composing OO layers of abstraction, whereby layers are stacked.” • Roughly corresponds to the refinement occurring in OO frameworks • Steps: Identify layers of abstraction Put more specialized layers on top Layer below as parameter to the above Families of parameterized layers
(Batory, 1996) • GenVoca Model (layering with Booch C++ Data sctructure)
Four key benefits of code generation: • Quality: increased because of the fixes in templates applied to all code base • Consistency: generated APIs are consistent in class structure • Productivity: generators use a fraction of time of an engineer. So, the engineer can concentrate on more creative solutions • Abstraction: layer of abstraction between design and code base. Definitions input files hold the business schema in a abstracted declarative form which can be inspected by domain experts (CGN, 2005)
Code generators models: • Code Munger • Inline Code Expander • Mixed Code Generator • Partial Class Generator • Tier Generator • Domain Language (CGN, 2005)
Code Munger – Example: JavaDOC (CGN, 2005) • Q– accurate with the code • C– consistent and reliable • P – no external docs • A – little abstraction
Inline Code Expander – Examples: CSQL, JSQL (CGN, 2005) • Q– infra-structure code reduced • C– consistent code adaptable to other DBs • P – save time in DB intensive applications • A – easier inspections in all SQL commands
Mixed Code Generator – Examples: CSQL, JSQL (CGN, 2005) • Q– infra-structure code reduced. Better with IDEs • C– consistent code adaptable to other DBs according to templates • P – save time to focus on SQL • A – easily extracted from code
Partial Class Generator – Example: Visual Studio .NET (CGN, 2005) • Q– database layer controlled by templates. OO to DB errors reduced • C– consistent in all generated classes and API • P – save time to upper layers and not worrying with persistence bugs • A – abstracted into definition files and templates
Tier Generator – Example: Hibernate (CGN, 2005) • Q– equivalent to quality in templates • C– class structure reliable • P – entire tier generated reduces much time • A – tier abstraction is held outside of the code
Domain Language – Examples: Mathematica, Matlab • Types, syntax and operations mapped directly to concepts in the domain • Easier to represent specific structures that general purpose languages do not provide, such as multi-dimensional matrix • Other examples: • COBOL: COmmon Business Oriented Language • Domain-Specific Language (DSL) Tools for Microsoft Visual Studio 2005 • CSound: to create audio files • GraphViz: define graphs and get a visual representation (CGN, 2005)
Qualiti Coder (Qualiti, 2005) • Java e C# • Eclipse Plugin • Wizard based • Layer architecture –Presentation, Data and Communication (PDC)
(Velocity, 2005) • Based on Model-View-Controller: • Allows to separate Java programmers from web designers • Can be used to generate SQL, PostScript and XML from templates • Also can be used to generate source code and reports
(Velocity, 2005) Template based HIBERNATE • GCodCESAR: Usa o Velocity
(J2ME Polish, 2005) • J2ME GUI Code generation • Based on CSS (polish.css file) • Bitmap fonts
(J2ME Polish, 2005) • The tool makes use of preprocessing directives:
Conclusions • Difficulties to be covered: • Domain peculiarities • Code Size and efficiency • Libraries for algorithmic problems • Future to generators: • More readable languages (5th generation) • Large domain coverage • Efficient “Drag-and-Drop generation”
References • (MacIlroy, 1968) MacIlroy, M. D. Mass Produced Software Components. Nato Software Engineering Conference. 1968. • (Freeman, 1983) Freeman, P. Reusable software engineering: Concepts and research directions. In Workshop on Reusability in Programming (Newport, R. I., Sept.). ITT Programming, Stratford, Corm., pp. 2-16. • (Biggerstaff and Ritcher, 1987) Biggerstaff, T. J.; Ritcher, C. Reusability framework, assessment, and directions. IEEE Software. 4, 2 (Mar.), 41–49. 1987. • (Biggerstaff and Perlis, 1989a) Biggerstaff, T. J.; Perlis, A. J. Frontier Series: So filoare Reusability: Volume I—Concepts and Models. ACM press, New York. EDS. 1989. • (Biggerstaff and Perlis, 1989b) Biggerstaff, T. J.; Perlis, A. J. Frontier Series: Software Reusability: Volume II—Applications and Experience. ACM Press, New York. EDS. 1989. • (Qualiti, 2005) Qualiti Coder. Available on http://coder.qualiti.com, accessed in November, 2005. • (Sametinger, 1997) Sametinger, J. Software Engineering with Reusable Components. Springer-Verlag, 1997. • (Krueger, 1992) Krueger, C. W. Software Reuse. ACM Computing Surveys, Vol. 24, No. 2, June 1992 • (Lesk and Schmidt, 1979) Lesk, M. E.; Schmidt, E. Lex: A Lexical Analyzer Generator in the UNIX Programmer’s Manual—Supplementary Documents. 7th ed. AT& T Bell Laboratories, Indianapolis, Ind. 1979. • (Johnson, 1979) Johnson, S. C. Yacc: Yet Another Computer-Compiler in the UNIX Programmer’s Manual—Supplementary Documents. 7th ed. AT&T Bell Laboratories, Indianapolis, Ind. 1979. • (Czarnecki and Eisenecker, 2000) Czarnecki, K.; Eisenecker, U. W. Generative Programming: Methods, Tools, and Applications. Addison-Wesley, May, 2000.
References • (Czarnecki and Eisenecker, 1999) Czarnecki, K.; Eisenecker, U. W. Components and generative programming. In Proceedings of the 7th European software engineering conference held jointly with the 7th ACM SIGSOFT international symposium on Foundations of software engineering ESEC/FSE-7. vol. 24. October, 1999. • (CGN, 2005) Code Generation Network. Available on http://www.codegeneration.net/, accessed in November, 2005. • (Pulvermüller and Speck, 2000) Pulvermüller, E.; Speck, A. Towards generative components. In ACM SIGSOFT Software Engineering Notes archive. Vol. 25 Issue 2. pp. 22-24. ACM Press, March, 2000. • (J2ME Polish, 2005) J2ME Polish. Available on http://www.j2mepolish.org/, accessed in November, 2005. • (Velocity, 2005) Jakarta Velocity. Available on http://jakarta.apache.org/velocity/, accessed in November, 2005. • (Neighbors, 1980) Neighbors, J. M. Software construction using components. Ph. D. Thesis, Department Information and Computer Science, University of California, Irvine, 1980. • (Neighbors, 1989) Neighbors, J. M. Draco: a method for engineering reusable software systems. In Source Software reusability: vol. 1, concepts and models. pp. 295-319. ACM Press, 1989. • (Batory, 1996) Batory, D. Software System Generators, Architectures, and Reuse. In Fourth International Conference on Software Reuse. Tutorial Notes, Orlando, 1996.
Application Generators Advanced Seminars in Software Reuse Leandro Marques do Nascimento