Concurrency pattern: Producer-consumer
Written by Mottola Michele - Italy - Reggio Emilia   
Monday, 07 September 2015 09:39
AddThis Social Bookmark Button

What is the problem

Basically this pattern solve the problem of a buffer, in which one or more Producer can push a data and one or more Consumer can pull a data. There are a couple of problems that can arise: the first is catch to ’race condition’, indeed since to the buffer can access more productors and consumers at the same time, can arise problems of inconsistency data. The second problem is catch to ’deadlock’, mean a lock of system.

Last Updated on Tuesday, 08 September 2015 18:39
 
Design pattern visitor with java reflection
Written by Mottola Michele - Italy - Reggio Emilia   
Saturday, 11 April 2015 09:26
AddThis Social Bookmark Button

What is the problem

I have a collection of object of different type and i want add some behaviour without modify existing classes. More specific i want add different behaviour based on object's type.
In our case i have objects of type Ferrari and Maserati and i want modify the property colour of this objects and print some message when i do that (this is the new behaviour). Due to this i want object of Ferrari in red and object of Maserati in blue.

Last Updated on Saturday, 11 April 2015 09:34
 
Design pattern mediator and java implementation
Written by Mottola Michele - Italy - Reggio Emilia   
Thursday, 04 December 2014 14:26
AddThis Social Bookmark Button

what is the problem

I have some object and they need to communitate each other and i want a software that do it

the soluzion of mediator

The first, not best solution, is programming the objects (collegues) so that each object can communicate with all other objects.
But in this way i have hight coupling between objects. We want avoid this.
The best solution is to use an object (mediator) through each object can communicate.

Last Updated on Thursday, 04 December 2014 14:55
 
Design pattern decorator and java implementation
Written by Mottola Michele - Italy - Reggio Emilia   
Sunday, 23 November 2014 18:47
AddThis Social Bookmark Button

what is the problem

The design pattern decorator is used in this case: i have some object and i want to add responsability.

what is the solution of decorator

To solve this problem i can use inheritance, but as we know the inheritance has some drawback and is to prefer composition over inheritance.
Alternative solution is the decorator design pattern that use composition.
Practically the decorator is a wrapper for the object whereto i want add responsability.
The advantage of this pattern is that we can add responsability at run-time, we can easily combine them and we can add responsability at some object or all.
To do that we don't have violate some bacis software design principles as SRP and OCP.

Last Updated on Sunday, 23 November 2014 19:03
 
<< Start < Prev 1 2 3 4 Next > End >>

Page 2 of 4