SlideShare ist ein Scribd-Unternehmen logo
1 von 36
WRITING CODE
           that
 WRITES CODE
        STEVE MARSHALL
But why?
Code munging
Inline code expansion

Code munging
Mixed code generation

Inline code expansion

Code munging
Partial class generation

Mixed code generation

Inline code expansion

Code munging
Tier generation

Partial class generation

Mixed code generation

Inline code expansion

Code munging
Full domain language

Tier generation

Partial class generation

Mixed code generation

Inline code expansion

Code munging
Full domain language

Tier generation

Partial class generation

Mixed code generation

Inline code expansion

Code munging
Source code




Code munger




 Output file
Full domain language

Tier generation

Partial class generation

Mixed code generation

Inline code expansion

Code munging
Source code



 Inline code
  expander


Output source
    code



  Compiler
Full domain language

Tier generation

Partial class generation

Mixed code generation

Inline code expansion

Code munging
Source code



 Mixed code
 generator


Output source
    code



  Compiler
Full domain language

Tier generation

Partial class generation

Mixed code generation

Inline code expansion

Code munging
Definition file



 Partial class
                               Templates
  generator


Output base                  Custom derived
 class code                    class code



                  Compiler
Full domain language

Tier generation

Partial class generation

Mixed code generation

Inline code expansion

Code munging
Definition file                    Templates



                  Tier generator



                  Output source
                      code



                    Compiler
Full domain language

Tier generation

Partial class generation

Mixed code generation

Inline code expansion

Code munging
What should I use?
Let me tell you
a story…
One for the team.
1.

Respect (and loathe)
hand-coding.
2.

Hand-code first.
3.

Control your source.
4.

Consider the
generator’s language.
5.

Integrate the
generator into your
workflow.
6.

Include warnings.
7.

Play nice with others.
8.

Document well.
9.

Consider the
cultural impact.
10.

Keep it maintained.
icanhaz.com/codegen-book
icanhaz.com/codegen

@stevemarshall
steve@nascentguruism.com


Stephen Wolfram photo:
flickr.com/photos/hybernaut/87907765/

Weitere ähnliche Inhalte

Andere mochten auch

HackU Barcelona 2011: YQL
HackU Barcelona 2011: YQLHackU Barcelona 2011: YQL
HackU Barcelona 2011: YQLSteve Marshall
 
HackU Dundee 2011: Tools to Hack With
HackU Dundee 2011: Tools to Hack WithHackU Dundee 2011: Tools to Hack With
HackU Dundee 2011: Tools to Hack WithSteve Marshall
 
Reuters: Pictures of the Year 2016 (Part 2)
Reuters: Pictures of the Year 2016 (Part 2)Reuters: Pictures of the Year 2016 (Part 2)
Reuters: Pictures of the Year 2016 (Part 2)maditabalnco
 
Open Source Creativity
Open Source CreativityOpen Source Creativity
Open Source CreativitySara Cannon
 
The Six Highest Performing B2B Blog Post Formats
The Six Highest Performing B2B Blog Post FormatsThe Six Highest Performing B2B Blog Post Formats
The Six Highest Performing B2B Blog Post FormatsBarry Feldman
 
The Outcome Economy
The Outcome EconomyThe Outcome Economy
The Outcome EconomyHelge Tennø
 
32 Ways a Digital Marketing Consultant Can Help Grow Your Business
32 Ways a Digital Marketing Consultant Can Help Grow Your Business32 Ways a Digital Marketing Consultant Can Help Grow Your Business
32 Ways a Digital Marketing Consultant Can Help Grow Your BusinessBarry Feldman
 

Andere mochten auch (7)

HackU Barcelona 2011: YQL
HackU Barcelona 2011: YQLHackU Barcelona 2011: YQL
HackU Barcelona 2011: YQL
 
HackU Dundee 2011: Tools to Hack With
HackU Dundee 2011: Tools to Hack WithHackU Dundee 2011: Tools to Hack With
HackU Dundee 2011: Tools to Hack With
 
Reuters: Pictures of the Year 2016 (Part 2)
Reuters: Pictures of the Year 2016 (Part 2)Reuters: Pictures of the Year 2016 (Part 2)
Reuters: Pictures of the Year 2016 (Part 2)
 
Open Source Creativity
Open Source CreativityOpen Source Creativity
Open Source Creativity
 
