CodeSmith - PowerPoint PPT Presentation

1 / 15
About This Presentation
Title:

CodeSmith

Description:

Ability to auto-execute SQL scripts ...and much, much more. Customers include... Strongly typed accessory to XML file. Read-only access. Without an XSD file ... – PowerPoint PPT presentation

Number of Views:120
Avg rating:3.0/5.0
Slides: 16
Provided by: robho
Category:
Tags: codesmith

less

Transcript and Presenter's Notes

Title: CodeSmith


1
CodeSmith .netTiers Using Code Generation to
boost productivity
Robert Hinojosarhinojosa_at_codesmithtools.com
2
For More Information
  • Learn more
  • www.codesmithtools.com
  • Download free 30 day trial
  • Contact Us
  • sales_at_codesmithtools.com
  • 1 972 407 0688
  • CodeSmith Telligent
  • Partnered together with a common goal
  • Build world-class software tools

3
Agenda
  • What is Code Generation?
  • What is CodeSmith?
  • What is .netTiers?
  • How can .netTiers help me?

4
What is Code Generation
  • Software creation
  • Can be fun and challenging
  • but also repetitive and monotonous
  • Repetition monotony leads to bugs
  • Code generation is not a new concept
  • With most tools you dont control the output
  • Often viewed as a Black Box solution
  • Ex, data layer created (but it is not your code)
  • CodeSmith 4.0
  • Not a Black Box solution
  • Template driven code generation (it is your code)
  • Use existing templates or write new ones

5
The value of .netTiers
  • The cost of creating a home grown framework
  • Design, Development, Test, Release
  • Easily runs between 50 - 300/hour
  • CodeSmith
  • .netTiers 2.0 Free open source templates with
    thriving community
  • CodeSmith 4.0 Professional 399
  • For you, FREE!
  • Equivalent to 3-6 hours of development
  • Real value you can measure
  • Dramatically reduces time to market cost
  • Quickly pays for itself

6
Your code. Your way. Faster!
  • CodeSmith
  • Version 2.6, released January 2004
  • Version 3.0, released May 2005
  • Version 3.1, released August 2005
  • Version 3.2, released Nov 2005
  • CodeSmith 4.0 includes
  • CodeSmith Professional Studio (IDE)
  • Visual Studio .NET integration
  • Command line code generation engine
  • CodeSmith Projects, ActiveSnippets

7
CodeSmith Version 4.0
  • Manage templates anywhere with CodeSmith Projects
  • Extremely Integrated Visual Studio Support
    (ActiveSnippets and CodeSmith Projects)
  • Statement Completion, AKA Intellisense
  • Deep XML support
  • New merge strategies preserve region
  • Easy template debugging
  • Template caching for faster execution
  • Event driven template architecture
  • Ability to auto-execute SQL scripts
  • and much, much more

8
Customers include
and many others
9
Using CodeSmith 4.0
10
CodeSmith Professional Studio
  • Integrated Development Environment
  • Editing and Executing templates
  • Template Explorer
  • Professional Edition only
  • Features
  • Database schema browser
  • Template syntax highlighting
  • Template, Output, and Compilation views
  • Property editing

11
CodeSmith Templates
  • Similar to ASP.NET page
  • CodeSmith Templates will be familiar
  • Event and lt gt code
  • Template contains
  • Directives
  • Template logic (VB C code)
  • Output Text (your code, comments, etc.)
  • Template events, methods, and properties
  • A CodeSmith template is
  • Document with .cst extension
  • Edit with CodeSmith Studio or text editor

12
My First Template
13
Visual Studio Integration
  • Integrated with Visual Studio .NET
  • Automatically integrated during installation
  • Visual Studio Package Integration
  • Using CodeSmith within Visual Studio .NET
  • Tools -gt CodeSmith
  • Executing Templates in Visual Studio .NET
  • View/Execute CodeSmith Projects in your VS
    Solution
  • Easy to use ActiveGeneration
  • View templates in Template Explorer
  • Right-click to execute templates
  • Drag and drop onto Editor

14
CodeSmithProjects
CodeSmithExplorer
15
Visual Studio Integration
16
Working with XML
  • New XmlProperty
  • Work with XML in a strongly typed manner
  • Using XML as metadata very easy
  • With an XSD
  • Strongly typed accessory to XML file
  • Read-only access
  • Without an XSD file
  • XmlDocument type returned

