COMPANY
COMMUNITY
BLOG
HELP
MY ACCOUNT
EN PT ES

Imagen6632E

A Glance at the New Tool: Patterns

Marcos Crispino, from Concepto, talks about his vision and experience as beta tester of the Patterns tool, whose beta version was released with the beta 1 of GeneXus Yi

What is a pattern?
Patterns are frequently used in object-oriented programming: a recurring problem and the best solution for it -previously used to solve that same problem- are described. That makes the solution of these problems easier, as it is not necessary to "reinvent the wheel" every time.

ARTech's Patterns tool is a framework that enables the generation of GeneXus code from these patterns. This tool already has some patterns implemented, and it is possible to implement new ones or to adapt the existing ones. For example, the Work With pattern allows, given a transaction, to generate all the objects necessary to implement a "work with?" web for this transaction.

In the case of Concepto, this idea of automatic generation of GeneXus code has been used for some time.

How was the Patterns idea previously used in Concepto?
We developed the first code generator two years ago. It uses GXPublic to access the structure of the knowledge base and generates the code that is then incorporated to the same knowledge base.

Some examples of the things we have been doing are:

  • Given a transaction, generate the code of a GeneXus procedure that loads (and another one that reads) an XML with the transaction structure.
  • Given the structure of a Data Warehouse, automatically generate the code necessary to load the information in the tables. SQL scripts generation from the tables and the columns in the database (this item is independent from GeneXus).
  • Given a transaction -representing a message-, generate the XML Schema with the same structure to validate it.
  • Given a table -representing a message-, generate the GeneXus procedure that loads (and another one that reads) ASCII files delimited by commas with the fields of the message and validate data types.

What are the advantages of using Patterns?
The advantages of using these patterns -or code generators- are quite obvious. For example, saving the content of a transaction in an XML depends only on the structure of the transaction -as long as we have the possibility of defining the XML structure-. In this case, all programs carrying out this task will be similar, and only the attributes used will vary.

This is a clear example of a case where it is convenient to use patterns. We have to program the code generator only once, and then request it every time we want to make the program save the content of the transaction to XML.

These are the most important advantages:

  • With very little effort (just a few clicks) we can generate programs with the desired functionality.
  • Code errors are avoided. There might be errors in the code generator, but they are corrected as it is used. With hand programming, each new program may have new errors.

The same happens with the Work With pattern, which already has the Patterns tool. This pattern allows generating several objects that make a "work with ?" from the transaction selected. The tool allows configuring the properties for each transaction, such as the filters to be used in the selection web panel, the attributes and the order of the grids, the folder where the objects will be created, etc.

What has been Concepto's experience using Patterns?
We've been running tests in Concepto to create new patterns and adapt existing ones. For example, we extended the Work With pattern so it could generate an Excel worksheet with the data of the selection grid. We had a good experience; we were able to assess how difficult it is to develop these patterns that allow us to generate code automatically. The main difficulty to develop these patterns is that one needs to program in C#.

I think it is great to have a standard framework like the Patterns tool to develop these patterns. It will allow the community to develop new patterns, therefore making the development of applications with GeneXus even easier.

In our case, we are evaluating the migration of the code generators to Patterns; right now our code generators are not standardized -each one was developed independently. If they are defined as patterns, it will be easier to use and to exchange with other members of the community, which in turn may also make contributions.

Petroglifo:
http://www.concepto.com.uy/petrocsharp

More information about Patterns on the Wiki:
http://wiki.gxtechnical.com/wiki/tiki-index.php?page=Patterns

 

 

 

Related
Patterns Beta 1 Has Been Released
GeneXus Patterns in Action
The RC Version of GeneXus Patterns Has Been Released
WW PATTERN: When less is more!