The Six Highest Performing B2B Blog Post Formats
The Six Highest Performing B2B Blog Post FormatsThe Six Highest Performing B2B Blog Post Formats
The Six Highest Performing B2B Blog Post Formats
 
The Outcome Economy
The Outcome EconomyThe Outcome Economy
The Outcome Economy
 
32 Ways a Digital Marketing Consultant Can Help Grow Your Business
32 Ways a Digital Marketing Consultant Can Help Grow Your Business32 Ways a Digital Marketing Consultant Can Help Grow Your Business
32 Ways a Digital Marketing Consultant Can Help Grow Your Business
 

Ähnlich wie Writing Code That Writes Code

Intro to Reverse Engineering
Intro to Reverse EngineeringIntro to Reverse Engineering
Intro to Reverse EngineeringNull Bhubaneswar
 
Lecture 1 introduction to language processors
Lecture 1  introduction to language processorsLecture 1  introduction to language processors
Lecture 1 introduction to language processorsRebaz Najeeb
 
compiler and their types
compiler and their typescompiler and their types
compiler and their typespatchamounika7
 
Lecture 10 software development
Lecture 10 software developmentLecture 10 software development
Lecture 10 software developmentJehanzaib Yousuf
 
Native client (Евгений Эльцин)
Native client (Евгений Эльцин)Native client (Евгений Эльцин)
Native client (Евгений Эльцин)Ontico
 
Weekly Session with the local .NET Developer Community
Weekly Session with the local .NET  Developer CommunityWeekly Session with the local .NET  Developer Community
Weekly Session with the local .NET Developer Communitykazimanzurrashid
 
Introduction to c_sharp
Introduction to c_sharpIntroduction to c_sharp
Introduction to c_sharpHEM Sothon
 
Introduction to c_sharp
Introduction to c_sharpIntroduction to c_sharp
Introduction to c_sharpJayanta Basak
 
Development workflow
Development workflowDevelopment workflow
Development workflowSigsiu.NET
 
aditya malkani compiler.pptx
aditya malkani compiler.pptxaditya malkani compiler.pptx
aditya malkani compiler.pptxWildVenomOP
 
NetWork - 15.10.2011 - Applied code generation in .NET
NetWork - 15.10.2011 - Applied code generation in .NET NetWork - 15.10.2011 - Applied code generation in .NET
NetWork - 15.10.2011 - Applied code generation in .NET Dmytro Mindra
 
Mono for Android... for Google Devs
Mono for Android... for Google DevsMono for Android... for Google Devs
Mono for Android... for Google DevsCraig Dunn
 
Porting your favourite cmdline tool to Android
Porting your favourite cmdline tool to AndroidPorting your favourite cmdline tool to Android
Porting your favourite cmdline tool to AndroidVlatko Kosturjak
 
.NET Fundamentals and Business Application Development
.NET Fundamentals and Business Application Development.NET Fundamentals and Business Application Development
.NET Fundamentals and Business Application Development명신 김
 
Peer review - A new to code and debug online.
Peer review -  A new to code and debug online.Peer review -  A new to code and debug online.
Peer review - A new to code and debug online.Dipankar Dutta
 
01 Introduction to programming
01 Introduction to programming01 Introduction to programming
01 Introduction to programmingmaznabili
 
Embedded firmware
Embedded firmwareEmbedded firmware
Embedded firmwareJoel P
 

Ähnlich wie Writing Code That Writes Code (20)

Intro to Reverse Engineering
Intro to Reverse EngineeringIntro to Reverse Engineering
Intro to Reverse Engineering
 
Lecture 1 introduction to language processors
Lecture 1  introduction to language processorsLecture 1  introduction to language processors
Lecture 1 introduction to language processors
 
compiler and their types
compiler and their typescompiler and their types
compiler and their types
 
Lecture 10 software development
Lecture 10 software developmentLecture 10 software development
Lecture 10 software development
 
Native client (Евгений Эльцин)
Native client (Евгений Эльцин)Native client (Евгений Эльцин)
Native client (Евгений Эльцин)
 
Weekly Session with the local .NET Developer Community
Weekly Session with the local .NET  Developer CommunityWeekly Session with the local .NET  Developer Community
Weekly Session with the local .NET Developer Community
 
Introduction to c_sharp
Introduction to c_sharpIntroduction to c_sharp
Introduction to c_sharp
 
Introduction to c_sharp
Introduction to c_sharpIntroduction to c_sharp
Introduction to c_sharp
 
Development workflow
Development workflowDevelopment workflow
Development workflow
 
