Head F i r s t...

Thursday, February 23, 2012

When to use and when not to use a Design Pattern?

What is a design Pattern?
A solution to a common problem in object-oriented programming context.

Base requirement is: We should not complicate the solution, i.e. it should be simple and clean.

When to use a Design Pattern?
Scenario1: Starting solution without using any pattern and later you can decide to refactor the solution to add certain design pattern after evaluation, if it is applicable and can be correctly applied.

Scenario2: When you are pretty sure that you can correctly apply a design pattern, then you can start your solution directly with it or doing some sort of proof-of-concept before starting.

Points that should be remembered here:
1. Try NOT doing over-engineering of the solution which may complicate it and will result into maintenance nightmare.
2. Follow KISS principle, i.e. keep your solution design simple.
3. Use design pattern only when it's really needed.
4. Following any given pattern rigidly is not really the answer.
5. Using design patterns is a good coding practice, but again it doesn't mean that writing a simple and clean solution without any design pattern is bad. We just have to identify the points where in future the application have to be made scalable should not make the simple solution complex. Using design patterns can keep it simple to enhance in future.

Frankly speaking, the rule is 'there is no rule' about when to use and when not to use a Design Pattern. Your experiences (success more than failures) when to use them purely, when to adapt them or when not to use them at all will be a deciding factor here :)


Happy coding :)

Friday, February 10, 2012

Please don't use the term "Chicken and Pigs" in SCRUM context

I came to know on one of the website that in SCRUM context, core roles are called as "pigs" and ancillary roles are called as "chickens". This was named after the story/joke of Chicken and Pig. The "chicken-and-pigs" joke was very old many years before it became a foundation of SCRUM, but still this terminology is been used today. The joke is meant to point out the difference between those who are committed on a project and those who are only involved. But it's ok if these terminologies are kept for understanding the core roles and not so called 'defining' them.

More info on this topic: Agile Coach

Monday, April 4, 2011

"SEVERE: Error filterStart" - Occurs when starting Tomcat

This problem basically occurs when you've different java versions for compiling the source code and for starting the Tomcat server.

Checks you've to do:
1. Java version of your IDE with what you compile the source code
2. Java version used by Tomcat

If the above mismatches, you'll face the error "SEVERE: Error filterStart" during the Tomcat server start and your web application will not be deployed.

Sunday, March 13, 2011

Attending: DevCamp Pune 2011

DevCamp Pune - The Developer Community Meet Pune,
April 9th, 2011 | 10:00 am - 6:00 pm




Register here

Serializing / De-serializing bean object using XMLEncoder / XMLDecoder

The java.beans package provides very useful classes [XMLEncoder / XMLDecoder] to save an object state [persist] into an XML file [Serialize] and easily read it back [De-serialize]. It's very helpful while debugging the state of objects especially in the production environments.


No need to provide any examples as the below are some useful links that already contains the same:

Saturday, November 20, 2010

Developing distributed apps? Think "JavaSpaces"

We know that Distributed Computing is all about building network-based applications as a set of processes that are distributed across a network of computing nodes that work together to solve a problem. The advantages of this approach is like performance improvement, resource sharing, fault tolerance, scalability, etc. But still, to achieve this, special care should have to be taken while design and implementation of such systems. There are many challenges in distributed computing like synchronization of process across heterogeneous networks, network latency, partial failures of processes and language incompatibilities.

JavaSpaces technology, to the rescue...

1. JavaSpaces is both, distributed programming model and an API.
2. It's a high-level coordination tool for gluing processes together into a distributed application.
3. JavaSpaces are best considered as distributed shared memory with additional features which provide transactional integrity and support for the handling of failure.
4. In JavaSpaces applications, processes don't communicate directly, but instead coordinate their activities by exchanging objects through a space, or shared memory.
5. A process can write new objects into a space, take objects from a space, or read (make a copy of) objects in a space as shown in figure below:



6. JavaSpaces uses the most common software pattern, the Master-Worker pattern. The Master hands out units of work to the 'space', and these are read, processed and written back to the space by the workers.

7. JavaSpaces provides a simplified approach to dynamic communication, coordination and sharing of objects between network resources.

