Thursday, August 20, 2015

Spring - What exactly Dependency Injection is ?

Dependency Injection (DI):

The whole  Spring framework roam around the concept of  Dependency Injection (DI)  which is an implementation of  Inversion of Control. The Inversion of Control (IoC) is a software architect, which goes against the traditional procedural programming.

From wiki  of procedural programming is identified as 

In traditional programming, the custom code that expresses the purpose of the program calls into reusable libraries to take care of generic tasks, but with inversion of control, it is the reusable code that calls into the custom, or task-specific, code.

When writing a complex Java application, traditional programming makes an application tightly coupled between the connection points and make the code almost disqualifies to reuse. And then the term Inversion of Control coined.

With Inversion of Control (IoC) a drastic change happened in software architect and complex applications became a bunch of modules. With IoC, modularity of the application increases and thus extensibility as well. 

Coming to Dependency Injection -What is dependency injection exactly?  Dependency Injection is a methodology which implements IoC. This term really became a jargon and puzzling many minds for years. The simplest definition I found for the term DI is by James Shore 

Dependency injection means giving an object its instance variables. Really. That's it. 

Imagine Class Y is dependent on Class X. When ever there is a need of  Class X for Class Y, X will be injected to Y. That is all. There are several ways of Injections like Constructor Injunction, Setter Injection, Interface Injection. All these type are injection do the same but the ways are different. Main goal is to inject the dependency to it's receiver. 

Saturday, January 3, 2015

Three things I'm going to follow this year as a developer.

The below three things are not at all resolutions since they are my bad habits. I'm gonna change them this year. Don't know how perfectly I execute but I'll try to.

  • Google...stop helping me, please.

These days I'm being lazy and searching a simple for loop syntax to copy paste in my code. If this continues, I even gonna search for a declaration soon. With no blame on Google, I want to reduce using Google search. Too much dependency on Google making me lazy and may dumb even. I'm feeling inside that it reducing my memory power as well. I hope I use Google in more productive way from now onwards.

  • Let me update my kit.

I'm sure that I'm working on some old age concepts and technologies. Planing to learn a new technology or framework in a month. Such that I'l learn 12 things in this year. That's very huge compared to my current technical state. Only thing I have to do this for is stop postponing it.

  • Stop thinking and start doing it.

I never start the things in time. Perhaps never for some things. For example, I want to become master in Maven and thinking of it for last 4 months, of course I bought a book too. But the problem is I never opened it for a single time. And I want to learn few techniques in Spring as-well but never started reading it. But now I'm going to read that book atleast an hour in a day. So that I can easily achieve the second point :)

All the best to myself.

Thursday, December 25, 2014

Software developer life with funny gif images.

In holiday mood and bored with technical stuff so I just put my funny thoughts in this post with my favourite Tollywood movie gif images.

Expectation about entering in office.....


In I end up...

Expectation about solving a bug..

In reality, when an issue comes ...

Expecting a hike soon.......

After the appraisal review meeting ...

Expectation about telling a joke to female team-mate...

How actually she responds ...

How I would like to give a demo..

And when the demo time comes...

When there is a meeting with client.....

After 10 min....client rocks ......

When team leader reviewing my code..

And I'm trying to explain what I wrote...

When my bug is unnoticed in a demo...

My reaction that when my colleague requesting to do his work..

When I'm alone in night shifts...

When I agreed to work on a festival day, my team lead reaction...

But when I ask a leave to my team lead ..

When I mistakenly entered into CEO's room...


My reaction after solving a production issue with in a sec..

Team vacation party expectation..

Software industry funny images

And in reality...

Software industry funny images

Thank god, It's Friday ..

How I actually want to enjoy in weekend..

In reality how I actually spend both days..

Software funny images

Ufff... again Monday ....



SHARE  the fun, if you really enjoy it.

Thursday, December 11, 2014

No source code is available for type *Class*: did you forget to inherit a required module?

If you found the above titled error in your IDE, probably you are facing the most common error for every GWT beginner. The fact is that,  in GWT you are limited to use only some of the Java classes from whole Java API. You cannot simply use all the available classes in Java with GWT. 

Keeping in mind the fact that GWT compiles Java code to JavaScript  there are multiple reasons and limitations from JavaScript side to limit most of the Java features. So GWT is very choosy with Java API classes and you have to use those classes only.

