SlideShare a Scribd company logo
1 of 66
Download to read offline
APPLIED CODE GENERATION IN
           .NET
        Dmytro Mindra
        Lohika, Odessa

         @dmytromindra
@dmytromindra
The question of Origin ?
• We are engineers !
• Engineers’ time is valuable and expensive;
• Engineers don’t like repetitive tasks;




                   @dmytromindra
Task classification
• Brains
• Experience
• Procedures




                @dmytromindra
Houston, we’ve got a problem !

Our business domain contains 500+ entities.
         Each entity needs CRUD.




               @dmytromindra
Houston, we’ve got a problem !
         And you have lots of time.
           The whole 4 months.

For your big team of 4 developers that should
               not be a problem !




                 @dmytromindra
Houston, we’ve got a problem !
Oh, and we’re not sure which parts will stay
 generic and which won’t




                   @dmytromindra
Houston, we’ve got a problem !
Be agile, don’t wait for the analysts to finish their
job, because we don’t have that kind of time.

Just change your code when the Requirements are
finished.




                     @dmytromindra
Houston, we’ve got a problem !
For each domain entity we should have
• Stored Procedures
• Repository
• Service
• Controller
• Views
• etc

That’s about 1000 lines of code per entity.


                          @dmytromindra
Houston, we’ve got a problem !
But we have 500+ entities

500*1000 = 500000 lines of code.

Who wants to type this in ?




                  @dmytromindra
Houston, we’ve got a problem !
• And when the changes arrive someone should
  make corrections to 500*1000 lines of code.




                 @dmytromindra
What are the solutions ?
• Hand-code everything (and every change)
   – Hire a lot of monkeys coders

• Design everything generically, correctly the first time
   – Mission impossible

• Use only code generation
   – And spend your life changing generator to match all
     possible requirements

• Use combination of tools including code generation.
   – This seems reasonable
                          @dmytromindra
Boilerplate
• Interestingly, the term (boilerplate) arose
  from the newspaper business. Columns
  and other pieces that were syndicated
  were sent out to subscribing newspapers
  in the form of a mat (i.e. a matrix). Once
  received, boiling lead was poured into this
  mat to create the plate used to print the
  piece, hence the name boilerplate. As the
  article printed on a boilerplate could not
  be altered, the term came to be used by
  attorneys to refer to the portions of a
  contract which did not change through
  repeated uses in different applications,
  and finally to language in general which
  did not change in any document that was
  used repeatedly for different occasions.



                              @dmytromindra
@dmytromindra
CODE GENERATION is code that writes code




                 @dmytromindra
Some common terms
• Code generation
• Automatic programming
• Generative programming




                @dmytromindra
IDE Generated Code Example




         @dmytromindra
Tools evolution




   @dmytromindra
Code Smith
http://www.codesmithtools.com/

             Demo
           @dmytromindra
Generator




Input
          Code           Output
        Generator



         @dmytromindra
Why CG?
•   Productivity
•   Quality
•   Consistency
•   Abstraction




                    @dmytromindra
@dmytromindra
PROS
•   Code uniformity
•   Easy to debug
•   Easy to introduce huge changes
•   No more boilerplate code




                    @dmytromindra
CONS
• Someone should maintain the generator
• Generator has learning curve
• Generator usually has limitations




                 @dmytromindra
Applications
•   Database Access
•   Generate Test Data
•   Generate Integration Tests
•   User Interface
•   Documentation
•   Unit tests
•   File Formats
•   Web services
•   Business logic
•   DLL Wrappers
•   Firewall configuration
•   Website configuration
•   Looking for localizable strings

                              @dmytromindra
Code Generation is Fun ?
• CG makes boring job for you

• Writing generator is fun

• Once written generator works for you

• You can experiment with different implementations by
  modifying generator and regeneration the code.

• While writing the generator you get deeper into the
  technology instead of doing dull job.

                      @dmytromindra
Scaffolding and prototyping
• Code generation can help you to build fast
  prototypes.




                  @dmytromindra
MVC Scaffolding Demo




      @dmytromindra
Rules
1. Give the proper respect to hand-coding
2. Handwrite the code first
3. Control the source code
4. Make a considered decision about the
   implementation language
5. Integrate the generator into the development
   process


                  @dmytromindra
Rules
6.  Include warnings
7.  Make it friendly
8.  Include documentation
9.  Keep in mind that generation is a cultural
   issue
10. Maintain the generator



                   @dmytromindra
A note about DSL

A domain-specific language (DSL) is a
programming language or specification
language dedicated to a particular problem
domain




                 @dmytromindra
LOGO




@dmytromindra
Model Driven Architecture



         @dmytromindra
@dmytromindra
Model Driven Architecture
• Code generation has a dramatic impact on
  development time and engineering productivity.

• The application is amenable to change on a large scale.

• The business rules are abstracted into files that are free
  of language or framework details that would hinder
  portability.

• The code for the application is of consistently high
  quality across the code base.

                       @dmytromindra
Benefits of MDA
•   Quality
•   Consistency
•   A single point of knowledge
•   More design time
•   Design decisions that stand out




                    @dmytromindra
