Search This Blog

Monday 5 December 2016

What is MVC architecture in J2EE

MVC stands for Model-View-Controller architecture. It promotes loose coupling between components by separating the functionality of displaying and maintaining of the data. It is often used by applications that need the ability to maintain multiple views like HTML, WML, Swing, XML based Web service etc. Multiple views and controllers can interface with the same model. Even new types of views and controllers can interface with a model without forcing a change in the model design.

To summarize the MVC does the following
  • Separation of Model from View components makes it possible to implement several user interfaces that reuse the common core business logic.
  • Duplication of low-level Model code is eliminated across multiple UI implementations.
  • Decoupling of Model and View code results in an improved ability to write unit tests for the core business logic code.
  • Modularity of components allows core logic developers and UI developers to work simultaneously without affecting the other.

  
A model represents the core business logic and state. A model commonly also maps to data the database and will also contain core business logic.
  • Manages the app data and state
  • Not concerned with UI or presentation
  • Often persists somewhere
  • Same model should be reusable, unchanged in different interfaces

  
A view renders the contents of a model. A view accesses the data from the model and adds display logic to present the data. 
  • Present the Model to the user in an appropriate interface
  • Allows user to manipulate data
  • Does not store any data.
  • Easily reusable & configurable to display different data


A controller acts as the glue between a model and a view. A controller translates interactions with the view into actions to be performed by the model. User interactions in a Web application appear as GET and POST HTTP  requests. The actions performed by a model include activating business processes or changing the state of the model. Based on the user interactions and the outcome of the model actions, the controller responds by selecting an appropriate view.
  • Intermediary between Model & View
  • Updates the view when the model changes
  • Updates the model when the user manipulates the view
MVC pattern decouples how data is manipulated from how data is displayed or stored. MVC is a way of developing apps by keeping the data (model) used in the program, and the visual (view) component separate from one another, each interacting only with a controller containing the logic. The view and the model interact only with the controller NEVER with each other.
MVC
MVC

Saturday 3 December 2016

How to enter Current Dates and Times in Excel?

To enter the current date and time , select a cell and in the cell enter =NOW()
To enter the current Date in excel, select a cell and in the cellr =TODAY()

The dates and/or times will be automatically updated when the sheet is updated or reopened.

To insert a fixed date, select a cell, and Press [Ctrl] + [;]
To add a fixed time, Press [Ctrl] + [Shift] +[;]


For above 2 the dates and/or times will NOT be automatically updated when the sheet is updated or reopened.


Excel Dates Tips
Excel Dates




Wednesday 30 November 2016

What is static class loading and dynamic class loading in Java

Static Loading
Classes are statically loaded in Java using new operator.

For Example :
class MyClass {
public static void main(String args[]) {
Car c = new Car();
}
}

A NoClassDefFoundException is thrown if a class is referenced with Java’s new operator but the runtime system cannot find the referenced class.


Dynamic loading is a technique for programmatically invoking the functions of a class loader at run time.
The following specifies how classes are loaded dynamically in Java

Class.forName (String className); //static method which returns a Class
The above static method returns the class object associated with the class name. The string className can be supplied dynamically at run time.
Unlike the static loading, the dynamic loading will decide whether to load the class ClassXXX  or the class ClassYYY at runtime. Once the class is dynamically loaded the following method returns an instance of the loaded class.


class.newInstance (); //A non-static method, which creates an instance of a class
Creates a new instance of the class represented by this Class object. The class is instantiated as if by a new expression with an empty argument list.

. . . read more

Monday 28 November 2016

Packages in Java

Use of packages in Java

Packages in Java helps resolve naming conflicts,  when your project have classes with the same names.
Java Packages helps you organize class files within your project.
If we to put all .java files into a single package,then it become a nightmare to manage all your files as the project gets bigger.
You can create a package with package keyword, which is the first keyword in any Java program
followed by import statements.
The java.lang package is imported implicitly by default and all the other packages must be explicitly imported.
package com.package01.util ;
java.io.BufferedReader;
import java.util.Date;

A package in Java is an encapsulation mechanism that can be used to group related classes, interfaces, and subpackages.
The dot (.) notation is used to uniquely identify package members in the package hierarchy. 
The class java.sql.Date is different from the class java.util.Date. The MyClass class can be easily identified by the name com.mypackage.MyClass. This is called the fully qualified name of the package member. 
It is not surprising that most Java programming environments map the fully qualified name of packages on the underlying (hierarchical) file system.
Defining Packages: A class or interface can indicate that its Java byte code be placed in a particular package, using a package declaration. 
The package statement has the following syntax: 
package <fully qualified package name>;
At most one package declaration can appear in a source file, and it must be the first statement in the unit.
If a package declaration is omitted in a compilation unit, the Java byte code for the declarations in the compilation unit will belong to an unnamed package, which is typically synonymous with the current working directory on the host system.

Using Packages
Given a reference type that is accessible from outside a package, the reference type can be accessed in two ways. 
  • The first form uses the fully qualified name of the type. However, writing long names can become tedious. 
  • The second form uses the import declaration to provide a shorthand notation for specifying the name of the type. 
The import declarations must be the first statement after any package declaration in a source file. The simple form of the import declaration has the following syntax: 
import <fully qualified type name>; or 
import <fully qualified package name>.*;
An import declaration does not recursively import subpackages. 


Thursday 24 November 2016

AngularJS 2 - Whats there ??


Angular 2 is not a version upgrade, but a complete REWRITE.
Features of Angular 2 are as below
Ø  Mobile development – Angular 2 is mobile oriented & better in performance.  The rationale is desktop development is much easier when mobile performance issues are handled first
Ø  Modularity – Various modules are removed from Angular’s core, resulting in better performance. These will find their way into Angular’s ever-growing ecosystem of modules, meaning you’ll be able to pick and choose the parts you need.
Ø  Modern browsers – Suggested to work with modern browsers thus, reducing the need for browser compatibility workarounds
Ø  Angular 2 recommends the use of Microsoft's TypeScript language, which introduces the following improvements:
o   Class-based Object Oriented Programming
o   Static Typing
o   Generics
o   Lambdas
Ø  TypeScript is a superset of ECMAScript 6, and is backwards compatible with ECMAScript 5 (i.e.: JavaScript). Angular 2 also includes the benefits of ECMAScript 6:
o   Iterators
o   For/Of loops
o   Python-style generators
o   Reflection
Ø  Improved dependency injection – Angular 2.0 will address the challenges faced in Angular 1.x , as well as adding missing features such as child injectors and lifetime/scope control.
Ø  Dynamic loading : This will enable the developers to add new directives or controllers on the fly.
Ø  Asynchronous template compilation : The template compilation process will be asynchronous
Ø  Simpler Routing : The router in Angular 2.0 has been reworked to be simple, yet extensible
Ø  Diary.js logging – Angular 2.0 will contain a logging service called diary.js—a super useful feature which measures where time is spent in your application
Ø  Replacing controllers and $scope - $scope will be removed in Angular 2.0 in favor of ES6 classes.