Tuesday, 22 December 2015

J2EE Architecture




Two-Tier Architecture:

The two-tier is based on Client Server architecture. The two-tier architecture is like client server application. The direct communication takes place between client and server. There is no intermediate between client and server. Because of tight coupling a 2 tiered application will run faster.



The Two-tier architecture is divided into two parts:
1) Client Application (Client Tier)
2) Database (Data Tier)
On client application side the code is written for saving the data in the SQL server database. Client sends the request to server and it process the request & send back with data. The main problem of two tier architecture is the server cannot respond multiple request same time, as a result it cause a data integrity issue.
Advantages:
  1. Easy to maintain and modification is bit easy
  2. Communication is faster
Disadvantages:
  1. In two tier architecture application performance will be degrade upon increasing the users.
  2. Cost-ineffective
- See more at: http://www.softwaretestingclass.com/what-is-difference-between-two-tier-and-three-tier-architecture/#sthash.Px770obL.dpuf



The Two-tier architecture is divided into two parts:

  1. Client Application (Client Tier)
  2. Database (Data Tier)

On client application side the code is written for saving the data in the SQL server database. Client sends the request to server and it process the request & send back with data. The main problem of two tier architecture is the server cannot respond multiple request same time, as a result it cause a data integrity issue.



Example:  

   Let’s take a look of real life example of Railway Reservation two-tier architecture:

   Let’s consider that first Person is making Railway Reservation for Mumbai to Delhi by Mumbai Express at Counter No. 1 and at same time second Person is also try to make Railway reservation of Mumbai to Delhi from Counter No. 2

   If staff from Counter No. 1 is searching for availability into system & at the same staff from Counter No. 2 is also looking for availability of ticket for same day then in this case there is might be good change of confusion and chaos occurs. There might be chance of lock the Railway reservation that reserves the first.

   But reservations can be making anywhere from the India, then how it is handled?

   So here if there is difference of micro seconds for making reservation by staff from Counter No. 1 & 2 then second request is added into queue. So in this case the Staff is entering data to Client Application and reservation request is sent to the database. The database sends back the information/data to the client.

   In this application the Staff user is an end user who is using Railway reservation application software. He gives inputs to the application software and it sends requests to Server. So here both Database and Server are incorporated with each other, so this technology is called as "Client-Server Technology".


Advantages:

  1.     Easy to maintain and modification is bit easy
  2.     Communication is faster

Disadvantages:

  1.     In two tier architecture application performance will be degrade upon increasing the users.
  2.     Cost-ineffective

Three-Tier Architecture:

   Three-tier architecture typically comprise a presentation tier, a business or data access tier, and a data tier. Three layers in the three tier architecture are as follows:

  1. Client layer
  2. Business layer
  3. Data layer










 1. Client layer: 

 

   It is also called as Presentation layer which contains UI part of our application. This layer is used for the design purpose where data is presented to the user or input is taken from the user. For example, designing registration form which contains text box, label, button etc.

 2. Business layer:


    In this layer all business logic written like validation of data, calculations, data insertion etc. This acts as a interface between Client layer and Data Access Layer. This layer is also called the intermediary layer helps to make communication faster between client and data layer.

 3. Data layer:

   In this layer actual database is comes in the picture. Data Access Layer contains methods to connect with database and to perform insert, update, delete, get data from database based on our input data.


Client tier represents Web browser, a Java or other application, Applet, WAP phone etc. The client tier makes requests to the Web server who will be serving the request by either returning static content if it is present in the Web server or forwards the request to either Servlet or JSP in the application server for either static or dynamic content.

Presentation tier encapsulates the presentation logic required to serve clients. A Servlet or JSP in the presentation tier intercepts client requests, manages logons, sessions, accesses the business services, and finally constructs a response, which gets delivered to client.

Business tier provides the business services. This tier contains the business logic and the business data. All the business logic is centralized into this tier as opposed to 2-tier systems where the business logic is scattered between the front end and the backend. The benefit of having a centralized business tier is that same business logic can support different types of clients like browser, WAP, other stand-alone applications etc.

Integration tier is responsible for communicating with external resources such as databases, legacy systems, ERP systems, messaging systems like MQSeries etc. The components in this tier use JDBC, JMS, J2EE Connector Architecture (JCA) and some proprietary middleware to access the resource tier.

