Course Hive
Search

Welcome

Sign in or create your account

Continue with Google
or
Chain of Responsibility Pattern | Build Cash Dispenser(UML & Code) | System Design
Play lesson

System Design Full Course - Chain of Responsibility Pattern | Build Cash Dispenser(UML & Code) | System Design

5.0 (4)
27 learners

What you'll learn

This course includes

  • 34.3 hours of video
  • Certificate of completion
  • Access on mobile and TV

System Design Full Course Chain of Responsibility Pattern | Build Cash Dispenser(UML & Code) | System Design

Chain of Responsibility Pattern | Build Cash Dispenser(UML & Code) | System Design Transcript and Lesson Notes

حنجی کرے ڈیسٹٹ سو Welcome Back Co-Dur Army in our LLD series اور آج کے سلیکٹر میں ہمیک نیا دیزائیں پیٹن اور بہت ہی انٹرسٹین دیزائیں پیٹن چین او فریس پہنسیلیڈی پیٹن پڑن پڑنے والے یہ پیٹن again a G use case specific design pattern بہت ساری ایسی پروبلومس ہے جو LLD interviews میں بھی

Quick Summary

حنجی کرے ڈیسٹٹ سو Welcome Back Co-Dur Army in our LLD series اور آج کے سلیکٹر میں ہمیک نیا دیزائیں پیٹن اور بہت ہی انٹرسٹین دیزائیں پیٹن چین او فریس پہنسیلیڈی پیٹن پڑن پڑنے والے یہ پیٹن again a G use case specific design pattern بہت ساری ایسی پروبلومس ہے جو LLD interviews میں بھی

Key Takeaways

  • Review the core idea: حنجی کرے ڈیسٹٹ سو Welcome Back Co-Dur Army in our LLD series اور آج کے سلیکٹر میں ہمیک نیا دیزائیں پیٹن اور بہت ہی انٹرسٹین دیزائیں پیٹن چین او فریس پہنسیلیڈی پیٹن
  • Understand how System Design fits into Chain of Responsibility Pattern | Build Cash Dispenser(UML & Code) | System Design.
  • Understand how Low Level Design fits into Chain of Responsibility Pattern | Build Cash Dispenser(UML & Code) | System Design.
  • Understand how High level Design fits into Chain of Responsibility Pattern | Build Cash Dispenser(UML & Code) | System Design.
  • Understand how System Design for Beginner fits into Chain of Responsibility Pattern | Build Cash Dispenser(UML & Code) | System Design.

Key Concepts

Full Transcript