Some useful pointers to know more about JavaSpaces:
Link1, Link2, Link3

Break ke baad

It's been long break from my last post... Hope such break doesn't occur this time round :)

Monday, March 8, 2010

TABS Series session on "Agile and Lean Concepts for IT Professionals"

On Friday, Mar 5th, 2010 attended ThoughtWorks TABS (ThoughtWorks Agile Business Series) session on "Agile and Lean Concepts for IT Professionals". It was a great piece of experience. They took all the attendees to the actual Project teams and showed how their teams are agile. Followed by that was the session on "Lean Concepts for IT" by Scott Shaw. It was a really informative session.

Now looking forward for ThoughtWorks Master Class Series talk on "10 Ways to Improve Your Code" by Neal Ford on Wednesday, Mar 10th, 2010.

Monday, November 16, 2009

Intel - Software Developer Supercomputing Conference, 2009

Today I attended Intel's - Software Developer Supercomputing Conference, 2009. It was a really great conference. Lot of ideas were shared by intel people like how to improve application performance using threads, libraries (like MKL-Math Kernel Library), using their new products, etc. etc.

The session was interactive enough and at the last they distributed Intel's T-shirts :)

Some useful pointers:
whatif.intel.com
go-parallel.com

Tuesday, November 10, 2009

..."sixth sense" - yes, it's coming...

Today I came across bleeding edge research of the year 2009 - Pranav Mistri's "sixth sense". It's a simple, wearable device that enhances the real world with digital information.

Great to see future developments in this area..

You can find more info on his website here.

Monday, November 9, 2009

J2SE 5.0 reached its End of Service Life (EOSL) Notice

On November 3, 2009, J2SE 5.0 reached its End of Service Life (EOSL), which is the date of final publicly available update of version 5.0 (i.e. J2SE 5.0 Update 22).

You can find more information here.
Learn more about EOL policy here.

Thursday, October 29, 2009

Ubuntu 9.10 coming...

Ubuntu: For Desktops, Servers, Netbooks and in the cloud

Thursday, September 24, 2009

Code Kata by Dave Thomas

Dave Thomas took the idea of coding practice and made something very well, pragmatic out of it.
There are series of katas, which are small, thought-provoking exercises that programmers can do in the language of their choice.

You can find it here. Really worth giving a try :)

Friday, June 26, 2009

Chaining methods using power of "return this"

In one of my older post [here], I discussed about the power of Fluent Interfaces. We can use those in building method chaining, thus improving the readability of code just english-like sentences.

We can also implement this using "return this" in class methods.

Take a look at below source code:

Bug.java



CreateBugs.java



Output:



The above programs are self explanatory :)

Monday, May 25, 2009

To overcome "Maximum open cursors exceeded" issue

When we execute a query in oracle, a ResultSet is created and stored in the memory. Oracle allows the programmer to access this ResultSet in the memory through cursors.

When we fire SELECT query / DML query from Java code, Oracle returns the reference of this created cursor to the Java program, which we refer as a ResultSet. Following is the hierarchy of creating objects in JDBC:



[For DML queries, we don't require "ResultSet" object]

Now, when we execute this query in loop for multiple records, we can use the same "Connection" object, but we'll have to close ResultSet object and Statement object at the end of each loop.

[Here we're using distributed database connection which means for each request, we create new "Connection" object and after the request is processed, we close this "Connection" object. Now, there might be the case that for one request, we need to fire multiple SELECT / DML queries, so we use the same "Connection" object to process this request.]



Closing ResultSet object and Statement object at the end of each loop will make sure that the cursors opened by executing this query will be closed / released.

[For DML queries, we need to close only "Statement" object].

Finally we close the connection object when we finish executing the queries in loop.



All the resources (including cursors) are released when the "Connection" object is closed.

Following this, we'll never encounter "Maximum open cursors exceeded" issue in any application :)


_________________________________________________________________________________________________________________

"Look at the sky. We are not alone. The whole Universe is friendly to us and conspires only to give the best to those who dream and work."

- Dr. A P J Abdul Kalam
_________________________________________________________________________________________________________________