Course Hive
Search

Welcome

Sign in or create your account

Continue with Google
or
SOLID Design Principles | part 2
Play lesson

System Design Full Course - SOLID Design Principles | part 2

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 SOLID Design Principles | part 2

SOLID Design Principles | part 2 Transcript and Lesson Notes

hange kare start so welcome back to the RME our salary dhik series so last lecture we discussed solid design principles in which we discussed the open close and list of substitution already now we have two principles so we discuss it with a pata fatu and we end it so let's go to screen

Quick Summary

hange kare start so welcome back to the RME our salary dhik series so last lecture we discussed solid design principles in which we discussed the open close and list of substitution already now we have two principles so we discuss it with a pata fatu and we end it so let's go to screen

Key Takeaways

  • Review the core idea: hange kare start so welcome back to the RME our salary dhik series so last lecture we discussed solid design principles in which we discussed the open close and list of substitution
  • Understand how System Design fits into SOLID Design Principles | part 2.
  • Understand how Low Level Design fits into SOLID Design Principles | part 2.
  • Understand how High level Design fits into SOLID Design Principles | part 2.
  • Understand how System Design for Beginner fits into SOLID Design Principles | part 2.

Key Concepts

Full Transcript

hange kare start so welcome back to the RME our salary dhik series so last lecture we discussed solid design principles in which we discussed the open close and list of substitution already now we have two principles so we discuss it with a pata fatu and we end it so let's go to screen so we have remembered in the last video single responsibility open close and list of substitution already discussed we have IOD which is interface aggregation and dependency inversion now before we shift to these two before we shift to these two I want to talk about list of substitution about some of the other things because in the last video I told you this principle is very simple but this is the most important principle it is very important to break because many people do not identify that list of substitution is breaking it becomes a little tricky so some rules are some principles which you can say some guidelines which you follow so whenever you break you will not be able to maintain well and you will be able to work on your life project and you will be able to do a lot of work and you will be able to do a lot of interviews so let's start with the guidelines and then we will move to the next principle okay so let's start list of substitution from the second one let's go if you remember what we discussed in the list of substitution principle we discussed that from the first one we have a parent class A and a child class B and a client okay this is a client so I told you in the list of substitution that whenever we expect a client and if we give it B without giving a client without giving a client or if we do not have any restrictions then I will say that the list of substitution principle follows this that the child class is an easily replaced parent class now to follow this follow this a little guidelines see this B child class is a one will replace this one in the inheritance we used to explain that whatever methods are made from let's say M1, M2 first we have to override B so B M1, M2 first we have to override B so just override B we have to follow the inheritance but we do not need we will follow this of substitution that is not necessary every child class the parent class is a subclass we replace the parent class how see the child class is the only method of parent class so it can be we used to see what we did in the account section we did in the account we did in the account we could inherit so B we do not need inheritance but we need to just behave so the child class should behave as a parent class basically means if a client does not know what to write then the parent class and child class so for this we have to look at the guidelines what guidelines so the guidelines are divided in three parts very simple first the guidelines are divided which guidelines first we have signature rule what is the signature rule what is the method of signature the name of the method the arguments and the method the return type is the method of the signature of the meeting now let's see what is the rule besides this we have property rule and the last we have method rule let's see what these three first let's see the signature rule first let's see first let's consider the theory and then let's see in the code C++ how can we implement first let's understand when I will use broad so what is the meaning of this and when I will use narrow then what is the meaning of this let's say when I will say that a class is the second class so the word is parent class or any ancestor for example let's say an animal class and an animal class can be a dog so the animal is a dog's broader class in the same way it is narrow or it is a child class or it is a disaddent so in the same way the dog is an animal class but you will be very help when we will discuss let's see let's see let's see let's see let's write a simple class and we have a child class in the same way let's make a child class and what do you call the parent class public we call this suppose this is the parent class method let's say the method is solve avoid there is a string type string s and it does nothing but saying that we have a جو ایک ڈرگیمٹ لیتے ہیں جو آپ اس میتھڑ کو overwrite ڈگے اپنی چایل ڈکلاس میں تو آپ کیا کروگے same ڈگیمٹھڑک ہوگے solve Right Now the method argument sorry signature rule is that the argument you took was string type same argument you have to take it here or you have to take the broader argument or not here the argument you gave whatever object you gave as you gave the string type so here you have the same object here string type or then a broader object where you can pass string type parent class then you have to pass so here we have to write same string s type Now this is a very simple rule this is basically c++ which imposes i.e. method signature c++ is always the same overwrite function but you remember so it means whenever you override any method where you have solved so as solve string so this solve will be string you can't add anything here so c++ you impose so this is a theoretical rule language independent rule if you impose but this language independent rule if you don't understand then how do you understand why we are saying the argument of child class is the exact equal of parent class should be the same or should be the broader see, we understand suppose we have a client and we were doing we were expecting the client which was expecting we gave the child and we didn't know because the client was expecting the child and we didn't know what the child was expecting and we didn't know what we did in this case we applied the string integer int s so the solution of the solve is the parent's string but the client knows that I can call solve the parent's object with the client so the function pk reference solve call solve the same contract interface interface which is an abstract class like this parent that the parent class function has to call the string argument if I call integer then it will be wrong that string is not a parent class it is not a parent class the integer is a different class from the string and the nth is not a class it is a primitive type but if we are not primitive then we can write integer class in Java but we can say integer is a class and the string is a class so if we call the string then we expect this is not a parent class so the same argument we had in the parent and this is not the same as we can impose the same nth string and this is a different function here we can تو آپ اس کا فٹھہ فٹھ سے same ڈھے سے کوڑ دیکھلے تھیں آجو screen پے تو آپ یہ دیکھ سکتے ہو ہم نے same ڈھے یا آپ نے دیکھا پیرینٹ class لیا اور ایک child ڈھے دونوں کے پاس print کا function تو یہ string expect ڈھے یہ بھی string ہی expect ڈھے گے جب اسے override کر رہا گا دیکھو تو اگر آپ نے گلتی سے بھی ہمیں انٹ لکھا تو آپ دیکھو ہمارے پاس compilation ڈھے رہا گیا کیا کہا ہے Member function ڈکلڈ بھی override does not override a base class member اس کے سب سے بھی اس کو یہ override کر رہی نہیں رہا کیا کہ صگنےچہ Different ڈھے اس صگنےچہ میں string ڈھے اور اس صگنےچہ میں انٹ لڑھے تو یہاں پیرینٹ ہی لکھنا پڑے گا تو یہ rule ڈھے so یہ تو simple اب دیکھو میں نے ہمیں کیا کیا کیا کیا کیا کیا Klein بنالیا جو ایک parent class object p expect ڈھے ہم اس کو constector میں rfqarwalia اور اس کے بعد ہم نے کیا کیا ایک function ڈھے print message جو اس parent class object p کوئی فرق نہیں بڑھتا یہ تو child message print ڈھے گایاں parent class کیا ہم نے پہلا принципیل کو follow کیا جو کیا signature rule right چاہلو اب second principle دیکھتے آجو بہت screen پہ چاہلو احو بہت کو یہ والا rule سمجھایا ہوں گا یہ signature rule کے اندر اس کو ہم بلتے ہیں method argument rule کیا کیا کیا کیا کیا ہمارے پاس لت سے ایک animal class اور لت سے بارے پاس ایک animal ہے dog یہ اس کی child class ہے یہ high rq ہے تو dog is a relationship ہے right dog is a animal اب return type rule یہ کہتا ہے اس high rq کو دان سے سمجھ کرکنے ایلا گیاں کیا اب ہم کیا کرتے ایک ایک more high rq بنانتے let's suppose یہاں پہلا принцип یہاں پہلا принцип یہاں پہلا принцип اور اس کی ہمارے پاس ایک child class ہے ہم اس کا چلا ایو ام لیسی دا کوڑ لکتے تو زاادہ بیٹھا ساہا جائے گا تو ہمارے پاس کیا ہے ہمارے پاس ایک class ہے parent اور ویسے ہمارے پاس ایک class چلا جو کی same کیا کرتے اینہرٹ کرتے parent کو تھی گیاں اب وہی چیس same کرتے سپوص کرو ہمارے پاس parent والی class میں ایک method اس کرتے سم random method وہ کوئی ارگیمان نہیں لیتی پر اندر کچھ کچھ کرتے پر کوئی ارگیمان نہیں لیتی پر لیت سے وہ جیریندم class ہے وہ ایک return ایک return وہ تو لیتی وہ void اس بار ایک animal type object return ایک animal take ایک animal type object اس return type rule یہ کہتے جب میں this method override جب میں this child class میں this override this random function تو اس override ایک animal i am same return type which is animal only or its subtype or its narrow type like dog but I can never be an animal or an ancestor ears ابอقسกہ بت Bryan subscrib كان do you guys proprietor then don't؟ touched how i'm going wrong BENTI اینیمال class کی عبجیکٹ میں پڑھ کرتے تھا اینیمال A equal to this تو اب اس میں کیا کیا اس نے اینیمال class کی reference میں PKRNM goal کیا تو PKRNM n لیکن یہ برقمان لوحظة نمال نمال نمال نمال نمال نمال نمال نمال نمال نمال نمال نمال نمال نمال نمال نمال نمال نمال نمال نمال م کیا کرے گی ہی ہی ہی ایک سپشن کلاس کا عبجیکٹ ہے ای جو اسے مل جائے گا لوجی کا لیرر رہا ہو گا تو یا پھر اوٹف میمری اررر ہو گا تو وہ ای کو مل جائے گا یا نکے اگی ان ایک رفرینز ہے جو ایک عبجیکٹ کو ریفر کرے گا چاہی وہ پیرنٹلاسکوں چاہی وہ چاہیلٹلاسکوں پر اگر وہ پیرنٹلاسکہ ہوا تو تو کوئی دکتکتی ہیں اوٹف میمری ارر ہے یا پی بھی ہم نے لیٹ سے sorry یا پی بھی پھر our runtime era نہیں ہو گا یا پی بھی ہم اوٹف میمری ارر ہو گا یا out of range error sorry out of range error ہو گا کیوں کیوں کیا ہم نے کہا تھا یہ والا جو پیرنٹلاسکہ امرے وہ out of range error throo کر رہا اور again client کے پاس kontract ہے پیرنٹ کا تو اس کو پا دے کی مر کو out of range error hendel کرنے تو out of range error کا و ایک سپشنگلس کا اوپجگ نا دیتا ای تو اب یہ جو ای ہے یہ جو ای رفرنٹ ہے یہ صرف out of range error کے ایک سپشن کو ہی پونٹ کر سکتے پر اگر آپ نے اس کو چیل خلاس کا اوپجگ دیتیا اور پیر آپ نے پیرٹ امریکن کال کیا یعنی کی یہاں امریکن کال ہو جائے گا اور اگر یہاں امریکن کال ہو گیا تو وہ تو وہ لوگی کا لرط ہو کرے گا پر اگر یہ جو ای ہے یہ لوگی کا لرط کو رہا کر رہا کر رہا کر رہا کیونکی یہ تو out of range رہا رہا رہا رہا ہوں اوپجگت ہے رہا ہوں اگر اگر ایک سپشنگلس کی یہ تو پیر انگلس ہے اور یہ چیل خلاس ہے تو اسے رہا ہوں نہیں کر سکتا اسلے یہ ہمیں کرنا پوزیبل نہیں ہونا چاہیے بیسکلی یہ ایک سپشنگلس ہمیں ماننا چاہیے ٹک ہے تو یہ ایک سپشنگلس تھا اب فتح فٹ سے ان دونوں کا ہم کورٹ دیکھلے تھا آجو اسکرین پے چلو اب فتح فٹ ریٹنٹائب کو ایک سپشنگل کورٹ دیکھلے تھا اگر آپ کو کوئی بھی پروبلم میں یوگی سے سمجھنے میں تو کورٹ دیکھیک دم بلکل سیر ہو جائے گا یا پہ دیکھلے تھا یا پہ دیکھلے تھا ایک چیز لکیو یہ اب پڑھ سکتے ہو اب وہی کورٹ جو ہمیں بیسکلی ویگی بھی ایک زمپل جو ہمیں کیا تھا ویگی اس کا کورٹ دیکھلے تھا ایک اینیمل کلاس میں نہیں اور ایک داک کلاس میں نہیں جو کی ایک ٹائپ کا اینیمل ہے تو یہ ایک ترکہ حیرار کی ہے تکہ اینیمل اور داک کی same ابہم کیا کرتے ایک اور حیرار کی براتے پیرینٹ اور چیل کی تو ایک پیرینٹ ہے اور اس کے کچھ اینیمل سے چیل دونوں میں ایک میتھڑ ہیں گیٹ اینیمل اب یہ جو پیرینٹ کا گیٹ اینیمل یہ اینیمل کلاس کا اینیمل Type کا Reference Return کرتے اور یہ جو چیل ہے یہ کیا کرتے ہیں گیٹ اینیمل اس کا داک کلاس کا Reference Return کرتے ہیں تو میں نے کہتا یہ علاуд ہے کیا ہے کیا یہ پیرணٹ اینیملрейٹنگر سکت ہے اور یہ چاہل دог ریٹنگر سکت ہے کیا کیا ان کی بھی hider کیا ہے کہ اینیمل اور دог جو ہے وہ ایک سے رہا ہے۔ اسی کو ہم کووویرینز بولٹیں اب یہ جو چاہل ہے یہاں پہیں دог کی جگا اینیمل بھی ریٹنگر سکتا تھا یہ تو سیم ہوا گیا یہ بھی علاوڈ ہے پر کیا علاوڈ نہیں ہے کی اینیمل کی جگا اینیمل کا بھی کوئی پیرணٹ کو وحی میں نے کہتا, اگر ہم اس کی جگہ یہاں پیرینٹ پاس کر دے دے اگر ہم اس کی جگہ پیرینٹ پاس کر دے دے تو اب دہان سے دیکھو قوڈ بے گیا ہوا پیرینٹ рیٹنگ این ملیستنسو این ملیستنسو این ملیستنسو این ریٹنگ ایتا تو چلو اب نکسٹٹ کی درف مف کرتے قد حنجی, تو یہ ہے ایک سپشن رول کی قلاس اب دیکھو یہاں میں نے اوری کی بری حیرار کی دیکھ لک دیا جو کی ایک سپشن رہ کی ہوتی ہے دیکھو ہمارپس دو درگے رہے رہے رہے رہے رہے ایک سپشن سوتے ہیں, لوجی کے رہے رہے رہے اور یہ سب کے سب کلاسے ہیں تینوں کے اندر, تو میں نے کہاں بولا تھا ایک زمپل میں آتا ہے وقت ہمارے پیرینٹ پاس ہے چلو اب نکسٹٹ کی دوروں میں ایک فنگشنے گیٹ بلیو جب ہم لکتنسی بلس پلس میں نوم ایک سپفلس جو جک ایرر کے بھی پیرینٹ کو thro کر دے یا فر لیکس رنٹائی مررٹ thro کر دے which is completely different class تو گرس نے رنٹائی مررٹ thro کر دیا تو یہ بہت گلے تو جیے گا کیوں کیوں کیاں کلاینٹوں سے اندل نہیں کر پائے گا تو same ایک زمپلے کلاین میں نے ایک ریفرنس بنایا اس کو قنسٹٹن میں پاس کیا اسم ایک میتھر بنا ایک ٹیک بلیو جو try catch blok میں پوتو تا ہے سپسے بلے try blok میں وقت ہم کیا کر دے اب دیکھو again یہ جو کلاینٹ ہے نا اسے پیرینٹ کے بارے میں باتا تھا یعنی کی پیرینٹ کے کنتریک کے بارے میں باتا تھا تو اسے بتا تھے جو get value method یہ logic error thro کر دے گا تو مجھے logic error hendler کر دے تو یہ جو اسے لیکنٹ ہے یہ اپنے catch میں logic error کے لیو عبجیکٹ رہتے اور اس کو کسی درہ hendler کر دے پر ہم نے دیکھو main class میں کیاں ہم نے پہلے parent object میں ہے چایلٹوں اپجیکٹ میں ہے جس نے نے child past کیا اسے لوگی کا لیرار ہے یعنی کی اس کے سب طائب کو refer کر سکتے اب میں کام کرتے پہلے اس کولکو جلاکے دیکھتے اوٹو فرینجے ہم نے اپے کیا کیا parent بنایا a client بنایا اس کو child past کر دیا اس کی client کا take value call کر یعنی کی اس child کا take value call ڈو جو کی out of range error thro کر دے گا تو out of range a better thro کر دے گا تو catch میں گا اور logical error کا reference بناوے جو اسے hendler کر دے گا یہ print جیگا logical error exception occurred تو دیکھو logical error exception occurred child error دیکھا اب یہاں پیارن بھی پاس کر دے دیکھتے تو بھی کوئی دکت نہیں ہوتی کیوں دکت نہیں ہوتی کیوں کی parent already logical error thro کر رہے تو اب اگر ہم اس code کو چلاتے تو دیکھو logical error exception occurred parent error تو بلکل سی ہے تو اب دیکھتا مکھا نہیں کر سکتے اب اگر ہم کیا کر دے کی child ke jo class a na اس میں out of range ke jo ایک run time error thro کر دے دیکھتے لیکھت سپوز دیکھا تو اب run time error thro run time error and run time error کوئی logical error کا part to hai ni تو یہ اس cag block میں گیا نہیں اس کے نیچے کوئی اور cag block hini تو یہ فٹ گیا اور exception thro کر دی تو یہی وہ code ای ہو بہا پہ کوئی سمجھایا گا چلو بہا پس اسکرین پیارتے ہیں و راگے بڑھتے ہیں ای ہو بہا پہ کو signature rule dhansi سمجھا گیا گا افتا فٹ سے دوسرے rule کے درف move کرتے ہیں تو دوسرا rule تھا ہمارے پاس property rule اگر آپ کو signature rule dhansi اس کے نیچے کوئی یہ بہت ایزلی سمجھا گیا گیا تو property rule کے بھی اندر 2 سب رون سے تو 1st ہمارے پاس class invariant اور 2nd history constraint اب یہ بہت theoretical نہ میں ہو سکتا آپ کو نام قاملگیٹ لگیں پر جب آپ ان کو پڑ رہو سمجھ رہو آپ کو لگیا بہت سمجھا گیا تو چلو سب سے پہ لے کے کر کے دونوں دیکھیں ہم پہ لے دیکھیں class invariant اب class invariant کیا تھی سب سے پہ لے ہم سمجھتے ان invariant کا مطلب کیا ہوتے دیکھو invariant کا مطلب ہوتے کوئی بھی اصف فیکٹ یا کوئی بھی اصف رول جو کسی class کے لئے ہمشا ٹرو ہوگا تو وہ class invariant ہوتے ہیں تو invariant کو آپ ایک rule کہ سکتے ہو اگرون سمجھ سکتے ہو تو یہ کوئی بھی ایک class کے لئے ہمشا ٹرو ہو تو کوئی بھی ایک rule جو کسی class وہ ایک rule وہ ایک invariant تو اب ایک ایک example کہ ہے نا کہا چاہتے پہ لے وہ سمجھتے ہو سکتے ہو تو یہ rule class invariant rule کہ ہے نا کہ لیکن سپو سمجھتے خلاص ہے parent OK اور اس parent class کے لئے ایک invariant ہے ایک invariant ہے باتلا بھی گھرورل ہے R1 بھی گھرورل ہے اب rule کیا ہوتے rule کچھ نہیں ہوتے rule آپ کے من کی چیز ہوتے جو آپ چاہتے ہو جو چاہتے ہو class follow کریں rule کوئی c++ operation یا méthod نہیں ہے آپ just comment میں لیک دیتے تو یہ class یہ rule follow کر نی چاہتے اور آپ خود سے اسے follow وہ کر وقت ہے تو وہ آپ کے responsibility کی وہ class rule follow کریں اب ایک example بھی گھرورل تو میں نے کہا ایک parent class جس کا ایک invariant ہے نا R1 تو جو بھی اس کی چاہتے آپ کیا ہے یا تو اس کو as it is follow کریں یا فر اس کو strengthen کریں پر بلکل بھی veak نہ کریں تو جس ہم نے کہ کہاں بہت ایک invariant ہے R1 اس parent class کر تک ہے اب جو child class اس کی his responsibility کی وہ parent class کے اس invariant کو follow کریں بلکل بھی سے break نہ کریں اس rule کو break کر دے دی ہے تو ہم کہیں کہ وہ invariant دی ہے لیکن ایک مجھے لگتا بھی اس سے کچھ کلیر ہو آگا تو اب اس کو ایک ایک بہت ایلے سمجھا سپوص کرو آپ کے پاس ایک ایک ایک ایک ایک ایک ایک ایک ایک ایک ایک ایک ایک ایک ایک ایک ایک ایک ایک ایک ایک ایک ایک ایک ایک ایک ایک ایک ایک ایک ایک ایک ایک ایک ایک ایک یہ چیٹھیکون کیا کرتے ہیں؟ یہ اس بیلنس کی پروپٹی کو نگیٹیف سٹ کر دیا تھا لیکنے میں کچھ کر دیا تھا کہ وہ نگیٹیف سٹ ہوں پائے تو میں یہ کہوں گا کہ یہ کلس انویرین کو پروپٹی کو فلو نہیں کر رہے کیوں کہ اب کوئی جو کلاینت ہے جو اس ایک کون سے انٹریک کر رہا ہوگا وہ یہ ایک سپٹ کر رہے گا کہ یہ بیلنس کا مینگیٹیவ نہیں ہوگا پر اگر آپ نے اس کو چیٹھیکون دے دیا تو اسمتھ نگیٹی وہ جائے گا اسکتے کلین فٹ جہ اس و جہ سے تو یہ انویرین پروپٹی کو فلو نہیں کر دیا فٹہ فٹ سے کا کوڑ دیکھ لے تھے تو یہ ہے کلس انویرین کا رول کوڑ Sorry سی میں بالکل جو ام نے بھی دسکت کیا تھا بھارے پہ سے ایک بینگ کیا ہونٹ ہے اس کے بیلنس پروپٹی ہے اور یہ دیکھو یہاں میں نے انویرینس کیا تھا لیکھا انویرینٹ بیلنس کے not be negative تو میں نے بس کمینٹ لک دیا کچھ نہیں کیا تو یہ میری زیب میں دا رہے اس رول کو فلو کرو اپنی پیرینٹ لاز میں اور ہر چیلٹ لاز کی زیب میں دا رہے کی وہ اس رول کو فلو کر اپنی چیلٹ لاز میں تو میں نے کیا دیکھو again ایک کنسٹر میں جب بیبینگ کیا ہونٹ بنتے اور تو یہ جو بیلنس آتا ہے میں چیک کر لیتا ہم پہلی کی وہ negative تو نہیں کر دیا تو میں انویرینٹ ارکیمٹ کرتا ہم بیلنس کانٹ بی negative اور اگر negative نہیں ہے تو ہی میں بیلنس کو بھی اسائن کرتا ہم سے میں ایک میتھر میں رکھا ہے تو جو بھی اپنی امرون دالتے ہو وہ بیلنس میں سے قد ہو جائے گی اور اسے پہلی میں سے چیک کر رہے کہ بیلنس مینہ سے امرون کبھی بنیگیٹ مینہ چی اگر ہے تو میں رنٹائی میررٹ رو کر دو گا ان سفیشن فند نہیں تو اگر ایسا کچھ نہیں ہے یعنی کی بیلنس زادہ ہے امرون سے تو بیلنس میں سے امرون قد ہو جائے گا اور امرون بیلنس پرنٹ ہو جائے گا سمپل اور یہ کیا کر رہے ان ویرن پرپٹی کو بریک کر رہے جو علاوڑ نہیں دا او سے علاو کر رہے تو اب دیکھو اس کے ویڑروفنش میں کیا کرتے جب بھی کو امرونٹ آتا ہے وہ سیدہ بیلنس میں سے سے قد کر دے نو میٹر امرونٹ جو ہیا گر بیلنس سے زادہ بھی ہوا تو تو گر آپ کے بھی سورو پیئے اور آپ کہر میں جو سو رکھا لے تو یہ چیٹے گا ہوں تو کو نکھا لے یہ سیدہ کیا کر رہے گا اللہ سپی کو بریک کر دے گا نگیٹیف بیلنس کو علاو کر دے گا تو یہاں پیئے امرونٹ جو سیدہ بھی نہیں اس کو چک لگا ایتی گا تو یہ بریک کر رہے قلاس انویرینٹ کو جیسا کیا جیسا کیا مہنے دیکھا تو same main میں آپ دیکھ سکتے ہو ہم اس کو ایس کر دیکھ سکتے کیا مبینک کیا کر رہے گا ہوں اور یہاں پیئے بینگا ہوں کہ جگا گر چیٹے گا ہوں کہ اور ہم سور پے بیلنس کی جگا سور پے بیلنس ہوتا اور دوستر پے نکار لے تھے تو یہ نکار لے تھے تو یہی وہ کلاس ایتی بیرینگ کی پرپٹی کو بریک کر رہے اب نیچ پرپٹی دیکھتے فٹوفٹ تو یہی تھا پرپٹی رول میں کلاس این بیرینٹ پرپٹی رول کا جو نیچ تھا جس کو ہم نے قادہ حیسٹری کنسٹینٹ اس کو دیکھ لے دیکھ لے کی وہ کیا ہوتا ہے حیسٹری کنسٹینٹ دیکھو یہ بھی بہت سمپلے حیسٹری کنسٹینٹ کیا گیا تھے حیسٹری کبھی چیج نہیں ہونی چیے تو ایک بار جو پیرینٹ کلاس نے کہہا کہ یہ سٹیٹ ہے چیل گلاس اسی سٹیٹ کو فالو کرے کیا مطلب اس کا دیکھو ہمارے پہ سگے نک پیرینٹ کلاس ہوتی اور ایک چیل گلاس ہوتی سی پے اگے نکار کنسٹینٹ بھی کوئی اپریٹر یا کوئی میتھنی نیو داں کیا کہ یہ اس پیرینٹ کلاس کی ایک کنسٹینٹ ہے تو ایک کنسٹینٹ کا سکتے امریک ہے ایک ہیسٹری ہے جو ایک سٹیٹ ہے جو پیرینٹ کلاس چاہتی ہے ہمیشہ ٹرور ہے ہمیشہ ٹھر ہے ایک کنسٹینٹ کو چیج نہیں کریں لیکن لیٹ سے چاہل دنے اس ہیسٹری کو رسپیکٹنگی اور چیج کر دیا تو ہم کہیں گے ہیسٹری کنسٹینٹٹ گیا سی رہی اگسامپل سمجھیں اب اس بار ہم ایک چیٹھ ایک ہون کا نام پتے ہے ہم ایک چیٹھ ایک ہون کو لیکنے کے ضرط نہیں ہے ہمیشہ ٹھر ہے فیکسٹ دیپوزٹ ایک ہونٹ کچھ یا دیا لسکارف سپسٹڈوشنگے میں ایک کنسٹینٹ کیا تھا فیکسٹ دیپوزٹ ایک ہونٹ اب فیکسٹ ایک ہونٹ بیکتر ایک ہونٹ ہے پر اسم ایو درال تو پاسیبل ہوتا ہی نہیں ہے تو ہم کیا کرتے ہم جنٹلی ویی کرتے جو ہم اس میں کیا تھا ایک ایک ایک ایک سپسٹنٹھ رو کرتے تھو نیو سم ایک سپسٹنٹھ کیا یہ کہتے ہوئے یہ تو پاسیبل ہی نہیں ہے پر یہاں پہنے پتے کیا ہم نے ہیسٹری کنسٹینٹ کو بریک کرتے کیا ہم نے کہاں ٹھر ہے کہ وہ کبھی بیو درال علاوڈ ہمیشہ رہنا چاہیے پر فیکسٹ دیپوزٹ ایک ہونٹنٹھ اس کو بریک کرتے تو یعنی کی یہ لسکارف سپسٹڈوشنگے کیا ہم یہی کہاں ٹھر ہے کہ وہ کبھی بیو درال علاوڈ ہمیشہ رہنا چاہیے پر فیکسٹ دیپوزٹ ایک ہونٹنٹھ اس کو بریک کرتے تو یعنی کی یہ لسکارف سپسٹڈوشن پرنسپل کے ساب سے سپسٹڈوٹیبل چاہیل کلاس نہیں ہے اس لیے ہمارا جو مین ایک زمپل تھا اس میں ہم نے جب یہ شو کیا تھا تو ہم یہی کہاں کہاں یہاں کہاں ٹھر ہے کہ وہ چاہیل کلاس وہ چاہیل کلاس سپسٹڈوٹیبل نہیں ہے جس کو ٹھیک کرنگلے ہم نے پھر ملٹیبل انٹھفیز بنائیتے اب وہاں پیاہ پیاہ دکارتکتے ہو وہ چاہیل کلاس اس لیے سپسٹڈوٹیبل نہیں کیونکہ وہ ہیسٹری کنسٹینٹ کو بریک کر رہیتے اب یاد رکھنا کی وہ کیوں بریک کر رہیتے بگیسکلی کیوں سپسٹڈوٹیبل نہیں تپنے پیر انٹلاز کے تو یہی کہاں کیوں کیوں کہ ہم نے ہیسٹری کنسٹینٹ کو sorry ہیسٹری کنسٹینٹ کو بریک کر دیاں پے دیکھیں تو یہ آپ دیکھ سکتے یہ بہتے ہیں کہ ہیسٹری کنسٹینٹ کا اس کے بعد میں ان فکشن میں پوی کرو کہ ہم نے ایک بینکان بنائیہ نیو بینکان طائب کا اور اس میں ودРوک ہے یہاں پے ودРو ہو جائے گا پر اگر ہم یہاں پے سکس دی پوزیٹے گاڑا گاہ کر دیاں پاس کریں گے تو یہاں پے اب مال میں یہ کلائنٹ ہے, main function یہ کلائنٹ تو یہ کسپشن کو ایک سپیکنی کرتے کلائنٹ کیکسپٹ کرتے کہ جب میں withdraw کروں withdraw ہو جہے پر اس کی وجہ سے withdraw نہیں ہوں پارا کیوں کیس نے LSP کو بریک کر دیا چلوں تو I hope آپ کو یہاں پروپٹی رول بھی سمجھایاں ہوگا History Constraint History Constraint میں a small thing اور باتاں بڑی انٹرسٹیں گے آپ کو immutable class پتے کیا ہوتی ہے Immutable class ایک ایسی class جس کا کوئی چاہی جس کو کوئی انہاریٹ نہ کر پائے اوسے میں immutable class بلتے کیس کو immutable مطلب that cannot be changed اور ایسی ایک immutable methods ایسی methods جس کو کوئی override نہ کر پائے وہ immutable method تو اگر آپ نے کسی class کیا آگے C++ پائینل لگا دیا تو وہ immutable class بن جائے گئی تو ایمیٹبل تو وہ immutable method بن جائے گئی تو اگر class immutable کوئی ایک ایسی ایک ایسی کوئی ایمیٹبل تو کوئی override نہ کر پائے یہاں اگر آپ کوئی ایک پائینل لگا کسی بھیحیر کوئی کسی کسی پرپٹی کو اپنی immutable کہ اسے آپ چینز نہ کرو اور اگر چیل لگا اس کو immutable موتےول یہ بھی ایسی موتےول وہ موتےول کو موتےول بن آ دے تو وہ یہاں بھی وہ جس فکٹ جو آپ کوئی بھی وہ یہاں بھی وہ یہاں بھی وہ یہاں بھی وہ وہ وہ وہ وہ وہ وہ وہ وہ وہ پیست어줄 اب remembrance پری نی نی جpen verf موتےول اللہ flood کی طرح communaut ایما pointing نی پیرینٹلا سے پی اس کے پاس ایک میتھ�y m1 اور اگر ہم نے اس کے پر ایک پریک اینڈیشن لگا یا پریک اینڈیشن اگیین کو ایوپریٹر نہیں ہے کوئی میتھ�y نہیں ہم کمینٹ کر کے لئے لیکنے اور وہ ہماری دیمیداری ہوتے اسہ فالو کرنا تو اگر ہم نے اس کے پر ایک پر کوئی پر اینڈیشن لگا ہے تو m1 کے ایک زیکیوت ہونے سے پہلے وہ پریک اینڈیشن فالو ہنی چیئے تو پریگ انڈیشن رول یہ کہتا ہے کہ لیٹسے ہمارے پیرینٹلا سوبجیکٹ ہے پی اس کا ایک چیل ہے ہمارے پاس سی تو اگر m1 جو کی پیکہ ایک میتھ�y m1 اس کے اپر کوئی پریگ انڈیشن لگی ہے تو ایوپریگ انڈیشن لگی ہے تو ایوپریگ انڈیشن لگی ہے تو ایوپریگ انڈیشن کو اووورڈ کرے گا تو ایوپریگ انڈیشن کو as it is فالو کروا سکتے یا اس کو اور ویک کر سکتے ہے ایوپریگ انڈیشن میں اور کنسٹرینٹ سی ایدنی کر سکتا کیا مطلب ہے؟ اب ایک زمپل کے وی میں دیکھیں آپ کو بہت ایسی سما چاہ چاہ چاہ گا چاہا چاہا دیکھتے ہیں یہ ایک زمپل بہت ایوپریگ ایک زمپل میں لنگا اس کو ایسی لیسامجھانے کے لئے اور اس کے بعد ہم ایک بیٹھر ایک زمپل میں اگر آپ یہ سما چاہ گا تو وہ ایک زمپل اور زادہ چاہ سما چاہ گا تو سب سے پہلے ایک بیٹھر ایک زمپل تو اگر میں ایک ایک زمپل میں لیسامجھانے ہمارے پاس ایک پیرینٹ کلاسے اس کلاس کے پاس ایک میتھر ہے ایموان اور اس کے بعد ہمارے پاس ایک چاہ لیساہ جو اسے اوورڑ کرتی ہے تو اس کے بعد ہمارے پاس ایک زمپل اب ایس کے اوپریگ انڈیشن لگی ہے تو میں ایس ایموان میں ترکو یہاں راک کر رہا اب دعان سے دیکھنا ایک نمبر لیتا اور وہ ایک نمبر 0 سے چھوٹا ہے یا پاٹ سے بڑا ہے تو ایک سبسن کر رو کرتے گا تو میری پریگ انڈیشن یہاں تو جو بھی آپ اس کو نمبر 2 وہ 0 سے 5 کے بیچ میں دو ایک ہے اب جب same method میں چایلد میں ناگا m1 تو میں اس کو overwrite کروں تو overwrite کر کے میکہ کروں میں same as a liqonga void m1 وہ بھی نمبر لے گا اور وہ بھی same condition لگا گا اب میں اس پریگ انڈیشن کو as it is یہاں پہ اطار سکتا ہے تو میں بھی ہاں کہتا ہے بھی same یہ جو نمبر ہے یہ 0 سے بڑا ہونا چایئے اور 5 سے چھوٹا ہونا چایئے تو یہ بھی علاوڈ ہے یا پھر میں اس کو اور vee کر سکتا ہے میں کہتا ہے 0 سے بڑا ہونا چایئے پر 5 کے جگا لیٹھ سے 10 سے چھوٹا ہونا چایئے تو میں نے 0 سے 5 ایک ریجتی میں نے 0 سے 10 کر دی ریج یہ بھی چل جائے گا تو اس کنڈیشن میں same یہاں او تارلوں گا اب اس نم گریدن 5 کے جانا میں لکھ دنگا نم گریدن 10 تو میں ایک سپشن کر دیں گا تو اچھا میں کہا رو یہ چل جانا چی یہ کیو چل جانا چی اب امیاجن کرو بمارے پاس ایک کلاینت ہے ٹھیک ہے جو کی again پیرینٹلس کا اپجٹ ایک سپیک کر دیا دیا تو اب سمجھے کہاں گیتے گا تو جب وہ کلاینت پیرینٹلس کا اپجٹ ایک سپیک کر دیا تو وہ کیا کرتا اس پے امیان کال کرتا جب وہ امیان کال کرتا اسے بیدا کونٹریکٹ یہ پتا ہوتا کہ وہ جی امیان کو جنمبر دینہ نمبر دینہ وہ 0 سے 5 کے بیچ میں دینہ ہے اگر میں اس کے آگے بیچھے کنمبر دیے تو فٹ جائے گا کوڈ مجھ دکھتے گئی تو کلاینت کو ابتا اوڑی بات ہے لیکن میں نے کلاینت کو کے لئے گا چاہل کا عبجت پاس کر دیا اور چاہل جو ہے وہ دینہ سے 0 سے 10 کے بیچ میں چیزیں ہلاؤ کر رہے تو جسی میں نے چاہل کا عبجت پاس کیا کلاینت کو اور 0 سے 10 کے بیچ میں لاؤ کر رہے تو کلاینت پہلے ہی بہت زیادہ کنسہن ہے کہ مجھے 0 سے نمبر دینہ 5 تک کر رکھنے تو وہ ابھی 0 سے 5 کر رکھے گا چاہل کو ای دیکھتے کا 3 چاہل 0 سے 10 تک ایک سپرڈ سکتے تو 5 بھی کری لے گا پر اگر گلتی سے Klein 6 7 8 دیا تو بھی Klein تو تو بھی چیلو سے hendle کر لے گا کیا وہاں 10 تک hendle کر سکتے ہیں تو بھی Klein نہیں فٹے گا تو بیسے گلے گے دکت نہیں ہے آپ اگر اس کو تھوڑا تھا ویک بھی کر دو کندیشن کو پر کبھی بھی آپ constrain t に کر سکتے تو کر میں ان اس کندیشن کو اٹھڑ کر دے تھا کہ بلٹ سے میں کہتا 0 سے 10 نہیں میں کہتا ہوں بھی 0 سے سے 3 تک الاثڑ ہنا چیے پر Klein تو گے نیا پے 4 دیதتا جو کی علاوڑ ہونا چیے پیڑیں کی طرف سے پر چیلو سے علاوڑ نہیں کر دیا تو اگرینی لسکوف سٹریٹشن کو بریک کر دے تھا تو یہ ایک تاریگے کا اگرامبلے جس آپ سے سامت سکتے ہو پری کندیشن کو پر یہ ایک بیٹر اگرامبل نہیں ہے ایک بیٹر اگرامبل کیا ہوں سکتے ہیں دیکھو بیٹر اگرامبل یہ ہو سکتے ہیں جو پر ایک تکل اگرامبلے سپو سمارے پاسے کی ایوزر کلاس ہے تک ہے اور ایوزر کلاس کے پاس ایک فنگشن ہے لیکسے چیج پاسوڑ یا لیکسے not چیج Create PASSWARD تک ہے Create PASSWARD یہ فنگشن ہے اور میں again یہاں پر پری کندیشن لگا دیا تو کی پاسوڑ کی جو لن تھی وہ شود بھی گریٹتا دن ایکو لڑ to 8 یہ کندیشن ہے تک ہے اب لیکس سپوز اس کی ایک چیلد کلاس ہے جس کا نام ہے Edmine User تو اب یہ کس کی چیلد لازتے تو میں نے کہا اس کے پاس بھی فنیم سمپل میں تھا لوگا Create PASSWARD اور وہ بھی اسی پری کندیشن کو فولو کرے گا آئی کی وہ بھی اس پری کندیشن کو فولو کرنا چاہیے کی پاسوڑ کی لن تھی شود بھی گریٹتا نکول to 8 پر اگر لٹسے وہ اس پری کندیشن کو as it is فولو نہ کرتے تھا لوگ بھی گریٹتے کی لٹسے PASSWARD not greater than equal to 8 بلکی greater than equal to 6 تو اب یہ کتنی ہوگی کسی کلینٹ کو جو یہコード use کر رہا ہے کیا کیا کلینٹ کو user کا contract پتا کلینٹ کو پتا ہے مجھے minimam Password Ki Lend 8 تو کر میں نے گلتی سے کلینٹ کو Edmine User بھی پاس کر دیا تو کلینٹ کیا کرے گا Password 8 Lend کا بنائے گا تو ابھی Edmine User allow کر دے گا کیا وہ 610 پر کلاو کر دیا اب گلتی سے کلینٹ نے 8 کی جگا 7 کا password نہ دیا تو ابھی Edmine User Xepp کر دیا آپ سمجھ رہا ہے کوئی دکت نہیں ہوگی اب اگی یہاں use кейس پڑی پینٹ کر دیا ہو سکتا کئی کی اپلیگیشنگ ایس کیسے ساہ ہوگی Password Strictly 8 Lend اس کے اس میں یہ چاہل ہے یہ پریکہ دیشن کو as it is follow کر نہ چیئے نہ کم نہ زیادہ پر ان جنڈل میں بول رہا ہے کیا پریکہ دیشن کو تھوڑا سا ویک کر سکتے پر سے یہ بیسی پرنسی پل ہے چاہلو اسی کا ایسی فٹ آفر سے کوڑ دیکھ لے تو دیکھو یہ وہی کوڑ ہے ہمارے پس user کی کلاس ہے جس کے اپنے پریکہ دیشہ لک دی Password must be 8 character long اور ہم نے set password کا BethraBranaya جو Password لے تھا چک کرتا 8 کا ہے نہیں ہے اگر 8 سے کام گا تو Invalid argument throw کر دے دیا same پھرم نے کہا کہ Edmine User of user type اور اس میں بھی set password کا BethraBranaya جو overwrite کی ہم نے پر اس میں تو یہ ایک زمپل ہے Pre-condition اور اگر آپ Pre-condition follow کر رہے ہیں تو اگر ایک اپنے Substitutable ho تو چلو فٹ افٹ نیکس کنیشہ ن دیکھنے تو اگر آپ کو Pre-condition سمجھا جا گئی تو اگر اگر پوست کنیشہ نے وہ تو بہت زلی سمجھا جا جائے گی کیو وہ just its کے اولٹی ہے دیکھو Post-condition وہ کنیشہ رو دی جو کئیسی Method ke Run ہونے کے بعد true ہونے چاہیے اگر اور Post-condition کہتا بھی وہی ہے جو ایک دم Pre-condition کہتا just its کا اولٹی ہے کی our past let's say ایک Parent class P اور let's say اس کی ایک child class C اور Parent ke pasik method ہے M1 چل کے pas بھی same method ہوگا M1 تو Post-condition کہ suppose اس M1 take Post-condition لگیوی ہے تو Child class یا تو Post-condition کو as it is لگا دے یا تو اسے اور زیادہ constrain کر دے Post-condition بھی بھی بھی بھی بھی کنگہ گری تو ایک دیسی پری کنگہ گری پری کنگہ گری کر دے پری بھی کنگہ نہیں ہے اب آپ کو گے اس کا کو ایک دمپل اس کا ایک دمپل اسے بوٹ بیٹے سمجھے گا چلو اس کا بہت نورمال سمپل ایک دمپل سپوز کرو باپسپنے کارو لیک دمپل بھی لسکہ فڑھڑشن پرنسپل کو فولو کر رہے Post-condition کو فولو کر رہے کیو کی اس کو بس فرنتن کر رہے پر بلکل ویگ نہیں کر سکتا اگر یہ کہا ہے بریک اسپید کام ہو گی اور ایک دیکھتے کیا رہا ہے یہ بہت بڑڑی دکتا ہے کیو کی جو ایسا ہے جو کی ایک ایک چل یوزر ہے جو گادی چلا نہیں آئے ہیں اسے پتا میں گادی باگہ گادی رک جائے گی پر اگر ہم اس کی گاڑی کلاس کی جگا ڑیٹریکٹر کار پاس کر دی تو اس میں تو وہ بریک دبائے گا تو گاڑی تو رکے گی نہیں تو جانلے و خدرا ہو سکتا رائٹ تو یہ لسکار پسٹڈیوشن فولو نہیں کرتا اس کے اس میں that's it اس کا بھی فتحفٹ سے قوڑ دیکھلے تھے تو یہ را پوزٹ کنیشن کا قوڑ same ہے بلکول ہم نے کار لیا speed لیا اور excel rate اور break 2 function مناہy break پم نے لکھا speed must reduce after break اس کے بعد ام نے کیاکھے high-bred car بنائی of type car electric car بناؤسکتے تھے پر suppose کرو same یہاں جو breakا method جو override کر رہا ہے اس کے وہ post-condition میں دو کر دی ایک تو speed must reduce ایک charge must increase تو یہاں پہ دیکھا ہم نے speed minus کر دی 20 یہاں پہ بھی میں minus کر دی 20 لیکن charge خم نے 10 سے بڑھا دیا کوئی دکھت نہیں ہے جب یہ جو Client جب یہ گاڑی چلایا ہے چاہی وہ high-bred car چاہی وہ normal car چاہی وہ normal car چاہی یہ جو breakا دوانے سے speed ہمے ساکہ کر موجا گی جو بیسیٹ پوست کنٹیشنٹی اس کے بعد High-bred car میں چاہی کچھ بھی ہوتا رہا ہے breakا دوانے کے بعد breakا موجودا ایک بار اس کے بعد وہ charge increase کرے وہ AC تیس کرے کرے کم کرے کچھ بھی کرے ہمیں مطلب نہیں ہے لیکن جو breakا main post-condition دی وہ فلسلوری ہے رہا ہے تو سا مجایا آپ کو کبھی گلتی نہیں کر ہو گے. اب آپ ہمیں شا کریکٹلی ایڈنٹفائ کر لگے گے. کئی کلاس, کوئی بھی سبگلاس کیا سبسٹیٹیٹیٹیبل ہے.

