Theory
Partsને સાથે કામ કરાવવું
તમારી પાસે front end, back end અને database design તૈયાર છે. Integration એ આ બધા parts અને બહારની servicesને એક working systemમાં connect કરવાની phase છે. આ અલગ અને ઘણીવાર tricky phase છે, કારણ કે દરેક ભાગ એકલો કામ કરતો હોય છતાં બધું સાથે કામ ન પણ કરે.
ત્રણ connections મહત્વની છે: back end અને database વચ્ચે, back end અને external APIs વચ્ચે, તથા front end અને back end વચ્ચે. આ lesson integration કરવાની રીત અને તેને early તથા carefully કરવાથી surprises કેવી રીતે ટળે છે તે સમજાવે છે. Integration partsના collectionને actual applicationમાં ફેરવે છે.
Theory
Database અને external APIs
Back end તમારા database સાથે data store અને retrieve કરવા connect થાય છે. આ connection માટે ER diagramમાં design કરેલી structure વાપરો. આ core integration છે: તમારી business logic actual persistent data read અને write કરે છે.
Back end external APIs સાથે પણ connect થઈ શકે છે. આ એવી third-party services છે જેને તમે જાતે build કરવાને બદલે call કરો છો. Examples: payments માટે payment gateway, locations માટે maps service, notifications માટે email અથવા SMS service, અને authentication માટે Firebase.
External APIs semesterમાં જાતે બનાવી ન શકાય તેવી complex capabilities આપે છે, પરંતુ systemમાં dependency ઉમેરે છે. Service down હોય, request reject કરે અથવા અલગ error આપે તો તેને handle કરવું પડે છે. તેથી documentation ધ્યાનથી વાંચો અને external-service errors માટે તૈયાર રહો.
Formula
વહેલું integrate કરો અને surprises expect કરો
Hard-won advice: early અને incrementally integrate કરો. Front end અને back endને અઠવાડિયાઓ સુધી સંપૂર્ણ અલગ રાખીને અંતે જ connect ન કરો. Integration વખતે જ hidden problems દેખાય છે: mismatched data formats, authentication issues, external API errors અને assumptionsથી અલગ behaviour.
બધી integration last minute સુધી મુલતવી રાખશો તો fix કરવા સમય નહીં રહે. તેના બદલે build કરતી વખતે partsને ધીમે ધીમે connect કરો, દરેક integration point test કરો અને errors gracefully handle કરો. Parts individually કામ કરે છે તે system working હોવાનો proof નથી; system working છે તે integration જ સાબિત કરે છે.
Quiz
Front end, back end, database અને external APIsને અંતે નહીં પરંતુ early અને incrementally integrate શા માટે કરવાં જોઈએ?
- કારણ કે integration first time હંમેશા perfectly કામ કરે છે
- કારણ કે integration વખતે mismatched formats, authentication અને errors જેવી hidden problems બહાર આવે છે, અને વહેલું connect કરવાથી તેમને શોધવા તથા fix કરવા સમય મળે છે
- કારણ કે partsને ક્યારેય connect કરવાની જરૂર નથી
- Project લાંબો કરવા માટે
Show the answer
કારણ કે integration વખતે mismatched formats, authentication અને errors જેવી hidden problems બહાર આવે છે, અને વહેલું connect કરવાથી તેમને શોધવા તથા fix કરવા સમય મળે છે
Early અને incremental integration જરૂરી છે કારણ કે integration વખતે mismatched data formats, authentication issues, external-service errors અને assumptionsથી અલગ behaviour જેવી hidden problems બહાર આવે છે. વહેલું connect કરવાથી deadline પહેલાં problems શોધી અને fix કરી શકાય છે. Option A dangerous છે: integration first time perfect રહેતી નથી. Option C ખોટું છે: projectનો હેતુ partsને એક working systemમાં connect કરવાનો છે. Option D ખોટું છે: early integration overall time બચાવે છે, કારણ કે problems નાના હોય ત્યારે fix થાય છે. Parts individually work કરે છે તે system work કરે છે એવું નથી.
Think first
દરેક part અલગથી કામ કરતો હોવા છતાં connect થયા પછી fail કેમ થાય?
Front end કામ કરે છે અને back end પણ કામ કરે છે. છતાં બંને connect કરતાં નવા problems કેમ દેખાય છે? પછી tap.
Show the answer
કારણ કે separately build થયેલા parts ઘણીવાર એકબીજા વિશે અલગ ASSUMPTIONS પર આધારિત હોય છે. દરેક part એકલો test થાય ત્યારે પોતાની assumptions consistent હોય છે, પરંતુ integration point પર બંનેની expectations મળે છે અને mismatch બહાર આવે છે.
ઉદાહરણ તરીકે front end dateને text તરીકે મોકલે અને back end number expect કરે; back end fieldનું નામ એક રાખે અને front end બીજું નામ વાંચે; API authentication token માંગે પરંતુ front end token attach ન કરે; external service unexpected error format આપે; અથવા data field database columnની limit કરતાં લાંબું હોય.
આ problems isolationમાં દેખાતા નથી કારણ કે દરેક side પોતાની assumption પ્રમાણે test થાય છે. Integration વખતે real data અને real behaviour એકબીજાની expectations સાથે મળે છે. Authentication across boundaries, remote-call failure handling, network issues, data format agreement અને timing જેવી નવી concerns પણ parts વચ્ચે જ ઊભી થાય છે.
Remedy છે early અને incremental integration. Build કરતી વખતે real interaction connect કરીને test કરો, જેથી mismatched assumptions નાના હોય ત્યારે reconcile કરી શકો. Integration testingનો હેતુ પણ આ જ છે. 'મારો part કામ કરે છે' અને 'whole system કામ કરે છે' અલગ બાબતો છે. Partsને early wire કરો અને દરેક connection test કરો.
Summary
Key takeaways
- Integration front end, back end, database અને external APIs જેવા separately built partsને એક working systemમાં જોડે છે.
- Back end ER design પ્રમાણે database સાથે data store અને retrieve કરવા connect થાય છે.
- Back end payments, maps, email/SMS અથવા Firebase auth જેવી external APIs call કરી શકે છે.
- External APIs complex capabilities આપે છે, પરંતુ dependency ઉમેરે છે; તેમની documentation વાંચો અને errors handle કરો.
- Front end API calls દ્વારા back end સાથે connect થાય છે.
- Integration વહેલું અને incrementally કરો, કારણ કે mismatched formats, authentication અને errors જેવી hidden problems અહીં બહાર આવે છે.
- Memory hook: partsને early wire કરો અને દરેક connection test કરો; parts individually working હોવું whole system working હોવાનો proof નથી.