Your Ad Here

Friday, June 25, 2010

Difference between ResultSet TYPE_SCROLL_SENSITIVE and TYPE_SCROLL_INSENSITIVE

Difference between ResultSet TYPE_SCROLL_SENSITIVE and TYPE_SCROLL_INSENSITIVE

If you would like to have a scrollable ResultSet Object then you need to supply constant when you create an object of it. By default it is FORWARD_ONLY, you can traverse forward in order to fetch records from table.

e.g. Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE , ResultSet.CONCUR_READ_ONLY);
Or
Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE , ResultSet.CONCUR_READ_ONLY);

Or
Statement stmt = this.con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);

Or
Statement stmt = this.con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);


A result set that is TYPE_SCROLL_INSENSITIVE does not reflect changes made while it is still open and one that is TYPE_SCROLL_SENSITIVE does.
Changes will be visible if result set is closed and re-opened.

TYPE_SCROLL_SENSTIVE does not *guarantee* that all changes made to the result set by others will be visible.It depends on a number of factors including the driver implementation (whether it caches the rows or not), the transaction isolation level etc...

Wednesday, June 2, 2010

Why should use Stored Procedures

In software development its very common to interact with Database(s) and Application Layer used to fetch data from DB using any programming language like java, C# conjunction with SQL.
There are two kind of DB languages
1) SQL : Non procedural language, where you can not write your own logic / subroutines.
2) PL/SQL: Procedural language, where you can write business logic and subroutines.

Stored procedures used where we would require the following
* modular programming at DB level
* Faster execution.
* Reduce network traffic.
* Security mechanism.

Advantages:

->You can modify stored procedures independently of the program source code.The application doesn't have to be recompiled when/if the SQL is altered.
->Stored procedures abstract or separate server-side functions from the client-side.
->Stored procedures allow a lot more flexibility offering capabilities such as conditional logic.
->Stored procedures are stored within the databse and run directly in database engine, bandwidth and execution time are reduced. This is because a single stored procedure can execute a complex set of SQL statements.

Disadvantages:

->If we need to modify anything in stored procedure then its definition has to be replaced.
->Any changes in the stored procedure will impact all the places whereever this procedure is used.

How to create :
http://download.oracle.com/docs/html/B16022_01/ch3.htm
Examples in java:
http://www.oracle.com/technology/sample_code/tech/java/jsp/oracle9ijsp.html

Sunday, May 23, 2010

Best Strategy ? Abstract classess Or Interface

Few points before to proceed :

1) Abstract class can have one or more abstract methods as well as concrete methods.
2) An abstract class can't not be instantiated.
3) To use functionality of abstract class One can create a concrete class that has to instantiate the abstract class and must have implementation for each abstract method.
4) Abstract classes are usually declared where two or more subclasses are expected to fulfill a similar role in different ways through different implementations.
5) Interfaces defines the behavior of the classes. in another word Contract.
6) All methods declared in interface are abstract by default, no need to use abstract keyword.
7) Basic feature of OO is Encapsulation : Reveal an object's programming interface (functionality of the object) without revealing its implementation.
8) Interfaces have no direct inherited relationship with any particular class, they are defined independently. Interfaces themselves have inheritance relationship
among themselves.

When Should Interfaces or Abstract classes some point are below :
First and very important is "Choice of design".
Second there are some facts and features of each, according to design we should use them.

1) Using Interfaces, The implementation can change without affecting
the caller of the interface.
2) Using Interfaces, Unrelated (One class is not a sub-class of another class) classes can implement similar methods(behaviors).
3) An interface can only define constants while abstract class can have fields.
4) Use Abstract classes, where you want to provide common implementation code for all its sub classes. It reduces the duplication. However we should not forget that a concrete can extend only one super class whether that super class is in the form of concrete class or abstract class.

I would use interfaces when I think that something there are very frequent changes in my design. How??? Simple example :

Consider an interface that you have developed called "TaskHandler":

public interface TaskHandler{
void performSomething(int i, float x);
int performMore(String s);
}


Now after some time , you want to add a third method to "TaskHandler", so that the interface now becomes:

public interface TaskHandler{
void performSomething(int i, float x);
int performMore(String s);
boolean willYouPerform(int i, float x, String s);
}


Points to be noted:

If you make this change, all classes that implement the old TaskHandler
interface will break because they don't implement all methods of
the the interface now.

Solution :
Create one more interface OtherTaskHandler that extends TaskHandler interface

public interface OtherTaskHandler extends TaskHandler {
boolean willYouPerform(int i, float x, String s);
}


Now Its up to users, he/she can choose to continue to use the old interface or to upgrade to the new interface.

Tuesday, May 18, 2010

Java is not a Pure Object Oriented Language






Theoretical a Pure Object Oriented Language must contains all entities as in the form of Object. There could be two categories of OOPL :
1) Hybrid OO languages :
Hybrid languages are based on some non-OO model that has been enhanced with OO concepts. e.g. C++, ancestor was C, may be more...

2) Pure OO languages
Pure OO languages are based entirely on OO principles; Smalltalk, Java, and Simula are pure OO languages.

But Due to following reasons Java can't be considered as Pure OOPL:
1) Java violates principle "Everything must be Object". Java has primitive types int, long etc.
2) static works on class level.
3) Multiple inheritance is not supported.
4) Operator overloading is not supported.

