Power to Build

Home » Programming

Category Archives: Programming


Tools: UMLet – Great tool for drawing UML diagrams

UMLet is an open source UML diagramming tool with a twist! I’ve used many UML tooumlet_logo_smallls in the past, but UMLet is different.

It’s a diagramming tool for the diagram-challenged in us!! You simply type text and it will convert to UML boxes and arrows immediately. It can create simple UML diagrams, Use cases, Activity diagrams and sequence diagrams. I use it to produce some non-UML diagrams as well.

It has a pallet of UML elements already available which you can double click or drag and drop onto your diagram. You will a properties box on the right, where you can start typing – rename, add arrows, lines etc. Yes, you can change the already present elements in the pallet as well!

I particularly like the fact that you can add custom elements to the already rich set of drawing elements. While creating a drawing element, you add Java code snippets to create shapes to your custom elements. Really powerful! OH yeah, it compiles the Java snippets on the fly!!!

Here is a really nice presentation on Prezi to get you started. It has an embedded video as well. Short and sweet.


If you want to learn more about the tool, you can always look at the Source code on github.

The diagrams are stored in UXF (UML Exchange format) format. It is really an XML file with specific format used by the tool. I’ve tried and succeeded in generating this file for some simple diagrams. It is available in various flavors – as a standalone (Java) executable or as a plugin in various IDE including Eclipse.

As a tool, it is intriguing – from the simplicity of use to the versatility of adding to new elements. Complex Diagrams can be produced quickly. I love it. Give it a try! You can download the tool here.


Quick Tip: Line continuation Char in code

In English, we use sentences that are made up of words which are typically separated by spaces (” “) and tabs. We use commas, and semi-colons to create pauses and we keep reading until we see a period. If the sentence is too long to fit on a line (typically 72 – 80 characters on a page). Often times, we feel the need to break in the middle of a word, to keep the right margin neat. For this we use hyphen (“-“).

Programming languages and scripts are not very different. After all, they are made by us, humans. Each language has a set of punctuations like English. As for wrapping a statement onto next line, each language may have it’s own character and conventions. In any case, you cannot break in the middle of a word.

Generally, Microsoft programs and script use hyphen (“-“) to indicate the statement is continuing on the next line. Unix world typically use a backslash (“\”).





DOS/Windows Batch File