Resource tier is the external resource such as a database, ERP system, Mainframe system etc responsible for storing the data. This tier is also known as Data Tier or EIS (Enterprise Information System) Tier.




Advantages:

  1. High performance, lightweight persistent objects
  2. Scalability More hardware can be added and allows clustering (i.e. Each tier can scale horizontally).
  3. Manageability Each tier can be monitored, tuned and upgraded independently and different people can have clearly defined responsibilities.
  4. Maintainability – Changes and upgrades can be performed without affecting other components.
  5. Performance – Because the Presentation tier can cache requests, network utilization is minimized, and the load is reduced on the Application and Data tiers.
  6. Improved Security – Client is not direct access to database.
  7. Extensibility – Additional features can be easily added.
  8. High degree of flexibility in deployment platform and configuration
  9. Better Re-use
  10. Improve Data Integrity
  11. Easy to maintain and modification is bit easy, won’t affect other modules
  12. In three tier architecture application performance is good.
Disadvantages:
  1. Increase Complexity/Effort  


 


   
         


This is the common Question asked in the Interview. Hope this article helped you understanding Two-Tier and Three-Tier Architecture with example.
Thanks !!
 




Two-Tier Architecture:

The two-tier is based on Client Server architecture. The two-tier architecture is like client server application. The direct communication takes place between client and server. There is no intermediate between client and server. Because of tight coupling a 2 tiered application will run faster.
- See more at: http://www.softwaretestingclass.com/what-is-difference-between-two-tier-and-three-tier-architecture/#sthash.Px770obL.dpuf

Two-Tier Architecture:

The two-tier is based on Client Server architecture. The two-tier architecture is like client server application. The direct communication takes place between client and server. There is no intermediate between client and server. Because of tight coupling a 2 tiered application will run faster.
- See more at: http://www.softwaretestingclass.com/what-is-difference-between-two-tier-and-three-tier-architecture/#sthash.Px770obL.dpuf

Two-Tier Architecture:

The two-tier is based on Client Server architecture. The two-tier architecture is like client server application. The direct communication takes place between client and server. There is no intermediate between client and server. Because of tight coupling a 2 tiered application will run faster.
- See more at: http://www.softwaretestingclass.com/what-is-difference-between-two-tier-and-three-tier-architecture/#sthash.Px770obL.dpuf

Thursday, 3 December 2015

What Is OpenGL?


OpenGL

OpenGL is a software interface to graphics hardware. This interface consists of about 150 distinct commands that you use to specify the objects and operations needed to produce interactive three-dimensional applications.  

In other words, OpenGL is a low-level graphics library specification. It makes available to the programmer a small set of geomteric primitives - points, lines, polygons, images, and bitmaps.  

Brief Overview of OpenGL

   OpenGL is a software interface that allows the programmer to create 2D and 3D graphics images. OpenGL is both a standard API and the implementation of that API. You can call the functions that compriseOpenGL from a program you write and expect to see the same results no matter where your program is running.
 

   OpenGL is independent of the hardware, operating, and windowing systems in use. The fact that it is windowing-system independent, makes it portable. OpenGL program must interface with the windowing system of the platform where the graphics are to be displayed. Therefore, a number of windowing toolkits have been developed for use with OpenGL.

   OpenGL functions is a client/server environment. That is, the application program producing the graphics may run on a machine other than the one on which the graphics are displayed.The server part of OpenGL, which runs on the workstation where the graphics are displayed, can access whatever physical graphics device or frame buffer is available on that machine.

   OpenGL's rendering commands, however are "primitive". You can tell the program to draw points, lines, and polygons, and you have to build more complex entities upon these. There are no special-purpose functions that you can call to create graphs, contour plots, maps, or any of the other elements we are used to getting from "old standby programs”. With OpenGL, you have to build these
things up yourself.


    With OpenGL any commands that you execute are executed immediately. That is, when you tell the program to draw something, it does it right away. You also have the option of putting commands into display lists. A display list is a noteditable list of OpenGL commands stored for later execution. You can execute the same display list more than once. For example, you can use display lists to redraw the graphics whenever the user resizes the window. You can use a display  list to draw the same shape more than once if it repeats as an element of the picture.


   OpenGL is hardware-independent. Many different vendors have written implementations that run on different hardware. These implementations are all written to the same OpenGL standard and are required to pass strict conformance tests. Vendors with licenses include SGI, AT&T, DEC, Evans & Sutherland, Hitachi, IBM, Intel, Intergraph, Kendall Square Research, Kubota Pacific, Microsoft, NEC, and RasterOps. The RS/6000 version comes with X and Motif extensions. However X is not required to run OpenGL since OpenGL also runs with other windowing systems.

    Modern computers have dedicated GPU (Graphics Processing Unit) with its own memory to speed up graphics rendering. OpenGL is the software interface to graphics hardware. In other words, OpenGL graphic rendering commands issued by your applications could be directed to the graphic hardware and accelerated.

