Tuesday, October 2, 2018

JTD-DesignerSeries-9-JavaSkills-101


Let's set some context
I have usually worked in an integration layer and used DSL, but I must agree that direct manipulation of C pointers are extremely difficult and one must understand data structures & algorithms to play with it. However as engineers we all study about it search & sorting on maps & lists.

Languages like C++ & Java support Object Oriented Design with objects modeling provides another layer of abstraction to database relationships. Java popularized Object Oriented Design by supporting platform compatibility with a intermediary layer of Interpreters.

Frameworks like Java EE & Spring have been developed by Java community to support development of complex enterprise applications.

Preliminary Java

a) A developer can use 8 primitive types [byte, short, int, long, float, double, char, boolean] to create variables and 9 one is String which is treated as primitive data type but is really a class.

b) Java is an object oriented language and allows designers to model the data layer with real world objects as classes by applying principles of Abstraction, Encapsulation, Inheritance & Polymorphism.

c) OOPs support Abstraction by blueprinting with class definition & creating objects as instances of class in method implementations. Encapsulation is is managed by defining state with private fields along with getters & setters & behaviors with public methods.

d) Inheritance is a OOPs principle which allows you to define common state & behaviors in base class [Generalization] which are accessible automatically in derived class [Specialization] created by extending from base class.

e) Polymorphism is another OOPs concept which helps Java runtime to dynamically invoke a method implementation depending upon the subclass reference assigned to the base class variable.


f) Arrays allocate memory space for storing fixed number of same data type and each element can be accessed by an index. ArrayList are dynamic arrays which allocates as the elements are added to the ordered list.

g) Java use interfaces to standardize the behaviors and classes can implement multiple interfaces. Abstract classes not only standardize common base behavior which can be implemented in derived but also provides standard implementation of base methods.



h) Java Collection Framework simplifies working on complex functions of searching, sorting by providing interfaces [List, Set, Queue] and classes [ArrayList, LinkedList, Stack] and Generics allows compiler to check collection objects with declared parameterized types.


j) Map Interface, though not really defined in Collection hierarchy provides a container of objects mapped with unique key and uses get & put method to add & retrieve key value pairs from collection classes.

h) Exception happens when something goes wrong in the normal processing. Java compiler is responsible for marking checked exceptions. Developers can then either use throw to delegate exception handling to calling program, or use try / catch for generic handling, or try with multiple catches for specific handling.


i) Unchecked exceptions are direct subclass of Runtime exceptions and it is developer responsibility to handle them as unchecked exceptions like Nullpointer, ArrayIndexOutOfBound are not checked by compiler.



Preliminary Spring

a) Most scalable Java applications are designed using separation of concern design principle & implemented with layered architecture [Data Access Layer--->Service Layer---->Presentation Layer].


b) Designers also use loose coupling by developing with Interfaces & use factory pattern to initialize the dependent objects, and use proxy implementation to enable cross cutting concerns like cacheing, transactions, logging.

c) Rod Johnson developed Spring framework by implementing a BeanFactory which allows developers to manage dependencies & cross cutting concerns with xml configuration & annotations. Factory relies on pattern like Inversion of Control which uses Reflection API to manage a bean lifecycle.


d) An important term in spring application is bean configuration file, which lists the POJO that implement the application features as well as their dependencies. Usually environment specific properties like database urls, tuning parameters, authentication are externalized in properties file rather than hard coded in bean definition.

e) Beans in configuration file are usually assigned an ID & bean dependencies are managed in different ways, either constructor or setters. Spring modules also support Bean Inheritance & Spring Expression Language to support reusability & dynamic assignments.

No comments:

Post a Comment