Software Factories




     @dmytromindra
Industrializing Software Development




             @dmytromindra
Software Factory




    @dmytromindra
Consider this:
• Code generation has a large initial schedule
  overhead;

• Code generators are ideal for well-known large-
  scale problems;

• Code generation is powerful when used
  appropriately;

• Always keep in mind code generation limitations!

                    @dmytromindra
Code Generation Skills
•   Text Templates
•   Regular Expressions
•   XML Parsing
•   Reflection




                    @dmytromindra
Show me
the tools


       @dmytromindra
Available tools
•   StringBuilder
•   CodeSnippets
•   XSLT
•   Reflection Emit
•   EnvDTE
•   CodeDom
•   T4
•   … (Python, Ruby,

                       @dmytromindra
StringBuilder
• Advantages
  – Almost all .net developers should feel comfortable using
    the StringBuilder class so it requires no additional
    languages / tools to learn.
  – Even with the disadvantages, the StringBuilder can be an
    excellent choice if you need to generate code quickly.
    Especially if you don’t need to maintain the “template”
    long term.
• Disadvantages
  – Unable to truly see the “template” within the control logic.
  – Requires a recompile if the “template” should be changed.


                        @dmytromindra
Code Snippets
• Advantages
  – Simple Xml based template with numerous
    samples provided within Visual Studio.
  – Several open source code snippet libraries
    available.
• Disadvantages
  – Limited snippet functions and at the present time
    developers are unable to author additional
    snippet functions!
                    @dmytromindra
XSLT
• Advantages
  – Xml based template.
  – Simple code generation technique for those
    developers comfortable with XSLT
    transformations.
• Disadvantages
  – While Xml is a relatively simple technology, XSLT
    has been known to bring grown men to tears!
  – XSLT can be difficult to debug.
                     @dmytromindra
Reflection Emit
It is rocket science mixed with the black arts.

• Full representation of physical structure
• Allows building modules and assemblies at
  runtime
   – Transient code only used at runtime
   – Persistent code for reuse
• Create classes, types and emit IL
• Used by .NET compilers to build .NET apps
• Can be as fast as normal code
                      @dmytromindra
EnvDTE
• EnvDTE is an assembly-wrapped COM library
  containing the objects and members for Visual
  Studio core automation.

• Using EnvDTE you can develop your own add-
  ins for Visual Studio that can generate code.



                  @dmytromindra
CodeDom
• Advantages
  – Allows a single “template” to generate code within several
    target languages, such as VB and C#.
  – Additional language providers can be written to support
    other languages.
  – Proven technology, used by Microsoft for code generation
    in all versions of Visual Studio since .net was released.
• Disadvantages
  – Unable to truly see the “template” within the control logic.
  – Requires a recompile if the “template” should be changed.
  – Very few developers have experience using the CodeDom
    even though it has been with us since the .net framework
    1.0.
                        @dmytromindra
Text
Template
Transformation
Toolkit


   @dmytromindra
How T4 Works ?




   @dmytromindra
T4 Tools
• Tangible T4 Editor for Visual Studio 2010
  RTM adds IntelliSense and Syntax Coloring to
  T4 Text Templates.

• T4 Toolbox




                  @dmytromindra
T4 Pros and Cons
• Advantages
   – Ability to embed C# control logic within the template.
   – Syntax that will be somewhat familiar to classic ASP developers..
   – Preferred code generation technique for Entity Framework 4.0
     and the Visual Studio 2010 modeling tools., which means lots of
     samples on MSDN, etc.
   – Templates can be precompiled.
• Disadvantages
   – While third parties have written language support for Visual
     Studio no built in support for editing T4 templates exists in
     Visual Studio today.
   – Relatively new technology, therefore not many developers have
     experience with T4 templates.


                          @dmytromindra
ReSharper 6.0
           Code Generation

Create from Usage
Generate Type Members
Generate Type Constructor
Generate Properties
Generate Delegating Members
Generate Formatting Members
Generate Equality Members
Implement/Override Methods

               @dmytromindra
Some advices




  @dmytromindra
Shall I Generate Interfaces?




          @dmytromindra
Shall I Generate Interfaces?
No !




          @dmytromindra
Shall I Unit Test generated code ?
• You shouldn’t unit test generated code. You
  may unit test generator instead.




                  @dmytromindra
Real World
Case Studies

   @dmytromindra
Case 1: Client – Server Communication


                                Communic
 Existing    Generated            ation    Generated
   API      Server Proxy         channel   Client Proxy




                           @dmytromindra
Legacy API

                Adapter




@dmytromindra
                   Existing
                                Case 2: API Wrapper




                  Application
Case 3: Protocol Parser




       @dmytromindra
Case 4: Model Driven DAL



          Hand written services


                        Generated Repositories


XML                       Generated Entities
Model

                        Partially generated DB

          @dmytromindra
It’s an Engineering, Baby !
Conclusion:
  • Not a silver bullet but another good
  tool;

  • Makes life easier when applied
  properly;

  • Writing generator is much more fun
  than writing boilerplate code;

  • Generated code is easier to debug;

  • You can make huge changes in
  regenerated code easily;




                              @dmytromindra
Do try this !
• Code generation can make you flexible and
  responsive. Do try this at home. (Or at work)




                   @dmytromindra
@dmytromindra

More Related Content

Viewers also liked

Oleg Koss design thinking breaking silos
Oleg Koss design thinking breaking silosOleg Koss design thinking breaking silos
Oleg Koss design thinking breaking silosOleg Koss
 
Pactical case of Atlassian Tools implementation
Pactical case of Atlassian Tools implementation Pactical case of Atlassian Tools implementation
Pactical case of Atlassian Tools implementation Yuriy Kudin
 
Need Robust Software? Make It Fragile
Need Robust Software? Make It FragileNeed Robust Software? Make It Fragile
Need Robust Software? Make It FragileYegor Bugayenko
 
Dependency Injection або Don’t call me, I’ll call you
Dependency Injection або Don’t call me, I’ll call youDependency Injection або Don’t call me, I’ll call you
Dependency Injection або Don’t call me, I’ll call youDmytro Mindra
 
Project Manager - Глупая идея
Project Manager - Глупая идеяProject Manager - Глупая идея
Project Manager - Глупая идеяNikita Filippov
 
Microservices as Chat Bots
Microservices as Chat BotsMicroservices as Chat Bots
Microservices as Chat BotsYegor Bugayenko
 
How Do You Talk to Your Microservice?
How Do You Talk to Your Microservice?How Do You Talk to Your Microservice?
How Do You Talk to Your Microservice?Yegor Bugayenko
 
How to build rubust org structure for Agile at scale
How to build rubust org structure for Agile at scaleHow to build rubust org structure for Agile at scale
How to build rubust org structure for Agile at scaleYuriy Kudin
 
Applying both Agile and Waterfall in one project
Applying both Agile and Waterfall in one projectApplying both Agile and Waterfall in one project
Applying both Agile and Waterfall in one projectMaksym Dovgopolyi, PMP
 
Introduction to Value Planning for iHUB
Introduction to Value Planning for iHUBIntroduction to Value Planning for iHUB
Introduction to Value Planning for iHUBDmytro Mindra
 
Chat Bots are the new UI
Chat Bots are the new UIChat Bots are the new UI
Chat Bots are the new UIYegor Bugayenko
 
VMware Integrated OpenStack with NSX-V POCガイド (第3版)
VMware Integrated OpenStack with NSX-V POCガイド (第3版)VMware Integrated OpenStack with NSX-V POCガイド (第3版)
VMware Integrated OpenStack with NSX-V POCガイド (第3版)Shojiro Ohtani
 
Meetings Help Us and Kill Our Projects
Meetings Help Us and Kill Our ProjectsMeetings Help Us and Kill Our Projects
Meetings Help Us and Kill Our ProjectsYegor Bugayenko
 
Meetings-free Programming
Meetings-free ProgrammingMeetings-free Programming
Meetings-free ProgrammingYegor Bugayenko
 

Viewers also liked (17)

Scrum roles
Scrum rolesScrum roles
Scrum roles
 
Oleg Koss design thinking breaking silos
Oleg Koss design thinking breaking silosOleg Koss design thinking breaking silos
Oleg Koss design thinking breaking silos
 
Pactical case of Atlassian Tools implementation
Pactical case of Atlassian Tools implementation Pactical case of Atlassian Tools implementation
Pactical case of Atlassian Tools implementation
 
Need Robust Software? Make It Fragile
Need Robust Software? Make It FragileNeed Robust Software? Make It Fragile
Need Robust Software? Make It Fragile
 
Dependency Injection або Don’t call me, I’ll call you
Dependency Injection або Don’t call me, I’ll call youDependency Injection або Don’t call me, I’ll call you
Dependency Injection або Don’t call me, I’ll call you
 
Project Manager - Глупая идея
Project Manager - Глупая идеяProject Manager - Глупая идея
Project Manager - Глупая идея
 
Microservices as Chat Bots
Microservices as Chat BotsMicroservices as Chat Bots
Microservices as Chat Bots
 
How Do You Talk to Your Microservice?
How Do You Talk to Your Microservice?How Do You Talk to Your Microservice?
How Do You Talk to Your Microservice?
 
How to build rubust org structure for Agile at scale
How to build rubust org structure for Agile at scaleHow to build rubust org structure for Agile at scale
How to build rubust org structure for Agile at scale
 
Blame the Project
Blame the ProjectBlame the Project
Blame the Project
 
Applying both Agile and Waterfall in one project
Applying both Agile and Waterfall in one projectApplying both Agile and Waterfall in one project
Applying both Agile and Waterfall in one project
 
Introduction to Value Planning for iHUB
Introduction to Value Planning for iHUBIntroduction to Value Planning for iHUB
Introduction to Value Planning for iHUB
 
Chat Bots vs UI
Chat Bots vs UIChat Bots vs UI
Chat Bots vs UI
 
Chat Bots are the new UI
Chat Bots are the new UIChat Bots are the new UI
Chat Bots are the new UI
 
VMware Integrated OpenStack with NSX-V POCガイド (第3版)
VMware Integrated OpenStack with NSX-V POCガイド (第3版)VMware Integrated OpenStack with NSX-V POCガイド (第3版)
VMware Integrated OpenStack with NSX-V POCガイド (第3版)
 
Meetings Help Us and Kill Our Projects
Meetings Help Us and Kill Our ProjectsMeetings Help Us and Kill Our Projects
Meetings Help Us and Kill Our Projects
 
Meetings-free Programming
Meetings-free ProgrammingMeetings-free Programming
Meetings-free Programming
 

Similar to Code Generation Tools for .NET Developers

Domain Driven Design Big Picture Strategic Patterns
Domain Driven Design Big Picture Strategic PatternsDomain Driven Design Big Picture Strategic Patterns
Domain Driven Design Big Picture Strategic PatternsMark Windholtz
 
Using LLVM to accelerate processing of data in Apache Arrow
Using LLVM to accelerate processing of data in Apache ArrowUsing LLVM to accelerate processing of data in Apache Arrow
Using LLVM to accelerate processing of data in Apache ArrowDataWorks Summit
 
Domain specific modelling (DSM)
Domain specific modelling (DSM)Domain specific modelling (DSM)
Domain specific modelling (DSM)PG Scholar
 
Modeling on the Web
Modeling on the WebModeling on the Web
Modeling on the WebIcinetic
 
Docfacto release 2.4
Docfacto release 2.4Docfacto release 2.4
Docfacto release 2.4Darren Hudson
 
10 Reasons You MUST Consider Pattern-Aware Programming
10 Reasons You MUST Consider Pattern-Aware Programming10 Reasons You MUST Consider Pattern-Aware Programming
10 Reasons You MUST Consider Pattern-Aware ProgrammingPostSharp Technologies
 
Old code doesn't stink - Detroit
Old code doesn't stink - DetroitOld code doesn't stink - Detroit
Old code doesn't stink - DetroitMartin Gutenbrunner
 
How to write good quality code
How to write good quality codeHow to write good quality code
How to write good quality codeHayden Bleasel
 
Selecting The Right 3D Printer for the Job
Selecting The Right 3D Printer for the JobSelecting The Right 3D Printer for the Job
Selecting The Right 3D Printer for the JobDesign World
 
Design Like a Pro: Scripting Best Practices
Design Like a Pro: Scripting Best PracticesDesign Like a Pro: Scripting Best Practices
Design Like a Pro: Scripting Best PracticesInductive Automation
 
CGM (Computer Graphics Metafile) v SVG (Scalable Vector Graphic)
CGM (Computer Graphics Metafile) v SVG (Scalable Vector Graphic)CGM (Computer Graphics Metafile) v SVG (Scalable Vector Graphic)
CGM (Computer Graphics Metafile) v SVG (Scalable Vector Graphic)Vizualsite LLC
 
Design Like a Pro: Scripting Best Practices
Design Like a Pro: Scripting Best PracticesDesign Like a Pro: Scripting Best Practices
Design Like a Pro: Scripting Best PracticesInductive Automation
 
2019-Nov: Domain Driven Design (DDD) and when not to use it
2019-Nov: Domain Driven Design (DDD) and when not to use it2019-Nov: Domain Driven Design (DDD) and when not to use it
2019-Nov: Domain Driven Design (DDD) and when not to use itMark Windholtz
 
[2020 git lab commit] continuous infrastructure
[2020 git lab commit] continuous infrastructure[2020 git lab commit] continuous infrastructure
[2020 git lab commit] continuous infrastructureRodrigo Stefani Domingues
 
Oh the compilers you'll build
Oh the compilers you'll buildOh the compilers you'll build
Oh the compilers you'll buildMark Stoodley
 
DevOpsCon 2015 - DevOps in Mobile Games
DevOpsCon 2015 - DevOps in Mobile GamesDevOpsCon 2015 - DevOps in Mobile Games
DevOpsCon 2015 - DevOps in Mobile GamesAndreas Katzig
 

Similar to Code Generation Tools for .NET Developers (20)

Domain Driven Design Big Picture Strategic Patterns
Domain Driven Design Big Picture Strategic PatternsDomain Driven Design Big Picture Strategic Patterns
Domain Driven Design Big Picture Strategic Patterns
 
Using LLVM to accelerate processing of data in Apache Arrow
Using LLVM to accelerate processing of data in Apache ArrowUsing LLVM to accelerate processing of data in Apache Arrow
Using LLVM to accelerate processing of data in Apache Arrow
 
Domain specific modelling (DSM)
Domain specific modelling (DSM)Domain specific modelling (DSM)
Domain specific modelling (DSM)
 
Modeling on the Web
Modeling on the WebModeling on the Web
Modeling on the Web
 
Modeling on the Web
Modeling on the WebModeling on the Web
Modeling on the Web
 
Docfacto release 2.4
Docfacto release 2.4Docfacto release 2.4
Docfacto release 2.4
 
Mobile Single Source Strategy
Mobile Single Source StrategyMobile Single Source Strategy
Mobile Single Source Strategy
 
10 Reasons You MUST Consider Pattern-Aware Programming
10 Reasons You MUST Consider Pattern-Aware Programming10 Reasons You MUST Consider Pattern-Aware Programming
10 Reasons You MUST Consider Pattern-Aware Programming
 
Old code doesn't stink - Detroit
Old code doesn't stink - DetroitOld code doesn't stink - Detroit
Old code doesn't stink - Detroit
 
Manasa
ManasaManasa
Manasa
 
How to write good quality code
How to write good quality codeHow to write good quality code
How to write good quality code
 
Selecting The Right 3D Printer for the Job
Selecting The Right 3D Printer for the JobSelecting The Right 3D Printer for the Job
Selecting The Right 3D Printer for the Job
 
Design Like a Pro: Scripting Best Practices
Design Like a Pro: Scripting Best PracticesDesign Like a Pro: Scripting Best Practices
Design Like a Pro: Scripting Best Practices
 
CGM versus SVG
CGM versus SVGCGM versus SVG
CGM versus SVG
 
CGM (Computer Graphics Metafile) v SVG (Scalable Vector Graphic)
CGM (Computer Graphics Metafile) v SVG (Scalable Vector Graphic)CGM (Computer Graphics Metafile) v SVG (Scalable Vector Graphic)
CGM (Computer Graphics Metafile) v SVG (Scalable Vector Graphic)
 
Design Like a Pro: Scripting Best Practices
Design Like a Pro: Scripting Best PracticesDesign Like a Pro: Scripting Best Practices
Design Like a Pro: Scripting Best Practices
 
2019-Nov: Domain Driven Design (DDD) and when not to use it
2019-Nov: Domain Driven Design (DDD) and when not to use it2019-Nov: Domain Driven Design (DDD) and when not to use it
2019-Nov: Domain Driven Design (DDD) and when not to use it
 
[2020 git lab commit] continuous infrastructure
[2020 git lab commit] continuous infrastructure[2020 git lab commit] continuous infrastructure
[2020 git lab commit] continuous infrastructure
 
Oh the compilers you'll build
Oh the compilers you'll buildOh the compilers you'll build
Oh the compilers you'll build
 
DevOpsCon 2015 - DevOps in Mobile Games
DevOpsCon 2015 - DevOps in Mobile GamesDevOpsCon 2015 - DevOps in Mobile Games
DevOpsCon 2015 - DevOps in Mobile Games
 

More from Dmytro Mindra

Mastering public speaking skills
Mastering public speaking skillsMastering public speaking skills
Mastering public speaking skillsDmytro Mindra
 
XP Days Ukraine 2014 - Refactoring legacy code
XP Days Ukraine 2014 - Refactoring legacy codeXP Days Ukraine 2014 - Refactoring legacy code
XP Days Ukraine 2014 - Refactoring legacy codeDmytro Mindra
 
Odessa .NET User Group - Kinect v2
Odessa .NET User Group - Kinect v2Odessa .NET User Group - Kinect v2
Odessa .NET User Group - Kinect v2Dmytro Mindra
 
Building Windows Phone 8 Games With Unity3d
Building Windows Phone 8 Games With Unity3dBuilding Windows Phone 8 Games With Unity3d
Building Windows Phone 8 Games With Unity3dDmytro Mindra
 
IT Brunch - SpecFlow and Gherkin by Example
IT Brunch - SpecFlow and Gherkin by ExampleIT Brunch - SpecFlow and Gherkin by Example
IT Brunch - SpecFlow and Gherkin by ExampleDmytro Mindra
 
Odessa Pluralsight Study Group 28.11.2012
Odessa Pluralsight Study Group 28.11.2012Odessa Pluralsight Study Group 28.11.2012
Odessa Pluralsight Study Group 28.11.2012Dmytro Mindra
 
Тестируем код с Visual Studio 2012 - XP Days Ukraine 2012
Тестируем код с Visual Studio 2012 - XP Days Ukraine 2012Тестируем код с Visual Studio 2012 - XP Days Ukraine 2012
Тестируем код с Visual Studio 2012 - XP Days Ukraine 2012Dmytro Mindra
 
Compilable Specifications - XPDays Ukraine 2012
Compilable Specifications - XPDays Ukraine 2012Compilable Specifications - XPDays Ukraine 2012
Compilable Specifications - XPDays Ukraine 2012Dmytro Mindra
 
NetworkUA - 2012 - Introduction TypeScript
NetworkUA - 2012 - Introduction TypeScript NetworkUA - 2012 - Introduction TypeScript
NetworkUA - 2012 - Introduction TypeScript Dmytro Mindra
 
Ciklum .NET Saturday - Introduction to TypeScript
Ciklum .NET Saturday - Introduction to TypeScriptCiklum .NET Saturday - Introduction to TypeScript
Ciklum .NET Saturday - Introduction to TypeScriptDmytro Mindra
 
Lean Lego Game for Agileee 2012
Lean Lego Game for Agileee 2012Lean Lego Game for Agileee 2012
Lean Lego Game for Agileee 2012Dmytro Mindra
 
Lohika .Net Day - What's new in Windows Azure
Lohika .Net Day - What's new in Windows AzureLohika .Net Day - What's new in Windows Azure
Lohika .Net Day - What's new in Windows AzureDmytro Mindra
 
Web В РЕАЛЬНОМ ВРЕМЕНИ С Node.js - AgileBaseCamp - 2012
Web В РЕАЛЬНОМ ВРЕМЕНИ С Node.js - AgileBaseCamp - 2012Web В РЕАЛЬНОМ ВРЕМЕНИ С Node.js - AgileBaseCamp - 2012
Web В РЕАЛЬНОМ ВРЕМЕНИ С Node.js - AgileBaseCamp - 2012Dmytro Mindra
 
Windows Azure & NodeJS Microsoft SWIT 2012
Windows Azure & NodeJS Microsoft SWIT 2012 Windows Azure & NodeJS Microsoft SWIT 2012
Windows Azure & NodeJS Microsoft SWIT 2012 Dmytro Mindra
 
Lean Software Development
Lean Software DevelopmentLean Software Development
Lean Software DevelopmentDmytro Mindra
 
Craftsmanship - XP Days 2011
Craftsmanship - XP Days 2011Craftsmanship - XP Days 2011
Craftsmanship - XP Days 2011Dmytro Mindra
 
IT Brunch - 12.11.2011 - Myths about Design
IT Brunch - 12.11.2011 - Myths about DesignIT Brunch - 12.11.2011 - Myths about Design
IT Brunch - 12.11.2011 - Myths about DesignDmytro Mindra
 
Myths about design - PechaKucha Odessa IT Jam 20.08.2011
Myths about design - PechaKucha Odessa IT Jam 20.08.2011Myths about design - PechaKucha Odessa IT Jam 20.08.2011
Myths about design - PechaKucha Odessa IT Jam 20.08.2011Dmytro Mindra
 

More from Dmytro Mindra (20)

Mastering public speaking skills
Mastering public speaking skillsMastering public speaking skills
Mastering public speaking skills
 
XP Days Ukraine 2014 - Refactoring legacy code
XP Days Ukraine 2014 - Refactoring legacy codeXP Days Ukraine 2014 - Refactoring legacy code
XP Days Ukraine 2014 - Refactoring legacy code
 
Odessa .NET User Group - Kinect v2
Odessa .NET User Group - Kinect v2Odessa .NET User Group - Kinect v2
Odessa .NET User Group - Kinect v2
 
Building Windows Phone 8 Games With Unity3d
Building Windows Phone 8 Games With Unity3dBuilding Windows Phone 8 Games With Unity3d
Building Windows Phone 8 Games With Unity3d
 
IT Brunch - SpecFlow and Gherkin by Example
IT Brunch - SpecFlow and Gherkin by ExampleIT Brunch - SpecFlow and Gherkin by Example
IT Brunch - SpecFlow and Gherkin by Example
 
Odessa Pluralsight Study Group 28.11.2012
Odessa Pluralsight Study Group 28.11.2012Odessa Pluralsight Study Group 28.11.2012
Odessa Pluralsight Study Group 28.11.2012
 
Тестируем код с Visual Studio 2012 - XP Days Ukraine 2012
Тестируем код с Visual Studio 2012 - XP Days Ukraine 2012Тестируем код с Visual Studio 2012 - XP Days Ukraine 2012
Тестируем код с Visual Studio 2012 - XP Days Ukraine 2012
 
Compilable Specifications - XPDays Ukraine 2012
Compilable Specifications - XPDays Ukraine 2012Compilable Specifications - XPDays Ukraine 2012
Compilable Specifications - XPDays Ukraine 2012
 
NetworkUA - 2012 - Introduction TypeScript
NetworkUA - 2012 - Introduction TypeScript NetworkUA - 2012 - Introduction TypeScript
NetworkUA - 2012 - Introduction TypeScript
 
Ciklum .NET Saturday - Introduction to TypeScript
Ciklum .NET Saturday - Introduction to TypeScriptCiklum .NET Saturday - Introduction to TypeScript
Ciklum .NET Saturday - Introduction to TypeScript
 
Lean Lego Game for Agileee 2012
Lean Lego Game for Agileee 2012Lean Lego Game for Agileee 2012
Lean Lego Game for Agileee 2012
 
Lohika .Net Day - What's new in Windows Azure
Lohika .Net Day - What's new in Windows AzureLohika .Net Day - What's new in Windows Azure
Lohika .Net Day - What's new in Windows Azure
 
Web В РЕАЛЬНОМ ВРЕМЕНИ С Node.js - AgileBaseCamp - 2012
Web В РЕАЛЬНОМ ВРЕМЕНИ С Node.js - AgileBaseCamp - 2012Web В РЕАЛЬНОМ ВРЕМЕНИ С Node.js - AgileBaseCamp - 2012
Web В РЕАЛЬНОМ ВРЕМЕНИ С Node.js - AgileBaseCamp - 2012
 
Windows Azure & NodeJS Microsoft SWIT 2012
Windows Azure & NodeJS Microsoft SWIT 2012 Windows Azure & NodeJS Microsoft SWIT 2012
Windows Azure & NodeJS Microsoft SWIT 2012
 
Lean Software Development
Lean Software DevelopmentLean Software Development
Lean Software Development
 
Craftsmanship - XP Days 2011
Craftsmanship - XP Days 2011Craftsmanship - XP Days 2011
Craftsmanship - XP Days 2011
 
Agile architecture
Agile architectureAgile architecture
Agile architecture
 
DCI
DCIDCI
DCI
 
IT Brunch - 12.11.2011 - Myths about Design
IT Brunch - 12.11.2011 - Myths about DesignIT Brunch - 12.11.2011 - Myths about Design
IT Brunch - 12.11.2011 - Myths about Design
 
Myths about design - PechaKucha Odessa IT Jam 20.08.2011
Myths about design - PechaKucha Odessa IT Jam 20.08.2011Myths about design - PechaKucha Odessa IT Jam 20.08.2011
Myths about design - PechaKucha Odessa IT Jam 20.08.2011
 

Recently uploaded

Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 

Recently uploaded (20)

Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 

Code Generation Tools for .NET Developers

  • 1. APPLIED CODE GENERATION IN .NET Dmytro Mindra Lohika, Odessa @dmytromindra
  • 3. The question of Origin ? • We are engineers ! • Engineers’ time is valuable and expensive; • Engineers don’t like repetitive tasks; @dmytromindra
  • 4. Task classification • Brains • Experience • Procedures @dmytromindra
  • 5. Houston, we’ve got a problem ! Our business domain contains 500+ entities. Each entity needs CRUD. @dmytromindra
  • 6. Houston, we’ve got a problem ! And you have lots of time. The whole 4 months. For your big team of 4 developers that should not be a problem ! @dmytromindra
  • 7. Houston, we’ve got a problem ! Oh, and we’re not sure which parts will stay generic and which won’t @dmytromindra
  • 8. Houston, we’ve got a problem ! Be agile, don’t wait for the analysts to finish their job, because we don’t have that kind of time. Just change your code when the Requirements are finished. @dmytromindra
  • 9. Houston, we’ve got a problem ! For each domain entity we should have • Stored Procedures • Repository • Service • Controller • Views • etc That’s about 1000 lines of code per entity. @dmytromindra
  • 10. Houston, we’ve got a problem ! But we have 500+ entities 500*1000 = 500000 lines of code. Who wants to type this in ? @dmytromindra
  • 11. Houston, we’ve got a problem ! • And when the changes arrive someone should make corrections to 500*1000 lines of code. @dmytromindra
  • 12. What are the solutions ? • Hand-code everything (and every change) – Hire a lot of monkeys coders • Design everything generically, correctly the first time – Mission impossible • Use only code generation – And spend your life changing generator to match all possible requirements • Use combination of tools including code generation. – This seems reasonable @dmytromindra
  • 13. Boilerplate • Interestingly, the term (boilerplate) arose from the newspaper business. Columns and other pieces that were syndicated were sent out to subscribing newspapers in the form of a mat (i.e. a matrix). Once received, boiling lead was poured into this mat to create the plate used to print the piece, hence the name boilerplate. As the article printed on a boilerplate could not be altered, the term came to be used by attorneys to refer to the portions of a contract which did not change through repeated uses in different applications, and finally to language in general which did not change in any document that was used repeatedly for different occasions. @dmytromindra
  • 15. CODE GENERATION is code that writes code @dmytromindra
  • 16. Some common terms • Code generation • Automatic programming • Generative programming @dmytromindra
  • 17. IDE Generated Code Example @dmytromindra
  • 18. Tools evolution @dmytromindra
  • 20. Generator Input Code Output Generator @dmytromindra
  • 21. Why CG? • Productivity • Quality • Consistency • Abstraction @dmytromindra
  • 23. PROS • Code uniformity • Easy to debug • Easy to introduce huge changes • No more boilerplate code @dmytromindra
  • 24. CONS • Someone should maintain the generator • Generator has learning curve • Generator usually has limitations @dmytromindra
  • 25. Applications • Database Access • Generate Test Data • Generate Integration Tests • User Interface • Documentation • Unit tests • File Formats • Web services • Business logic • DLL Wrappers • Firewall configuration • Website configuration • Looking for localizable strings @dmytromindra
  • 26. Code Generation is Fun ? • CG makes boring job for you • Writing generator is fun • Once written generator works for you • You can experiment with different implementations by modifying generator and regeneration the code. • While writing the generator you get deeper into the technology instead of doing dull job. @dmytromindra
  • 27. Scaffolding and prototyping • Code generation can help you to build fast prototypes. @dmytromindra
  • 28. MVC Scaffolding Demo @dmytromindra
  • 29. Rules 1. Give the proper respect to hand-coding 2. Handwrite the code first 3. Control the source code 4. Make a considered decision about the implementation language 5. Integrate the generator into the development process @dmytromindra
  • 30. Rules 6. Include warnings 7. Make it friendly 8. Include documentation 9. Keep in mind that generation is a cultural issue 10. Maintain the generator @dmytromindra
  • 31. A note about DSL A domain-specific language (DSL) is a programming language or specification language dedicated to a particular problem domain @dmytromindra
  • 33. Model Driven Architecture @dmytromindra
  • 35. Model Driven Architecture • Code generation has a dramatic impact on development time and engineering productivity. • The application is amenable to change on a large scale. • The business rules are abstracted into files that are free of language or framework details that would hinder portability. • The code for the application is of consistently high quality across the code base. @dmytromindra
  • 36. Benefits of MDA • Quality • Consistency • A single point of knowledge • More design time • Design decisions that stand out @dmytromindra
  • 37. Software Factories @dmytromindra
  • 39. Software Factory @dmytromindra
  • 40. Consider this: • Code generation has a large initial schedule overhead; • Code generators are ideal for well-known large- scale problems; • Code generation is powerful when used appropriately; • Always keep in mind code generation limitations! @dmytromindra
  • 41. Code Generation Skills • Text Templates • Regular Expressions • XML Parsing • Reflection @dmytromindra
  • 42. Show me the tools @dmytromindra
  • 43. Available tools • StringBuilder • CodeSnippets • XSLT • Reflection Emit • EnvDTE • CodeDom • T4 • … (Python, Ruby, @dmytromindra
  • 44. StringBuilder • Advantages – Almost all .net developers should feel comfortable using the StringBuilder class so it requires no additional languages / tools to learn. – Even with the disadvantages, the StringBuilder can be an excellent choice if you need to generate code quickly. Especially if you don’t need to maintain the “template” long term. • Disadvantages – Unable to truly see the “template” within the control logic. – Requires a recompile if the “template” should be changed. @dmytromindra
  • 45. Code Snippets • Advantages – Simple Xml based template with numerous samples provided within Visual Studio. – Several open source code snippet libraries available. • Disadvantages – Limited snippet functions and at the present time developers are unable to author additional snippet functions! @dmytromindra
  • 46. XSLT • Advantages – Xml based template. – Simple code generation technique for those developers comfortable with XSLT transformations. • Disadvantages – While Xml is a relatively simple technology, XSLT has been known to bring grown men to tears! – XSLT can be difficult to debug. @dmytromindra
  • 47. Reflection Emit It is rocket science mixed with the black arts. • Full representation of physical structure • Allows building modules and assemblies at runtime – Transient code only used at runtime – Persistent code for reuse • Create classes, types and emit IL • Used by .NET compilers to build .NET apps • Can be as fast as normal code @dmytromindra
  • 48. EnvDTE • EnvDTE is an assembly-wrapped COM library containing the objects and members for Visual Studio core automation. • Using EnvDTE you can develop your own add- ins for Visual Studio that can generate code. @dmytromindra
  • 49. CodeDom • Advantages – Allows a single “template” to generate code within several target languages, such as VB and C#. – Additional language providers can be written to support other languages. – Proven technology, used by Microsoft for code generation in all versions of Visual Studio since .net was released. • Disadvantages – Unable to truly see the “template” within the control logic. – Requires a recompile if the “template” should be changed. – Very few developers have experience using the CodeDom even though it has been with us since the .net framework 1.0. @dmytromindra
  • 51. How T4 Works ? @dmytromindra
  • 52. T4 Tools • Tangible T4 Editor for Visual Studio 2010 RTM adds IntelliSense and Syntax Coloring to T4 Text Templates. • T4 Toolbox @dmytromindra
  • 53. T4 Pros and Cons • Advantages – Ability to embed C# control logic within the template. – Syntax that will be somewhat familiar to classic ASP developers.. – Preferred code generation technique for Entity Framework 4.0 and the Visual Studio 2010 modeling tools., which means lots of samples on MSDN, etc. – Templates can be precompiled. • Disadvantages – While third parties have written language support for Visual Studio no built in support for editing T4 templates exists in Visual Studio today. – Relatively new technology, therefore not many developers have experience with T4 templates. @dmytromindra
  • 54. ReSharper 6.0 Code Generation Create from Usage Generate Type Members Generate Type Constructor Generate Properties Generate Delegating Members Generate Formatting Members Generate Equality Members Implement/Override Methods @dmytromindra
  • 55. Some advices @dmytromindra
  • 56. Shall I Generate Interfaces? @dmytromindra
  • 57. Shall I Generate Interfaces? No ! @dmytromindra
  • 58. Shall I Unit Test generated code ? • You shouldn’t unit test generated code. You may unit test generator instead. @dmytromindra
  • 59. Real World Case Studies @dmytromindra
  • 60. Case 1: Client – Server Communication Communic Existing Generated ation Generated API Server Proxy channel Client Proxy @dmytromindra
  • 61. Legacy API Adapter @dmytromindra Existing Case 2: API Wrapper Application
  • 62. Case 3: Protocol Parser @dmytromindra
  • 63. Case 4: Model Driven DAL Hand written services Generated Repositories XML Generated Entities Model Partially generated DB @dmytromindra
  • 64. It’s an Engineering, Baby ! Conclusion: • Not a silver bullet but another good tool; • Makes life easier when applied properly; • Writing generator is much more fun than writing boilerplate code; • Generated code is easier to debug; • You can make huge changes in regenerated code easily; @dmytromindra
  • 65. Do try this ! • Code generation can make you flexible and responsive. Do try this at home. (Or at work) @dmytromindra