Lub caij nplooj ntoos hlav khau raj DTO yog dab tsi?
Lub caij nplooj ntoos hlav khau raj DTO yog dab tsi?

Video: Lub caij nplooj ntoos hlav khau raj DTO yog dab tsi?

Video: Lub caij nplooj ntoos hlav khau raj DTO yog dab tsi?
Video: SUAB ZAJ TSHOOB, ntxhais yuav hla niam txiv lub taw rooj mus ua nyab 2024, Kaum ib hlis
Anonim

DTO , uas sawv cev rau Cov Ntaub Ntawv Hloov Cov Khoom, yog tus qauv tsim tsim los txo cov xov tooj hu thaum ua haujlwm nrog cov chaw taws teeb interfaces. Raws li Martin Fowler txhais hauv nws qhov blog, qhov laj thawj tseem ceeb ntawm kev siv Cov Ntaub Ntawv Hloov Cov Ntaub Ntawv yog txhawm rau txhawm rau ua dab tsi yuav yog ntau qhov chaw taws teeb hu rau hauv ib qho.

Raws li, DTO yog dab tsi nyob rau lub caij nplooj ntoo hlav?

Cov Ntaub Ntawv Hloov Khoom DTO yog ib yam khoom uas nqa cov ntaub ntawv ntawm cov txheej txheem. Thaum koj ua haujlwm nrog cov chaw taws teeb interface, txhua tus hu nws kim. Yog li ntawd koj yuav tsum tau txo tus xov tooj hu. Feem ntau ib tug assembler yog siv nyob rau sab server rau hloov cov ntaub ntawv ntawm lub DTO thiab tej yam khoom siv.

Ib tug kuj nug, DTO qauv yog dab tsi? Ib Qhov Kev Hloov Cov Ntaub Ntawv ( DTO ) yog ib qho khoom siv los nqa cov ntaub ntawv, piv txwv li ntawm tus neeg siv khoom thiab lub server lossis nruab nrab ntawm UI thiab cov txheej txheem sau npe. Qee zaum a DTO tuaj yeem pom raws li tus kab mob anemic qauv . DTOs feem ntau yog siv tawm ntawm lub hexagon, nyob rau hauv tus me nyuam mechanism.

Hauv qhov no, DAO thiab DTO yog dab tsi nyob rau lub caij nplooj ntoo hlav?

DAO yog ib chav kawm uas feem ntau muaj cov haujlwm CRUD xws li txuag, hloov tshiab, rho tawm. DTO tsuas yog ib yam khoom uas tuav cov ntaub ntawv. Nws yog JavaBean nrog piv txwv hloov pauv thiab setter thiab getters. DTO yuav dhau raws li tus nqi kwv yees rau DAO txheej thiab DAO txheej yuav siv cov khoom no mus txuas ntxiv cov ntaub ntawv siv nws txoj kev ua haujlwm CRUD.

Dab tsi yog qhov txawv ntawm Dao thiab DTO?

DTO yog ib lub npe luv rau Data Transfer Object, yog li nws yog siv los hloov cov ntaub ntawv nruab nrab chav kawm thiab modules ntawm koj daim ntawv thov. DAO yog ib qho luv luv rau Cov Ntaub Ntawv Nkag Mus Nkag, yog li nws yuav tsum encapsulate lub logic rau retrieving, txuag thiab hloov kho cov ntaub ntawv hauv koj cov ntaub ntawv khaws cia (cov ntaub ntawv, cov ntaub ntawv-system, txawm li cas los xij).

Pom zoo: