1 / 22

Practical Code Generation

Practical Code Generation. Peter Bell SystemsForge. Overview. Who am I? Why Listen? Problems to solve Potential solutions Domain Specific Languages Software Product Lines Code Gen/Frameworks Next Steps. Who Am I?. Programmer - 30-40 projects/yr.

shandi
Download Presentation

Practical Code Generation

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Practical Code Generation • Peter Bell • SystemsForge

  2. Overview • Who am I? • Why Listen? • Problems to solve • Potential solutions • Domain Specific Languages • Software Product Lines • Code Gen/Frameworks • Next Steps

  3. Who Am I? • Programmer - 30-40 projects/yr. • Researcher - Published academic papers DSM forum/ooPSLA • Entrepreneur - Profitable/practical • SystemsForge - 10,000 custom apps/yr. • Writer - CFDJ, Fusion Authority Quarterly • Presenter - cf.objective(), CF United, Frameworks, Code Generation 2007, ooPSLA, Domain Specific Modeling Forum, CFCamp . . .

  4. Why Listen? • Companies are reporting 5-10x faster development using Domain Specific Languages and Software Product Lines • You’re already doing these things • A few concepts will help you to do them better

  5. Calibration • Have you: • Written OO code? • Heard of DSLs? • Written a DSL? • Heard of SPLs • Created a SPL?

  6. Problems • OO coding is slow • Changes are painful • Reuse is difficult

  7. OO Coding is Slow Add Products to site . . . • Admin controller/views • Front end controller • Catalog.cfc • Front end views • ProductList.cfm, ProductDetail.cfm • ProductService.cfc • ProductDAO.cfc • Product.cfc • tbl_Product • ColdSpring/Lightwire config

  8. Changes are Painful • Add services from tbl_Service to product catalog • Products -> multiple categories • Change form error handling (error list to in-form display)

  9. Re-use is Difficult • Libraries/utility components/cut and paste/snippets - usually OK • Problem with cfc reuse is usually cross cutting concerns: • Logging • Error handlers • Notification services • Other dependencies . . .

  10. Solving Same Problems • Techniques • Form processing • DB access • Paginated lists • Reporting • Imports/Exports • Solutions • Content management • Workflow • Shopping carts

  11. Potential Solutions • Code quicker - DSL • Maintain easier - DSL • Re-use better - SPL

  12. Domain Specific Language “An executable language targeted to a specific problem domain” • Specific - can’t do everything • Executable - not just conceptual • Raising level of abstraction

  13. Types of DSLs • Vertical (business focused) • Insurance policy language • Product configuration language • Academic requirements language • Horizontal (tech focused) • SQL • RegEx • Import description language • General workflow language

  14. Types of DSLs - Internal • Custom tag • <cf_import filename="test.csv" record-delimiter="," field-name-list="FirstName,LastName,Email" source="tbl_User" method="update"> • API • UserService.import("test.csv", ",", "FirstName,LastName,Email", "tbl_User", "update"); • Method Chaining • User.IsValid.FirstName()

  15. Types of DSL - External • Comma delimited • "test.csv", ",", "FirstName,LastName,Email", "tbl_User", "update" • XML • <import filename="test.csv" record-delimiter="," field-name-list="FirstName,LastName,Email" source="tbl_User" method="update" /> • Databased • “Little Language” • Import test.csv using commas update tbl_User with FirstName,LastName,Email • Visual

  16. DSL Key Concept • Abstract Grammar vs. Concrete Syntax • What you say vs. How you say it <cfset Objects.User.Title = “User”> <cfset Objects.User.Attributes.Name = “FirstName”> <Object title=”User”> <Name>FirstName</Name> </Object> User @FirstName

  17. Example DSL Product extends: BaseObject tableName: tbl_Product Identity: ProductID Properties: Title title required Price money optional default:0 Description WYSIWYG optional ClassMethods: AdminList: Title,Price OrderBy Title DefaultAdd: Title,Price,Description QuickAdd: Title,Price multiple:5 DefaultEdit: ID, Title,Price,Description Relationship has-many Category associated optional

  18. Benefits of DSLs • More concise (less to write/edit) • Can add constraints • MAY be end user editable

  19. Software Product Lines • Design a collection of applications • Bounded and unbounded variability • Bounded: feature model/configuration • Unbounded: DSLs • Extension points

  20. Code Gen/Framework • Both use DSLs • Compiled/interpreted • Late bound decision

  21. Next Steps • Single Application? • Reusable services • Raise abstraction levels • DSLs: Custom tags, APIs, external config files, CMSs, visual editors (Eclipse EMF) • Multiple Applications? • Plan variability • Feature model • Configuration options • DSLs • Generators/framework

  22. Questions? • Blog: • www.pbell.com • Email: • peter@pbell.com • Yahoo: • freshstartsw • AIM: • appgeneration

More Related