^, (

C, C++












See this wiki post for more on this and other punctuation in programs.


Have you heard of a magic word CAFE BABE? They are the magic numbers of the Java class files. See below link for the interesting story behind it:


And the words, CAFE and BABE both actually make up the below hexadecimal numbers:

(CAFEBABE)16 = (3405691582)10

If you wonder why a magical word is needed, it’s a long practice in identifying files. See the wiki postwiki post about this.

DEAD BEEF (actually an hexa decimal number) is the magic word used by Texas Instrument in MAC Addresses.

Oh, the other word in my title, DOCFILE0 is actually a pseudo word = D0CF11E0. That is magic word used in the header of Windows EXE files. See here for more on that.

Sybase EAServer: Taking Control – Changing JVM in Jaguar Manager

EA Server 5.5 comes with a manager application called Jaguar Manager (also called Sybase Central). This is really a Java product, but in this version it’s wrapped in a program called scjview.exe. This is available in %SYBASE%\Shared\Sybase Central 4.3\win32.

I found out this is using an old JRE 1.4. (I use process explorer in Sysinternals. It’s a great tool!). I wanted to switch the EA Server to Java 1.5 , which is the latest version of Java supported in EAS 5.5. With the EA Server itself, this is easy. Just pass -jdk15 to the serverstart batch file.

With Jaguar Manager, this is not as straightforward. There is a batch file called, jagmgr.bat, but this only calls scjview.exe mentioned above. The Java runtime is probably picked up using a DLL named jsyblib142.dll, in %SYBASE%\Shared\win32.

After googling for a bit, I found a solution to this problem. Apparently, scjview.exe has a command line argument -batch.


scjview -batch

When you run it like that, the program generates a batch file called sybasecentral.bat in the same directory as scjview.

Now, this batch file runs Java with a bunch of Jar files. You can change the path of the Java command to change the Java version it’s run in. Such a simple solution, completely hidden! And with this available, why did they have to create an EXE like that?? Beats me!

Of course, once you convert to batch file, you can tweak the java parameters such as memory etc to run better.

Powerbuilder: Datawindow – what tier?

In continuation of my recent post about PowerBuilder – what tier, I would like to explore a little more on the technical front. In any books or articles on the power of PowerBuilder, you will always confront a Datawindow. A Datawindow is the heart of the GUI development in PowerBuilder.

By design, a datawindow is truly 2-tier. You design a Datawindow by adding a SQL Statement – from the database tier, the 2nd tier. Then you design the GUI of the database to be displayed in the client – tier 1. This is a datawindow. If you follow MVC pattern, Model is there, View is there and the controller is sort of built into the GUI itself (like validation etc). It’s a great innovation of that time.


Fig 1. How a (2-tier) Datawindow works – couresy: Hyderabad College

To use a datawindow in such an environment, all you need to do is the following:

dw_employee.DataObject = d_employee

You are done! (I left out details of the datawindow object, connection parameters and Retrieveal parameters for simplicity). In this case, you are directly connecting to the database from the client and the data flows directly into the datawindow control. You could actually share the data on a datawindow with another (using ShareData function). This allows you to retrieve once and show the same data in different formats.

Distributed Datawindows/Datastores

Then came the n-tier or the distributed architecture revolution. With Datawindow being at the heart of PowerBuilder design, how would you get the middle tier in? Particularly, when the middle tier being the one that’s supposed to connect to the Database.

Before going full on to middle tier in the form of an Application Server, PowerBuilder floated the idea of the Distributed PB as early as ver 5.0. They introduced the concept of HTML datawindows. They also introduced the idea of a Datastore, a non-GUI datawindow object. (Before datastore, we used to create a hidden datawindow, which still painted the datawindow behind the scene and thus still the overhead). These were steps in the right direction to distribute an application. (I have a gripe though that Datawindow (control) and Datastore don’t share the same object hierarchy!! So, you constantly have to test for the type of the object. How Sybase missed such a basic thing, beats me!).

Then came the Application Server called, EAServer. To be able to retain the datawindow and still be able to follow a MVC pattern, Sybase introduced the distributed Datawindow. Well, it wasn’t exactly an attribute of the data model, but a method in the datawindow object to synchronize a Datawindow (or datastore) object structure and data across the tiers. To do this, they use Serializing/De-serializing a datawindow using couple of new methods – GetFullState and SetFullState. See here for more detail.

3tierig 2. 3-tier architecture – courtesy: Simcrest

With the distributed Datawindow, you create a Datastore in the Application Server (EAServer) and synchronize it with a client side Datawindow (control) with the same structure.

With the Datawindow control being on the client and that you cannot connect to the database directly, above example requires some code adjustment:

dw_employee.DataObject = d_employee
// Get the blob from the Server
lblb_dwblob =iuo_employee.RetrieveData()
dw_employee.SetFullState(lblb_dwblob) ...

Where iuo_employee is a non-visual object created on the server.


Function iuo_employee.RetrieveData()


ds_employee.DataObject = d_employee ds_employee.SetTransObject(SQLCA) ds_employee.Retrieve() lblb_dsblob = ds.employee.GetFullState()

// Somehow send it to the client.


Distributed_DatawindowFig 3. Simple implementation of a distributed Datawindow

There you have it. PowerBuilder somehow, did manage to distribute their GUI object called the datawindow. You essentially create a non-visual Datastore that has the same attribute as the Datawindow control. Retrieve it and send the results as a blob to the client to be shared and shown on the Datawindow control.

Only one problem is that you are sharing both the data and the structure of the Datawindow object between client and server. This is slightly in cotrast with how other platforms would implement this. In Java, for example, your JTable still stays on the client, while the TableModel could be made to use a middle tier object to fetch the data. The middle tier object could then connect to the database to get the actual data.

I would have preferred  if they made the Datastore the data/model portion of the Datawindow, instead of making it a new object as a Datawindow minus GUI. This way we could have reused the ShareData function in a distributed capacity in some way and implement the dealings with blob behind the scene. But that’s crying over a spilled milk. EAServer and the associated architecture is going away and thus the idea of distributed datawindow may disappear from PowerBuilder altogether. (However, Appeon may carry the concept forward. See here).

Powerbuilder – what tier left?

First it was 2-tier

Client/Server (2-tier) technology was the leading application development methodology in the early 1990s. This was in total contrast to the centralized development methodologies applied to mainframe architecture before. Now, suddenly, you can have localized programs that can be made to cooperate, to get major business functions done. Companies were feverishly working on replacing their old (mainframe) green screens with shiny new Windows programs. People who wrote spaghetti code in COBOL before suddenly found this new thing called IDE where you design GUI and write a few lines of code, bam! a database application was done. I worked on a couple of pilot projects in PowerBuilder where I brought along mainframe programmers and users into the shiny new Windows (Windows 3.1!!) machines!

PowerBuilder started in the early 1990’s and showed a lot of promise. It gave run for the money to other similar tools – Gupta SQL, Oracle CDE, Visual Basic etc. Visual Basic (through 6.0) was a good competitor, but their domains were different. PowerBuilder beat VB as the tool of choice for Business (database) application development. It was all great.

Then came trouble in those 2-tiers

Sybase bought Powersoft in 1994! I heard that Powersoft wanted to sell themselves to Sybase to protect another corporate giant, Oracle, gobbling them. Trouble already started for PowerBuilder, as Sybase, a database company, seemed least interested in developing the cash cow any further than that.

Trouble was also brewing for Client/Server technologies in general. As the client/server programs started growing in size, suddenly we ran into performance issues. Flashy Windows suddenly didn’t matter, if they took 5 minutes to load. People looked at ways to split the program logic into multiple parts and try to improve the performance by running these parts on different machines. I myself worked on a project where I refactored a PowerBuilder client/server application, so users in Hong Kong didn’t have to connect to our databases all the time. I used a store-forward technique for this. Data was transferred across behind the scenes using C programs on Unix (what they call ETL programs now).

Later, I found out that part of the blame was the same companies that tried to move out of mainframes. They kept one foot in the door. The global shipping company where I worked, they kept the network still geared up 60% of the traffic on the SNA network (mainframe) and the rest for all the things you do – email, your PB applications, Oracle database etc. It was bound to fail!

PowerBuilder meets n-tier world

In the later part of the 1990s, since the advent of internet technology as a viable public medium, the dynamic web became a necessity. This was mainly achieved with Perl CGI back then. Several other programming environments added access from/to the web from every programming environment. PowerBuilder was no exception. As of PB 5.0, there was “Distributed PB” which was not unlike CGI – running and accessing PowerBuilder application on a remote node through sockets. PB provided a new Transport object that helped with the connectivity, but data exchanges needed to be handled by the programs.

Then came Java J2EE that changed* the way the server side programming was done. CGI had a lot of overhead in having to invoke a runtime environment (VM) each time the program was invoked. What if there was a server that provided this environment all the time and lets you access those programs running inside this server. A Java J2EE server is much more than that. It bundled several software components including an application server, transaction monitor/processor, security module etc.

EAServer** (or more popularly referred to as Jaguar) was Sybase’s answer to bringing Powerbuilder to middle tier and n-tier architecture. It was actually an application server (and others) built over a J2EE Java server. EAServer is actually many containers in one. It’s a J2EE server, a COM server (to be able to run Windows components) and PowerBuilder Application Server rolled into one. It incorporates a C++ application Server, a Java Container (Actually, it includes full-blown J2EE server; EAS 5.5 supports JDK 1.2 – 1.5), a basic Apache Web Server (so you can run HTML based pweb pages inside EAServer), a Servlet Container (version of Tomcat in versions through 5.5 and Jetty Container in Ver 6.x). It also includes a Transaction Processing (TP) Monitor, a Database interface. Components running in EA Server can be accessed through CORBA IIOP or Microsoft Active-X/COM interfaces. It was all cutting edge, but alas! only briefly!

So, one could actually develop multi-lingual (PB, Java, VB, C/C++ etc) applications talking to each other through EAServer. The only criterion was that they had to be CORBA or “COM” compliant. You can thus run a .Net (C#, VB.Net) components inside EAServer, as long as they are COM-compliant. Imagine that: a server that can connect PB, Java and .Net components.

Sybase EAServer seemed to deliver till ver 5.5. If they left it at that, things would have at least continued status quo. Briefly, before Sybase started leaning towards Microsoft .Net, Sybase was seemingly heading towards the Java world. So, they came up with ver. 6.3 which is essentially a full blown Java EE server. What happened to Server side PowerBuilder? Well, PB was still supported, but now, PB objects were wrapped up and presented as J2EE objects. This caused the PB objects to be suddenly slow (almost twice) and complex.

The idea was good as this technique led to Sybase creating another product called Application Server plugin, which is essentially Java wrapped PB objects that can then be run in any Java containers. Great idea, right? Even before it was adapted, Sybase killed it. Why they didn’t go fully that route, beats me. Sometimes, companies killed products by ignoring it, and sometimes by paying too much attention to it! Either way, we developers pay for it.

Appeon, a company involved with PowerBuilder for over a decade, has been recently asked by SAP to maintain PB code base. They have vowed to revive PowerBuilder, but more as a .Net tool. Appeon being a young company and having a vested interest in PB, may be able to give PB a new life. Hopefully, SAP doesn’t interfere or another company doesn’t buy out PB product to kill it!

Unfortunately, EA server does not share the same fate as PowerBuilder. It has been end of life’d by Sybase (and now SAP) and is no longer supported. With that Powerbuilder is back to the 2-tier product that it used to be. In the times of several open source technologies for the web and mobile, who is going to pay any attention to it? I hope Appeon does something quick!

History repeats (at least for me)

This is the second time I see a good product goes away, for no fault of its own, leaving the customers in a limbo. In the early 2000’s we were trying to migrate out of a great product called Forte into something else? Not everyone could move to Java. Sun made so much money in providing extended support for Forte for the next decade. Now, you can still find information on Forte. History repeats again. Now, in 2016, my client is looking to migrate out of PowerBuilder/EAServer platform to Java or .Net platform.

Forte was such a great n-tier development IDE and was ahead of its time in the 90’s. But its life was short-lived. I remember, when I went for a training class in Forte (in Oakland,CA) the instructor announced “Welcome to Forte. er.. Welcome to Sun”. That was in 1999. Sun bought that to kill the product, as Forte was a precursor to Java J2EE and a direct threat to Java J2EE. Though Java EE was powerful, it wouldn’t stand a chance against Forte in terms of simplicity. I would take Forte any day over Java, .Net or PB.

Sun systematically replaced the information on Forte on the web with their own half-baked product called Forte for Java (I believe this was the precursor to their Netbeans, but don’t quote me on this). It was an insult to any decent programmer. They seemed to have succeeded, but Sun itself was bought over by Oracle who is a database company. History seems to repeat itself. Will Java face the same fate as PB suffered in the hands of another database company, Sybase, is something for us to see!

It’s a shame. It seems corporate America decides not only what toothpaste you use or what it is going to be called, but also what software tool/language is good for you. They ripped up all the railroad tracks in the past, so airplane and automobile industry can thrive. Now, in the 21st century, several cities are scrambling to pull out those tracks to run their light trains and subways! Within 50+ years of inception, the computer software industry is in the same situation. Thank God for open source!!

* Actually Micoroft’s server side scripting, ASP was a precursor to Java’s J2EE technology.
* It’s probably more appropriate to write it as EA Server for Enterprise Application Server.  I write it as a one word to avoid getting hits to EA.com, a gaming site or servers in general.
** For the same reason I write the Sybase GUI based IDE as one word, PowerBuilder. My uppercasing of the words is just a personal preference.

Java: Pass by what?

I was talking to a co-developer last week during one of our lunch time walks(yes, we talk tech during out walks – even if our topic starts with something else, we always end up with tech stuff – once a geek, always a geek! :)). He is a C programmer and we often discuss Java vs C. One thing that came up last week was about Pointers. Having done both C and Java, I started explaining how Java doesn’t really have pointers, but internally it uses pointers. And that though Java has pointers (actually references), we won’t be able to change the address of a pointer like you would in C or C++.

In this context, we touched on parameter passing. I mentioned casually that Java passes the primitives by value and objects by reference (this seems to be common urban myth! Judging by the hits on this topic in Google, I think I am not the only one thinking this). I thought this would make sense, as it would be ridiculous for Java to pass around bulky objects, but instead the pointers (references) to the objects around. This makes sense, as you are able to change the values of attributes inside the object. (This was only possible in C/C++, if you passed the pointer/reference/address to an object/structure). Since we are passing around reference to the object, I said, it’s pass-by-reference when it came to objects, with the condition that “you cannot change those references”. This is where I slipped.

Apparently, those references (addresses) of those objects are passed around “by value” – meaning you cannot change them. And thus the argument that everything is pass-by-value in Java. Definitely got me. As the O’Reilly book describes it, “Java handles Objects and Arrays “by reference”, but when it comes to parameter passing, it is a Pass-by-value language. When a reference type is involved, the value that is passed is the reference!!”. Here is a nice discussion on Stackoverflow about this. There are several nice responses there that explain this in detail, so I won’t waste your time explaining the same thing here.

But Java is not alone in this – here is a nice discussion on the topic in Python. In the author’s words,

Unfortunately, Python is “pass-by-object-reference”, of which it is often said:

“Object references are passed by value.”

Incidentally, C is also a pass-by-value by default, but a programmer can achieve pass-by-reference there by passing pointers or pointer-to-pointers!! See here. It’s splitting hair at this point, but many languages are pass-by-value by default, but offer some mechanism to pass-by-reference. Even PHP employs a similar technique to pass by reference, as discussed here. Great wikipedia offers this on the topic:

Many languages support call-by-reference in some form or another, but comparatively few use it as a default, e.g. Perl. A few languages, such as C++, PHP, Visual Basic .NET, C# and REALbasic, default to call-by-value, but offer special syntax for call-by-reference parameters. C++ additionally offers call-by-reference-to-const.

There we go, the saving grace. At least, my understanding was not totally off, though I needed new terminology!! Moral of the story is “never assume anything” in IT.

Here are some more interesting links on the topic: