Continuing our series on software development on Linux, today we will cover some concepts about Java.
Java is a high-level language that supports the object-oriented paradigm, born in the mid-1990s in a project funded by Sun Microsystem. The language was conceived in a project codenamed Green, however, the first name of the Java language, given By its creator James Gosling was Oak (in English meaning Oak), named after a tree that overlooked his office window at Sun, but it turned out that there was already a language called Oak.
The Green project resulted in the development of a C and C ++ based language, and its product could no longer be called Oak due to the existence of another language bearing that name. One fine afternoon, a Sun team visited a local coffee shop. which served a coffee imported from a city called Java, so the name was suggested, took and to this day the Java logo is a cup of coffee and the name Java.
Java was formally announced by Sun in 1995 at an important conference. So the Java language has generated immediate interest in the business community because of its ease in providing an environment where the end product could be interactive and dynamic on the web for large application and mobile application development. Java stick for all work!
Today, Java is owned by Oracle.
The key words of this language are: reusability, polyiformism, inheritance, encapsulation, portability. Java uses the concept Write once, run anywhere! (Write once, run anywhere!)
With Java an object-oriented language, code is usually divided into files. ClassesIn Object Oriented Programming, classes are structures that represent the characteristics of an object in an abstract form, and can have attributes and methods, which define the behavior of the object.
Good programming practices define that the ideal that each class should be responsible for its own function or functions in a given context (High cohesion), and as little as possible dependent on other classes (Low coupling), ie have their own responsibilities. well defined.
One of the best ways to design Java programs using UML diagrams (class diagrams, use-case diagrams, interaction diagrams, etc.) that help identify responsibilities, class boundaries, attributes, relationships, etc. Diagrams Classes act as baselines in a project, and are part of the project documentation.
See in UML what a class with attributes and methods looks like.
And how is the same class written in Java: The methods, as you can see, perform tasks and return (or not) information. There are also the Constructor methods, which, as the name implies, construct objects.
Advantages and disadvantages of Java
Of the many advantages that Java has over C, the most notable is the extensive set of libraries available that contain hundreds of functions ready to use, simply importing the classes that contain such methods. It was a language that has syntax much like the C / C ++ language. Making a C-linked list complicated for you? In simple Java, because aside from the logical part of programming, there are hundreds of functions ready, such as Lists, Stacks, Trees, etc. You can encapsulate the attributes of classes or make them accessible to other classes, as well as having access to public methods of other classes. It is possible to check the correctness of the code while it is still being entered through IDEs, which are programs for building programs (unlike C, which only knows the result at the time of compiling or executing the program).
Another great advantage is the ease of porting your application to any system, since Java applications run on a Java Virtual Machine JVM you don't have to worry about rewriting half of the code as it is designed to run inside a Java machine itself.
Code reuse in Java is much more visible than in procedural languages, because if you follow good programming practice conventions, your code tends to be modularized, which also contributes to code maintenance.
Running on a virtual machine, Java applications tend to lose a little faster than programs written in other languages that generate files through compilation (the executable files), because Java does not generate the executables, but bytecode, thus, Java programs are not executed, but interpreted.
Another disadvantage of Java is the ease of discovering bytecode content through reverse engineering, which can lead to code discovery related problems and consequent loss of intellectual property, however there are solutions that make the code blurry.
Code reuse in Java is much simpler than in procedural languages because, using the concept of interfaces, you can create modular applications that engage across interfaces.