Code Generation - PowerPoint PPT Presentation

About This Presentation
Title:

Code Generation

Description:

Shell here document' Use existing example. Replace specifics with $variables ... Shell scripting is fast and readable. Take care when modifying generated code. 9/16/09 ... – PowerPoint PPT presentation

Number of Views:96
Avg rating:3.0/5.0
Slides: 21
Provided by: citrp
Category:
Tags: code | generation

less

Transcript and Presenter's Notes

Title: Code Generation


1
Code Generation
  • Tips
  • Tricks
  • Pitfalls

2
Why?
  • Speed up development
  • DeltaX 8X
  • Remove bugs
  • Consistency
  • Less flexibility

3
Why Not?
  • May be difficult
  • May not be appropriate
  • Readability of generated code
  • Debugability of generated code
  • Less flexibility

4
Example - DeltaX What
  • High level design
  • Detailed design
  • API Document
  • SNMP MIBs Database Access
  • SNMP Agent functionality
  • C SNMP Corba Classes ...
  • GUI

5
Example - DeltaX EMS
  • EMS SNMP Agent
  • API Document
  • High Level Design
  • MIB Master C Code
  • Subagent Set CB
  • Cache access
  • API calls

6
Example - DeltaX NMS
  • NMS - C Corba Ilog GUI
  • IDL
  • Corba Impl
  • DB schema access
  • SNMP access
  • Ilog GUI
  • GUI C

7
Example GUI
8
Lines
9
Percent
10
Tips
  • Metadata
  • Utility printing executables
  • Parsing executables
  • Integrated executables
  • Shell here documents

11
Metadata
  • Describes the data
  • Want it compiled in I.e., accessible in scripts
  • Source code
  • Database
  • Metadata parser input file

12
Parsing
  • MibMaster etc.
  • Bulk Code
  • Metadata
  • No Changes
  • Generic
  • Difficult to debug/change

13
Integrated
  • Based on intermediate metadata
  • Can do complex tasks - e.g., if then else
  • Difficult to modify

14
Utilities
  • PrintMibs
  • Prints metadata
  • Print 17 items per attribute
  • Flexible - uses printf
  • Absolute key

15
Shell here document
  • Use existing example
  • Replace specifics with variables
  • Enclose with cat ltlt EOF EOF
  • Easy to read, write and debug
  • New age of code generation

16
Metadata Applications
  • E.g., GOA
  • Array of attributes
  • Switch statements/virtual functions
  • Very good for raw applications
  • Low code base size
  • Easy to add new ones dynamically
  • Low code ability
  • Difficult to add special cases

17
Tricks
  • How to identify
  • Doing the same thing over and over
  • Use generation when possible.
  • Only use generation when possible.
  • Only use generation when possible.
  • Cut and Paste for small amounts.
  • Dont try to be optimal initially

18
Pitfalls
  • Modifying Code
  • Stub Files
  • RCS
  • ifdef wrappers
  • Derived classes
  • Registered Callbacks
  • Dont generate as part of the normal build
  • Code understandability

19
Conclusions
  • Generation can reduce time
  • Use 90 generated 10 hand coded
  • Use metadata based for raw apps
  • Shell scripting is fast and readable.
  • Take care when modifying generated code.

20
References
  • MM hptools/yacc
  • PrintMibs mibmaster/008.Tools/print_mibs
  • GOA mibmaster/007/src/monitor/goa
  • gen nms nc867.15/007/src/gen_nms
  • ems nc867.15/007/bin
Write a Comment
User Comments (0)
About PowerShow.com