اپنے پیرینٹ کلاس کے. تو یہی کچھ گائدライنس کی جو ہمیں شا فولو کرنی چے. آپ کو اگر میں موتا موتا کنکلوڈ کروں. تو آپ کو دیکھنا چیے.

کوئی بھی چائل کلاس کسی بھی پیرینٹلاس کے سبسٹیٹیٹیبل تو بھن نہیں رہا جاتی. اگر وہ اپنے پیرینٹلاس کے جو میتھڈ اووڈ رائد تو کرتی ہے. پر لیٹ سے او سے دنگزے اووڈ رائد نہیں کرتی. اگر وہ اس کو ایکسپشن تھرو کرتی ہے.

اگر یہاں پھر ایکسپشن کی جگا امتی چھوڈ دیتی ہے. پورا کا پورا میتھڈ. رائد کی میہ اووڈ رائد کرنی سکتی. جس ام نے ایکانٹ ایکسپن لیا تھا.

تو ہمارے پس کیا تھا فکس جو پوزیڈ ایکانٹا. اپنی پیرینٹلاس کے اگر آپی سارے روز سیادرک ہوگے پککا پککا پککا پک کبھی قلتی نہیں کروگے. چلو. لیٹس مووڈ اووڈ رائد کی مرینٹلاس کے جو اگر ایکسپشن تکنی پرینسپشن.

