Problem Solving Approach: Production and Non Prod behavior is different

In this article:

  • You will able to answer how to debug issue when production code behavior is not as expected as in non-production.
  • You will able to learn some basic causes due to that same code base behave differently in production and non-production.
  • You will get idea how to approach for this kind of scenario.
  • This will help to resolve production issues in quick time to avoid SLA.

newidea

Scenario:

Some functionality which is working as expected in non-production environment, but does not work in production.

The background:

Some time we come to those situations when production code behavior on some functionality (which was part of current release) is not as expected. QA already gave sign off, UAT also performed their testing, RTP team followed proper migration document. But still that functionality does not work.  What got wrong? In production we can’t enable debug info to check everything. Then how to resolve the issue? How to make production code working as expected? Following may be the solution which are truly based on real time experiences.

Explore this:

Below are the sequential steps we usually follow. At any point of time when gap found stop the analysis and correct the migration document, follow the rest steps to make sure there is no more gap and go for release.

1.       Verify WAR file version

  • Check the WAR file version in production and non-prod where sign off was given.
  • Check the code base. If it is J2EE, verify if the java class is up-to-date in version control system.
  • Check if the above changes are in WAR file.

2.       Missing Property file/Database changes

  • Based on the project management, check the tracking document which contains all the changes required to implement particular changes.
  •  It may be design document or kind of solution approach document.

3.       Enable same level log in Non-prod

  • Based on observation found, sometime few developers write some part of code in debug/info logger level by mistake. And that may also cause this situation where same code base is working fine on non-prod but not in production.
  • To identify this, set the logger level to same level as in Production.
  • Usually Error level is enabled in production and in non-prod, it is debug.
  • Read this article for more info.

4.       Hit Node URL-

  • Production code base usually deployed on more than one server or node (may be same server with different JVM as well). So rather hitting direct URL (like google.com), hit node specific URL (like nodeid:8080).
  • If any node URL gives desired result that means there is some problem with server and/or deployment process. May be temp directory did not get cleared in case of web logic server. Clear the temp directory and restart the application.
  • Check whether startup parameter is in sync.

5.       Stop external scripting on specific page

  • To get the user experience and/or to make changes in site look and feel using campaigns, companies are using external scripts like Adobe TestNTarget etc.
  • These script runs on our application core data returned. Hence these can be also responsible for the behavior of production code base.
  • To make sure if external scripts are creating problem, just stop on specific pages where desired functionality is not in working in production.

What Next:

  • Just apply above tips; these are based on personal experiences. May be you came across different scenario. Then please share it.
  • In next article planning to share real-time tools to resolve production issue.

Till then Happy Reading,

Nirbhaya Bhava!!

Error when Starting Eclipse: 64 Bit on Windows 7- 64 Bit

Problem: Error occurred while starting eclipse 64 Bit on Windows 64 bit.