حنجی کرے ڈیسٹٹ سو Welcome Back Co-Dur Army in our LLD series اور آج کے سلیکٹر میں ہمیک نیا دیزائیں پیٹن اور بہت ہی انٹرسٹین دیزائیں پیٹن چین او فریس پہنسیلیڈی پیٹن پڑن پڑنے والے یہ پیٹن again a G use case specific design pattern بہت ساری ایسی پروبلومس ہے جو LLD interviews میں بھی آتی ہیں اور پوچی جاتی ہیں لگا تار جو اس چین او فریس پہنسیلیڈی پیٹن سے سال ہو جائیں گی گیڈیو کے لازت میں مون پروبلومس کو دیسکس بھی کریں گے تو فتح فیڈیو پیٹن سمجھتے ہیں پہلے ہوتا گیا اور فیرون پروبلومس کی درف مفکٹ کرتے ہیں تو دیکھو چین او فریس پہنسیلیڈی پیٹن کو نا سامجنے گلیا اپی ماجن کروں کی آپ کے پاس ایک کلاینت ہے یہ کلاینت ہے اور یہ کریکویسٹ بھیجتے ہیں اور یہ کریکویسٹ جب بھیجتے ہیں کیسی کو اسی بلیڈیدیسکی پیٹن سے لنکلسٹ کیا دائیں گی ہمے شاہ چیگیں تو اتنا بس مجھ گئے کہ ہمارے پاس ایک بہت سارے اپجیکس ہیں جو آبس میں چین سے جو دیا ہے اور کلاینت پہلے والے اپجیک کو کلاک کرتے ہیں جو کی دوسری والے وہ کرتے ہیں جو کی دوسری والے وہ کرتے ہیں ایسے کرتے ہیں جب تک ہمارے پاس اپجیکس کی چین ہے اور فیڈ واپس وہ ایک دوسری کو رسپنز دیتے ہیں کیا جان پیٹی میں جاتھو بہت سی نہیں گالے تو پیسے کہی نہیں گالتے ہیں اس میں اندر what is going to be in the money اس کے اندر کوئی حینلر سوتے ہوگئے جو پیسوں نہیں گالتے ہوگئے اب آپ کو نہیں لگتا جو thousand rupees کی not ہوگے 500 rupees کی not empowerکہ 200 or 100 rupees کی not ہوگے وہ سب اعلag ڈاگ حینلرس کے بہت سوتے ہوگئے لیکن کی ایک ساتھ وہ سارے پیسے نہیں ہو سکتے ہیں ہر پیسے کی دینامیییشن الگیا ہے پیسوں کا تو جب آپ ریکویس بیچتے ہو کہ لیکھ سے میرے کو 3,000 روپے نکال نے ہے تو سپ سے پہلے وہ جاتے ہوگے 1,000 روپی حندلر کے پاس وہ دیکھتا ہوگا کہ کیا میری پس سپیشے نوٹ ہیں اس ریکویسٹ کو فلفل کرنے گیے اور اگر اس کے پاس ہیں تو وہ اس ریکویسٹ کو فلفل کر دیا گا نہیں تو وہ آگے بیچھتا ہوگا تو ایک بڑس کا فلو سبچھتے ہیں ایسے ہوتا ہوگا ایمانجنگروں کہ آپ ایک لینٹ ہو اور آپ جاتے ہو ATM ان کے پاس اینفنائٹ نوٹھ سے ہر دینوینے کے پر جنگر لی ان کے بات ایک فکس ٹمبر افنوٹسی ہوگے حنہ تو چلو اینفنائٹ نہیں ہم مانتے ہمانتے ہمانتے ہمانتے ہمانتے ہمانتے ہمارپس پاچ نوٹے ویلے بل ہے اور سو کے ہمارپس بیز نوٹے ویلے بل ہے چکے اس کو ایسے مانتے ہے اب جب کلائنٹ ہے مانلو وہ پاچھتے ہمارپے نکالنا جاتے تو کیا ہوتا ہوگا کلائنٹ بیسٹاؤگا ریکوست ایک ATM کی طرف اب ATM اُسے كیری فوروٹ کیسے کرتا ہوگا دیکھو سب سے پہلے کلائنٹ بھیجا ATM کو اور ATM نوٹھ اس كیری فوروٹ کی سب سے پہلے حندر 1 کو جو کیا ہمارپس ٹاؤزن روپی دھا حندر وہ دیکھے گا کہ کیا میں سریکوست کو فلفل کر سکتا ہم کیا میں پاچھتے ہمارپس داروپسیدہ اپنے سے نکال سکتا ہم اس کے پہنچ نوٹھ حزار ہزار تو یہ نکال سکتے ہیں یہی سے ریٹنٹ کر دے گا لے بھی پہنچ داروپے اب معلو ایوزر پہنچ دار کی جگا ایوزر کہتا کہ بہی نہیں میر کو تو چھے ہزاروپے نکال میں تو اگی سب سے پہلے ریکوست اگا ہمارے حندر 1 کے پہنچ داروپس کیا میں سریکوست کو فلفل کر سکتا ہم اس کے پہنچ داروپے ہیں پہنچ نوٹھ حزار کے پہنچ دار تو دیسکتا ہے تو کیا کریں گا پہنچ نوٹھ حزار کے نکال دی گا اور باکی حزاروپے کی ریکوست بیز دے گا اس ویہندر کو اس کے پہنچ بہنچ داروپس کو ٹں نوٹھ تو دون ہوں پہنچ داروپس کا نکال داروپے یہ دون ہوںٹھ پہنچ داروپس کا care وییوڑھ ریکوست بھے جیگا ہندر 1 کی بایا ت�نہوںٹھ پہنچ داروپس کا اوپنچ نوٹھ حزار کے نکال کے پہنچ سکتا ہے ہے. ھنی Client کے پاس چھےزار پہچھیں گے. تو اس طرح ابھی مجھن کرو. کوئی بھی دیノی نیشن, جو Client کو نکالنی ہوگی.

لیٹ سے Client کو نکالنے 10 000. تو Same ھگا پہلے اس کے 5 دہ نکلیں گے اور فیر باکی کے 5 دہر یہ نکال دے گا. Right. ایسے کرکے نکلے گا.

اور کوئی بھی اگر ایسا دیノی نیشن ہوگی. جو اس میں Exist ھنی کرتی ہوگی. Manlo. Right.

Client کو نکالنے ہیں. 1 50 Rupees. Right. We have said that we have made the handlers here.

We have made the handlers here. We have said that we have made the handlers here. So what can we say to the client? So you cut this whole transaction.

So that the first request will be handed down. I can't do that. I have 1000 notes. I can't do that.

I can't do that. I can't do that. I can't do that. I can't do that.

I can't do that. I can't do that. I have 100% note. But Client has a date.

We have only 100% note. We have said that we have to fulfill this request. We have not made 50% note. Or we fail the whole transaction.

We fail the entire transaction. We have used this case. But I hope you understood that how this whole whole interact will be. We have multiple handlers.

Right. And they are connected in the same way. With a chain. So what is the name of this principle?

So what is the name of this principle? Chain of responsibility. Design principle. Design pattern.

Right. So now we understand this as a UML. We will ask, how we can guess what we want to say and how to see it as an UML diagram. Right.

So we agree that we have one handler before us. Mine is the mean of the abstract method. Handler. Right.

We have one method that we need to bear with us. Handler request. Or we need to bear with us. Because the money is doing dispensions.

Right. We need to bear with us. Or we need to bear with us. And we need to bear with us.

ghbhenatś雨. Saade نومنیشن فیروسے چھوٹر نومنشن لیکن در سارے بس ایک ساتھ پڑے نہیں ہو سکتے Right So 1000 hendler ہو گیا As i let's say 1 ہمارے پاس 500 hendler ہو گیا 500 hendler یہ 100 بھی آجے ہیں آپے 500 hendler ہو گیا Like that آپی مجم کر سکتے Asi maripas کیا کہتے ہیں 100 hendler بھی ہو سکتے ہیں 200 hendler کا 50 جتے بھی آپ کو بنا نہیں کو Expend کر سکتے ہیں ابھی ہم 2 بھی رکتے اور یہ ان் دونوں کا Relation کیا ہے کیا یہ دونوں انہرٹ کرتے ہیں ہمارے میین hendler Object کو اب میں نے کیا کہا تھا کی چین of Responsibility ہوتی ہے یعنی کی ہر hendler کے پاس 2 ہendler کا Reference ہوتی ہے کہنے کا ھمتلاب یہ کی 1000 کے پاس 500 رک ایک Reference ہو گیا Like that یہاں Drockia H1 ke پاس H2 ke H2 ke Reference H2 ke پاس H3 ke Reference اب دیکھا بھی آپ کو 2 Option یا تو یہ جو hendler Relation fund Sk告 formas C einer Various Things Vic SD Yang Hen H1 Bду A בteokbokki کرprised दोंसेलेटि तोतीती interactive भ़ लेगं यहींन ग ऋनी यक से भा Sa senators टे लेगंंे कर म एे नहभना तो अहीं से दें जती हूचाा लेग्नी का अबिर् कथिव रहनी रहें एनवियं मालेलगं पह हसार power आहिं फिहनर थ देंपसेलस आस नीमhoo تو ہم نہیں جاتے تائٹلی کا پلو تو ہم کیا کرتے ہیں ہم اس ہائرار کی کو basically vor this reference ھ ignore ھیں اس کو ہٹا دö دö اہیں پے کوئی ہائرار کی نہیں ہے کوئی reference ھیں ہم نہیں ہے یہ سب انڈپندنٹ ہے اہیں کو نہیں پتا ان کا نکس کیا ہے ان کا نکس sendler کیا ہے یہ کس کو پتے ہیں یا our handler ھ جو ابسٹٹ کلس اس کو پتے ہیں تو یا نی کی ہم کیا کرتے ہیں اپنے hendler میں ایننا ایک hendler 的 reference ھ پاس کر دے دے hendler 的 reference ھ پاس کر دے لیکنے نقسٹ لنگلسٹ میں گردتے سکتے ہیں نقسٹ پائنٹر ہے تو اب 1000 ہندل ہے یعنی کی ایک مثل جائے گا لیکنے سٹ ہندلر وہ گیا گا گا گا گا گا گا گا اور اس کو یہاں پیسٹ کر دے گا یہاں پیسٹ کو دفین پیگ کر دے گا گا گا گا گا یعنی کی اس کے پاسٹ فایک کی دیسپنسے میں گا گا جو اپسٹ رہٹ یعنیوں ہی گا گا گا باکی سٹ ہندلر ہمار از میں جو اس پورے اینٹر فیسٹ یعنی کی اس پورے لوگیخ سے بات کرنا چاہتے ہیں پیسے نکالنا چاہتے ہیں تو قلائن کیا کرے گا قلائن کے پاسٹ بھیلے تو ہم کیا کہیں گے ایک رفرنس ہوگا اس ہندلر کا ایک رفرنس ہوگا تو وہ دروک کر دے گا اینلر اچ وہ گیا گا گا گا وہ اچ کا دنسپنس کل کر دے گا اسیمپل اماؤٹ دے گا گا اچھی اس کو چے یہ 3,000 روپے وہ یہ کل کر دے گا اب سب سے پہلے گیا گا اگر دیپین کر دے گا اچھ میں سب سے پہلے کس کا رفرنس ہے لیکس سے سے پہلے ہزارپے کر رفرنس ہے وہ 3,000 روپے دے گا کہ وہ اس 3,000 روپے رکو اس کو فلفل کر سکتے اگر وہ کر سکتے ہیں اور کوئی اماؤں اور بچتا نہیں آگی دے گے تو وہ یہیسے اس کو رسپنس دے گا نہیں تو یہ کہ کرے گا یہ سد بیسکل یہاں پہ اپنے نکسٹ کو بلے گا اس کے بازری مثہڈوں کا dispense جسے اوووریٹ کر رہا ہوگا یعنے کی ہر وہ کلاس جو بھی ہمیں آپیں نہیں کلاس بناتے گے جو اس کو بیسکل انہرٹ کر رہی ہوگی اُن سب کے بہت ایک dispense مثہڈوں کا اب ہمیں ایک بار بس دیکھلے اِس کا dispense مثہڈ کیسا دکتا ہوگا دیکھو اب خود سے سوچوں اس کے dispense مثہڈوں میں یہ ہوتا ہوگا یہ سب سے پہلے چک کرتا ہوگا کہ اِف اٹھ کن فلفل رکوست تو اس کا کوئی لوگی کو گا تو فلفل رکوست وہ اب ہم قوڑ میں دیکھلیں گے کیسے کرے گا کیس تین نظار پہ کو یہ دیکھلے گا کی میری بس کیتے نے نوڑ سے ویلے بلے اِس کو دیوائد کر دیکھلے گا کیا میں اُس کو ایک زیکلی فلفل کر سکتا ہوگا اگر کچھ ریمینٹر میں بچر ہے یعنی کی مجھ آگر رکوست بھیجنی پڑیگی اور پھر آگی بیجنے کے لئے کیا کرے گا یہ اپنے نکسٹ کو کہے گا اس کا نکسٹ کیا ہے اس کے نکسٹ کا ریفرین سے یہاں بھی اس کے پیرین کے پاس اپنے نکسٹ کو کہے گا کی میری نکسٹ کا дисپنس کول کر دو بچے ہوئے اماؤنٹ کے ساتھ اب لیٹ سے اس کا نکسٹ کا дисپنس کیا ہے اس 500 روپیس کا дисپنس یہ بھی اسے مجھیس کرے گا یہ چک کرے گا کیا میری کسٹ کو پوری طرف افلفل کر سکتا ہوں اگر نہیں کر سکتا تو جتما افلفل کرتا ہوتنا کروں گا اور پھر میں اپنے نکسٹ کا дисپنس کو کہا کر دو اسیگ this line اور یہ چلتا رہے گا چلتا رہے گا جتنا ہمارے дисپنسر سویلے بلوں گے یہ جتنا ہمارے ہندلر سویلے بلوں گے تو احب آپ کو اس UML سے اور یہ اپنے یہ تھوڑا سا کمپلگیڈ ہو گیا یہ بیٹھر ایڈیالا گا گا کہ یہ کری چا رہے چکے اس کو ہم فتفت کوڑ میں دیکھتے ہیں اور پھر اس کا stand-in UML بھی دیکھتے ہیں چکے تو دیکھوں بہی جو ہم نے بات کی بہی کوڑا یہ سب سے پہلے میں نے کیا کیا ایک اپسٹٹلاظ بنای مانی ہندلر جو مانی کو ہندلر کرے گا اور اسی میں دیکھوں میں ایک Protected Variable رکھا Protected Islay رکھا کہ جو بھی ہماریز کی چیلتلاظ سے دوں گی اس کو ہماریز کی مانی ہندلر کا ایک اپسٹلاظ بنای نیکس شندلر اسی کا ریفرنس رکھا نیکس شندلر اور ہم نے اس کے public میں ایک تو конструкٹر دیا конструкٹر میں کیا کرے گا پہلے تو ہم نے اس کو null pointer sign کر دیا یہ کہ پہلے یہ independent league zist کرتے ہیں کوئی بھی اس میں hendler رہے ہیں پھر ہم نے اس میں ex set next handler reference ڑیا جو ایک next اور اس next handler کو یہ next assign ڑا دیتے ہیں یہ ابھی دیکھتے تو اس کے اس میں linguist میں saree je de public کیا وہ تو ہم data structure میں اس کا as it is use کرتے ہیں ہم اس میں clean coding ٹھوڑی practic ڑھا ٹھوڑی practic ڑھا تو ابھی اب اسے ٹھوڑا سا سے ling ڑھا کرتے پر میں اس کو بعد میں discuss ڑھا کیا لست میں ہمارے پاسم نے کیا کرتے ہیں ورچل بیتھر بنا دیا dispenser دیسپنس اپسٹیک کیا کیا ہر dispenser رہا گوگا لست ٹھوڑی تو سپسے پہلے ہم نے Concrete class seresم نے 1000 hendler یہ ایک ممین hendler اور اس کے پاس کیا ہے ایک پرائیوٹ وریوڑی نمبر افنوڑز کیا ہم نمبر افنوڑز کے پاس کیا ہم یہ ہے کیا ہم بزنس لوجکہ کیا ہم پہلے چک کر لے کیا ہم نمبر افنوڑز کیا ہم کیا ہم کیا جو Node s needed end. جتنی Node s ھا میں چاہیی رکوست کو ہنگی کرنے گلے. وہ Number of nodes ھے ذا دا دا ہے.