آجو اسکرین پہ. تو اب اپنے نیٹ دیانپرینسپشن کی درفا مفکر رہے. جس کو ہم بولتے ہیں. انٹرپس سگریگیشن.

مرینسپشن. تک ہے. اب یہ کیا کہتا ہے. سپسے بیلسی دیفینیشن دیکھنے.

تو یہ ہے ایسپی کی دیفینیشن. انٹرپس اگرییشن. انٹرپس برسیبل. کہ many clients.

اسیپشن انٹرپس ار بیٹھر دن بجنڈل پرپس انٹرپس. نام سے ساما جا رہے. کہ بہت سارے کلائنٹ. اسیپشن.

بنا نا ہمے سیپیڈ ہے. کہ آپ ایک جنڈل پرپس انٹرپس. بنا دو جنہے. سارے کی سارے میستر گوسید دو.

بسیگلی سے کیا دیکھا تو تھی ہے جب آپ اس انٹرپیس کی چیل میں نہتے ہو تو بہت سارے ایسے چیل میں ہوتے ہیں جن کو سارے میترسی تیزورت نہیں ہوتی پر پھر بھی ان سب کو وہ سارے میترس کو اووورڑڑ کرنا پڑھا ہے تو ابھی ہم نے یہ ساری پروبلوم لسکоф سپسٹیٹیشن پر زیبل میں بھی دیکھی دی اب اسے ایک زمپل سے سمچھتے ہیں آپ کو ایسلی سمچھا جا جا جا جا جا دیکھو بہت سمچھا جا جا جا جا جا سپسٹ کرو ہمارے پاسنا ایک پیرنٹ کلاس ہے شیپ دیکھا میں نے کہ ایک شیپ ایک پیرنٹ کلاس ہے اور ہر شیپ میں میں نے پہلے بولا کی بہی ایریا تو نکلی جاتا ہوگا تو میں نے ایریا کا ایک میترٹ لیا دیکھا اب میں نے اس کی کو چیل دازیز بناتا ہوں تو ایک میں نے لٹ سے بنادیا سکویر تو یہ ایک چیل داز بن گئی ایریا کو اوڑڈ گ diapers miel گای ایریا کو اوڑڈ کریں بھائوں furnitureی چاف کریں نحن اpr Arc ٹھال کوен ایک الطو andra فBC ایک ایک اوٹڑڈ لوprowadي میں پہنے کیوں میں ایریا کا میتھر مجھ اووریٹ کرنا پڑے گا تو میں نے کیوب میں ایریا کا میتھر oh sorry کیوب میں ایریا کا میتھر اووریٹ کر دیا yes yes پر کیوب میں صرف ایریا نہیں ہوتا کیوب میں تو اب Volume میں نقال سکتے ہو تو مجھ لگا ہوا باتا صی ہے اب میں اور بھی دھیر دھیر کر گیا اور 3D a 2D objects کو جب انتڈیوس کروں گا تو اس میں Volume میں نقال سکتا ہوں تو یہاں پہنے volume کا میتھریں بھی ہو سکتے تو ہر 2D Objects ke le volume ko define ka na padhe ga تو اس سے better, میں karm gator na یہ جو main, mere jo shape class, shape interface let's say abstract class tige, to interface ka ka na gam ga rai pura abhi abstract class hai, to is mein ko definition a sub declaration hai تو is mein walu me define ka gator na declier ka gator na ki bhai walu me bhi saap ko override ka na padhe ga ki hara shape hu walu me mo tige baad ek chali hara shape me walu me na heo ta, square meo rectangle me walu me na heo saakta ek 2D figure hai kiw bhamara 3D figure hai so muleke ka gator na padhe ga zabad das ti ki jaaphe volume hai tu muleke yeh da bhe bhe volumeke metha dal na padhe ga aur usko declare ka na let's say mein kaisa kitaan trou invalid argument same tali kaisa muleke yeh da bhe volumeke metha dal na padhe ga aur yeh da bhe bhe usko dal na kaisaktaan in valid argument par jaaphe volumeke metha dal na yeh da bhe menko simply execute ka kitaan aur simply declare ka kitaan ki bhai cube ka volumeke ho ta bhe link to ab heo ka kia me ne کیا؟ میں نے کیا گلٹی کی بیسکلی؟ میں نے کیا؟ میں نے یہ تو کہاں کہ کی کیوں بیکترا کا شیپ ہے اور کیوں میں وولیم ہوتا ہے تو میں نے شیپ میں بھی وولیم دالگیا پر ہر کلاث میں وولیم نہیں ہوتا یہاں پہ جیسے کی سکویر میں رکٹنگل میں وولیم کی ضرد تھیں نہیں تو انٹرپھے سگریگیشن принципل یہاں پہ یہ کہہ رہا تھا کی many clients specific interface are better than one general purpose interface اب ہم نے جنگل پرپھے سیپھے شیپ تو بنا دیا جس میں بہت سارے métھڑs ay but sare subtypes کو ہر métھڑ چاہیے این شیپ کلاس کا so یہی اس کی دوسری لائیں تھی client should not be forced to implement method that they don't need جس کہ ہپے sqr اور rectangle کو وولیم کی ضرد نہیں تھی پر تبین کو اسے اگزیکیٹ کرنا پڑا اگزیکیٹ سے میں نہ بطلبہ ان کو دفائن کرنا پڑا صرف cube کو اس کی ضرد تھیں تو cube کو دفائن کرنے دے ہم کیا کرتے دو الغا لگئے انٹرپھے سمنا لیتے ایک ٹڑیشپ کا لگ بناتے ٹڑیشپ کا لگ بناتے اور یہی ہے انٹرپھے سکریگےٹ کرنے کا принципا لیتے سکریگےٹھن پھنپھے اگزیکیٹ اب اس کو مٹھیک کیسے کرتے اس کو مائے سے ٹیک کرتے کی ہم دو درا کی شیپ بناتے ایک بناتے ٹڑیشپ اور ایک بناتے ٹڑیشپ ٹڑیشپ ٹڑیشپ میں ہمارے پاس صرف ایریا ہوتا اور ٹڑیشپ میں ہمارے پاس ایریا اور وولیم دونوں ہوتا اور یہ دونوں کیا ہوتے ابسٹریکٹ ہوتے دونوں ابسٹریکٹ ہوتے اب جو بھی چیل ہوتا اس کے جسے لیٹھ سپوز سکویر ہوجیا وہ چیل ہوجاتا ٹڑیشپ کا اگیں سیم ریکٹنگل ہوجیا وہ بھی چیل ہوجاتا ٹڑیشپ کا جیس کو بھی یا اسے نکڑتے ٹڑیشپ ٹڑیشپ ٹڑیشپ سکویر ہوجید diverse اگہ یہ پورا پرنολی اگہ چیل ہاتی ٹڑیشپ ٹڑیشپ ٹڑیشپ ٹڑیشپ ٹڑیشپ ٹڑیشپ ٹڑیشپ ٹڑیشپ ٹڑیشپ ٹڑیشپ ٹڑیشپ ٹڑیشپ ٔڑیشپ ٹڑیشپ ٹڑیشپ சیم رکٹنگل کرے گا ڈیے کو ورڈ کر دے گا لن تینٹھوں گیت پر ورڈیم کو ورڈیگن کر پائے گا تو لوجکہ لڑتھر ہو کر دے گا ڈیگا اور 3D شейب دونوں کو ورڈ کر دے گا ڈیگا کو بھی ورڈیم کو بھی کوی دکت نہیں ہو گی پر یہ جو ہے کلاینڈ ہی آپ ایسپی کو بریک کر دے گا کیوں کی بہت سارے جنڈل پر پس ہم نے بیتیک لیگ جنڈل پر پس انٹرپیز بنادیا جس میں بہت سارے جو چیلز لاز ہے ان کو ہر میتھڈ کو override کرنا پڑ رہا ہے اب اس کا سلیوشن کیا ہے تو یہ ہے اس کا سلیوشن ہم نے کیا اعلقہ لگ انٹرپیز بنائیں ایک 2 دیمیشنال شیب ایک 3 دیمیشنال شیب 2 دیمیشنال میں میں صرف ایریاد آلا 3 میں ایریار وولیم دونوں دونوں دونوں اور same کیا square 2D سے 2D شیب سے انہرٹ کر دے رکٹنگل بھی 2D سے کر دے اور cube 3D سے کر دے اب cube 3D اور volume 2D کو override کر دے رکٹنگل سے فیریار اور square سے فیریار کو override کرے گا کیو کیا اب اسے volume کی ضرورتی نہیں ہے so that set یہی ایریار انٹرپیز بنائیں ایک ایحو بھی سب سے سمپل بنائیں ایک اب فتافٹ سے مف کرتے ہیں پھر last principle کی طرف جو ہے dependency inversion principle تو چا لو اب اپنے last principle دیکھتے ہیں which is dependency inversion principle سب سے پھل اگیین اس کی definition تو یہ ہے اس کی definition اور یہ کہتی ہے ki high level module should not depend on low level module but rather both should depend on abstraction definition is very vague but it is very simple it is very simple that we have some high level module some low level module these two should not interact directly but in their beach an abstraction layer should be needed abstraction layer should be an interface or an abstract class whose through which they interact so the high level module should not talk directly to low level and the low level should not talk directly to high level but they should talk directly to contract an interface through which they interact and this is how we have followed all these design principles are very intertwined if you read one, then you remember yes, this was applied on the other side the same thing is for this so let's take an example you will understand better okay let's see this suppose you make an application okay so you have an application mobile application hello software application hello kuch b you make an application what is it done it interacts with database okay now database is equal right it can be mongo no database okay so in this case this application is your high level module high level of all modules which deals with your business logic right and low level this database layer which we call as low level module so low level is the high level module which interacts with the system like to interact with a database to interact with file systems to call an external API that is all low level module high level means to deal with business logic so I was saying that no high level module no direct interact with any low level module right what we should do in the middle of them introduce an interface layer talk to this application and talk to this sequence talk to the same sequence and talk to this application this simple thing I was saying if you don't understand then when I see an example then it will be understood okay so let's expand this example a little so I was saying that suppose we have an application this is our class okay now what do I have to do I had said in this application to interact with the database so to interact with the database this is our database okay let's draw it from the similar color from here here this is the DB now to interact with this we will need some classes right directly so I have said I will make two classes another name MongoDB which will interact with MongoDB and one is SQLDB which will interact with SQLDB so I will make two different different types let's say this is an SQLDB and this is an MongoDB so let's move this okay MongoDB so I made two different classes MongoDB MongoDB is an SQLDB it is an SQLDB class okay now this application this is the application it has some data someone who is coming to me using the data has some random data I have to save these two and I have to save these two so I have a function save to DB so I have some function so let's write this function on the database so I have a function save to DB but I have to save both of them even in MongoDB SQL so I don't have one function what I do? I work I take a reference of these two i.e. a has a relationship I take a reference i.e. what is the meaning of this?

