After discussing Singleton Pattern and Observer Pattern in my previous posts, I will be talking about Factory Design Pattern in this one. What is a Factory Pattern? Factory Pattern is also among the most commonly used design patterns. Instantiating an object with the new() operator couples the code tightly to the concrete implementation leading to … Continue reading Factory Design Pattern – Implementation in Java
Observer Pattern – Implementation in Java
What is an Observer Pattern? Observer Pattern is one of the most commonly used design patterns. It is useful when you are interested in getting notified of the state changes of an object. It defines a one-to-many relationship between the subject and the observers. Terminologies Observer or Listener or Subscriber The objects which are interested … Continue reading Observer Pattern – Implementation in Java
Singleton Pattern – Implementation in Java
What is a singleton pattern? Singleton pattern is used in cases where we want to ensure that only a single instance of the class exists in the application. It is one of the most popular patterns. With lot of views around the web calling it a code smell. In this post I will not be … Continue reading Singleton Pattern – Implementation in Java
Variable Arguments in Java
Variable arguments to a function in any language gives us a flexibility while calling the function. The number of arguments to a function are not fixed, and a number of calls can be made to the same function which would otherwise have been impossible without method overloading. Consider the following example: You have to write … Continue reading Variable Arguments in Java
The Magic of Final Keyword in Java
In this post, we will discuss all things final in Java. Final Classes, Final Methods, Final Variables and finally Final Arguments. Final Classes Let us look at an example. We have a class A that is declared as final. https://gist.github.com/anjanashankar9/8adc9729a7b4d26d9bb110767b10d1fc Now let us try to create a subclass of A https://gist.github.com/anjanashankar9/5ad56b973687dab6c5bd60042ea5403a This will give a … Continue reading The Magic of Final Keyword in Java
Absolute Git Essentials
Working with Git. Here are 5 must have settings that make you life so much easier
How memory works in Java?
As a developer, it is extremely important to understand how memory management in java works. It can help avoid creating difficult to trace problems. This blog post would give a simplistic view of memory management in java. With respect to memory management of Java applications, you need to understand two terms, the stack and the heap. The memory … Continue reading How memory works in Java?
Java Strings
String literals and String Objects String s1 = "abc"; String s2 = "abc"; Both string s1 and s2 refer to the same string object and value residing in the string literal pool. String A = new String("abc"); String B = new String("abc"); The two strings A & B are two different string objects, because we … Continue reading Java Strings
Java Static Initialization vs. Instance Initialization – When to use which?
Static Initialization Typically static initialization block is used to initialize static variables of a class. The block is called at the time of class initialization. It is called only once. You can initialize static variables inline. If more complicated logic is required for initialization, a static initialization block can be used. The static initialization blocks … Continue reading Java Static Initialization vs. Instance Initialization – When to use which?
Do you ssh too often and to many different machines?
It's been a long time, since I last wrote a post. And this is going to be a short one. At my recent job, we have all these test environments (about 3500 of them) that have the same username and password. I kind of got tired typing the username and password every time I had … Continue reading Do you ssh too often and to many different machines?
You must be logged in to post a comment.