اگر ایسا ہے تو اس کے پاس تو اتنی Node s ھی نہیں اونے چی ہے. رہیت تو ایک کرے گا جتنی اس کے پاس Node s ھے بسیگلی ہے Number of nodes ھ. اون کو سائن کر دے گا Node s needed ھ. یعنی کی ماان لو کی ھیوزر نے رکوست کری 5 ھ.

پہر اس کے پاس تو 3 ھ. بلے بلے ہزا رکوست ہنگ ہے. ہے نا. بہی میں 5 ھ.

رکوست کو فلفل کرنی سکتا. میں 3 ھ. تو یہ کرے گا Node s needed ھ. جتنی Node s ھ.

وہ Number of nodes ھ. ایسا ان کر دے گا نکی 3 ھ. اور Number of nodes ھ. اگر ایک کر دے گا نکی 0 ھ.

پر اگر ایسا نہیں ہے. یعنی کی Node s needed ھ. کام ہے Number of nodes ھ. یعنی کی Node s needed ھ.

تو Number of nodes ھ. اُس کو اتنا گھتا دے گا. یہ تو آپ کو پتے ایسا نورمال بسیسلوجیک چل رہے. پھر ایک بار یہ کیا کرے گا.

اگر Node s ھ. جتنی Node s needed ھ. بڑے ہیں تو Print ھ. کہ بہی Dispensing ھ.

