Application generation Peter Bell SystemsForge Peter Bell SystemsForge Beyond Scaffolding
Overview Beyond Scaffolding A New Approach to Programming Key Concepts Anatomy of a Generator Software Product Lines Generating Web Applications
Let’s Start With Scaffolding Scaffolding is “free functionality” List, view, add, edit, delete Typically driven by DB schema Usually end up rewriting
Why Rewrite? Databases are dumb!... SSN is not just char(9) Form fields Advanced validation Display rules Business rules
A New Approach to Programming Language Oriented Programming “Building software around a set of Domain Specific Languages” - Martin Fowler Programmer as Language Designer
Language Oriented Programming OMG: Model Driven Architecture Microsoft: Software Factories Charles Simonyi: Intentional Programming JetBrains (IntelliJ): Meta Programming System MetaCase: MetaEdit EVERYONE is Doing It!!!
Language Oriented Programming Custom TagsUDFs CFCsAPIs YOU’re Already Doing It Property: Value FileXML Config File
API As Language Design... CODE... String = getDependentObjectList(ObjectName: String) Concept: getDependentObjectList Attribute: ObjectName
Language Oriented Programming Why do it?... Encapsulating Complexity (layered software) Key concepts...
Domain Specific Languages Limited form Specific domain Horizontal: - SQL - Reg-Ex - Objects - Notifications Vertical: - Newsletter - Shipping Rules - Insurance Quotes - Newspaper Workflows “Trade generality for expressiveness”
Three Types of Language Declaritive: What to do (requirements) Templating: Where to put (layout) Scripting: How to do (imperative)
Declaritive Name: Password: Required SELECT FullName FROM tbl_User Where UserID = 7
Templating #Title# $#Price#
Scripting For (Count = 1; Count lte listlen(ObjectDependencyList); Count=Count+1) { // Get current object name LoopObjectName = ListGetAt(ObjectDependencyList, Count); If (LoopObjectName NEQ "LightWire") { // Prepend it with ObjectName LoopObjectName=ListAppend(arguments.ObjectName,LoopObjectName,"|"); // Add it to the new object dependency list TempObjectDependencyList=ListAppend(TempObjectDependencyList,LoopObjectName) };
Three Types of Language Declaritive: Ideal for Reuse Templating: Simplify for designers Scripting: Use to implement
Abstract vs. Concrete grammar WHAT say vs. HOW say FirstName Boxes and Arrows
In-Language vs. External DSL In Language: CFC, UDF, Custom Tag Easy to create No validation Can use core language External: XML/custom file Store in database Harder to create Validation Can limit language
Types of Generation Passive Active Round trip Not much use Works great Not Required ->
Anatomy of a Generator Metadata Templates Iterator Orchestrator Extensions
Metadata Scripting XML Custom Syntax Databased
Templates Generating n-Getters: Template: > > Velocity - XSLT - CF Template Generate a File
Templates
Iterator One DAO per business object One template per screen In general: one file per instance of concept Possibly filter concepts Generate n-Files
Orchestrator Metadata (getObjectList) Template (ObjectDAO.cft) Iterator (Object: All) File name (#ObjectName#DAO.cfc) Generate m-Collections of n-Files
Extensions “Safe Code Snippets” Inheritance
Anatomy of a Generator Metadata Templates Iterator Orchestrator Extensions Generation NEQ Deployment
Software Product Lines Core Framework (scripts, DSLs, metadata) Feature Model Configurators
Generating Web Applications What is a website? Object Model+Interface Model
Object Model Objects: Attributes: Relationships Objects and Attributes: Optional: Datetime: Optional: Datetime: Required: Status: approved Page: extends Required: Title Article: extends Optional: HTML Relationships: Page: Article: optional: multiple Article: Page: required: single
Object Model (2) Custom Data Types AsDate StatusList WYIWYG
Interface Model Screens: Actions: Steps = = = 10,25,50,all ArticleAdminList Title
Conclusions Programming as Language Design Horizontal and vertical DSLs Top down and and bottom up Generate everything: scripts, database, documentation, config XML, build scripts, etc. Layer software product line for higher levels of reuse Look out for CFGen, CF Template