I am working recently in a JAVA EE project, where i have to check and understand existent code.
the project architecture is Core,DAO,Manager,Web
...
In Core
, we are supposed to write the POJO class that will later persist !
What i don't understand, why the developer is using interface first to define a User
where he just expose some essential method used by other module (Web
...) then he define the interface implementation to use it in the core
module.
Is this a well known Design pattern ? if so What is it name ? thx
Asked
Active
Viewed 156 times
-1

Omar
- 31
- 5
-
If I get it right, here lies the answer http://stackoverflow.com/questions/383947/what-does-it-mean-to-program-to-an-interface – digital illusion Mar 03 '15 at 09:27
-
1Maybe what you're looking at is [Inversion of Control](http://stackoverflow.com/questions/3058/what-is-inversion-of-control) – Tommaso Bertoni Mar 03 '15 at 09:29
-
Also read up on Separation of Concerns (SoC) http://en.wikipedia.org/wiki/Separation_of_concerns - for open source projects using IoC/DI check out Spring. – chrisburke.io Mar 03 '15 at 09:56
1 Answers
0
Well this is a well known design pattern named Bridge, we use it when we want to reduce coupling between two different layers.
Suppose we have a business class that use DAO methods to persist data. The business class have only an instance of type Dao interface, so we are free to implement as much as Dao class we want, without any change in the businesss class.
PS: POJO class should not have to implement prespecified interfaces ! The use of interface in this case isn't appropriate but as I said you can use this pattern to solve problem of tight coupling

user3728064
- 158
- 1
- 11