Architectural pattern: publisher-subscriber
Written by Mottola Michele - Italy - Reggio Emilia   
Tuesday, 15 September 2015 13:54
AddThis Social Bookmark Button

Introduction

This pattern is also know as ’Observer’ (GoF). The mainly difference is that in architectural patterns there is a distinction for what is a components and what is a connectors. Here i want show just a basic working without this distinction. Besides i want show how implement it using the API of java, utility class that simplify the java implementation.

What is the problem

I have one or more objects (observer or listner or subscriber) that are interested to know when there are some events from another object (subject or publisher) and they want be informed when it happen. When that event happen the subscriber can perform their action that can be different from subscriber to subscriber.

Last Updated on Tuesday, 15 September 2015 14:10
 
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
 
<< Start < Prev 1 2 3 4 5 Next > End >>

Page 2 of 5