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 with
Data 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: