Sunday, February 19, 2017

Design pattern composite

What is Composite Design Pattern
Composite Design pattern is ideal for designing a system where part-whole hierarchies exist, and where the part and the whole components are to be treated in the system uniformly.
Composite design pattern treats both the parts and the whole in the same way. This is very beneficial for handling hierarchical part-whole hierarchies which are recursive in nature.
Consider a binary tree. The left sub-tree and right sub-tree are themselves full-fledged binary trees. Traversals of these trees is recursive in nature due to this part-whole similarity.
Another ubiquitous example is a UML editor, every element of the diagram is treated(drawn) in the editor the same way as the whole UML diagram.


Composite Pattern consists of following objects.
  1. Base Component – Base component is the interface for all objects in the composition, client program uses base component to work with the objects in the composition. It can be an interface or an abstract class with some methods common to all the objects.
  2. Leaf – Defines the behaviour for the elements in the composition. It is the building block for the composition and implements base component. It doesn’t have references to other Components.
  3. Composite – It consists of leaf elements and implements the operations in base component.


References: 
http://www.javabrahman.com/design-patterns/composite-design-pattern-in-java/
http://www.journaldev.com/1535/composite-design-pattern-in-java

Design pattern Adapter

Adapters in the Real World 

A real world analogy always helps with the understanding of a design pattern. The best example for the adapter pattern is based around AC power adapters. Say you're visiting Europe from the US, with your laptop, which expects a US power supply. To get your laptop plugged in, you're going to need to get a power adapter that accepts your US plug and allows it to plug in to the European power outlet. The AC adapter knows how to deal with both sides, acting as a middleman - this is the adapter pattern.

Convert the interface of a class into another interface clients expect. Adapter lets classes work together that couldn't otherwise because of incompatible interfaces.

The Adapter Pattern
The Adapter is known as a structural pattern,as it's used to identifying a simple way to realize relationships between entities. Thedefinition of Adapter provided in the original Gang of Four book on DesignPatterns states: 
The Target interface defines the domain specific interface that the Client used, so the client collaborates with objects that implement the Target interface. On the other side of things, the Adaptee is the existing interface that needs adapting in order for our client to interact with it. The Adapter adapts the Adaptee to the Target interface - in other words, it translates the request from the client to the adaptee. 


Realtime:
  • java.util.Arrays#asList()


Reference: https://dzone.com/articles/design-patterns-uncovered-0
https://www.javacodegeeks.com/2015/09/adapter-design-pattern.html

All design patterns : https://www.youtube.com/watch?v=0jjNjXcYmAU

Design patterns observer


1.   Observer design pattern


Observer Pattern is one of the behavioral design pattern. Observer design pattern is useful when you are interested in the state of an object and want to get notified whenever there is any change. In observer pattern, the object that watch on the state of another object are called Observer and the object that is being watched is called Subject.


Realtime used:  Badge creation

a.  public class BadgeResultEvent extends ApplicationEvent {


b. @EventListener

public void handleBadgeEvent(BadgeResultEvent badgeResultEvent) {

c. applicationEventPublisher.publishEvent(new BadgeResultEvent(badgeTransaction));


Refernces: 
http://www.journaldev.com/1739/observer-design-pattern-in-java

Thursday, February 16, 2017

link eclipse maven source code

http://stackoverflow.com/questions/10569663/eclipse-not-picking-up-maven-attached-source-on-debug

I found this com.ifedorenko.m2e.sourcelookup plugin. The link was provided in "Java Debugging: Source not found".
Go to Help > Install New Software .. and use
http://ifedorenko.github.com/m2e-extras/
to search for the links. After installing this plugin I was finally able to debug the source code of dependencies.

Tuesday, February 7, 2017

Download java source from maven

mvn dependency:sources dependency:resolve -Dclassifier=javadoc

Monday, March 14, 2016

Download the source jars for maven

 mvn dependency:sources

Sunday, June 22, 2014

dosa batter & palli chetuney

Dosa batter

1. Add 2 glass of rice & 1 glass of urad dal
2. Add water and leave it for 3hrs
3. with 1 1/2 glass water grind it


Palli Chetuney

1. one table spoon oil, onion, tamarind, 3 mirchi, garlic
2. Peanuts powder, curd, salt
3. Mix #1 & #2 & grind -add 1cup water 
4. Talimp for the above