Share
Embed
Transcript
27 slides
-
2 Who’s speaking? @ltguerin [email protected] Laurent Guérin Open Source supporter
Passionate by software engineering and development industrialization By day Senior architect at By night Creator of code generator -
5 What is Telosys ? A light and simple tool
that generates code -
6 What is Telosys ? A light and simple tool
that generates code and boosts your projects -
7 Usual problems with code generators • It’s heavy and
complicated • The generated code is not clean or does not meet expectations • The tool is intrusive: the generator imposes choices (code style, framework, etc.) Why Telosys ? Black box Model Generated files Result : different from what we want! -
8 Templates Model at all levels : project, model and
templates Project conf Result : exactly what we want Generated files Black box Model Generated files Result : different from what we want! Telosys is fully customizable customization -
10 Telosys is able to generate any type of code
Each project can make its own choices : You decide, Telosys adapts! It is possible thanks to : • model extensibility ( 50+ “annotations” & specific “tags” ) • customizable templates ( Velocity language improved with many additional features ) • native support for composite primary keys (and FK) Telosys is the only generator offering such flexibility -
12 An entity is described using a DSL (Domain-Specific Language)
Very simple grammar , extendable with "tags" DSL #tag 1 model = 1 directory 1 entity = 1 text file ( « .entity » ) What does a Telosys model look like? Simple & easy -
13 @AggregateRoot @DbTable(T_ORDER) #MyEntityTag Order { // Id ( Primary
Key ) num : int { @Id @NotNull @Label("order number") } ; orderDate : date { @NotNull @Label("order date")} ; status : short { @NotNull @DefaultValue(0) #MyTag(123) }; comment : string { @Size(120) } ; // FK referencing Customer customerId : int { @FK(Customer) } ; // Links items : OrderItem[] ; // Many deliveryAddress : DeliveryAddress ; // One // No link to Customer (not in the aggregate, just FK) } Attributes Links Entity Annotation (pre-defined) Tag (user-defined) Neutral type (language-independent) composite PK supported with multiple “@Id” What does a Telosys entity look like? -
14 Models & entities in different editors/IDE Visual Studio Code
Eclipse Notepad++ -
15 Model creation From scratch From a relational database Model
Model “New model” command nm {model-name} nm {model-name} {db-id} One entity for each table with columns mapping, PK, FK, links based on FK, etc… -
16 Models & entities in Telosys-CLI Main commands : •
lm list models • m print or set current model • cm check model validity • em edit model description • nm new model • dm delete model • le list entities in current model • ee edit entity • ne new entity • de delete entity -
17 Templates Templates Templates Templates Templates Templates Templates are used
to generate any kind of file from a given model ( they can generate files for any language with any framework ) One model to rule them all MODEL declarative part processing part -
19 /** * REST DTO for entity "${entity.name}" * *
@author ${AUTHOR} * */ public class ${entity.name}RestDto { #foreach($attribute in $entity.attributes) private $attribute.type $attribute.name; #end What does a Telosys template look like? http://velocity.apache.org/ Telosys template engine is Velocity (well-known, open source and well documented) Templates language is VTL (Velocity Template Language) • Directives : #foreach, #if, #set,... • Variables & objects (from model) : $entity, $AUTHOR, $attribute.type, ... • Specific Java Classes can be added (if necessary) -
20 A "bundle of templates" is a set of templates
that can be used to generate a specific part of the application (persistence, entities, screens, rest handlers, etc) Telosys templates packaging (“bundle”) Each "bundle of templates" is usually stored in a Git repository Git repository -
22 Templates in Telosys-CLI Main commands : • lb list
bundles • b print or set current bundle • ib install bundle • eb edit bundle • db delete bundle • lt list templates in current bundle • et edit template -
24 Code generation in Telosys-CLI Launch global code generation :
gen * * Launch generation for all entities in the current model and all templates in the current bundle -
25 Do you really want to waste your time writing
boring repetitive code? N entities N times… Copy/Paste? Productivity? Bugs? Quality? Standards? -
26 N entities N times… Get started faster and easier,
improve quality, set your standards Let Telosys do it for you! -
27 https://www.telosys.org/ • Telosys CLI : https://github.com/telosys-tools-bricks/telosys-cli • Telosys Eclipse
plugin : https://github.com/telosys-eclipse-v3/TelosysToolsPlugin all stars are welcome ;-) Stay tuned ! https://www.youtube.com/@telosys @telosys tag "telosys" https://www.linkedin.com/company/telosys [email protected] Eclipse Plugin