اتنی H. یعنی کی Node s. یعنی کی Node s. ریال Project ھ.

اگر یہ Proper A-Team ھ. انہیں دلو رہا ہوتا. تو یہاں پہ کیا کرتا. کامسول پہ اوپورت سوڑی Print ھ.

ایکٹیلی Node s. کو Dispense ھ. اس کے لئے ہو. اوزکتے ایک اعلک class.

جو کسی Hardware ھ. انتریک کرتے ہو. جو ایکٹیلی Node s. کو Dispense ھ.

کرتے گے. اور جسی یہ Node s. کو Dispense ھ. اپنا Remaining Amount ھ.

نکھا لے. کہ اس نے صرف ملو 30.000 ھ. ریالت. پہنچ از ریالت.

تو ابھی بھی 2000 ھ. تو کیا کیا کرتے گا. جو بھی Total ھ. مینس.

جتنی Node s. needed ھ. انتو 1000. اب یہ 1000 ھ.

یہ کس کا Dispense ھ. کل کرتے ہو. یہ کل کرتے ہو. 510 ھ.

اپنا نکھا لے. اپنا نکھا لے. اس میں بھی بلکل سیم. کھوڑ ہے.

اس کا Constructor ہے. Number of Notes ھ. اس کو سنگ کرواتے تھا. اور اس کا Dispense ھ.

جو ایسی دکتے. پہلے Notes ھ. نیڈی تکلکلٹ کرتے. پھر چیک کرتے.

جو امرے Number of Notes ھ. سے زادہ تو نہیں ہے. اور فیلے اگر نہیں ہے. تو پہلے تو اتنے امونٹ Dispense ھ.

