Author: anand reddy rikka

Moved to Jekyll

Hello Everyone !!

I have successfully migrated from wordpress to Jekyll. I’m now available at


#1 Class Access Types

Class can be declared with public and default access-modifiers and abstract, final non-access-modifiers.

Where as inner classes can include all access modifiers public, private, default and protected.

Singleton – Creational Design Pattern

Singleton Design Pattern is one of the creational design pattern which creates only one instance of the class. Only one instance of the class is created per Java Virtual Machine. Singleton pattern is used for logging, drivers object and thread pool. There are different ways to create singleton design pattern, but all of them follow three concepts

  1. private constructor to restrict access to other classes.
  2. private static variable of the same class that is only instance of the class.
  3. public static method to return the instance of the class.
class SingletonPattern {
   private static SingletonPattern defaultInstance;
   private SingletonPattern() { }
   public static SingletonPattern getInstance() {
      if(defaultInstance == null) {
         System.out.println("Singleton Pattern Default Instance Created");
         defaultInstance = new SingletonPattern();
      return defaultInstance;

The above singleton class is not thread-safe and may not be useful in multi-thread environment. Need to take necessary steps to make it thread safe. The below method of creating singleton pattern is the most widely used and doesn’t require any synchronization techniques.

class SingletonPattern {
    private SingletonPattern() { }	
    private static class SingletonHelper {
        private static final SingletonPattern INSTANCE = new SingletonPattern();
    public static SingletonPattern getInstance() {
        return SingletonHelper.INSTANCE;

Share files to download from tomcat

Sharing files with friends or colleagues who are in same network is every easy now. All you need is tomcat and name of your computer. So let’s see how we can do it.

I’m assuming tomcat installation be tomcat=”C:\tomcat”

  1. Download Apache Tomcat & Java. Configure environmental variable “JAVA_HOME” with path for Java installation directory and “CATALINA_HOME” with path for Tomcat installation directory.
  2. Go to tomcat/bin and run “startup” batch file. check from browser whether you able to access tomcat home page(http://localhost:8080). if you reach here it means your tomcat installation is good, now lets do some setup.
  3. Go to folder that you want to share and create a simple web.xml file in it.
  4. Go to tomcat/conf open server.xml file and add context for the directory that you want to share like “<Context docBase=”D:\Personal\Tutorials” path=”/Tutorials” reloadable=”true” source=”D:\Personal\Tutorials”/>”
  5. Go to tomcat/conf open web.xml, search for “listings” in “init-param” tag you will find param-name as “listings” change its corresponding param-value to “true

That’s all now save all the changes and run tomcat, folder you shared will be available in the path you mentioned in step 4.

For example in my case directory is available at http://localhost:8080/Tutorials


Design Patterns – Introduction

Design Patterns are proven solutions provided to commonly occurred problems while designing software solution. They evolved over years to resolve most common problems, so we can follow them blindly without any hesitation.

Are Design Patterns dependent on any programming language? No, Design Pattern is an approach, it is not tied to any programming language. Once understood can be applied in any programming language.

Little History from wiki-

Patterns originated as an architectural concept by Christopher Alexander (1977/79). In 1987, Kent Beck and Ward Cunningham began experimenting with the idea of applying patterns to programming – specifically pattern languages – and presented their results at the OOPSLA conference that year. In the following years, Beck, Cunningham and others followed up on this work.

Design patterns gained popularity in computer science after the book Design Patterns: Elements of Reusable Object-Oriented Software was published in 1994 by the so-called “Gang of Four” (Gamma et al.), which is frequently abbreviated as “GoF”.

GoF Design Patterns are foundation for all the design patterns out there. They are 23 in number divided into three categories.

  1. Creational Patterns – Different ways of creating objects.
    • Singleton
    • Factory
    • Abstract Factory
    • Prototype
    • Builder
  2. Structural Patterns – Different ways of orgainising classes and objects, using associations and aggregations to form complex structures.
    • Adapter
    • Bridge
    • Composite
    • Decorator
    • Facade
    • Flyweight
    • Proxy
  3. Behavioural Patterns – Interaction/Communication b/w objects, they help to keep communication loosely coupled.
    • Chain of responsibility
    • Command
    • Interceptor
    • Iterator
    • Mediator
    • Memento
    • Observer
    • State
    • Strategy
    • Template method
    • Visitor

We will discuss each one of these patterns in details in the subsequent posts.

Shared Git repository on LAN

Few days back me along with my colleagues came up with an idea to do POC on healthcare mobile app using ionic. I thought of creating a common code repository in one of our systems and share that code repository using office LAN. A part from pull and push commands in git I didn’t know anything. So obviously like any other developer I googled, after lot of research I successfully created a Git repository in our LAN. Here are the steps

Create a bare repository (Bare repository is the one that has no working tree. It means its whole contents is what you have in .git directory. You can only commit to bare repository by pushing to it from your local clone. It has no working tree, so it has no files modified, no changes)

 git init –bare project1.git

Share it to the users on LAN

Clone this project in some other location on our system using command.

git clone //

Create you project setup files here or dump project into cloned project1 folder and Add the files to cloned repository using

git add .

Then commit the files using

git commit -m “First commit”

At this point your bare repository doesn’t have any branches, when you commit the files in our local cloned project repository it creates a master branch local to our codebase.

Push the changes to the newly created master branch in local code using

git push

The default branch of bare repository is “origin” and default branch of your local cloned repository is “master”. You can check it by commands from cloned repository

git remote (returns origin)

git branch (returns master)

Now it’s very simple, we know the branch of our remote repository & our local branch. Now we need to push the local changes on master to origin.

git push [remote-repository-name] [local-branch-name]

git push origin master

It’s done !! Now any one who has access to project1.git can simply clone the project using command

git clone //*/*/project1.git

Finally we can use the most used command pull & push to do our daily activities on code base. Hope this helps.

Gradle Error: Ionic build for android

I’m learning Ionic framework to develop hybrid apps. However when I’m trying to build the application encountered “gradle” errors. If you encountered any of these errors follow below instructions

  1. Download gradle distribution from here.
  2. Go to “<<project>>/platforms/android/gradle/wrapper” paste the downloaded zip file at this location
  3. Edit <<project>>/platforms/android/gradle/wrapper/ replace distributionUrl to “” which you copied in above step.

This should solve gradle errors.