I have one so what is the object of SQLDB? let's say I call it sg and I have one and I have a MongoDB object I call it md so I have a relationship the application has a MongoDB the application has a SQLDB now in this application it has become very small so I am writing some methods here in this application some methods so one save to SQL in that method the object of SQLDB is sg it will be called on sg it will be a SQL method let's say save so sg.save so another method save to MongoDB and what is it? the object of Mongo is md it will be called on md so it will be a save method so this is all now what is the point? the point is that this is a high level module and these two are a low level module because they are interacting with database now in this this high level module is interacting with a low level module now the point is that I have to set the Mongo database and in this place I have to use CassandraDB which is another type of DB so I have to do something I have to open this application class and I have to change the object of MongoDB and then I have to make a new method to open this open close principle I have to break this principle so I have to break this principle and I should do something for it I should do an inverse of dependency basically what should I do?

I should introduce an interface in between in between the two which is to talk about MongoDB and SQLDB and talk directly about the application directly with the interface I should solve this problem I should introduce a new interface I should introduce a new class and then I thought of how I did this last time so I should introduce a class first of all I should remove all this so now I have removed all this and now what do I do? I should introduce a new class which is the name the persistence class now the application the first application is SQL and MongoDB is the same but now the application is only the persistence class the application has an object of persistence class P and now the persistence class will inherit both the subclass which subclass SQLDB and MongoDB and the persistence class will inherit the same method and they will override both the subclass how do I do this? they will override the subclass to save the subclass and then they will save the subclass and then they will connect now the benefit of this is that the high level application has no need to function if we remove this function then this is how our application looks now our application is just one function which will be P P.save now we will call this P now the persistence class is that they want to save the SQL or Mongo how? whenever we refer to this P and sign it then we can pass the SQL and then we can pass the Mongo which we will allocate through polymorphism P.save will be called application means we have to call this interface this acts as abstraction between a high level module and between those two low level modules if we change the SQLDB or MongoDB then what will I do?