جتے 500 بھی گے Note ھ. اور اگر کو Remaining Amount بچتے. تو اس کو Next pointer ھ. دی.

Next handler ھ. اور Dispense ھ. اور ایس میں گڑالتے کہ اگر ماللو Remaining Amount ھ. قام ہو جا ماللو اس کے پاس جتے 500 ھ.

اس سے زادہ چاہیئے ہو. اور اس کے بعد کچھ Next pointer ھ. اگر Next handler ھ. اس کو Request بھیت سکتے.

تو وہ کیا رہتے ہو کرتے گا. Remaining amount of this can not be fulfilled. insufficient fund.idm kepast. ماللو اگر اس کے پاس Handler ھ.

یا Dispenser ھ. تو یہپنے 2-3 Dispenser ھ. لیٹ سے وہ ہے. our 200 is handler.

تو نیک 200 ھ. یہ بھی بلکل سیم کر رہے. پر Note ھ. پھر یہ نکال رہے.

پھر یہ نکال رہے. کی کتھے Note ھ. اگر اس کے پاس جیتے. اور باکھی Remaining Amount ھ.

اپنے Next Rispenser ھ. اس کے پاس Let's say 100 ھ. 100 ھ. 100 ھ.

same ھ. اور Dispensing ھ. اور اگلے اپنے Handler ھ. کر دے گا.

ابھی تک کے لئے ہم نے just 100 ھ. last ھ. پر کل کوحمی سے Expand ھ. 50 ھ.

20 ھ. 10 ھ. جتنا آپ چھوٹا من سکتا بنا سکتا. بنا سکتا.

پر کوئی تو ایک last handler ھ. لیٹ سے یہ ایک last handler ھ. یا نکی یہ ایک بلوک اگزیکیت ہو گئی نہیں. یا اپنے ایلس میں جائے گا.

اور کہ دے گا کہ Remaining Amount ھ. تو اس کے 3 ھ. پاچھو نھ. 10 ھ.

اب ام نے Chain Of Responsibility กو ستکیا. 1000 ھ. setNext ھ. دیگا ھ.

500 ھ. 500 ھ. 200 ھ. 200 ھ.

100 ھ. اور 100 ھ. تو اپنے اپنے اپنے اپنے اپنے اپنے انت a. first ھ.

اب ام نے دیکھا کہا ہم 3 ھ. بضروقت نی. تو, now you will know how to handle 1000 200 묻es? 200 & 100 Milk 200 Sekund 그럼, I will print it later So, Dis;;Pens give hendumerous 200 out of 1000 & 1 mil let's see the Ok, 3000 5000 1ρο تو یہ اپنے 3 の Note نہ لے گا اور کہ گا لوں Dispensing 3 の Note نہ لے گا ایک یہ بھی دیکھ لو اگر 3,000 کے جگ ہم یہاں 4,000 پاس کرتے یہ 1,000 HN نہ لے اس کے 3 Note نہ لے اور باکی 1000 کے لئے 5,000 کو بھول دے 5 نہ لے 2 Note نہ لے اور 4 نہ لے اور پورا کرتے تھا تو اگر ہم اس کو چلا کے دیکھیں تو Sorry یہ دیکھ لو پہلے ہم نے اس کے 3 Note نہ لے 1000 کی اور 2 5 نہ لے تو اگر ہم آپ کو اچھے سمجھا جائے گا اب اس پہ 1 چی دا اس کا اس کر لے ہو سکتے کئی لوگوں کے منم میں نہیں بھی کوئیسے آیا کہ ہم نے کیوں کیا werdے نے سارے HN نہ لے ہم کیا کرتے ہیں ہم یہ بھی کرتے تھا کہ ہم 1 HN نہ لے لیکن 1,000 HN نہ لے ہم اس کا کچھ بھی کمن نہ آم رکھلے تھے لیکن 1 , 1 , 2 , 1 , 1, 2 ہندلے تو ہمارا جو پیرینٹھا اسی کا نام لیجوز کر لے تھے کوئی پیرینٹھ ہوتا ہی نہیں اس کا اور یہ سبتا ہم ایفیلس میں بھی دال سکتے تھے بای جو ہم نے یہاں λوچک لکھا ہے یہ سب لوچکتا ہم ایفیلس میں بھی اس کر سکتے تھے کہ اگر ایمانٹ پہلے ہزار سے زادہ ہزار سے دیوائیڈ سکتے تو یہاں لگر لگا السف یہاں پاٹ السف یہاں پاٹ اور السف یہاں پاٹ یہاں پاٹ یہاں پاٹ تم نے ایتنے سارے ہندلر کیوں بنائیں اگر اگر اپنے میں کوشن آیا تو واپس سے جو سوالی دیزائن کنسیپلس میں خم نے کہاں کہاں کہ ہم اپن گلوز پرنسیپل کو فولو کروانا چاہتے ہیں اگر ایسا ہم کرتے تو کلکو کر میں کوئی اور نیا دیسپنسر نیا ہندلر انٹڈیوز کرنا پڑھا جسے بیتاکسی ف سوطک کے ہندلر ہے پہچاس پر پہچاس پہلے کا ہندلر بھی ہم انٹڈیوز کرنا پہنے پہچاس کنس کا ہندلر دیں گے یہ کریں گے نا تو بیسک لئے کیا کیا اپن گلوز پرنسیپل کو فولو کروانا چاہتے ہیں پھرس تک سیکن تک سینگل رسپنسیپل کو فولو کروانا چاہتے ہیں اب ہم ہندلر کی ہندلر کا کامن صرف ہزاروپے کو معنچ کرنا پہچسور پے کامن پہچسور پے کو معنچ کرنا اگر دیسپل اگر دیسپل کلکونا نوٹ چیج جاتا ہے پہلے بلک دکتے تھے نای نوٹ سا گے ما نوٹ نای نوٹ سنتروڈیوز ہوئے ایک دیمینشہ یہ لا گوتا ہوگا ان کو ویریفہ کرنا کی ریل نہیں وہ لگوتا ہوگا یا تو ہم صرف اس کو ہندلر کیا کرنا مانی کو دیسپنس کر رہے پر بلٹ سے ہندلر ہی ہندلر کا ہی کامن جیک کرنا کہ مانی Authenticated Heavy or Real Money or Money.