aditya malkani compiler.pptx
aditya malkani compiler.pptxaditya malkani compiler.pptx
aditya malkani compiler.pptx
 
NetWork - 15.10.2011 - Applied code generation in .NET
NetWork - 15.10.2011 - Applied code generation in .NET NetWork - 15.10.2011 - Applied code generation in .NET
NetWork - 15.10.2011 - Applied code generation in .NET
 
UnDeveloper Studio
UnDeveloper StudioUnDeveloper Studio
UnDeveloper Studio
 
Mono for Android... for Google Devs
Mono for Android... for Google DevsMono for Android... for Google Devs
Mono for Android... for Google Devs
 
Clean Code Style
Clean Code StyleClean Code Style
Clean Code Style
 
Porting your favourite cmdline tool to Android
Porting your favourite cmdline tool to AndroidPorting your favourite cmdline tool to Android
Porting your favourite cmdline tool to Android
 
.NET Fundamentals and Business Application Development
.NET Fundamentals and Business Application Development.NET Fundamentals and Business Application Development
.NET Fundamentals and Business Application Development
 
Introduction to Programming Lesson 01
Introduction to Programming Lesson 01Introduction to Programming Lesson 01
Introduction to Programming Lesson 01
 
Peer review - A new to code and debug online.
Peer review -  A new to code and debug online.Peer review -  A new to code and debug online.
Peer review - A new to code and debug online.
 
01 Introduction to programming
01 Introduction to programming01 Introduction to programming
01 Introduction to programming
 
Embedded firmware
Embedded firmwareEmbedded firmware
Embedded firmware
 

Kürzlich hochgeladen

Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 

Kürzlich hochgeladen (20)

Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 

Writing Code That Writes Code

Hinweis der Redaktion

  1. Gonna talk about codegen. Steve Marshall - Interested in everything - Want to be a pirate - Y! Ents Why codegen - Don’t like repetition - Don’t like repetition - Interesting problem of scale - Lack of resources => be creative
  2. Quality, consistency, single point of knowledge, eases bulk refactoring, improves architectural consistency, increases abstraction, increases morale. Quality Lots of code => inconsistencies Templates => consistent quality Consistency - Consistent naming - API style - No surprises Single Point of Knowledge Schema describes system simply Architecture documented, not embedded in code Facilitates Bulk Refactoring Faulty assumptions in hand coding mean refactoring lots of code Generation makes refactoring minimal Also: generation can compress project timelines => more time to design/prototype, less need to refactor Architectural Consistency - Generator encourages working within architecture - “generator doesn’t do that” can indicate that the feature doesn’t fit the architecture - Consistent, structured approach, regardless of team members joining/leaving Abstraction - Application logic is language-independent. Can easily port templates to other languages (eg. for performance, also: WSDL describing inputs/outputs) - Can easily review/validate abstract designs - Aids development of non-implementation code (tests, documentation, etc) High Morale Less gruntwork to do by hand More focus on interesting problems Higher morale Also: higher quality, consistent code => confidence and pride
  3. Type of codegen… - Munging - Code expansion - Mixed codegen - Partial class gen - Tier gen - FDL
  4. Type of codegen… - Munging - Code expansion - Mixed codegen - Partial class gen - Tier gen - FDL
  5. Type of codegen… - Munging - Code expansion - Mixed codegen - Partial class gen - Tier gen - FDL
  6. Type of codegen… - Munging - Code expansion - Mixed codegen - Partial class gen - Tier gen - FDL
  7. Type of codegen… - Munging - Code expansion - Mixed codegen - Partial class gen - Tier gen - FDL
  8. Type of codegen… - Munging - Code expansion - Mixed codegen - Partial class gen - Tier gen - FDL
  9. Parses source code Produces some non-source output See documentation, linting, … Also: build header files, web service layers
  10. Parses source for special keywords Replaces with production code eg. Embedding SQL in source à la Pro*C/SQLJ
  11. Like inline code expansion, but output can be used as input (replaces in-place) Looks for specially formatted comments, fills comment-wrapped area with new production source eg. Marshalling code
  12. Reads abstract definition with enough info to build classes Applies def’n to templates to output base classes Used with subclasses for custom behaviour Can be a stepping stone to tier generation
  13. Generator builds a complete tier of your app (eg ORM) eg. Model-driven generation takes definition file and applies to templates Like partial class, but without special cases (or are codified in templates) Partial class generation requires extra code, tier doesn’t (but may have it)