|
|
|||||
JAVA for the COBOL ProgrammersIn reality, as the usual 20/80 rule also applies to Java, you only need to know the first 20% of the Java stuff for you to proceed on having a hands-on experience writing Java for maintenance purposes or for simple application. This is what they call in the Java community as POJO or ‘Plain Old Java Object’. The rest of the 80% is meant for the specifics of the trade and is only used by the more robust Java framework architecture. First, let us introduce the concept of object-oriented (OO) because Java is a pure ‘OO’ language alongside other OO programming language as C++, Smalltalk, etc. In an object-oriented paradigm; everything is seen as an object with characteristics and behavior just like any other normal object like animals, persons, cars, banks, movies, video, etc. Unlike in COBOL, you declare a variable in the working storage and access or assign to another variable as a simple data type like a PIC X or PIC 9. However, in Java, to declare and access or assign a value of the variable, you first have to declare or create a new instance of a class which is considered a definition of an object. When you want to access or set the value of that variable, you have to use what they call an ‘Accessor’ or ‘Mutator’ method using get and set methods. Just like any object in this world, say a car; an object or class in Java has internal make up or characteristics which the public does not need to know about. All they care is to be able to ride or use the car and need not know the engine, electrical systems and the body structure of the car. Do not fear the intricacies of Java. Just like any programming languages, it uses the basic four logic constructs namely, procedural or sequential processing, decision making conditions of if-then-else, a typical loop construct of ‘ITEML’ and a ‘goto’ or call to an object’s method, attributes and behavior. The ‘ITEML’ construct of a loop should always be followed in any language or else it will not work. ‘I’ stands for initialize, ‘T’ to test the condition, ‘E’ is to enter the body of the loop, and ‘L’ is to loop back. When you loop back, you have to change the condition of the expression or variable that the condition is tested for. Otherwise, you will get into an infinite loop which a novice programmer will encounter if he or she is not careful. If you forget anyone of this step, your logic will not work. In COBOL this is represented by the Perform-until, Perform-varying-until, perform varying x from 1 by 1. In java, this is done using the while(condition) {} or do {} while (condition). For the COBOL perform varying x from x by x, in Java it is done using the following example: For (x=0; x > 5; x++) {}. If you like to know more about this, wait for the eBook that I will launch which you can download for free. Meanwhile, ask me what your most interest of compelling question is and I will try to answer it as soon as I can possibly can. Next topic or eBook is the other way around, COBOL for the Java programmers. However, in order to properly put the proper perspective and not put it in a simplistic way, it is not enough for you to learn POJO or Java in order to build a simple web application. You have to understand the concept of Http, Servlet, Jsp, Server container, HTML form, elements, Java Script plus some open source technologies. More on this in my eBook. I will build specific examples for a banking application such as creating a savings and checking account, deposit and interest calculation, etc. All banking institutions uses both Java, .Net or package application like SAP or PeopleSoft and COBOL in their applications for their credit and debit accounting system. It is best to learn and adopt Java if you are a COBOL programmer because sooner or later, they will require both skills as a minimum requirement for a programmer analyst in the real enterprise system. Secondly, it is fun to write in Java or any other middleware languages as you have the luxury of trying it in your own PC unlike in COBOL where you need an IBM mainframe be it z/os systems. I do not exclude of course, the PC or UNIX COBOL using Micro-focus COBOL but that is another story. Where does Java and COBOL fit in say in the corporate world. Java and all the other middleware technologies will comprise the connectivity and presentation layer while the data and business layer will be provided primarily by COBOL legacy technologies. Why, because as it is, COBOL is still a language for business although Java is also now encroaching that territory. Maybe for new applications in business, an enterprise application can be provided by the Java enterprise technologies. In Java, there are three class relationships, namely Inheritance, Aggregation and Association. Inheritance in other terms can be called IS-A relationship. For example, the class dog has a IS-A relationship with the super class, animal. The parent class is called a super class and the child class is called a sub-class. If you see a real live enterprise Java code,when you see the term, 'public abstract return data type class name implements an Interface' class, this is a parent class. When you see a declaration of a class that says public class class name extends a super class name, then you are seeing a child or sub-class. The sub-class inherits all the behavior (methods) and characteristics or attributes of a parent class. Aggregation is sometimes referred to as HAS-A relationship with another class. It is a component or a part of another class. Take for example the class of a Car, the component classes or the part of it are the windshield glass, body, wheels, engine, the electrical system classes if we may call these parts as such. They are components of a class called car. How about, association? It is neither an aggregation nor an inheritance but rather a loose or general association between classes. For example a driver or passenger class is associate to a car class in that it uses or drives on it. In Java, there is this concept of Encapsulation and Polymorphism. Since Java was based or derived from the concept of C++ and other OO language, it adopts the same concepts. Encapsulation just means information hiding using terms like private inside the code. In Cobol, we may also call it has encapsulation as a sub-routine does not expose the internal statements that comprise it when another paragraph calls it. It just uses the linkage variables when it tries to execute that sub-routine. The caller program do not need to know the inner working of the called sub-program or sub-routine. Now about Polymorphism. It is a concept whereby the same message when calling a class can be used to have a different method of call in terms of what parameter to use or depending on the receiver of the class. It stems fom the C++ days, where a header declaration or constructors can be declared in various flavor or number of parameters say, a,b or a,b,c. Depending on the parameter class; calling the same class name will elicit a different response. More coming in the eBook.... |
|||||
|
|
|||||
|
|
|||||