With GWT it is not possible to convert all the Java classes to JavaScript because there are some functional differences with Java and JavaScript. It is not quite possible to achieve all the functional benefits of Java to JavaScript.

For instance, let see two functional differences, why it is not possible to use those Java classes in Javascript.

Instance 1 :

You cannot use/do IO operations in Javascript since HTML and Javascript cannot have access to file system. That's the reason GWT restrict io classes of Java to use.

Instance 2 : java.lang.Thread

You cannot use/do multi threading in Javascript since it is single thread model. That's the reason GWT restrict Thread related classes to use.

Like above instances, there are other instances to restrict the usage of many classes from Java. Again coming to the solution part, we can't do anything about the restriction and we have to stick to the available classes. You need not to remember all those classes list. Below is the complete list of subset that GWT can emulate.

Below are the packages support in GWT from JRE.


Even from the above packages you cannot use all the classes. Just go through the below link for complete list of classes GWT support from Java library.

When you stumble with the titled error just go through this list and check that you are using the white listed Java classes in GWT or not. If you are not using some other class/classes which are not white listed, you'll end up with the exception/error

Recent post : Why GWT loads slow and tips to load GWT app faster

Sunday, December 7, 2014

10 websites that help Java developers daily.

Though there are hell number of web sites on Internet, when it really need we end up with few sites that really helps. In my experience I found the below websites cracked my problems really quick and I use them regular to solve my problems. On top of learning from book and reading official documentation, I found below sites are very handy in my daily job.

When ever I feel like something crazy going on or whenever I have a question like "why this happening like this", immediately go to the language specification and refer the topic for clarity before jumping into Google. 

Writing code doesn't make you a programmer. Writing good code do that. When ever I start writing code on a new topic, the first thing I do is to go for this site and search for that practice to know what to do and what not to do. Since object oriented programming is easy to use, we easily do mistakes. This site helps you to learn good practises.

Stackoverflow site is a part of  world's largest Q&A site Stackexachange. I use  almost everyday to ask/answer questions there. It not only solves your problem but it explore the problems that fellow programmers facing. The place for Java developers to gather on stackoverlow ocean is Java tagged questions

(My profile on stack, if you want to visit)

Another website in Stackexachange network, which is useful for code review. When you have no seniors around to review your code or if you want an expert suggestions on code blocks you wrote, go ahead and post it here. I'm sure that you get your answer and suggestions in minutes form experts.

When ever I didn't find an answer in stackoverflow, the immediate option is that Java ranch which is quite informative and straight to the point. Since theoretical questions are little off topic in stackverlow, people found javaranch is a perfect site to get the answer they are looking for. It doesn't mean that this site don't have coding related questions.

If you are not updating with time we are no more in this field. When I'm free, I just go through this site and I browse the newly emerging techniques, frameworks and articles written by experts related to Java. Good part is that, you can share your own blogpost's there to the world.

It's almost a Google search for Java classes. If you have a class name and you don't have the Jar related to it, just open this site and paste your class name. Hold it tight for 2 sec, you got the all the Jar's related to that class. Just choose your jar and proceed. This is very useful when dependent jars are missing and you are facing ClassNotFoundException.

Best site to see source code from a .class file. This is actually a Java decompiler project. This project have plugins for almost all popular IDE's and the reason for mentioning here is, it have a on-line decompiler. You just drag and drop your class file and see the source code immediately.

This is another site I use very frequently to show some running code online or to show some compiling errors to other persons. It is not possible to tell some problems without proof. I just copy paste my code there and run it. It even generate a link for you to use in future. Most beautiful thing  here is you can select JDK version. When you want to execute some piece of code in some other JDK which you are not using currently, this site is gold for you.

Another better site to resolve your daily coding problems. There are 2 parts in this site basically. First thing is that the wide range range of it's tutorials and articles on different Java frameworks. Second is it's solutions for the exceptions and errors a Java developer facing. Though it is providing good and quick solutions, I don't like those solutions without proper explanations. 

As @JavinPaul  pointed out in the comments, official forum for Java by Oracle

Though I rarely use it , this is the official forum for Java where you can share your technical problems either by question or answering and can participate in discussions.