![Page 1: آرمان حسينزاده آذر 89 1. Access to data varies depending on the source of the data. Access to persistent storage, such as to a database, varies greatly](https://reader035.vdocument.in/reader035/viewer/2022062803/56649f395503460f94c55bc4/html5/thumbnails/1.jpg)
آرمانحسينزاده89آذر
1
![Page 2: آرمان حسينزاده آذر 89 1. Access to data varies depending on the source of the data. Access to persistent storage, such as to a database, varies greatly](https://reader035.vdocument.in/reader035/viewer/2022062803/56649f395503460f94c55bc4/html5/thumbnails/2.jpg)
Accesstodatavariesdependingonthesourceofthedata.
Accesstopersistentstorage,suchastoadatabase,variesgreatlydependingonthetypeofstorage(relationaldatabases,object-orienteddatabases,flatfiles,andsoforth)andthevendorimplementation.
2
![Page 3: آرمان حسينزاده آذر 89 1. Access to data varies depending on the source of the data. Access to persistent storage, such as to a database, varies greatly](https://reader035.vdocument.in/reader035/viewer/2022062803/56649f395503460f94c55bc4/html5/thumbnails/3.jpg)
persistentstoragewithdifferentmechanisms
differentAPIstoaccessthesedifferentpersistentstoragemechanisms
explicitlyaccessthepersistentstorage directdependencybetweenapplication
codeanddataaccesscode tightcouplingbetweenthecomponentsand
thedatasourceimplementation difficultandtedioustomigratetheapplication
fromonetypeofdatasourcetoanother
3
![Page 4: آرمان حسينزاده آذر 89 1. Access to data varies depending on the source of the data. Access to persistent storage, such as to a database, varies greatly](https://reader035.vdocument.in/reader035/viewer/2022062803/56649f395503460f94c55bc4/html5/thumbnails/4.jpg)
Components needtoretrieveandstoreinformationfrompersistentstoresandotherdatasources
PersistentstorageAPIsvarydependingontheproductvendor
ThereisalackofuniformAPIstoaddresstherequirementstoaccesssuchdisparatesystems
4
![Page 5: آرمان حسينزاده آذر 89 1. Access to data varies depending on the source of the data. Access to persistent storage, such as to a database, varies greatly](https://reader035.vdocument.in/reader035/viewer/2022062803/56649f395503460f94c55bc4/html5/thumbnails/5.jpg)
PortabilityofthecomponentsisdirectlyaffectedwhenspecificaccessmechanismsandAPIsareincludedinthecomponents
Componentsneedtobetransparenttotheactualpersistentstoreordatasourceimplementation
easymigrationtodifferentvendorproducts,differentstoragetypes,anddifferentdatasourcetypes
5
![Page 6: آرمان حسينزاده آذر 89 1. Access to data varies depending on the source of the data. Access to persistent storage, such as to a database, varies greatly](https://reader035.vdocument.in/reader035/viewer/2022062803/56649f395503460f94c55bc4/html5/thumbnails/6.jpg)
Use a Data Access Object (DAO) to abstract and encapsulate all access to the data source. The DAO manages the connection with the data source to obtain and store data.
Intent abstracts the retrieval of data from a data
resourcesuchasadatabase.Theconceptisto "separate a data resource's clientinterfacefromitsdataaccessmechanism
6
![Page 7: آرمان حسينزاده آذر 89 1. Access to data varies depending on the source of the data. Access to persistent storage, such as to a database, varies greatly](https://reader035.vdocument.in/reader035/viewer/2022062803/56649f395503460f94c55bc4/html5/thumbnails/7.jpg)
DAOimplementstheaccessmechanismrequiredtoworkwiththedatasource
datasource persistentstorelikeanRDBMS externalservicelikeaB2Bexchange repositorylikeanLDAPdatabase businessserviceaccessedviaCORBA
DAOcompletelyhidesthedatasourceimplementationdetailsfromitsclients
7
![Page 8: آرمان حسينزاده آذر 89 1. Access to data varies depending on the source of the data. Access to persistent storage, such as to a database, varies greatly](https://reader035.vdocument.in/reader035/viewer/2022062803/56649f395503460f94c55bc4/html5/thumbnails/8.jpg)
interfaceexposedbytheDAOtoclientsdoesnotchangewhentheunderlyingdatasourceimplementationchanges allowstheDAOtoadapttodifferentstorage
schemeswithoutaffectingitsclientsorbusinesscomponents
Essentially,theDAOactsasanadapterbetweenthecomponentandthedatasource
8
![Page 9: آرمان حسينزاده آذر 89 1. Access to data varies depending on the source of the data. Access to persistent storage, such as to a database, varies greatly](https://reader035.vdocument.in/reader035/viewer/2022062803/56649f395503460f94c55bc4/html5/thumbnails/9.jpg)
9
![Page 10: آرمان حسينزاده آذر 89 1. Access to data varies depending on the source of the data. Access to persistent storage, such as to a database, varies greatly](https://reader035.vdocument.in/reader035/viewer/2022062803/56649f395503460f94c55bc4/html5/thumbnails/10.jpg)
10
![Page 11: آرمان حسينزاده آذر 89 1. Access to data varies depending on the source of the data. Access to persistent storage, such as to a database, varies greatly](https://reader035.vdocument.in/reader035/viewer/2022062803/56649f395503460f94c55bc4/html5/thumbnails/11.jpg)
BusinessObject (Client) objectthatrequiresaccesstothedata
sourcetoobtainandstoredata
DataAccessObject primaryobjectofthispattern abstractstheunderlyingdataaccess
implementationfortheBusinessObject enabletransparentaccesstothedata
source BusinessObjectalsodelegatesdataloadand
storeoperationstotheDataAccessObject11
![Page 12: آرمان حسينزاده آذر 89 1. Access to data varies depending on the source of the data. Access to persistent storage, such as to a database, varies greatly](https://reader035.vdocument.in/reader035/viewer/2022062803/56649f395503460f94c55bc4/html5/thumbnails/12.jpg)
DataSource representsadatasourceimplementation couldbeadatabasesuchasanRDBMS,
OODBMS,XMLrepository,flatfilesystem,andsoforth
TransferObject TransferObjectusedasadatacarrier DataAccessObjectmayuseaTransferObject
toreturndatatotheclient DataAccessObjectmayalsoreceivethedata
fromtheclientinaTransferObjecttoupdatethedatainthedatasource
12
![Page 13: آرمان حسينزاده آذر 89 1. Access to data varies depending on the source of the data. Access to persistent storage, such as to a database, varies greatly](https://reader035.vdocument.in/reader035/viewer/2022062803/56649f395503460f94c55bc4/html5/thumbnails/13.jpg)
Factory for Data Access Objects Strategy highlyflexiblebyadoptingtheAbstract
FactoryandtheFactoryMethod
Whentheunderlyingstorageisnotsubjecttochangefromoneimplementationtoanother,thisstrategycanbeimplementedusingtheFactoryMethodpatterntoproduceanumberofDAOsneededbytheapplication
13
![Page 14: آرمان حسينزاده آذر 89 1. Access to data varies depending on the source of the data. Access to persistent storage, such as to a database, varies greatly](https://reader035.vdocument.in/reader035/viewer/2022062803/56649f395503460f94c55bc4/html5/thumbnails/14.jpg)
14
Factory for Data Access Object strategy using Factory Method
![Page 15: آرمان حسينزاده آذر 89 1. Access to data varies depending on the source of the data. Access to persistent storage, such as to a database, varies greatly](https://reader035.vdocument.in/reader035/viewer/2022062803/56649f395503460f94c55bc4/html5/thumbnails/15.jpg)
Whentheunderlyingstorageissubjecttochangefromoneimplementationtoanother,thisstrategymaybeimplementedusingtheAbstractFactorypattern
15
![Page 16: آرمان حسينزاده آذر 89 1. Access to data varies depending on the source of the data. Access to persistent storage, such as to a database, varies greatly](https://reader035.vdocument.in/reader035/viewer/2022062803/56649f395503460f94c55bc4/html5/thumbnails/16.jpg)
16
![Page 17: آرمان حسينزاده آذر 89 1. Access to data varies depending on the source of the data. Access to persistent storage, such as to a database, varies greatly](https://reader035.vdocument.in/reader035/viewer/2022062803/56649f395503460f94c55bc4/html5/thumbnails/17.jpg)
17
![Page 18: آرمان حسينزاده آذر 89 1. Access to data varies depending on the source of the data. Access to persistent storage, such as to a database, varies greatly](https://reader035.vdocument.in/reader035/viewer/2022062803/56649f395503460f94c55bc4/html5/thumbnails/18.jpg)
Enables Transparency implementationdetailsarehiddeninsidethe
DAO.
Enables Easier Migration migrationinvolveschangesonlytotheDAOlayer
Reduces Code Complexity in Business Objects implementation-relatedcode(suchasSQL
statements)iscontainedintheDAOandnotinthebusinessobject
18
![Page 19: آرمان حسينزاده آذر 89 1. Access to data varies depending on the source of the data. Access to persistent storage, such as to a database, varies greatly](https://reader035.vdocument.in/reader035/viewer/2022062803/56649f395503460f94c55bc4/html5/thumbnails/19.jpg)
Centralizes All Data Access into a Separate Layer dataaccesslayercanbeviewedasthelayer
thatcanisolatetherestoftheapplicationfromthedataaccessimplementation
Adds Extra Layer Needs Class Hierarchy Design
hierarchyofconcreteproductsproducedbythefactoriesneedtobedesignedandimplemented
increasesthecomplexityofthedesign
19
![Page 20: آرمان حسينزاده آذر 89 1. Access to data varies depending on the source of the data. Access to persistent storage, such as to a database, varies greatly](https://reader035.vdocument.in/reader035/viewer/2022062803/56649f395503460f94c55bc4/html5/thumbnails/20.jpg)
Implementing the DAO pattern
20
![Page 21: آرمان حسينزاده آذر 89 1. Access to data varies depending on the source of the data. Access to persistent storage, such as to a database, varies greatly](https://reader035.vdocument.in/reader035/viewer/2022062803/56649f395503460f94c55bc4/html5/thumbnails/21.jpg)
Using Factory Method Pattern
21
![Page 22: آرمان حسينزاده آذر 89 1. Access to data varies depending on the source of the data. Access to persistent storage, such as to a database, varies greatly](https://reader035.vdocument.in/reader035/viewer/2022062803/56649f395503460f94c55bc4/html5/thumbnails/22.jpg)
Using Abstract Factory Pattern
22
![Page 23: آرمان حسينزاده آذر 89 1. Access to data varies depending on the source of the data. Access to persistent storage, such as to a database, varies greatly](https://reader035.vdocument.in/reader035/viewer/2022062803/56649f395503460f94c55bc4/html5/thumbnails/23.jpg)
23
![Page 24: آرمان حسينزاده آذر 89 1. Access to data varies depending on the source of the data. Access to persistent storage, such as to a database, varies greatly](https://reader035.vdocument.in/reader035/viewer/2022062803/56649f395503460f94c55bc4/html5/thumbnails/24.jpg)
24
![Page 25: آرمان حسينزاده آذر 89 1. Access to data varies depending on the source of the data. Access to persistent storage, such as to a database, varies greatly](https://reader035.vdocument.in/reader035/viewer/2022062803/56649f395503460f94c55bc4/html5/thumbnails/25.jpg)
25
![Page 26: آرمان حسينزاده آذر 89 1. Access to data varies depending on the source of the data. Access to persistent storage, such as to a database, varies greatly](https://reader035.vdocument.in/reader035/viewer/2022062803/56649f395503460f94c55bc4/html5/thumbnails/26.jpg)
26
![Page 27: آرمان حسينزاده آذر 89 1. Access to data varies depending on the source of the data. Access to persistent storage, such as to a database, varies greatly](https://reader035.vdocument.in/reader035/viewer/2022062803/56649f395503460f94c55bc4/html5/thumbnails/27.jpg)
27
![Page 28: آرمان حسينزاده آذر 89 1. Access to data varies depending on the source of the data. Access to persistent storage, such as to a database, varies greatly](https://reader035.vdocument.in/reader035/viewer/2022062803/56649f395503460f94c55bc4/html5/thumbnails/28.jpg)
28
![Page 29: آرمان حسينزاده آذر 89 1. Access to data varies depending on the source of the data. Access to persistent storage, such as to a database, varies greatly](https://reader035.vdocument.in/reader035/viewer/2022062803/56649f395503460f94c55bc4/html5/thumbnails/29.jpg)
29
![Page 30: آرمان حسينزاده آذر 89 1. Access to data varies depending on the source of the data. Access to persistent storage, such as to a database, varies greatly](https://reader035.vdocument.in/reader035/viewer/2022062803/56649f395503460f94c55bc4/html5/thumbnails/30.jpg)
Transfer Object ADAOusesTransferObjectstotransport
datatoandfromitsclients.
Factory Method and Abstract Factory The Factory for Data Access Objects
Strategy usestheFactoryMethodpatterntoimplementtheconcretefactoriesanditsproducts(DAOs).Foraddedflexibility,theAbstractFactorypatternmaybeemployedasdiscussedinthestrategies.
30
![Page 31: آرمان حسينزاده آذر 89 1. Access to data varies depending on the source of the data. Access to persistent storage, such as to a database, varies greatly](https://reader035.vdocument.in/reader035/viewer/2022062803/56649f395503460f94c55bc4/html5/thumbnails/31.jpg)
31