Tags

Showing posts with label Best Practices. Show all posts
Showing posts with label Best Practices. Show all posts

Feb 22, 2012

Standard Naming Conventions in Java

There are a set of standard conventions which should be followed.


Class Naming
1) The class and interface names should start with Capital letters. A few examples of good class names is:
Car
Customer

Package Naming
2) The naming convention for package names says that they should start from the reverse of the domain name of your company.
com.companyname.productName.util.StringUtil
com.mycompany.productName.controller.HomeeController

Do note that all characters in the package names are in small letters.

Variables Naming
3) The variables should have a naming convention of
a) The first letter should be small letter
b) Every word in the variable names should start with a capital letter

Method Naming
4) The method names Starting with small letter and every other word staring with Capital letter.e.g.
checkUser()
addUser()

Constants Naming
5) The constants which are declared as public static final in Java should have all letters as capital and the words within the constant should be separated by _(underscore) character as:
DATE_PATTERN

Note: Same naming conventions should be used across the Java application.

Feb 1, 2012

Know your strengths and weaknesses-Software careers

I have listed down  "checklist" here that covers various areas of knowledge in the IT industry.


software development consists of these skill areas:
  • Programming
  • Database management
  • Analysis ,Design
  • Testing
  • Communication
  • Development processes
 
Programming
Some things you should understand about programming:
  • Understanding one or more languages
  • Understanding language libraries/frameworks (Spring,Hibernate, JSF, Struts)
  • Understanding tools (Ant, maven, hudson)
  • Understanding IDE's (Eclipse, NetBeans)
  • HTML, CSS, JavaScript, DHTML, AJAX 

Database management
Knowledge areas in database management:
  • Database design
  • Awareness of Oracle, MySQL, Postgressql

Business analysis
Things you should understand as a business analyst:
  • Use cases
  • UML
  • Database design
  • Data flows
  • Cost estimating
    • Function Point Analysis (FPA)
    • Cocomo, or something like it
  • Roles in the analysis process
  • How to write use cases and requirements specifications
Testing
Knowledge areas in the field of software quality:
  • Testing (unit, regression, code coverage, GUI testing)
 
Communication
Your strengths and weaknesses as a communicator:
  • Technical writing
  • Verbal communication
  • Ability to lead a team
  • Communication as a manager
  • Communication as an employee

Software development processes
Your knowledge of software development practices:
  • Scrum
  •  "agile"

Software development best practices


  • Do use some form of repeatable agile process for building software applications. Almost any repeatable process is better than none at all. (If you need one I recommend Scrum.)
  • Do use a source code control system (svn, cvs, or commercial products).
  • Do use a formal bug-tracking system.
  • Do have some form of source code peer review.
  • Do have coding standards, preferably a consistent set of standards across all applications.
  • Do have a repeatable, automated build system for your applications.
  • Do have an automated testing system (regression tests) for your applications.
  • Do have some mix of experienced developers (who are good and experts in these practices) and relatively new developers.
  • Always keep your applications in a running, demonstrable state.

Jan 24, 2012

Session handling tips for web application


1) Specify default session timeout interval in web.xml

2) Execute request.getSession.invalidate() when user clicks logout button

3) Start a Javascript timer so that user can be alerted about session being going to expire and he should save his work before session actually expires

4) Capture browser window/tab closing javascript event so that session can be invalidated before user closes the application window/tab and opens a new browser window/tab to access the web application.

5) Maintain a list of users who are currently logged in either by storing a list in database and updating it as and when users log in or logout OR Maintain a Hashmap in application context and update it with user info of currently logged in users. The DB and HashMap can be updated by using Session Binding Listener API provided by JEE.

6) Use proper session handling mechanism by always encoding URL so that jsessionid can be used when cookies are disabled by a browser

7) Whenever user clicks a link, always check if his session is valid by using isValid function and if the session is invalid or expired, forward him to login/index page rather than processing his request.

8) If the session has expired then immediately forward the user to login page instead of showing him current page
9) If you are using AJAX calls then whole page refresh may not happen in your application but make sure that session is valid if Ajax calls are being sent.

10) Choose a proper default session timeout depending upon the kind of application. A banking application will have session timeout of the order of 2 minutes and internal portal should have session timeout of the order of 15 minutes

Jan 22, 2012

Good Practices for Rich Web Applications


Use jQuery
jQuery is the best thing that has happened to Javascript. The library is elegant, powerful and has exactly the right level of abstraction for working with the DOM.
Learn it and use it. Good resources are: the jQuery API,

Learn Javascript
Javascript is the programming language of the web. Learn it! Javascript is different from most other programming languages. 
If you want to learn Javascript you should get the following books, The Little Schemer, The Seasoned Schemer, Javascript, the Good Parts, and possibly High Performance Javascript
 
Learn CSS 


Many programmers think that CSS is the language of designers and not programmers. This is not the case at all. If you are lucky enough to have a designer on your team (most people don't), CSS is the language with which you communicate. It is the interface between designers and programmers and as a programmer you should know it better than the designers.
It will also be up to you to keep the HTML clean, and a good way to do this is to use semantic HTML, combined with CSS. You have no idea what the designers can come up with.

Decide how "Rich" your application should be


How rich should your application be? The scale varies from no Javascript to only Javascript, but you will probably want to land somewhere in between. Here are a few suggestions.
  • No Javascript, everything is server generated.
  • Slightly enhanced pages, simple validations, but no Ajax.
  • Ajax enhanced pages, but every page still reloads frequently.
  • Single page per area, entire area is handled by Javascript.
  • Only Javascript, Ajax interaction with the server
  • Only Javascript, no interaction with the server

    Html
    HTML is code! Divide your pages into partials by responsibilities. It allows you to keep your pages DRY and readable. The Single Responsibility Principle applies to HTML too.
    Make sure you keep the Javascript with the code that it manipulates. If you, for example, have a calendar partial that uses jQuery DatePicker, you have to make sure that the partial includes all the necessary Javascript to configure the calendar. Don't keep Javascript code in the page away from the partial. Things that change together should be together.
    Use clone()
    Separating the HTML and the Javascript goes both ways. Don't generate HTML code in Javascript. It doesn't matter that it is super simple to do it using jQuery.html(). Keep them separate, use jQuery.clone() instead.

    The point of this is, again, to keep the HTML separate from the Javascript.
    Conclusion :
              We have to realize that we are responsible for the entire application, not just the business logic, but  the HTML and CSS too