It's very common when developing applications to feel that some parts of the application are quite similar but not exactly the same. For example in an application where you have Customers and Products, it's natural to have a Form to list the Customers, and another Form to do the same for Products. Even Customers and Product are totally diferent, these two Forms have lot of things in common: the grid, a set of field for filter data, ordering, actions, etc..
This situation is called a 'pattern' and have been a very popular topic in the sofware industry recently (see What Is a Software Pattern for more info).
The question is if we can use this ideas in Genexus. Or in other words, what is exactly a pattern in Genexus, and why it is useful. Before answering these two questions we must first address some of the limitations of patterns these days:
- Passive. They exists only in books, the only way to use them is to read the books and use these ideas while coding.
- At the coding level. Even patterns are usually referenced as 'Design Patterns', they are mainly aimed to help on coding stuff.
Given Genexus works at a knowledge level instead of coding level, we wanted to use patterns as a way to facilitate knowledge reuse, not just code reuse. So we developed a framework for patterns whose design goals were:
- Active. An 'active' pattern isn't just a guideline, you can 'instantiate' it (meaning the framework generates all the Genexus objects needed to implement an instance of the pattern). See Pattern Instantiation concept.
- Knowledge reuse. Genexus always tried to encourage knowledge reuse, but with the use of patterns, it's possible to deliver a new level of knowledge reuse: the same knowledge can be used to many different situations. For example the Bill Of Materials Pattern can be instantiated to Products, but also to Menues.
- Open .Anyone can generate their own patterns (or modify an existing one).
- Easy to use. In this way we keep our promise of complexity reduction: to use a pattern you don't need to be an expert on this area. (Note: this is not necessary the case if you also want to develop your own pattern, where a more complex knowledge in the subject is needed).
The result of this goals is a tool called GeneXus Patterns. This tool was released for the first time withis part of Genexus 9.0, and it can therefore be executed from it. However, it can also be executed as an independent application and it can even be used with Genexus 8.0 KBs. It's basically a framework that allows Genexus developers to apply any pattern to his/her KB. The tool itself comes with a set of 'builtin' patterns, like Work With Pattern or Bill Of Materials Pattern so the developer can start using patterns without the need to develop a pattern himself/herself.
The framework also helps developers to create their own patterns. See Business Patterns Catalog for a list of patterns, some of which have already been implemented and others that are suggested for future implementation.
Briefly the tool lets the developer select a specific pattern, ask for all the parameters the pattern needs, and after that it generates all the GeneXus objects needed to implement the pattern. It also has the capability to import, compile and execute these objects.
Going back to the question why is this tool useful for a Genexus developer, a big improvement in productivity and quality of the application is expected with the use of this tool. For example a typical scenario of use is when developers need to migrate a KB from green screen or Windows forms to Web forms. In this case the Work With Pattern can be applied to generate most of the web objects needed for a nice-looking and user-friendly web application. See People And Organizations Knowledge Base for an example of it.