Agarabh Money Co. Let's say, Neekal Rho idioms. Agarabh Money Co. Dal Rho.

So, he handled check the money you put in, he didn't handle it. So, in that, your single responsibility principle should follow. So, if this is something that we change our money, the structure of the money, then we just have to change the code in one handler. If we change the code in the store, then we will change the handler.

All the handers don't need to change. So, single responsibility principle will follow. Right? So, this was so simple.

Now, let's see the extended UML diagram. So, see, this is a simple standard UML diagram that we discussed. We have a parent class, i-hendler, because this is an abstract class. This is a method of a handle request.

Right? Now, we can have a lot of concrete handler. Concrete handler 1, concrete handler 2. Both the handle requests are overriding.

Now, the i-hendler has the same reference, or the method of a next, which will tell us what is my next pointer. Right? That means, after that, it is in the relationship of the same person. And the client will talk to the handler.

The handler will call the handler and call the handler request. Now, the handler will manage the request by himself. First, we know that this one is called and this one has requested the handler. This one cannot be requested by the entire handler.

So, we will send this to our other person. This one will not be sent directly. This one will say that my next pointer is the next pointer. If this one says, my next pointer is the next pointer.

And this one will say the next pointer. Like that. Right? So, this is standard email diagram.

Now, we will see the standard definition of the foot. So, look. The standard definition is the same, which we have said till now, that it allows an object to pass a request along a chain of potential handlers. We have a lot of handlers.

So, we will log in to the request that it is a lot of handlers. And what will the handler do? He will decide that he can process the request here. Or pass it to the next handler.

Simple. Now, you go from yourself. What is the use case? So, first we discussed that we will tell you the link list and what is the chain of responsibility principle?

So, if you remember, when we read the composing design pattern that the link list and COR are different. That is, our chain of responsibility principle. See, first of all, this is the link list. This is a data structure.

It is called a data store. So, how do you store data? You know that a link list is made of multiple nodes. Right?

And every node is linked to each node. This chain of responsibility principle is like this. That in this, there is a link from another object. But, it has a lot of intent.

First of all, what is the intent? It is not to store the intent data. It is to handle a request. It will be a request.

It will handle it. If you don't want to handle it, it will not be able to handle it. It will not be able to handle it. Like that.

First of all, the intent is different. The second main difference was that the link list refers to another object, if we write a link list, then how do we write it? Right? We first have to make a next pointer and then we keep a data in it.

Right? So, the next pointer can be pointed to this next. But, if you look at the standard diagram of our data, what is the eye handler? The interface that is referring to the same thing.

