Pages

GIT Cheat Sheet


GIT is a distributed source code management system. It helps in versioning the code we write in day to day life. And yes GIT is not just for the programmers to store their thousands of lines of code and put them in the SCM repository.
GIT can be used by anyone and everyone. Its ease of use, minimal foot print and distributed storage helps many people who need versioning. For example, an author can write a book, using git, he can commit his changes for each chapter and if needed, he can rework on the previous versions. A civil engineer can make his blueprints and store in GIT so that he can work from several versions if at all any changes are to be done.
Due to the elegance, and ease of use the GIT is the most popular and powerful SCM available on the market as of today.

Maven Introduction


Maven is an open sourced project supported by Apache Software Foundation, which is gaining most importance in the software development industry currently. The main reason for the increasing adaptation of maven in most of the companies is because of its easy to use and maintain features.
Some of the features that makes it more interesting are
  • Dependency management
  • Distribution management
  • Versioning
  • SCM Integration
  • Site generation
  • Test Integration
  • Hundreds of plugins to customize
  • and of course, huge community support

Syntax highlighter sample post

 

Today am working on several ways for highlighting the syntax I write on my blogs, after some good research I found this simple library from Alex Gorbatchev. His library is awesome and very easy to work. I have used his library and hosted on my cloud server to use the syntax highlighting as and when needed in my blogs.

Have integrated the scripts and css elements in my blogs layout, and the only thing I need to do while posting any code in blogger is to properly align my code in the <pre /> tags.

I am sampling one program for the testing purpose in this post.

Steps I followed :

  1. Write a blog post
  2. Where ever I need to embed some code, copy the code from an IDE
  3. Paste the code in the “Source” tab of the Live Writer editor and
  4. Wrap the code with <pre class=”brush: java”> </pre>
  5. Ola! the code will be highlighted and formatted in the blogger. 

 

package test.onecloud.httpclient.call;

import static org.hamcrest.Matchers.containsString;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertThat;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.HttpMethod;
import org.apache.commons.httpclient.methods.GetMethod;
import org.junit.Test;

public class HttpClentCall {

@Test
public void callSimpleURL() throws HttpException, IOException {
String url = "http://www.google.com";
HttpClient client;
client = new HttpClient();
HttpMethod method = new GetMethod(url);
method.addRequestHeader("Authorization", "xyz");
client.executeMethod(method);
InputStream bodyIS = method.getResponseBodyAsStream();
StringBuilder buffer = new StringBuilder();
BufferedReader bsReader = new BufferedReader(new InputStreamReader(
bodyIS));
String line;
while ((line = bsReader.readLine()) != null) {
buffer.append(line);
}
method.releaseConnection();
assertNotEquals("", buffer.toString());
assertThat(buffer.toString(), containsString(""));
}

}


Hope this works for me.

Abstraction and Encapsulation Demystified

Abstraction in OOPS is well articulated, and states clearly of hiding the unnecessary details from other Components. Abstraction and Encapsulation comes hand in hand and often lead to misconceptions. In this article I would love to clear out all the ambiguity you ever had in mind about Abstraction and Encapsulation and their implementation in Java.

Wikipedia Definitions:

“In computer science, abstraction is the process of separating ideas from specific instances of those ideas at work. Computational structures are defined by their meanings (semantics), while hiding away the details of how they work.”

Encapsulation is the packing of data and functions into a single component. The features of encapsulation are supported using classes in most object-oriented programming languages, although other alternatives also exist. It allows selective hiding of properties and methods in an object by building an impenetrable wall to protect the code from accidental corruption.”

In layman terms, abstraction means hiding, and encapsulation means packing / gluing things together.

Factories in Software Development

From our childhood, we hear a lot of things about “Factories”, some are good and most of them are bad. That too if you are coming from a country like India, you will hear more bad stories of the factories destroying the communities and health.

In my own experience, I have heard a lot of criticism on factories, like they spoil the environment, contaminate the water, air and soil and devastation of the crops. When compared to the opportunities these give to the jobless the devastation gains and protests start.

Luckily, in Software development the “Factories” are doing the quite opposite of the physical “Factories” around the globe. As I have said above the “Factories” we are talking about reduces the pollution, improves the quality and gives more opportunities. (Ok finally one thing in common).

Sorting Binary Array with O(n) complexity


Welcome back, today am going to discuss about a solution I came up when solving a sorting problem given by my colleague. The problem statement is very simple and straight “Sort an Array of Binary Digits, with O ( n ) complexity (without using extra memory)”.

Novice Info: Uninstalling Software From Eclipse


Today, I am planning to present a small tip, which I wanted to share from a long time. Many of us use Eclipse for all our development needs. The main reason being, it is well organized and has the wonderful framework for adding any capabilities for building on more features to it. In my opinion the awesome feature of writing and adding Plugins and Features of the eclipse for its extended support is the main reason for its penetration into the developer market.

Importance of Data Structures and Algorithms in Programming


Today, I had a discussion with my colleague (Raveendra Chikkala), about Data Structures. It was a really interesting and motivating discussion, and today I wanted to share it with all of you. I have never taken the complexities of the algorithms seriously till date in my day to day programming, though I cared a lot on the design patterns and worked hard on making the system loosely coupled and having high cohesion.

Gist of the discussion is as follows:

Question: Why do we need to think of Data Structures, what do you mean by Data Structures. I know we use the data structures to store the data, and faster retrieval.

Singleton Pattern

As a programmer you should have come across many design patterns, in this blog entry I would like to spend some time on Singleton Design pattern. Before, further discussion on Singleton pattern, let us try understanding what is Design Pattern, and why do we need to learn about these patterns.
A Design pattern, is a specification defined to solve a particular problem. In our day to day programming we will be trying to solve several problems, design patterns are those solutions which are adopted by many developers around the globe to solve those specific problems you face today. Now its time for you to adopt some of those in your code, instead of fighting out your own solution for the problems you have on your table.

Novice Info: Difference between Classes, Interfaces in Java–Part 2


In my earlier post about Difference between Classes, Interfaces in Java I have explained about the differences in theory. Current post will be discussing about the practical differences that lets you make the decision on when to define a Class or Interfaces.
I am going to discuss about a 5 simple principles to be followed for creating a Class or an Interface. These principles will guide you in taking a right decision while defining the Types.