Your SlideShare is downloading. ×
PowerPoint Presentation
Upcoming SlideShare
Loading in...5

Thanks for flagging this SlideShare!

Oops! An error has occurred.

Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

PowerPoint Presentation


Published on

Published in: Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

No notes for slide


  • 1. Code Generation using Templates An Introduction
  • 2. TMR Management, Inc. Overview
  • 3. About TMR MGI
    • Local Company
      • A Women Business Enterprise (WBE) and Minority Business Enterprise
      • Founded in 2001 with continued growth
      • Headquartered in Harrisburg, PA
      • Approved in ITQ
      • Consistent track record of success in delivering mission critical projects in emerging technologies
      • Specialized in implementing CMM process and execution at Level 3
      • Specialized in implementing ITIL and BS799 process
      • Experienced in engaging quality consulting resource
  • 4. Services We Provide
    • Enterprise Migration Services
    • Application Architecture & Engineering Services
    • Business Intelligence Reporting
    • IV&V and Team Mentoring Services
    • Professional Staffing Services
      • SAP HR
      • Mainframe support
  • 5. Today’s Agenda
    • How to Increase Efficiency and Minimize Errors by code generation on .NET Projects
      • What is code generation
      • Benefit on the project
      • Demo of CODESMITH
        • To create web services (ASMX)
        • To create web services (WCF – both REST AND NON-REST style)
      • Template
        • How to create/edit
      • Different tools and Open source tools
      • CODESMITH – NON CODE generation use
      • Questions / Answers
  • 6. Why we need?
    • Code Generation – CG
    • Are we Lazy?
    • Are we SMART?
    • Or…?
    • Why we need code generation?
    • Are we using it without knowing it?
      • Let us talk about some examples we know
  • 7. Why….?
    • The two main constants in software engineering are:
    • Programmers’ time is valuable.
    • Programmers don’t like repetitive, boring tasks
    • Code generation takes over the task of writing repetitive infrastructure code, leaving more time for engineers to concentrate on the interesting programming challenges that they do enjoy.
    • Code generation doesn’t just eliminate grunt work; it provides benefits to the software engineering lifecycle
  • 8. What is CG any way?
    • Code generation is any way you create code other than writing it line by line in an editor.
    • Code generation is about writing programs that write programs
    • when one can work smarter rather than harder
    • < template > + < metadata > = < generated code >
    • Focusing on the big picture, one can build better solutions.
  • 9. Benefits
      • Productivity
      • Quality
      • Consistency
      • Abstraction
      • A single point of knowledge
      • More design time
      • Design decisions that stand out
      • Architectural consistency
      • High morale
      • Agile development
      • Efficiency
      • Minimize Errors
      • Standardization
      • Code Documentation
    APPLICATION CODE GENERATION REVOLUTIONIZES the way one writes program/code
  • 10. Objective
    • Build a higher quality application faster
    • Ready for changes during development and throughout the application life cycle.
    • Provides this level of software agility at the same time it allows you to create massive amounts of code.
  • 11. Top 10 Code Generation Rules
    • Give the proper respect to hand-coding
    • Handwrite the code first
    • Control the source code
    • Make a considered decision about the implementation language
    • Integrate the generator into the development process
    • Include warnings
    • Make it friendly
    • Include documentation
    • Keep in mind that generation is a cultural issue
    • Maintain the generator
  • 12. Principles for CG
    • 5 Principles - non-negotiable for code generation:
    • Principle #1 :
      • You have control of the templates that generate your code and can change or replace them as required.
    • Principle #2 :
      • You collect metadata as a separate, distinct step with usable output that can independently evolve.
    • Principle #3 : You, or someone unfamiliar with project, can regenerate
      • your code precisely as a one-click process—now or at any point in the future.
    • Principle #4 : You embrace handcrafted code by isolating and protecting it.
      • Code generation is a supporting player to human programming and doesn’t overwrite files unless they were generated and haven’t been edited.
    • Principle #5 :
      • The code-generated application is a high-quality application. It allows more effective testing, has equal or better performance, and is more easily maintained than a similar fully handcrafted application.
  • 13. Steps in CG
    • 5 steps are as follows:
    • Design architecture.
    • Collect metadata.
    • Build and run templates.
    • Handcraft code.
    • Tie it together with integration and testing.
  • 14. Code Category
    • Several types of handcrafted code:
    • Startup
    • Exception reporting
    • Components
    • Utility methods
    • Base class functionality
    • Debug support
    • Code with insufficient, inconsistent, or interspersed patterns
    • Class-specific code
  • 15. Other Examples
    • T4 (Text Template Transformation Toolkit) - the code generation engine used as part of Domain Specific Languages and Software Factories projects. With the T4 toolkit now built directly into Visual Studio 2008, you can easily add code generation to your arsenal
    • Microsoft Entity Framework - .NET 3.5 SP1
    • Software Factories – SCSF, WSSF etc.
    • Microsoft Blueprints
    • Class Library project and a class that implements the IDTWizard interface in VS2008
  • 16. What is CodeSmith Anyway….!
    • CodeSmith is a software development tool to help you get your job done faster. Technically speaking it is a template driven source code generator that automates the creation of common application source code for any language (C#, Java, VB, PHP, ASP.NET, SQL, etc.).
    • CodeSmith's syntax is almost identical to ASP.NET. So if you are familiar with ASP.NET then you should be able to quickly learn the template syntax. You can use the C#, VB.NET or JScript.NET languages in your templates and your templates can output any ASCII-based language.
  • 17. What is CodeSmith Anyway….!
    • Note from Microsoft Contact:
      • “ I have several clients that have used CodeSmith in the past with great success.  We even have some internal projects here at Microsoft that have utilized it for non-shipping code. Feel free to mention that even Microsoft has used it & you received a note from a contact too on this topic on being used in industry.“