Theory
Build करने से पहले Design कीजिए
आप एक plan के बिना एक house build नहीं करेंगे, और आपको एक design के बिना software build नहीं करना चाहिए। Requirements से directly code तक jump करना एक tangled, unplanned mess produce करता है जो build करना hard, test करना harder, और एक team के across divide करना impossible है।
System design पहले structure plan करना है, और यह दो levels पर होता है: high-level design (big picture) और low-level design (हर part के अंदर की details)। यह lesson दोनों explain करता है। दोनों levels पर design करना एक vague idea को एक clear blueprint में बदल देता है जिससे आपकी team confidently build कर सके, parallel में, एक-दूसरे पर कदम रखे बिना।
Theory
High-Level Design: Big Picture
High-level design (HLD) system का bird's-eye view है। यह major modules या components identify करता है (उदाहरण के लिए: एक user-authentication module, एक event module, एक registration module, एक reporting module), दिखाता है ये कैसे interact करते हैं, और overall architecture और इनके बीच data के flow को lay out करता है।
HLD answer करता है: main parts क्या हैं, और ये साथ कैसे fit होते हैं? यह वहाँ है जहाँ आप किसी भी internal detail की worry करने से पहले system का shape decide करते हैं। एक good HLD पूरी team को एक glance में structure देखने देता है और समझने देता है उनका piece दूसरों से कैसे connect होता है। यह पूरे system का map है।
Theory
Low-Level Design: हर Part के अंदर
Low-level design (LLD) हर module पर zoom करता है और इसके internals detail करता है: वह classes, functions या methods, data structures, algorithms, और logic जो उस module को काम कराते हैं।
LLD answer करता है: हर part अंदर कैसे काम करता है? Registration module के लिए, LLD functions specify करता (register, cancel, list attendees), वह data जो ये इस्तेमाल करते हैं, और ये कैसे behave करते हैं। जहाँ HLD map देता है, LLD इस पर हर building के लिए detailed plans देता है।
साथ में, HLD और LLD पूरे system से लेकर हर part के workings तक span करते हैं, तो जब आप finally code करें, आप एक clear design implement कर रहे हैं fly पर structure invent करने की बजाय। पहले दोनों levels पर design कीजिए; फिर code कीजिए।
Quiz
इनमें से कौन सा high-level design (HLD) का हिस्सा है, low-level design (LLD) की बजाय?
- Registration module के अंदर exact functions और इनका logic
- System के major modules identify करना (authentication, events, registration, reporting) और ये कैसे interact करते हैं
- एक single class के अंदर इस्तेमाल हुए data structures
- एक method के लिए step-by-step algorithm
Show the answer
System के major modules identify करना (authentication, events, registration, reporting) और ये कैसे interact करते हैं
High-level design (HLD) big-picture view है: major modules identify करना (authentication, events, registration, reporting) और ये कैसे interact करते हैं, system की overall structure। Option B exactly यही है। Options A, C, और D सभी low-level design (LLD) concerns हैं: specific functions और इनका logic, एक class के अंदर data structures, और एक method का step-by-step algorithm ये सब individual modules की internal DETAILS हैं। HLD answer करता है 'parts क्या हैं और ये कैसे fit होते हैं?'; LLD answer करता है 'हर part अंदर कैसे काम करता है?'। Module-level structure HLD है; internal workings LLD हैं।
Think first
Modules Code करना Start करने की बजाय दो Levels पर Design क्यों करें?
Code में dive करने की बजाय separate high-level और low-level design क्यों bother करें? फिर tap कीजिए।
Show the answer
क्योंकि दो levels पर design करना आपको code को commit करने से पहले STRUCTURE सही पाने देता है, जो costly rework रोकता है, team को parallel में काम करने देता है, और system को understandable बनाता है, जबकि design के बिना coding एक tangled mess produce करने की tendency रखता है जो build करना, test करना, और change करना painful है। दोनों levels अलग, दोनों-necessary purposes serve करते हैं। HIGH-LEVEL design पहले big questions settle करता है: major parts क्या हैं, ये कैसे interact करते हैं, और overall shape क्या है? इसे early सही पाना crucial है क्योंकि इसे बाद में change करना EXPENSIVE है, अगर आप coding के आधे रास्ते discover करते हैं आपके modules wrongly divided हैं या साथ fit नहीं होते, आपको बहुत सारा काम rip up और rewrite करना पड़ सकता है। HLD TEAM को work sensibly divide करने भी देता है: एक बार हर कोई modules और इनके interfaces देख सके, अलग-अलग लोग अलग-अलग modules PARALLEL में build कर सकते हैं, confident कि pieces connect होंगे, जो impossible है अगर structure लोगों के code करते हुए ad hoc invent हो रही है। LOW-LEVEL design फिर implementation से पहले work out करता है हर module अंदर कैसे function करता है, इसकी classes, functions, और logic, तो जब आप code करें, आप एक clear plan को code में translate कर रहे हैं simultaneously design और code करने की बजाय (जहाँ confusion और bugs breed होते हैं)। दोनों करने का मतलब है कि जब तक आप code लिखें, structure और logic के बारे में hard thinking पहले से done है, तो coding एक focused, confident activity बन जाती है dark में groping की बजाय। Design DOCUMENTATION और shared understanding भी produce करता है: diagrams और specs जो team, और बाद में evaluators, follow कर सकते हैं। 'Time बचाने' के लिए design skip करना एक false economy है: upfront बचाया time usually rework, integration problems, और एक ऐसी structure debug करने में कई गुना lost हो जाता है जो कभी planned नहीं हुई थी। तो two-level design discipline, पहले big picture फिर details, ही है जो एक project को एक risky improvisation से एक organised build में बदल देता है, जो exactly वजह है professional software code होने से पहले design होता है। दोनों levels पर structure plan कीजिए, और coding smoothly होती है।
Summary
Key takeaways
- System design coding से पहले structure plan करता है, एक tangled, unplanned mess रोकते हुए।
- यह दो levels पर होता है: high-level design (HLD) और low-level design (LLD)।
- HLD big picture है: major modules/components, ये कैसे interact करते हैं, और overall architecture (parts क्या हैं और ये कैसे fit होते हैं?)।
- LLD हर module में zoom करता है: इसकी classes, functions, data structures, algorithms, और logic (हर part अंदर कैसे काम करता है?)।
- HLD map देता है; LLD हर part के लिए detailed plans देता है।
- दोनों levels पर design करना team को parallel में काम करने देता है और coding को एक clear design implement करना बनाता है।
- Memory hook: HLD big picture है (modules और ये कैसे fit होते हैं), LLD close-up है (हर module के अंदर), code करने से पहले design कीजिए।