17
Debugging Templates
  • Set Debugger.Break() in code
  • Break-point in Template execution
  • .NET JIT Debugger window opens
  • From .NET JIT Debugger window
  • Select Debug Tool
  • EX, Visual Studio .NET 2005
  • Step through template source
  • Reports error in template directly
  • Most tools allow debugging of the result

18
Debugging Templates, cont
  • Compilation is similar to ASP.NET
  • Occasionally template is not enough
  • Need the ability to examine source
  • LinePragmas
  • Defined in lt_at_ CodeTemplate gt
  • Set to true or false
  • Default to true
  • Reports line number in template
  • False, reports line number in generated code

19
Debugging Templates
20
CodeSmith Project
  • Runs Everywhere
  • Consistently generate and/or configure your
    template sets from anywhere
  • Windows, Visual Studio, CodeSmith Studio, Command
    Line, MSBuild
  • CodeSmith Command line tool
  • Build project from command line
  • CodeSmith used for Active Generation
  • Easily integrated into environment

21
Command Line Tool
  • Console Application (cs.exe)
  • XML file identifying templates to run
  • Mirror CodeSmith Project usage anywhere
  • Execute single template, or N templates
  • Execute batches of templates

cs.exe MyCodeSmithProject.csp
22
Merge Strategies
  • Enable Active Generation
  • Cant always generate exactly what you need
  • Custom logic along with Active Generation
  • Example
  • SampleProjects\ConsoleSamples
  • PreserveRegionsMergeSample.cst

23
Merge Strategies
24
What is .netTiers
.netTiers is a library of Codesmith templates
that builds object-relational mapping for an
existing database.
  • Creates objects and domain based on the
    relationships in your database.
  • Creates separate Logical layers Entity, DAL,
    Business, Web, Forms, WebService
  • Creates stored procedures or parameterized SQL
    for data access layer.
  • Creates Asp.Net 2.0 admin user controls.
  • Creates code which is fully XML commented

25
.netTiers Advantages
  • 100 Open Source, Template Driven
  • Reduces development time
  • Reduces maintenance time
  • All applications have a consistent domain model,
    with standard code
  • Making changes / updates by another team member
    easier
  • Promotes reuse
  • Data Access completely separated from user
    interface
  • Promotes Enterprise Standards utilizing Microsoft
    P P Enterprise Library
  • Easier Application Integration

26
Domain Model vs DataSet
  • Predictable behavior
  • Compare the following methods
  • public Customer GetByCustomerId(int id)
  • public DataSet GetByCustomerId(int id)
  • Promotes loose coupling of presentation and
    domain logic
  • Easier to document
  • Intellisense in Visual Studio
  • Less memory intensive

27
Using .netTiers
28
Data API
  • Support for basic CRUD Update, Delete, Insert,
    Find, Paged, Custom Sprocs, GetBy (PK, IX, FK,
    MM)
  • Support for queries using
  • Primary Key
  • Foreign keys
  • Indexes
  • Many-Many join relationships

29
Data API
  • Transaction Support
  • API Plumbing generated from Your own Stored
    ProceduresEX. _TableName_MyMethodName
  • Support for deep object graph loading/saving
  • Use stored procedures or xml embedded
    parameterized SQL

30
Sample Method Calls
  • //All Providers kept within DataRepository
    class
  • EmployeeCollection employees DataRepository.Empl
    oyeeProvider.GetAll()
  • //When using primary key, single object is
    returned
  • Employee emp DataRepository.EmployeeProvider.Get
    ByEmployeeId(4)
  • Employee newEmployee new Employee()
  • newEmployee.FirstName John
  • newEmployee.LastName Doe
  • //when inserting the primary key value is set for
    the object
  • bool success DataRepository.EmployeeProvider.Ins
    ert(newEmployee)
  • //inserting collection
  • EmployeeCollection ec new EmployeeCollection()
  • Employee e1 new Employee()
  • ec.Add(e1)
  • bool success DataRepository.EmployeeProvider.Ins
    ert(ec)

31
Using .netTiers API
32
Conclusion/ QA
  • .netTiers 2.0
  • Proven Pattern Based Framework Generation
  • CodeSmith 4.0
  • Most powerful code generation tool available
  • Reduces time spent writing trivial code
  • Be more productive
  • Template driven means its still your code
  • Saves you time and money

33
  • Learn more
  • www.codesmithtools.com
  • Download free 30 day trial
  • Contact Us
  • sales_at_codesmithtools.com
  • 1 972 407 0688
Write a Comment
User Comments (0)
About PowerShow.com