COMPANY
COMMUNITY
BLOG
HELP
MY ACCOUNT
EN PT ES

GX_icono data provider

GeneXus X increases development productivity with Data Providers and Data Selectors

02December/2008
GeneXus X incorporates objects to the IDE in order to increase productivity. Today we will explain what Data Providers and Data Selectors are and how they optimize the development work.

When it comes to increasing the productivity of software development with GeneXus, Data Providers and Data Selectors take the leading role.

Since its creation, GeneXus was intended to be declarative: a repository of knowledge, regardless of technology.

What does it mean to develop declaratively? To develop declarative implies pointing out “what to do” instead of “how to do it.”

Today, (nearly 20 years later) this is turning into a worldwide trend and there is much talk about having more declarative languages. GeneXus is basically declarative but its Procedures are not, even though they access data at a very high level. Data Providers are a great step forward to minimize the need for procedural coding.


What are Data Providers and what role do they play?

Data Providers are completely declarative objects (see chart) that replace a certain class of procedures: those that receive an input, perform a process and whose final objective is to return a data set in a structured format. In this context, Data Providers aim at dramatically reducing the number of procedures.

Given a process with an input, transformation, and output where the transformation generally retrieves database data which is later returned in the output of some hierarchically structured format, Data Providers focus on this output in order to tell GeneXus “what to obtain” and not “what it should do to obtain it."

Later, this output can be easily converted to a standard format (XML, JSON, etc.).

Comparative example:

This would be the code of a procedure used to create an XML file with a list of airline passengers.


Looking at this procedural code we can see that it is tangled and a bit confusing, and that it's difficult to determine its objective.

Data Providers are intended to solve these shortcomings of procedural programming in procedure objects.



The objective is to program the same in a declarative way. Thus, the process input and output are clearly identified, that is to say, the intention behind the code is obvious and it saves a lot of code writing.

Therefore, Data Providers will have a structure similar to that shown in the image. On the left we can see the fields to return (as well as the output structure) and on the right we can see what each field in the structure will be assigned (attributes, in general). Control sentences can also be used (read Documentation: Data Provider Language).

Input parameters can be received (they will always be IN) and the DP output will be an SDT (or BC) which is indicated in its Output property.

The main functionalities stand out for writing XML files (Web Services, RSS feeds), filling SDTs (associated with User Controls, for example) and filling Business Component structures.


Data Selectors and the optimization of knowledge
Data Selectors are a new object type for storing a set of orders, filters and Defined By clauses in order to reuse them in various parts of the KB.

This greatly empowers code reuse; for example, if we have a Clients table and we need to filter the active clients in many objects, we will do so by defining it with a Data Selector and referencing it everywhere this filter is to be applied. In addition, Data Selectors can be used to filter grids, Data Provider groups, and to define formulas.

As a result, knowledge is optimized because programming is made clearer and simpler: by maximizing the savings and reuse of code that will be defined only once; it eases maintenance by allowing changes to be done in only one place and optimizes the knowledge stored in the KB through the encapsulation level provided.

In order to learn more about the declarative language and the possibilities of Data Providers and Data Selectors in GeneXus X, look at these two sessions offered during the XVIII GeneXus International Meeting:

GeneXus X IDE –Getting Started II by Fabián Bonilla

Data Providers by Luis Murillo

Related
GeneXus X features that increase productivity (II): Expression data type
How To: Examples of Data Providers with Conditions
Data Providers and Business Components to initialize data
Initializing data: one step ahead
Special Edition #GeneXusTheBestOf2014 :: Cloud Computing, the Internet of Things, GeneXus X Evolution 3, Success Stories, Smart Devices and ... Much More!
Release of U2 of GeneXus Evolution 3
Chopo Mobile introduces successful app in Mexico, developed with GeneXus and used for medical studies
GeneXus™ ERP Explorer and Connector for SAP® ERP Now Live on SAP Store
We have a new Download Center! The GeneXus download center has an enhanced appearance at its new location
Demand for Apple TV apps expected to double in 2016
What we've learned about GeneXus by working with Gartner (by Gabriel Simonet)
Agile or Waterfall development? (by Breogán Gonda)
We are pleased to share an interesting white paper about GeneXus, written by Kapil Ambwani from India!
Mickey, Toy Story & GeneXus: Why robots will transform developers?
GeneXus™ Named a NEW Challenger by Gartner In Its 2017 Magic Quadrant for App Development Platforms Report