Diese Präsentation wurde erfolgreich gemeldet.
Wir verwenden Ihre LinkedIn Profilangaben und Informationen zu Ihren Aktivitäten, um Anzeigen zu personalisieren und Ihnen relevantere Inhalte anzuzeigen. Sie können Ihre Anzeigeneinstellungen jederzeit ändern.

Modelling and code generation in .NET at Icinetic

1.048 Aufrufe

Veröffentlicht am

Veröffentlicht in: Technologie
  • Als Erste(r) kommentieren

  • Gehören Sie zu den Ersten, denen das gefällt!

Modelling and code generation in .NET at Icinetic

  1. 1. Modelling and Code Generationon the .NET Platform @ Rubén Jiménez rjimenez@icinetic.com @rubenjmarrufo Pedro J. Molina, PhD pjmolina@icinetic.com @pmolinam
  2. 2. Contents Introduction History of Microsoft Modeling MDSD: Approaches MDSD: Reference Framework MDSD: Tour of features Demos © Icinetic 2012 2
  3. 3. Introduction We do MDSD Tools for developers Focused on .NET technologies & Architecture Services HQ in Seville, Spain © Icinetic 2012 3
  4. 4. History of Microsoft Modeling 2005: First release of MS DSL Tools 2007: First details about its plans for the “Oslo” project 2008: First Microsoft “Oslo” CTP 2009: Visual Studio 2010 V&M SDK Beta 2010: Microsoft “Oslo” is obliterated 2010: Visual Studio LightSwitch 2011: Visual Studio 11 V&M SDK Beta © Icinetic 2012 4
  5. 5. .NET & MDSD Ready to dive? © Icinetic 2012 5
  6. 6. MDSD: Choose your path MDA/UML:  Metamodel is highly closed MDSD  Symbol and concept overloading  Not clear Semantics  Action LanguageMDA DSLs  Domains not cover by UML  Abuse of profiles  Tools: many dialects of XMI DSLs:  Cost of DSLs and tools required to develop with it. © Icinetic 2012 6
  7. 7. MDSD Reference FWK Metamodel(s)Textual Model Editor Reverse EngineeringVisual Model Editor Model(s) Model Checker Model repository IDE Model Transformation M2M M2T Code Model Doc, etc. © Icinetic 2012 7
  8. 8. Metamodeling The analysis, construction and development of the frames, rules, constraints, models and theories applicable and useful for modeling a predefined class of problems (Wikipedia) Source Based in CARs Class Relation  Classes / Entities / Objects Properties Cardinality  Attributes / Properties  Relationships Target At Icinetic: Customer Credit Card  MS DSL Tools 1 *  Essential Meta © Icinetic 2012 8 8
  9. 9. Metamodeling: MS DSL Tools Visual Studio Visualization & Modeling SDK. Features:  Graphical meta-modeling.  Build graphical designers.  M2T: T4.  Model validations.  IDE: Visual Studio. Benefits:  Agile  Visual Drawbacks:  Generated designers performance:  “Magnify diagrams and multiply it”: Pascal Recchia. © Icinetic 2012 9
  10. 10. Metamodeling: Essentialnamespace Meta{ class MailMessage { Person From; List<Person> To; string Subject; string Message; } class Person { string FullName; string Email; }} © Icinetic 2012 10
  11. 11. Metamodeling: Essential METAEssential META 2009 XCore 2012namespace org.example.library package org.example.library{ class Book class Book { { string title; String title int pages; int pages List<Writer> authors oppositebooks; refers Writer[] authors opposite } books } enum BookCategory { enum BookCategory Mistery, { ScienceFiction, Mistery Biography ScienceFiction } Biography} } © Icinetic 2012 11
  12. 12. MDSD: Models Metamodel(s)Textual Model Editor ReverseVisual Model Editor Engineering Model(s) Model Checker Model IDE repository Model Transformation M2M M2T Code Model Doc, etc. © Icinetic 2012 12
  13. 13. Models: some Cases of Use1. Validation 2. Interpretation 3. Code Generation Model Model Model Model Code Interpreter Checker Generation Runtime Code interpretation Metadata Generated Doc Report Code Config. Tests ... © Icinetic 2012 13
  14. 14. Models: Code generation techniques1. Parse model Input Model2. In-memory representation Template  AST / Object Model AST3. Output building  Free text concatenation  XSL-T (No thanks!)  Text Template based Output code © Icinetic 2012 14
  15. 15. Models: ParsersParsers License Url Grammar Parsing IDE Strengths notation algorithmANTLR BSD www.antlr EBNF LL Yes Mature & widely .org/ usedIrony.Net MIT irony.code BNF LALR Yes Interpreted plex.com/Gold parser FW goldparse BNF LALR No Supported r.org/ languages: more than any other parsing systemGrammatica GNU grammati EBNF LL No Readable generated ca.percede rberg.net/ parse code © Icinetic 2012 15
  16. 16. MDSD: Editors Metamodel(s)Textual Model Editor ReverseVisual Model Editor Engineering Model(s) Model Checker Model repository IDE Model Transformation M2M M2T Code Model Doc, etc. © Icinetic 2012 16
  17. 17. Textual Model Editors DDD Textual DSL  Essential Text Editor © Icinetic 2012 17
  18. 18. Graphical Model Editors MS DSL Tools  WinForms  WPF Custom:  WinForms  WPF Third party tools: Visio, EA, etc. © Icinetic 2012 18
  19. 19. Graphical Model Editors MS DSL Tools  WinForms  WPF Custom:  WinForms  WPF Third party tools: Visio, EA, etc. © Icinetic 2012 19
  20. 20. Graphical Model Editors MS DSL Tools  WinForms  WPF Custom:  WinForms  WPF Third party tools: Visio, EA, etc. © Icinetic 2012 20
  21. 21. Graphical Model Editors MS DSL Tools  WinForms  WPF Custom:  WinForms  WPF Third party tools: Visio, EA, etc. © Icinetic 2012 21
  22. 22. Other Model Editors Tables Trees © Icinetic 2012 22
  23. 23. MDSD: Reverse engineering Metamodel(s)Textual Model Editor ReverseVisual Model Editor Engineering Model(s) Model Checker Model repository IDE Model Transformation M2M M2T Code Model Doc, etc. © Icinetic 2012 23
  24. 24. Reverse Engineering External assets to model Sources:  Databases  EDMX Database importer  Services  Custom parsers  Legacy code  Custom parsers © Icinetic 2012 24
  25. 25. MDSD: Model Checkers Metamodel(s)Textual Model Editor ReverseVisual Model Editor Engineering Model(s) Model Checker Model repository IDE Model Transformation M2M M2T Code Model Doc, etc. © Icinetic 2012 25
  26. 26. Model Checkers: Validation Engine MS DSL Tools  AOP  IDE integration  Hollywood Principle © Icinetic 2012 26
  27. 27. Models Checkers: Validation Engine Essential  AST + Visitor  Two phase checking  Syntax check  Model Merge  Reference resolver  Semantic check  Validation FWK  Extensible © Icinetic 2012 27
  28. 28. MDSD: Model Repositories Metamodel(s)Textual Model Editor ReverseVisual Model Editor Engineering Model(s) Model Checker Model repository IDE Model Transformation M2M M2T Code Model Doc, etc. © Icinetic 2012 28
  29. 29. Model Repositories XML serialization to file Text serialization to file Relational DBMS Documental DB / NoSQL © Icinetic 2012 29
  30. 30. Model Repositories XML serialization to file Text serialization to file Relational DBMS Documental DB / NoSQL © Icinetic 2012 30
  31. 31. Model Repositories XML serialization to file Text serialization to file Relational DBMS Documental DB / NoSQL © Icinetic 2012 31
  32. 32. Model Repositories XML serialization to file Text serialization to file Relational DBMS Documental DB / NoSQL © Icinetic 2012 32
  33. 33. MDSD: Transformations Metamodel(s)Textual Model Editor ReverseVisual Model Editor Engineering Model(s) Model Checker Model repository IDE Model Transformation M2M M2T Code Model Doc, etc. © Icinetic 2012 33
  34. 34. Transformations M2T  Free text concatenation  XSL-T (No thanks!)  Text Template based  T4  StringTemplate M2M  Imperative  Declarative © Icinetic 2012 34
  35. 35. MDSD: M2T Metamodel(s)Textual Model Editor ReverseVisual Model Editor Engineering Model(s) Model Checker Model repository IDE Model Transformation M2M M2T Code Model Doc, etc. © Icinetic 2012 35
  36. 36. M2T: T4 Templates Text Template Transformation Toolkit Released in 2005 by Microsoft Syntax:  Directives  Text blocks  Control blocks Usages:  Standard  Precompiled: webResponseText=template.TransformText(); © Icinetic 2012. 36
  37. 37. M2T: StringTemplate Terrence Parr’s templates group Templates; Dynamic templates genMail(msg) ::= << From: $msg.From:genRecipient()$ Strong separation of To: $msg.To:genRecipient(); separator=", "$ concerns: Model, View and Control Subject: $msg.Subject$ MESSAGE: ------------------------------ $msg.Message$ Good maintanability ------------------------------ >> genRecipient()::= << $it.FullName$ <$it.Email$> >> © Icinetic 2012. 37
  38. 38. M2T: Template Engines Time to generate 5000 files of 5 Kb of average 40 35 T4 30 StringTemplate 25 Write File 20 Generation Precompiled T4 15 Load/compile 10 5 0 T4 StringTemplate T4 Precompiled T4 StringTemplate Precompiled T4 Total time (ms) 392.935 56.483 48.894 Time(ms)/file 78,587 11,297 9,779 Time(ms)/MB 4.066,142 876,654 505,961 Improvement/T4 base x7 x8 © Icinetic 2012 38
  39. 39. MDSD: M2M Metamodel(s)Textual Model Editor ReverseVisual Model Editor Engineering Model(s) Model Checker Model repository IDE Model Transformation M2M M2T Code Model Doc, etc. © Icinetic 2012 39
  40. 40. M2M: Imperative © Icinetic 2012 40
  41. 41. M2M: Imperative © Icinetic 2012 41
  42. 42. M2M: Declarative Essential TRX  Rule-based language  Interpreted © Icinetic 2012 42
  43. 43. MDSD: IDE Integration Metamodel(s)Textual Model Editor ReverseVisual Model Editor Engineering Model(s) Model Checker Model repository IDE Model Transformation M2M M2T Code Model Doc, etc. © Icinetic 2012 43
  44. 44. IDE Integration1. Model Editors VS packages Folders & Projects2. Model checkers Generated & custom Errors validation code coexistence3. Model to Text Generated assets tracking © Icinetic 2012 44
  45. 45. Making sense of it all Radarc  Plug-in on the top of Visual Studio  Modelling environment and code generation packetized by architectures © Icinetic 2012 45
  46. 46. Radarc Formulas A Formula is a code  Formulas available generator including:  ASP.NET WebForms  Models / DSLs  ASP.NET MVC  Editors  MVC + Azure  Traceability rules  Windows Phone 7  Best practices  DDD N-Layered  Templates  … and growing © Icinetic 2012 46
  47. 47. Demo© Icinetic 2012 47
  48. 48. Conclusions Modelling and code generation technologies have matured a lot in the latest years The .NET platform has a strong base of tools to make MDSD approaches feasible. MDSD is not more a luxury, is a precision tool. Take profit! © Icinetic 2012 48
  49. 49. Questions & (might be) Anwers © Icinetic 2012 49
  50. 50. www.radarc.net @RadarcNetpjmolina.com/essential 50

×