Data Transfer Objects sau ce sunt DTO-urile si de ce le-as folosi

Stefanescu Mihai 9 months ago Clean Code

Un DTO (sau Data Transfer Object) este un obiect ce transfera date intre procese. Puteti folosi aceasta tehnica pentru a imbunatati comunicarea intre 2 sisteme (de exemplu intre 2 API-uri) avand o structura fixa si asigurand transportul datelor intr-un mod organizat.

Ce este un DTO?

Cum am zis si mai sus, DTO vine de la data transfer object si este exact ce ne spune numele, un obiect ce transfera datele intre procese.
In mod normal, vei intlani acest tip de obiecte in limbaje orientate pe obiecte precum PHP, Python, C++, Java si altele.

O buna parte din programarea orientata pe obiecte este formata din "apeluri" de procese si/sau API-uri pentru a prelua sau trimite date fie in aceasi aplicatie intre bundle-uri fie intre aplicatii diferite.

De asemenea, DTO-urile pot fi folosite si pe post de "contract" intre 2 aplicatii.  Presupunand ca una dintre aplicatii trebuie sa trimita un set de informatii catre cealalta acestea pot comunica folosind un DTO in felul urmator.
Prima aplicatie completeaza DTO-ul si il serializeaza, iar a doua cand il primeste il deserializeaza, astfel stiind atat structura exacta a mesajului, cat si integritatea datelor.

De ce as folosi un DTO?

DTO-urile ne ajuta sa avem mai multa claritate si corectitudine in cod, pentur ca intotdeauna vom sti ce date se trimit intre bundle-uri sau intre aplicatii si ne ajuta sa stim ca acele date sunt corecte (conform structurii DTO-ului).

pentru acest articol m-am inspirat de aici.

Programator de ~8 ani, am lucrat la proiecte din mai multe industrstrii, de la eCommerce la telecomunicatii la automatizari. In acest timp am folosi diferite tehnologii, de la PHP, MySQL, PostgreSql, RabbitMq, Redis, Memcached si altele.

Get in touch
Pentru nelamuriri, dubii, comentarii si chestii de pe suflet ne putem auzi pe Discord, Reddit sau poti deschide o discutie noua pe forum

precio de buspar con receta en Bruselas # 1 month ago Hmm it seems like your blog ate my first comment (it was extremely long) so I guess I'll just sum it up what I submitted and say, I'm thoroughly enjoying your blog. I as well am an aspiring blog blogger but I'm still new to the whole thing. Do you have any points for newbie blog writers? I'd certainly appreciate it.
prix du nufloxib # 1 month ago I am now not certain where you are getting your information, however good topic. I needs to spend a while studying much more or figuring out more. Thank you for great information I used to be searching for this information for my mission.
Orymnp # 1 month ago order tricor 200mg generic <a href="">fenofibrate over the counter</a> buy fenofibrate 160mg without prescription
prix du sildenafil 50 mg au Maroc # 1 month ago Magnificent beat ! I would like to apprentice while you amend your website, how can i subscribe for a blog web site? The account aided me a acceptable deal. I had been tiny bit acquainted of this your broadcast offered bright clear idea
Uxayof # 1 month ago zaditor 1mg uk <a href="">buy ziprasidone pills for sale</a> brand tofranil 75mg
Iiaius # 1 month ago precose 50mg usa <a href="">precose 25mg uk</a> order fulvicin 250mg sale
Hjudrq # 1 month ago buy generic minoxytop <a href="">oral flomax</a> best ed pill
Sexwge # 4 weeks ago purchase aspirin generic <a href="">buy generic imiquimod</a> buy imiquimod generic
clomiphene 50 à acheter en ligne # 4 weeks ago A person necessarily lend a hand to make critically posts I'd state. This is the first time I frequented your website page and thus far? I surprised with the research you made to make this actual post incredible. Magnificent activity!
Monika # 4 weeks ago Today, I went to the beach front with my kids. I found a sea shell and gave it to my 4 year old daughter and said "You can hear the ocean if you put this to your ear." She placed the shell to her ear and screamed. There was a hermit crab inside and it pinched her ear. She never wants to go back! LoL I know this is completely off topic but I had to tell someone!
Alyce # 3 weeks ago In fact no matter if someone doesn't know afterward its up to other people that they will help, so here it takes place.
Qzdaiz # 3 weeks ago purchase florinef online cheap <a href="">buy generic rabeprazole 10mg</a> buy imodium pills
Aggcez # 3 weeks ago duphaston cheap <a href="">order generic januvia</a> jardiance 10mg cheap
Wiqrai # 3 weeks ago buy prasugrel 10mg online <a href="">buy chlorpromazine 50 mg pills</a> buy tolterodine 1mg for sale
Ichact # 2 weeks ago buy etodolac no prescription <a href="">order monograph 600mg pills</a> buy generic cilostazol
Adocju # 2 weeks ago pill ferrous sulfate 100 mg <a href="">generic risedronate 35mg</a> order sotalol 40mg generic
nordette online kaufen in Österreich # 2 weeks ago Appreciate the recommendation. Let me try it out.
Eiiygt # 2 weeks ago buy pyridostigmine sale <a href="">buy pyridostigmine 60mg pills</a> rizatriptan 5mg generic
Mcuduy # 1 week ago betahistine pills <a href="">probenecid online buy</a> order probenecid 500mg for sale
Qtnbsw # 1 week ago how to buy zovirax <a href="">xeloda 500 mg sale</a> generic exelon 3mg
acheter atridox en Belgique sans problème # 1 week ago Do you have a spam issue on this site; I also am a blogger, and I was wondering your situation; many of us have created some nice methods and we are looking to exchange methods with others, be sure to shoot me an email if interested.
Owviyo # 1 week ago buy generic telmisartan 20mg <a href="">plaquenil 200mg drug</a> molnunat order
Wrovtw # 6 days ago cenforce us <a href="">order aralen 250mg online</a> oral chloroquine 250mg
Rmppff # 3 days ago buy omnicef tablets <a href="">order omnicef 300mg</a> order lansoprazole 30mg pill
Club-ul este dedicat membrilor si ofera access la mai multe zone ale website-ului.
Login Register

🔖 Bookmarks
✨ Pentru a sustine aceasta comunitate am sa te rog sa te autentifici sau sa te inregistrezi!

🌪️ Discord
Back to top
Folosim cookie-uri pentru a oferi functionalitatile critice ale aplicatiei Invata-Programare. Folosim cookie-uri si pentru a analiza traficul, pentru care e nevoie de consimtamantul dvs. explicit.