We use 3 sets of libraries in our OpenGL programs:
  1. Core OpenGL (GL): consists of hundreds of commands, which begin with a prefix "gl" (e.g., glColor, glVertex, glTranslate, glRotate). The Core OpenGL models an object via a set of geometric primitives such as point, line and polygon.
  2. OpenGL Utility Library (GLU): built on-top of the core OpenGL to provide important utilities (such as setting camera view and projection) and more building models (such as qradric surfaces and polygon tessellation). GLU commands start with a prefix "glu" (e.g., gluLookAt, gluPerspective).
  3. OpenGL Utilities Toolkit (GLUT): OpenGL is designed to be independent of the windowing system or operating system. GLUT is needed to interact with the Operating System (such as creating a window, handling key and mouse inputs); it also provides more building models (such as sphere and torus). GLUT commands start with a prefix of "glut" (e.g., glutCreatewindow, glutMouseFunc). GLUT is platform independent, which is built on top of platform-specific OpenGL extension such as GLX for X Window System, WGL for Microsoft Window, and AGL, CGL or Cocoa for Mac OS. 
  4. Quoting from the opengl.org: "GLUT is designed for constructing small to medium sized OpenGL programs. While GLUT is well-suited to learning OpenGL and developing simple OpenGL applications, GLUT is not a full-featured toolkit so large applications requiring sophisticated user interfaces are better off using native window system toolkits. GLUT is simple, easy, and small."
  5. OpenGL Extension Wrangler Library (GLEW): "GLEW is a cross-platform open-source C/C++ extension loading library. GLEW provides efficient run-time mechanisms for determining which OpenGL extensions are supported on the target platform." Source and pre-build binary available at http://glew.sourceforge.net/. A standalone utility called "glewinfo.exe" (under the "bin" directory) can be used to produce the list of OpenGL functions supported by your graphics system.
  6. Others.

Features in OpenGL

3D Transformations
- Rotations, scaling, translation, perspective
• Colour models
- Values: R, G, B, alpha.
•Lighting
- Flat shading, Gouraud shading, Phong
shading
•Rendering
-Texture mapping
•Modeling
- non-uniform rational B-spline (NURB)
curves, surfaces


• Others
- atmospheric fog, alpha blending,
motion blur

The Sierpinski Traingle or Gasket

The Sierpinski Triangle is also called Sierpinski Gasket and Sierpinski Sieve.

A Sierpinski triangle or gasket can be constructed by recursively extracting triangular forms from within an original triangle. At each stage of recursion, three times as many triangles are extracted, each being a quarter of the area of those used in previous stage. This leads to another series, which can be summed to show that the total area extracted is equal to the area of the original triangle-no area remains, yet a set of points remains.
 This definition would be circular, if we did not have a base case at which to stop recursion. We shall say, therefore, that a very small Sierpinski gasket is just a very small triangle.

To make a large Sierpinski gasket:

==>Make a small Sierpinski gasket at one of the corners of the outer triangle.
==>Then move to another corner of the outer triangle and make another small Sierpinski gasket.
==>Then move to another corner of the outer triangle and make another small Sierpinski gasket.
==>Then return the turtle to the initial position and heading.

Program for generating a Sierpinski gasket:
 pi=22/7
SIERPINSKI(Level)
  IF Level=0, Poly(1,2*pi/3)
  OTHERWISE
    REPEAT 3 TIMES
        RESIZE 1/2
        SIERPINSKI(Level-1)
        RESIZE 2
        MOVE 1
        TURN 2*pi/3

Let N_n be the number of black triangles after iteration n, L_n the length of a side of a triangle, and A_n the fractional area which is black after the nth iteration. Then

N_n=3^n
L_n=(1/2)^n=2^(-n)
A_n=L_n^2N_n=(3/4)^n.