Mainak Goswami

Ranch Hand
+ Follow
since May 21, 2006
Mainak likes ...
Eclipse IDE Oracle Java
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Mainak Goswami

Any response will be appreciated.
8 years ago
Reference: http://docs.spring.io/spring/docs/3.0.x/spring-framework-reference/html/mvc.html#mvc-servlet

I was going through Spring's official documentation on ApplicationContext and WebApplication Context. However I am getting confused with the use of similar terminologies. e.g. In the diagram - "Context hierarchy in Spring Web MVC" from the official documentation link above it is mentioned that

ApplicationContext instances in Spring can be scoped. In the Web MVC framework, each DispatcherServlet has its own WebApplicationContext, which inherits all the beans already defined in the root WebApplicationContext. These inherited beans can be overridden in the servlet-specific scope, and you can define new scope-specific beans local to a given servlet instance.
My understanding is that both ApplicationContext and WebApplication context are the spring containers where WebApplicationContext is child of the ApplicationContext interface.



Question 1 So in the diagram "Context hierarchy in Spring Web MVC" what is the use of root WebApplicationContext? Is this same as ApplicationContext which is defined from applicationContext.xml file?

Question 2 Why can there be multiple WebApplicationContext (s) e.g. services, datasources etc.if ApplicationContext is considered to be the root context for every web application.
8 years ago
You can consider the abstract factory pattern as parent of factory method pattern...basically the abstract factory represents multiple factories and provide a single view to the client.

Abstract Factory Design Pattern provides an interface for creating families of related or dependent objects without specifying their concrete classes.


example in j2ee:
Data Access Object in JEE uses the (GoF) Abstract Factory Pattern to create various product DAO from RdbDAOFactory, XmlDAOFactory, OdbDAOFactory.

Tried to explain with example in the following articles:
abstract factory : http://idiotechie.com/abstract-factory-design-pattern-explained/
factory method: http://idiotechie.com/design-best-practices-using-factory-method-pattern/

Hope this helps.
I am still able to access this link. Anyways you can also get the hard copy of this book anywhere:
Core J2EE Patterns: Best Practices and Design Strategies (2nd Edition)
by deepak Alur
You can also go through the dzone article on Singleton. Though it does not cover anything on J2ee specifications but it is more related to core Java.
http://java.dzone.com/articles/singleton-design-pattern-%E2%80%93
You can try the following article. It shows the basics of the class diagram and also how it can be represented in Java code.
http://idiotechie.com/uml2-class-diagram-in-java/. Hope this is useful.

For the remaining chapters I will suggest to refer Martin Fowler's book on UML Distilled 3rd edition.
Hi Gerd,

Where will I get a book which gives case studies on various problem statements for design?

Cheers
Mainak

Gerd Reichinger wrote:I have now passed the OCMJEA exam parts II & III. My score is 129 of 160 - I actually expected to get a better score but I still want share my experiences.

http://ocmjea-experience.blogspot.co.at/2012/12/passing-ocmjea-exam-part-ii-iii.html

As you may know, I am not allowed to help you with your assignment or to send you my solution - please don't ask for it.

Good luck for your exam.

Greetings,
Gerd.

Well done. And thanks for sharing your experience.
That explains all. Thanks Mike and Tony.
Yes, indeed this is just a personal learning and experiment I was trying to implement iterator design pattern using HashMap - possibly an unsuccessful one as I can see. But your explanation was definitely a very good learning.
11 years ago
Thanks Winston. Got your point.
My HashMap is java.util.HashMap. Please find below what I was trying to do. I was trying to implement the Iterator design pattern.
a) create the Iterator interface....which in this case will be java.utl.iterator
b) create a child class which implements the Iterator interface. Also this class will take the Collection object as an input and run the implemented operations like hasNext(), next() and remove() method. Need to write custom code which will do the iteration to next elements.
c) create Collection interface with createIterator interface.
d) Create child implementation which will implement the createIterator interface by running over the HashMap. We can view the HashMap as a Set.
The HashMap will contain rows of a Key, value pair.

Hope this explains the requirement in detail. Please do advise of a better alternative.

11 years ago
Thanks Jayesh.

To give you little bit more background I am trying to implement iterator design pattern which must consist of ConcreteIterator implementation class. SO I have to provide an implementation of the next(), hasNext() and remove(). I am using a HashMap collection as input parameter.

Once these are done I will call the createIterator from the ConcreteCollection class. Hope I am making some sense.

Please advise if you can suggest a better approach.
11 years ago
Hi,

I am trying to implement a custom iterator using next() over the HashMap. I guess the Iterator provides an abstract view of the collections including the list, array, etc. Basically I am trying to implement the logic inside the next() something like:


Please advise.
Thanks.
11 years ago
Any help or advice?

Mainak Goswami wrote:Hi,

I am looking for some books which provides an in depth view of Applying Gang of Four design pattern. I know we have our favorite Head First series. But what I am looking at is an implementation to practical Software problems and how to apply these patterns individually or together to solve a specific problem example. How to design a real world sample application using GOF patterns etc? Please advise.

Cheers,
Mainak

I was going through this post and I was wondering why do we need to create the ConnectionManager class as singleton?
If we use singleton then it means that the App server will create a single instance of the ConnectionManager class in the App server for that instance of the classloader.
What is the benefit? Is it that we are reducing multiple object creation and restricting the access to one user at a time? How is the ConnectionManager object shared between multiple users?

I can understand the usage of the Singleton Pattern for Print spooler or Logger where we are trying to restrict the usage to one at a time by creating one instance and also we can restrict the concurrent usage by using synchronized. Perhaps after Java 5 we can use enum etc.

It will be really helpful if somebody can explain this usage. Might be very basic which I am not able to understand.

Thanks,
Mainak