Wednesday, 24 August 2011

Diff between struts1 and struts2


Those who don't have knowledge on Struts leave this topic as of now.But those who are all get confused with struts1 and struts2,i hope this definitely will helpful .And there are lot of difference between struts1 and struts2 and each has its own advantages and each developing simultaneously.And don't assume if you know struts2, struts1 is simple and vice versa.

Few diff between struts1 and struts2 are listed below.

Feature
Struts1
Struts2
Action
Action class extends abstract class
(Action Form and Action class are different)
Action class implements Action interface        (Same class can be used  for both Action Form and Action class)
Threading Model
Strtus1 Actions are singleton. So single object is created for all requests for that action. So care to be taken to make the Action resources thread safe and  synchronization
A separate object is created for each request. So no need to worry about the synchronization problem
Servlet Dependency
In Struts1, Actions are dependent on the servlet API because request and response object are passed to the execute method
Request and response object are not explicitly passed to the action execute method. But if want they can use request and response object
Expression Language
Struts 1 integrates with JSTL EL.So struts1 can use EL
Struts2 uses most powerful expression language called OGNL (object Graph Notation Language)
Type Conversion
All the form properties (All the properties in the Action form) are in the form of Strings
OGNL can be used for type conversion
Validation
In Struts1, Validation is done by using validate() method in action form or by using validation.xml and struts_validation.xml.Here chaining of validation on sub objects is not allowed.
Here validation can be done using validate() method or by using XWork validation framework.Using XWork validation chaining of validation is allowed on the sub objects
Control of Action execution
Each module in struts1 has separate request processor(life cycle).So all the actions in that module must share the common lifecycle
In struts2, different life cycles are created for each action using interceptor stacks.

Thanks

Monday, 22 August 2011

SDLC

During our college days, we used to start developing code once the requirement is given.But this is ok when developing application with one or two classes.

But when developing bigger application you may be stuck in the middle of the development.Or for example we have developed one application and delivered it to the customer.If there is a mismatch in the requirement after delivery then the entire effort will lost and developer needs to code it again.

In order to overcome these problem experts come up with an idea called SDLC.

SDLC stands for Sofware Development Life Cycle

This is the step of process to follow for the development of software application

SDLC makes your application more reliable and efficient.

There are lot of SDLC models are available
1) Waterfall Model
2) Iterative Model
3) V-Model
4) Spiral Model
5) Big Bang Model
6) RAD Model,etc.,

Here we  will see about only waterfall model and this is a basic model and all the other models are derived from this model.


1)Requirement Ananlysis and Definition  
  •  It means getting the requirement (functionality and constraints) from the end-user
  •  Requirement Specification Document will be prepared which serves as the input for the next phase of the   model
2)System Design

 Before we start developing we need to identify how the system should look like?

In this phase the requirements from the first phase will be studied and based on that design doc will be prepared using any one of the modelling tools like UML, Rational Rose,State diagram,Sequence diagram,etc,

3) Implementation and unit testing
 
 Here the actual coding will be done.The total application divided into number of unit and each will be developed and tested by the developer.
 Pls note that unit testing will be done by developer not the tester.

4)Integration Testing
 In the previous phase, the total application is divided into small units and are developed and tested.Here those units will be integrated and tested.

 Integration testing simply means whether all the unit coordinate to each other and to check whether the application works as expected.

5)Operation and Maintenance


 This is the last phase of SDLC.In this phase, issues in the deployed application will be resolved.And the maintenace will continue for long so we can say waterfall model will never ends.



 

 

Friday, 19 August 2011

Coding standards in Java

In college days, When we start coding we used to name the variables and functions (in java we will call it as methods) with meaningless name like a,b.And filename as test1,test2,etc, (Because at that time we don't think about the functionality when giving these names and also a,test1 are simpler to type, :P )

In this post will try to tell what is coding standard ? why should  I care about coding standard ? what makes me difficult if i forgot/ missed to follow coding standard ? what are the coding standards in java?

What is coding standard ?
          It simply means we have to follow some standard when we are giving name to varibles,functions and classes,etc.

Why should i follow coding standard ?
          As every programmer knows,Maintenance occupies major part in the Software Development Life Cycle (SDLC)( what is SDLC ??? :S This we will see in the next post ).
         For any IT development,No one will do the entire coding alone.All the projects are developed by many developers and everyone need to get enough knowledge what others did. So it should be necessary to name the state (In C language, we will call it as variablename) , methods (In java, We will not call as function),Classes .etc., (everything the developer name it ) with proper name so that others can understand the code (To some extent) and maintenance made easier.

what makes me difficult if i forgot/ missed to follow coding standard ?
         Statistics says that developement costs 20% and maintenance costs 80% (In terms of both time and money).If you missed/forgot to follow coding standards maintenace cost get increases a lot and sometimes code may be dumped into a dustbin in future.

what are the coding standards in java?

Classname -- should be CamelCase (Make the first letter of each word in Caps) E.g, PersonDetails

Methodname and State ( Don't call this as variable name) -- Should start with small letter and first letter of the following words should be in caps. E.g, userInfo , getUserDetails()

Interface Name -- same rule applies as class name E.g. PersonInterface

For constants - All should be in caps and sepeate two words by underscore ( _ )

package name -- All in small case e.g com.test.application

Coding standards is not only the name given to what we are defining and also format of the code is also more important

1) Do not define variable (state ) in a single line like
         int age,yearsExp;
 Instead define like below
           int age;
           int yearsExp;

2) Initialize the variable when you declare itself like below
           int age =0;
           int yearsExp=0;

3) Use appropriate comments wherever necessary

4)Do not omit curly brace in the if statemen eventhough the block consists of only one statements.

5) Use appropriate blank spaces

     Two blank lines should always be used in the following circumstances:
             • Between sections of a source file
            • Between class and interface definitions
      One blank line should always be used in the following circumstances:
           • Between methods
           • Between the local variables in a method and its first statement

6) A keyword followed by a parenthesis should be separated by a space. Example:
          
                  E.g while (true){
                                    .......
                                }
There are lot more in java.But this is for those who started their coding (For those who already developed some coding may be aware what we discussed so far) in java.


If you have any queries or comments pls let me know.

Thanks.

OCJP6.0 (Not SCJP6.0)

This post is for those who are going /planning to write OCJP 6.0 (Priorly it was SCJP because at that time this certification owned by Sun now its own by Oracle)

I would say Mc_Graw_Hill_-_SCJP_Sun_Certified_Programmer_for_Java_6_Exam_310-065_(2008).pdf by kathy sierra is the best book.This covers all the chapters with clear explanation and examples (Do not skip any chapter because each chapter is important for certificate)

Go through each chapter and take the test (Test is harder than actual OCJP 6.0 test) at the end of each chapter. I can say you can definitely get 70% if you read this book completely.

There are lot of dumps and certification kits available in the market.Whoever wants just certificate you can go with that materials.Whoever wants to improve their knowledge in java go through the book first before going with the dumps.

I think this post will be little bit helpful for those who are going to write OCJP.

See you in my next post.Untill then bye.




Tuesday, 9 August 2011

HelloWorld

Hi

This is the first blog I am going to write for those who are new to java and for those who started their career in java.

Pls share your comments.And if you want to learn anything new in java pls let me know and i will try to upate in my blog to my level best.