COMPANY
COMMUNITY
BLOG
HELP
MY ACCOUNT
EN PT ES

blog 1 12

It was just like Karina told me 20 years ago

An article by Gustavo Carriquiry, Artech’s Operations Manager, who starts by telling an anecdote about initializing data with transactions, procedures and Data Providers, and ends with practical examples of GeneXus X Evolution 1 use, such as the Business Component and Data Providers video.
A few weeks ago I realized that Karina (Santo) had been right 20 years ago, and it only took two decades for me to open my mind and accept new challenges. This post is meant to recognize her insight and to help other people open their minds.

My problem back then

I’ve been working with GeneXus for many years now. I started with a customer about 20 years ago, and I remember contacting the support team; at that time Karina was like a one-woman orchestra, covering “support, documentation, test, training, consulting, etc.”

Back then I was developing a system for fleet control (spare parts stock, fuel management, workshop management, etc.). I needed to carry out a “batch” stock update process, but GX only had Transactions and Reports at the time. There were no procedures (not to mention workpanels and the other features we have today).

I contacted support so that they would help me solve the problem, and Karina tried to convince me that what I was doing was "conceptually wrong," that the database update had to be performed through the transaction, as that was where the business rules were, and that that way I’d ensure data consistency, etc. An argument worth considering.

I was only 20 years old, still a college student, and Karina was very convincing. But in spite of that, she wasn’t able to convince me. I was rebellious (and headstrong like all Basque) and I built a little program in DBase III Plus (quite a product!). It was a very simple and easy to integrate program, and luckily it didn't need to be migrated to RPG, because that would have been more problematic.


Mi problem today

A few days ago I had to create an application and I wanted it to have a Geography structure (the typical Country/State/City list), and I decided to follow the “usual” path.

I started by defining the geographic structure I wanted, which was quite simple:

CountryID* CountryName (StateId*StateName(CityId*CityName))

Then, I started developing, following the “old familiar and reliable” path of a procedure with “news” for populating the data. Something like:

new
    CountryId=1
    CountryName=”Uruguay”
endnew
new
    CountryId=1
    StateId=1
    StateName=”Montevideo”
endnew
new
    CountryId=1
    StateId=1
    CityId=1
    CityName=”Montevideo”
endnew

etc, etc, etc.

I engaged in a long and boring process of copy/paste, making many mistakes along the way (not unusual for me when I’m bored), for example because I entered the wrong country code in a block and the resulting data was all wrong, and so on.

There has to be a better way

The data “initialization” process is something I usually have to do because I build many KBs from scratch and in such cases having a “reasonable" set of data is often a problem.
I think this is also pretty common in implementation processes, when after "creating" the database you need to populate it with initial data.

I looked in some KBs to see how they resolved this problem (GXserver rules!) and I found the same procedure and news solution in several cases. I even found some that were very close to what I was looking for, but not enough to reuse them at a low cost.

I remembered a post I published a while ago in the wiki, about a DataProvider that I had developed with a little program that read the ISO codes of an excel file and generated a TXT with DP format, then I “copied/pasted” from the TXT into the DataProvider. Sometimes I do that for fun.

While that DataProviders is useful , it doesn't include states or cities; that is, it didn't really apply to my case. However, it seemed to me that the solution had to be DP-related.

In the end (to make a long story short) I decided on a solution withData Provider   that returns data and a procedure that uses a business component instead of “news”; I also used autonumber and a couple of serials to avoid the primary key problem.

This is a video of how I did it:
 

Advantages I found

1. Simpler. I want to populate the Countries structure: Drag & drop from it to a DP; a few more things, and ready!
2. Cheaper. The initial version took me less time. In spite of the "copy/paste" work, the process was easier, at least I didn't have to worry about the CountryCode, StateCode, etc.
3. Clearer. I separated the “addition” from the “data source,” so that if I want to add data I don’t need to do anything with the news, I just add them in the DP.
4. More powerful. In my case, although it was a simple structure with simple rules, it helped me solve the issue of the addition, numbering and rules associated or to be associated to the Country, etc. (if I have to add a rule to the Countries TRN I know that I won’t have to change the procedure, this is important for data consistency/quality).
5. More reusable. My challenge now is to avoid copying and pasting, and I have a feeling that the Data Provider Generator and services such as those of freesbase.com will help me accomplish my goal (although it will have to wait until I have the time to take a more in-depth look at freebase.com).

In any case, if I were to implement this in a client, the data source might be different, and, having separated the data from the data entry itself, I think that it will be much easier to adapt the "input" of the DP.

Anyway, using DP and BC in a scenario as the one described above has quite a few advantages. After “opening my mind” with respect to DPs and BCs, I think that there are many more possible cases in which they can be used, so my message is simply the following: Keep an open mind, there are new and better solutions for both new and old problems.

Oh, I forgot: Karina, you were right. All I had to do was open my mind, and I realized that using the transaction was enough (or almost) for an update.

Posted in Gustavo Carriquiry’s Blog


 

Related
Data Providers and Business Components to initialize data
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
Free Live Webinar: Conversations on Digital Transformation - Wednesday, November 8, 2:30PM (EST)
GeneXus™ Announces Its Participation at SAPPHIRE NOW® to Showcase GeneXus for SAP® Systems