Errors:

  1.  Failed to load the JNI shared library “C:/{some library}/bin/client/jvm.dll”`.
  2.  Java was started but returned exit code 13

Image

Quick Solution:

  1. Download correct JDK and eclipse for windows 64 bit.
  2. Make sure all installation goes in “Program Files”.
  3. Correct the PATH variable for Java.
  4. Update the eclipse.ini for following value-

    -vm
    {path_to_64bit_java}\bin\javaw.exe

Explanation and Points to Remember:

  1. Eclipse looks for working and compatible java, which is specified above in step 4.
  2. Remember, irrespective of OS bits, eclipse and JDK must be of same bits only. Obviously OS bit should be higher or equal to JDK and eclipse as well. For example: You can not set up 64 bit eclipse on 64 bit OS using 32 bit JDK.
  3. Download JDK6 (or the JDK version on which you want to run) from JDK download. Select top most hyper link- at this time it is Java SE Development Kit 6u45. Accept the license agreement click to download 64 bit JDK as marked in red—Image
  4.  As well concern to the folder name convention, X86 is representation for 32 bit windows.
  5. While installing JDK make sure default installation directory is “Program Files” rather “Program Files (x86)”.  And if it is not you have downloaded 32 bit JDK.

Hope this solves the problem. If not just let me know your problem through comments or mail.

Happy Reading.

Nirbhaya Bhava!!

Design Principle vs.Design Pattern: Describing OOP elements

In This article:

  • You will able to learn basic elements of a Object Oriented Design.
  • You will able differentiate design pattern and design principle.
  • At the end you will get some useful links and books to read.
  • Finally you will bag at least one more interview question and their clarification.

The Background:

  • Why these definitions and descriptions needed-

Most of the time developers have to work on enhancements based projects, where they have to understand the code which is already written by some other people.  The understanding of code base takes time based on project architecture. Then during analysis of code a query always tickles, in one corner of the mind of the developers, “why-this-extra-class-needed” or some other similar lines.  This type of queries came in mind when one is not aware of the paradigm used and patterns. There are several books and sites you will find on this but here you will get the base of a good design. This is not so fancy, but if you will burn it in your mind- your understanding will be much deeper.

Explore this:

Elements of OOP

Elements of OOP

OOP—

  • Stands for Object Oriented Programming.
  • Object-oriented programming (OOP) is a programming paradigm that represents concepts as “objects” that have data fields (attributes that describe the object) and associated procedures known as methods. Objects, which are instances of classes, are used to interact with one another to design applications and computer programs.
  • OO basics are-
  1. Abstraction
  2. Encapsulation
  3. Polymorphism
  4. Inheritance
  • Please avoid writing it as OOPs or OOPS. Please see this article.

OO Design Principle—

  • OO principle is a set of guidelines that ensures OOP concept.
  • Based on the OOP concept, this defines ways to design better way, a better design.
  • The basic OO design principle is SOLID.
  • SOLID is known as-
  1. Single Responsibility Principle

         A class should have only one reason to change.

     2. Open Close Principle

        Software entities like classes, modules and functions should be open for extension but closed for modifications.

     3. Liskov’s Substitution Principle

         Derived types must be completely substitutable for their base types.

     4. Interface Segregation Principle

         Clients should not be forced to depend upon interfaces that they don’t use.

     5. Dependency Inversion Principle

        High-level modules should not depend on low-level modules. Both should depend on abstractions.

        Abstractions should not depend on details. Details should depend on abstractions.

OO Design Pattern-

  • A Design pattern provides a general solution to a design problem.
  • Please note “design pattern” can be applied to noon object oriented word too. So A OO design patterns (OODPs) are those which provide a general solution to object oriented design based OO principle.
  • Design patterns are discovered, not invented.
  • There are several ways to define OODPs and most famous one is BSC [Behavioral Structural Creational].
  • Understanding BSC-
    • To create objects one need of classes. This is start of design.
    • A class must have well defined attributes. The design solution made to compose class structure is known as Structural patterns.
    • Now you have class, to create objects one needs to create object(s). The design solution made to instantiate a class or classes is known as Creational patterns.
    • Once object instantiated, think of objects interactions. So those design solutions which are concerned with object interactions are known as Behavioral patterns.

Best Practices-

  • Best practices can be used in OODPs to avoid business errors or run time errors.
  • There can be multiple techniques to do some tasks but to do in efficient and effective way can be said Best practices.
  • Example-

In java there are multiple ways to iterate a map, but if you want to get just list of keys do not use iterator or entryset, but use keyset.

Type safety can be another example of best practices.

Summary-

So by understanding above definitions we can conclude that design patterns uses to implement an OO design problem. These patterns use OO Principles and Best practices to ensure OO paradigm with highly scalable and efficient design.

What Next:

Just start with basics principles and design. If you don’t know which way to go, then follow the links and books given in useful link. Don’t just dive in technologies; first grasp the basics of all these technologies.

Useful Link:

  • Notes on basic design principle and pattern-
  1. http://www.oodesign.com/
  2. http://hillside.net/
  • Some more design principle can be found at this site
  • The best book to start with design pattern is-
  1. Head First Design Patterns.
  2. Amazon Link
  3. Flipkart link

Print this article:

Happy Reading,

Nirbhaya Bhava!!!

OOPS vs. OOP – What “s” stands for?

In this article:

  • Explores the meaning of OOP and OOPS.
  • At the end of this article you will be able to differentiate OOPS and OOP.
  • This may be part of your interview question on Design pattern.

The background:

This is most common misunderstood short form related to object oriented paradigm. If somebody asks which paradigm you use or on which paradigm Java works. We generally answer it as OOPS or OOPs. And here we do mistake. Also this came as a conundrum when interviewer asked to my buddy what “s” stands for.

Explore This:

First grab the full form, then I will explain it further—

Differentiate OOPS and OOP

Differentiate OOPS and OOP

Oops!! Yes. This is the sound you must whisper. Well OOP you already know, following is the definition of OOPS (actually oops – not in CAPS)

Definition of oops

Yes this is official definition of oops.

What Next:

So next time, to break the awkward silence between you and another developer, you have got a nice    topic to break the ice.

Printable Doc:

OOPS vs OOP

Happy Readings,

Nirbhaya Bhava!!!

Spring – The Context: ApplicationContext vs. BeanFactory

This article describes the difference between ApplicationContext and BeanFactory in Spring framework.

- BeanFactory is recommended for lightweight framework like — Mobile and Applet.

- BeanFactory is core component of Spring IoC container.

- As ApplicationContext extends BeanFactory so ApplicationContext is more powerful than BeanFactory (like AOP, Internationalization etc.)

con1

-          You can configure your beans in the Spring IoC container through XML files, properties files, annotations, or even APIs.

-          Container reads these beans by using BeanFactory (or ApplicationContext)

-          Let’s say you define the beans in XML file, say applicationcontext.xml.

-          Now BeanFactory has to read applicationcontext.xml to load the beans in container.

-          For this BeanFactory needs an interface that can provide the xml file o BeanFactory.

-          This interface called resource object.

-          Sample:

context3

-          In case of ApplicationContext, the resource object is implemented internally, so as use We don’t  need of resource object.

context4

cntext2

Hope this will clarify the basic difference.

Happy Reading,

Nirbhaya Bhava!!

Spring Series: Spring JDBC – Review/Interview Questions

Image

Following is the list of useful questions and hints for recalling support provided by spring for JDBC. Please note, these basically cover Spring 2.5 version, few of them may applicable to higher version. –

  1. What are the core packages provided by Spring to work with JDBC?
  2. What is the difference between SimpleJDBCTemplate and NamedParamJDBCTemplate?
  3. How one can translate the exception using Spring JDBC classes?
  4. What are the essential callback interfaces to be implemented, to use JDBC Template?
  5. Where is Collections.singletonMap(…) method used and why?
  6. Where does one use ParameterizedRowMapper?
  7. When do one uses executeAndReturnKey method and where is it define?
  8. How to insert data into a table, where table is having five columns but you have to insert data just in three columns (obviously the rest two columns allows null values)?
  9. What is the better way to insert values in table, if the values are provided in the form of java bean instance?
  10. How MapSQLParameterSource is different from BeanPropertySQLParameter?
  11. How to call procedure using Spring?
  12. How to ensure case insensitive look-up for parameters name when calling procedure?
  13. What is the way to avoid metadata look-up from spring controller when calling procedure?
  14. How to call database functions in spring?

Hint:

  1. [CDOS in short] core, datasource, object, support.
  2. SimpleJDBCTemplate takes advantages of java 5 features – varargs, autoboxing.
  3. Using “support” package classes.
  4. PreparedStatementCreator, CallableStatementCreator, RowCallbackHandler.
  5. One example is when one uses NamedParameterJdbcTemplate, singletonmap used to provide value of parameter.
  6. When code selects data from database using SimpleJdbcTemplate class.
  7. If developer needs to implement auto generated keys.
  8. Either use usingColumns(…) method or MapSQLParameterSource.
  9. By using BeanPropertySQLParameterSource.
  10. BeanPropertySQLParameterSource uses java bean instance (value object) to store data while MapSQLParameterSource uses addValue method to set values of columns.
  11. Using withProcedureName(String name_of_procedue) provided in SimpleJdbcCall class.
  12. By setting new JdbcTemplate(datasource).setResultsMapCaseInsensitive(true).
  13. By calling SimpleJdbcCall(new JdbcTemplate(datasource)).withProcedureName(name_of_procedure).withoutProcedureColumnMetadataAccess();
  14. withFunctionName(name_of_function).

Happy Reading,

Nirbhaya Bhava!!

Code Build: Shortcut to open code location

Most of the time to fix a problem, dev people try to build the updated code. Since the update made was in just few classes so its really bad to provide full build on dev environment. So its better to ask for patch of class files. So people generally browse the location through windows or command by pasting the location. Stop doing that. Windows provide shortcut cuts, from command prompt itself.

Just type one of the following-

  1. explorer.exe .
  2. start .

These command will open the location of source file, from there its easy to navigate towards class files.

This is not a wow factor, but a way to simplify the hectic dev life..

Enjoy applying,

Nirbhaya Bhava!!

Follow

Get every new post delivered to your Inbox.