And, in this interface, we can make a concrete object. For example, if we had a thousand handler, in our example, it was referring to 500 people, it was referring to 500 people, it was referring to 200 people, and it was referring to 100 people. So, these are different objects. The only object is not the same.

It is not the same class. It is the same class. And, it is the same interface. Each class is the same, but it is the same class.

So, this is also a very big difference. In our link list, we refer to the same object. In fact, one object is the same. And, our COR, which is the chain of responsibility principle.

There is a interface, which is the multiple classes. And, the other class refers to the same class. So, there is a very big difference. But, yes.

If you look in a simplified way, somewhere, its idea, its perception, the link list, the multiple objects are connected to a chain. In addition, when we read the composing design pattern, we discussed about the composing design pattern, the tree, which is a node, which has multiple nodes. Now, one node can also be a leaf, which can also be a multiple object. Composite is the same.

So, when we traverse it, we traverse it three times. Same, when we traverse it, we traverse it like a link list. Using that next pointer. So, I hope, things are better clear.

Now, let's see what is the real world use case. Look, there are many standard problems, which are made of C, okay. Let me tell you one standard problem. Whenever you define a logger, let's say, a problem statement, that a logger is made, like a real application comes, some information logs, some error logs, some debugging logs, so, that one is made.

So, look, generally, in our logger, sorry, in the logger, there are three types of hierarchy. Okay. One is Info, one is D bug, and one is Error. And one level of this one is, the basic one is Info-Log, which you add in the log, when you want to provide information.

Then, debug and then Error. So, why is this hierarchy? So, if you come here and design a logger system, then you cut the basic stuff. So, if you have this problem, that the logger system is in an interview, if you have to tackle a problem, then you can use the chain of responsibility principle.

What is this? Three, one is Info, one is a different object, debug, one is a different object, and the error is a different object. Three of them will have a parent object, and all these will be connected to the chain. Right?

So, whatever is our client, whenever he will add a log, then he will check that this log is level. So, Info-Log is level 1. This is level 2, and this is level 3. So, these are levels.

So, you can implement this. This is a standard question in fact, it is very easy. It is very easy. Simple chain of responsibility principle, and put your log in.

This is a interesting question. And I will give you a homework, you can implement it yourself. This was also asked in interviews, in many companies. The question is, that a design, a leave request system, what happens in it?

That you have a client, this client is called a user, or a employee, employee is better, we call it employee. In a company, a employee, he requests a leave. And that leave request is a hierarchy. If he requests a leave request from two or less days, then that leave request is approved.

But if he requests a leave request from two or less days, then that request is applied on the manager. And after that, if the manager can't approve, then that request is applied on the director. And if the director can't approve, then he fails. No, we call it employee from the back, that request is approved.

So, try to implement this. The proper form of a UML diagram, write its code, and you also know that chain of responsibility principles are solved. Okay? So, you have homework too.

And this is also a standard question. So, this is the question in which you know, I will have a hierarchy of multiple if one request will fulfill, then it will output, or if the other person will say, the third person will say, like that. This is the question of the CEO R, and the chain of responsibility principles are solved. Okay?

I hope you will understand. In this video, I will see you in the next video. Till then, thank you so much.

Lesson FAQs

What is Chain of Responsibility Pattern | Build Cash Dispenser(UML & Code) | System Design about?

حنجی کرے ڈیسٹٹ سو Welcome Back Co-Dur Army in our LLD series اور آج کے سلیکٹر میں ہمیک نیا دیزائیں پیٹن اور بہت ہی انٹرسٹین دیزائیں پیٹن چین او فریس پہنسیلیڈی پیٹن پڑن پڑنے والے یہ پیٹن again a G use case specific design pattern

What key concepts are covered in this lesson?

The lesson covers System Design, Low Level Design, High level Design, System Design for Beginner, System Design for advance level.

What should I learn before Chain of Responsibility Pattern | Build Cash Dispenser(UML & Code) | System Design?

Review the previous lessons in System Design Full Course, then use the transcript and key concepts on this page to fill any gaps.

How can I practice after this lesson?

Practice by applying the main concepts: System Design, Low Level Design, High level Design, System Design for Beginner.

Does this lesson include a transcript?

Yes. The full transcript is visible on this page in indexable HTML sections.

Is this lesson free?

Yes. CourseHive lessons and courses are available to learn online for free.

Continue Learning

Course Hive

Continue this lesson in the app

Install CourseHive on Android or iOS to keep learning while you move.

Related Lessons

Related Courses

FAQs

Course Hive
Download CourseHive and keep learning anywhere
Get App