I will make a new CassandraDB and then we can also save the method and in runtime I will pass the P in the application but I don't know what the application is it will also call the save method this is the entire version of the inverse principle now let's look at the code of the FATA first of all where our DIP was the principal so let's see what we did we made the database of mySQL save to Mongo so what is the save to SQL we execute SQL query and save data in SQL and save to Mongo we execute some MongoDB function and save it in Mongo now let's make a user service here we have an example we do MongoDB and SQLDB have reference we do two methods again we do two methods now the user service is using the user so what will I do? what is the use? and what does the user do? what do we do?

we do SQLDB and use it and we do MongoDB and save to Mongo we do two methods we have a TITLE and we have a low-level module we have a TITLE and if we use MongoDB and use the standard DIP then we have to go inside the user service and use the store user to change the function and we have to change the reference and the open closed principle will break the entire break so to avoid this we have used the solution which is DIP so this is the code so we have done the DIP and we have made a database so this is an abstract class interface it is working for abstraction now the MySQL database and MongoDB database you have made it all database then we have done the same and we have executed it we have saved it in the MongoDB now we have the user service and the database object is DB so we have used the dependency injection and we have not used the dependency injection whenever you pass an object as a variable in any class we call it dependency injection we have injected this dependency and we have injected this dependency and we will read it in other terms in some other video so we have passed this DB in the constructor we have taken this DB this database can be used like polymorphism we cannot know what we will do with our DB and we have a method which we use in this DB which will be used in the type of data which will be used in Mongo we call it save method and we have finished our work now we have to change the MySQL and the Mongo we will have to write new classes but we have to change the class open closed principle will be your detector use it okay? let's discuss a fact first of all if we want to follow the open closed principle then the dependency inverse principle will be followed if the open closed principle is the target then the dependency inverse principle is the solution remember remember if the dependency inverse principle is understood in real life that the company has a CEO which is a high level and many of our team developers are developed so the low level is working on low level the CEO will not talk directly we will introduce a interface an abstraction which is manager the CEO will talk to the manager if the developer is able to be able to interact with the manager if the developer is able to change then the CEO is not needed the CEO is not able to tell who the developers are and who are going to go I know that the manager will have to say the manager will handle the rest of the manager the database is always used the database is always used to define the data which is passed dynamically through polymorphism this is all about dependency inverse principle and this is all about solid design principle in general now a last question you might have come to mind that we are in the object oriented programming but here we have the dependency inverse principle single responsibility principle we say that we need a class but in real life it is not like that in real life there are very complicated objects for example, a human if a human is an object he does a lot of things in real life he does not eat, he does not eat but when we were explaining what we were doing we say that we need a single responsibility so how will you explain this it is like in real life it is very complicated it can show many behaviors but every object does not show in every scenario basically it means if a human is an object if a human is an object then if a human is an object then if a human is an object then if a human is an object then the scenario is different it started calling the different behaviors in a different way programming is the same when we denote a real life object then we say the different scenarios we say that a human is an object that can also be used in the different applications for example if an object is an object then you can read the right you can go on the right you can cancel the right but if an application is changed then now the responsibility of the user will change the functionality of the user will change basically the user can do everything but at one time the only application that is showing a different behavior then what will the user do on the right he can order food he can't cancel the right but he can cancel the food then we say that we always map the real life object in a programming but in a real life every object in a different scenario in a different way the same thing we say that we will show the different applications so the user can be complicated we have to use the functionality that we have to use not to say that the law is that it is an ideal thing you must have seen that you can never upload all the applications to be very difficult if you are uploading all the different design principles it is an ideal thing sometimes you have to break the data in the terms of business logic so this always has a trade-off like in DSM تو time complexity or space complexity ke beach ki hameisha time bhaja na ke lehe abh zada space ne leisak te hri hameisha hash na puzin katsak te just because of ka time bhaja aa ka kaina kai space baig requirement ho tiyay waise yaha pe aa ek trade off ho tay ki kaab aapko solid design principle ko toodosa break karna hai aapne business logic ko sambal na ke lehe ki ki add end of the day business logic ke to main aa wehi to peh sa la ke dhe ra kise application ko write to kabe kaabar hame trade off hameisha maintain karna bhaja to yeh baa tha meisha adra na yeh design principle ko i laun heye principle se isle toodha bhaat unnis bhi sismi chal saak teye hamei koosesh karni chhe jitna zada hai se follow kar paha utna chay utna amara koud kleanar vaneya utna amara koud expandable hoga aur utna amara koud skale bhaa lhoga write to this video me baas itnai aapse milti annex video me tapta keliye thank you so much

Lesson FAQs

What is SOLID Design Principles | part 2 about?

hange kare start so welcome back to the RME our salary dhik series so last lecture we discussed solid design principles in which we discussed the open close and list of substitution already now we have two principles so we discuss it with a pata

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 SOLID Design Principles | part 2?

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