BTW Java never claimed to be "Pure OOPL".

Tuesday, April 13, 2010

How to communicate to senior management of the company effectively?




There are many points those need to keep in mind while you are communicating with senior managers.

  1. Most importantly to understand the business and customers of the organization and respect them.
  2. You should be aware about prospective/concerns of the senior manager.
  3. You need to have a much broader focus when communicating with senior management than you would when communicating to rest of employees.
  4. As time plays major factor in communication, as soon as you can communicate your ideas/ problems to managers, you are doing one thing right in order to communicate effectively. Moral : “focus on the most critical things you need to tell a senior manager”.
  5. If you are communicating in writing the gist / intent should be clear enough in first 2-4 lines and if you are communicating verbally then it should be clear with in first few mins say 1 min.
  6. Over communication is major problem among the team members while they communicate to their managers, many senior managers discard the information if it’s too much.
  7. Prepare a list or outlines of the points those you want to make.
  8. Feel free to take your notes with you and refer to them. That just shows you are organized and you have put thought into using your managers' time efficiently.
  9. If they ask you something that you don't have the answer to, don't panic. Just tell them you'll check on it and give them an answer later. It would be better if you can give time bound answers like “I'll give answer in next 1 hr or later today etc..”.
  10. One major problem i have seen that team members don't verify their EMails or messages If they are communicating in writing, So write out your messages / MoMs or e-mail but DON'T SEND IT until you have re-read it and edited it(if required).
  11. Remember that the way you use language reflects your attitudes and your respect for the audience.
  12. Be an effective Listener by understanding the complexities of listening, prepare to listen, Focus on each and every points, delay judgment, establish eye contact with the speaker, take notes effectively and encourage others to talk.
  13. If you are technical person then don't give your judgment very early. Generally people say its not possible, we can't do it, we should not do it, how this task will be done, etc etc.

    Apart from above points YOU MUST UNDERSTAND / RESPECT THE GIVEN DEADLINES BY YOU TO MANAGER or MANAGER TO YOU for the given tasks. Because using these deadlines / timelines your managers plan further activities and business plans.

Sunday, March 28, 2010

Refactoring of Code

Refactoring is basically a continuous job for a software programmer to improve code quality and maintainability.
Some good software programmer used to do this with / without knowing of it e.g. moving methods to the super class / abstract class, making general function to do more stuff in small code etc. Generally there will not be extra time given for refactoring the code, unless the code is not able to use without doing it. Whenever a new feature or bug arrives refactoring should be done to improve quality,maintainability and extendability of code.

Software developers are often not willing to do refactoring, because some refactoring are simply tedious and also there is no visible external benefit for all the efforts put in.

It is very common that management only emphasis / rewards externally visible code like new feature and enhanced performance etc but very much not interested to code's quality. However after the code reviews if software developers want to spend some time to refactoring the code, there could be some risk of breaking code via refactoring operations e.g. code is not written as per the coding standards etc.

A software developer wants to refactor some poorly written / structured code, their lead or manager would have a different vision altogether on it and its very common that he /she may deny to modify the working / deployed code. These things also can't be ignored. Sometimes developer and management take decision together of refactoring of bad code.

Wednesday, March 10, 2010

Scrum is Good but there must be some drawbacks / disadvantages in Scrum. What are they ?

As far as i know Its hard to get into Scrum and its implementation in the organization is also hard. Because some people in the team or management would not be ready or willing to accept it.

Any other things ???
In Scrum, there are three primary roles:
  1. Product Owner
  2. Scrum Team
  3. Scrum Master
The Product Owner is mainly responsible for gaining maximum business value, by gathering all the inputs from the customer and what should be produced to end user of the product. These inputs could be from Team Members and stakeholders. After gathering all inputs from customer / team members or stakeholders Product Owner translates them into a prioritized list.

In some cases, the Product Owner and the customer are the same person; in
other cases, the customer might actually be millions of different people with a variety of needs.

The Product Owner role could map to the Product Manager or Product Marketing Manager position in many organizations.

The Scrum Team develop the product / project that the customer is going to use: (Software or website / web application)

For example. The team in Scrum should be “cross-functional”.
A team in Scrum is typically five to ten people, although teams as large as 15 and as small as 3 report benefits, and for a software project the team might include analysts, core developers,UI designers, and testers.

The ScrumMaster is one of the most important elements of Scrum success. The
ScrumMaster does whatever is in their power to help the team be successful.

for More info : read my previous article.
scrum-master-n-responsible

Saturday, January 2, 2010

Scrum Master is responsible for a successfull Scrum in the organization

In Agile methodology, Scrum master is a new role who is having new roles and responsibilities. Basically He or she is mainly responsible for enforcing Scrum rules and practices to make it happen in the organization.
A Scrum Master is link between management and the team. Actually SM represents management to the team and a team to the management.

SM is a part of the scrum team and anyone can be a Scrum Master who knows about the Scrum practices, rules and its fragrance.
Sprint pre-planning meeting, Sprint planning meeting, Daily Scrum meeting and Retrospective meeting are the main meetings in the scrum and Scrum master is responsible to make them happen along with team and product owner. Each meeting has its goal and practices and those should be followed by all attendees.