mercredi 1 avril 2015

Version Control System

Let me ask you a question : "How do you manage your SQR files ?"

By how to manage SQR files I mean how to track modifications and modifiers to the SQRs.

Let me start with an example :

At one of my employers, there was only one Unix account every developer would use to access to the SQRs.  The rule was simply to login with this account, and modify the SQR; of course, people prefer to download it to their desktop, and then to upload it back to the server.  But one day, for some reason, someone forgot to download the current SQR to his desktop, took the one already present and overwrote the existing version on the server... that manipulation erased some changes that occurred since the first upload... Including tax updates improvement.  The company lost money because of this...

I propose to use SVN, a control version system, which is by the way used by other developers (Java / Web  developers) in the same department of IT.  But those developers, younger, work with new technologies, they document in a wiki, and use Scrum / Agile methodologies, whereas the Peoplesoft team is from old school.  At first, the boss is interested, but when she understands if a person really wants to commit without comparing with previous version and no-one makes checks after, the same problem may occur, she decided not to go forward.  She thought it would have been to difficult for "dinosaurs" to understand how to manipulate such a tool (even using Tortoise), and she didn't see the advantages to track modifications.

At another employer (or client), the method is relatively the same, except that they wanted us to rename a vanilla SQR with a prefix in front of it so their infrastructure team would see the SQR is custom.

At CGI, the SQR were managed by Stat, a migration tool... I found it complicated, but knowing the size of CGI, that may be the reason.

At my current employer, we have some paths that enables us to prioritize a custom SQR instead of a Vanilla one.  The SQRs are managed by Phire, a ticket software based on Peoplesoft, which is also used to migrate between environments.  It copies the SQR from one environment to another, but it seems complicated to track changes... and one day I noticed the infrastructure team put in prod a SQR not up to date... another story :)

Before working in Peoplesoft, I worked in PLM (Product Lifecycle Managment), which was C++ development to be short.  I worked at Boeing, and code was really well managed.  Boeing purchased a tool named ClearCase, which would track all of the sources and properties files.  Before modifying a file, we had to reserve it; of course, we could work on files without reserving them, but when the time to commit changes came, we could have to manage potential merges with the developer who had reserved the file.  It was always easy to know who modified what.  We were part of a large team, at least 30 developers, so there was a CleareCase administrator who would deploy different branches of the repository in different developing/testing environments.  Everything worked like a charm, even if it was a bit complicated at the beginning.

To be continued...

Another Horror Story

I'm still working for the same client that I won't name.  I was asked to debug a program delivered few years ago by "Expert Consultants" from huge firms I won't name either.

So I start looking at the appengine... find the Peoplecode where the file is generated... OMG : 1953 Lines.

Well I start with a quick look, I scroll up and down quickly... I notice something strange : some blocks of lines repeated, but idented to another level at each time.


I look closer, try to understand... I finally understands : a record ( &RECORD1 ) contains some fields named the same way (a number is distinguish them) and having the same usage.   There are 23 clones same 5 fields in the record.  So 23 if statements.

I finally understand the context : the code is part of a While statement.  At each iteration, the program checks the iteration number (stocked in a variable named &n_loop_2) and set the values of the fields ending with this number.

Do expert peoplesoft programmers, in particular those who charge 200$ an hour, ignore that we can access to a record or a field (or other objects) by stocking his name in a variable ?  Can't they search a little bit in Peoplebooks ? Can't they try to find a way to do stuff dynamically instead of copy-paste ?  I discover that when I had less than a year of Peoplesoft background... maybe I'm too curious... :)

Ok, I continue looking... I found 2 more times the EXACTLY same issue; The little difference is that a letter differs in the fieldnames of the 3 blocks :

ZZ_zzz_G_030_A_xx
ZZ_zzz_G_030_B_xx 
ZZ_zzz_G_030_C_xx

With this new discovery, I decided to investigate more... I found out that there is another while at an higher level.  The student (we are in Campus Solutions) can have 3 differents plans, for each plan, there is a block of code... I separated the three blocks, and compared them (thanks to Beyong Compare). The results are crazy : the block of code for B is identical to the block for C and A's differs just a little bit. Only suffix differs.

So I start refactoring... There is no way I will try to understand such a code.  I noticed other folks who repeated their correction up to 53 times, I'm not doing that.

I find out some fields are named with a D instead of a B or a G instead of a C, so I introduce another suffix.  Also for B and C fields, there are only 20 clones by field instead of 23 for A.  I end up with 3 variables to manage :


and the 23 ifs statements are replaced by 5 those lines :


For block of code specific to the first iteration, I just need to add exceptions such as :


Finally, the code ends up with 814 lines

After this work, I can investigate the code and understand something, instead of wasting my time.  2-3 hours later, I could explain it to the Business Analyst.