1. SOLID Principles with Easy Examples | OOPs SOLID Principles Interview Question - Low Level Design

Concept && Coding - by Shrayansh
26 May 202219:02

Summary

TLDRThe video script discusses the SOLID principles of object-oriented programming, which are crucial for writing understandable, flexible, and maintainable code. It provides examples of how each principle, such as Single Responsibility, Open/Closed, Liskov Substitution, Interface Segregation, and Dependency Inversion, can be applied to avoid code duplication and complexity. The script uses relatable examples like a market invoice system and a keyboard interface to illustrate these principles in action, emphasizing the importance of good coding practices for software development.

Takeaways

  • 📘 The video discusses the SOLID principles of object-oriented programming, which are guidelines to make software designs more understandable, flexible, and maintainable.
  • 🔑 The Single Responsibility Principle is highlighted, emphasizing that a class should have only one reason to change, meaning one job or responsibility.
  • 🔄 Open/Closed Principle is explained, advocating for classes to be open for extension but closed for modification, allowing the addition of new functionality without altering existing code.
  • 🔗 The Liskov Substitution Principle is touched upon, stating that derived classes should be substitutable for their base classes without affecting the correctness of the program.
  • 🔄 Dependency Inversion Principle is mentioned, suggesting that high-level modules should not depend on low-level modules but rather on abstractions (e.g., interfaces).
  • 🛠️ The video provides examples to illustrate the principles, such as creating an Invoice class that calculates total price based on price and quantity, demonstrating the Single Responsibility Principle.
  • 📚 The script mentions the importance of keeping classes focused on a single task to prevent the need for changes in multiple places when requirements shift.
  • 📈 The concept of extending functionality without modifying existing code is illustrated through examples, such as adding new features to a class without altering its core logic.
  • 🔍 The video script addresses the challenges of adhering to the SOLID principles in real-world scenarios, such as when changes in business requirements necessitate breaking the principles.
  • 🛑 The script uses the example of a Vehicle class to explain how the Liskov Substitution Principle can be violated if a subclass does not maintain the same behavior as its parent class.
  • 🔗 The Dependency Inversion Principle is exemplified by showing how implementing interfaces can lead to more flexible and maintainable code by reducing direct dependencies between classes.

Q & A

  • What is the main topic of the video script?

    -The main topic of the video script is the SOLID principles of object-oriented programming, with a focus on explaining each principle and providing examples of how they can be applied in software development.

  • What does SOLID stand for in software development?

    -SOLID is an acronym for five design principles intended to make software designs more understandable, flexible, and maintainable. The principles are Single Responsibility, Open/Closed, Liskov Substitution, Interface Segregation, and Dependency Inversion.

  • What is the Single Responsibility Principle?

    -The Single Responsibility Principle states that a class should have only one reason to change, meaning it should only have one job or responsibility.

  • Can you provide an example from the script that illustrates the Single Responsibility Principle?

    -An example given in the script is a class named 'Invoice' that calculates the total price based on the price and quantity of items. This class follows the Single Responsibility Principle as its only job is to handle the calculation logic.

  • What is the Open/Closed Principle?

    -The Open/Closed Principle states that software entities should be open for extension but closed for modification, meaning that you should be able to extend the functionality without changing the existing code.

  • How does the script explain the Liskov Substitution Principle?

    -The script does not explicitly mention the Liskov Substitution Principle, but it can be inferred from the discussion on extending classes without modifying them, which aligns with the principle that subclasses should be substitutable for their base classes without affecting the correctness of the program.

  • What does the Interface Segregation Principle suggest?

    -The Interface Segregation Principle suggests that no client should be forced to depend on methods it does not use, which means that interfaces should be small and client-specific.

  • Can you give an example from the script that demonstrates the Dependency Inversion Principle?

    -While the script does not provide a direct example, the Dependency Inversion Principle can be related to the discussion on depending on abstractions rather than concrete implementations, which is a way to reduce the dependency of one class on another.

  • What is the purpose of the examples provided in the script?

    -The purpose of the examples in the script is to illustrate how the SOLID principles can be applied in practical programming scenarios to create more maintainable, flexible, and understandable code.

  • How does the script address the issue of code duplication?

    -The script addresses the issue of code duplication by emphasizing the benefits of the SOLID principles, such as reducing complexity and avoiding duplication by adhering to the Single Responsibility Principle and Open/Closed Principle.

  • What is the significance of understanding SOLID principles in software development?

    -Understanding SOLID principles is significant in software development as it helps in creating a robust and scalable architecture, making the code easier to maintain, extend, and understand, which ultimately leads to higher quality software.

Outlines

00:00

📘 Introduction to SOLID Principles

The first paragraph introduces the SOLID principles of object-oriented programming, which are crucial for creating understandable, flexible, and maintainable code. The speaker discusses the importance of these principles in software development and provides a brief overview of the Single Responsibility Principle, one of the five SOLID principles. The paragraph sets the stage for a deeper dive into each principle through examples and explanations.

05:02

🔍 Exploring the Open/Closed Principle

The second paragraph delves into the Open/Closed Principle, emphasizing that software entities should be open for extension but closed for modification. The speaker uses the example of a dance class to illustrate how this principle can be applied to create flexible and adaptable code. The paragraph discusses the benefits of adhering to this principle, such as preventing the need for changes in existing code when new functionality is required.

10:03

🛠 The Liskov Substitution Principle

In the third paragraph, the Liskov Substitution Principle is explored, which states that derived classes should be substitutable for their base classes without affecting the correctness of the program. The speaker provides an example involving a motorcycle and its engines to demonstrate how this principle ensures that objects of a superclass can be replaced with objects of a subclass without causing errors or unexpected behavior in the program.

15:05

🔗 Understanding the Interface Segregation Principle

The fourth paragraph discusses the Interface Segregation Principle, which advises that no client should be forced to depend on methods it does not use. The speaker explains this principle with the example of a restaurant employee who should not be burdened with unrelated tasks. The paragraph highlights the importance of creating fine-grained interfaces that allow clients to depend only on the methods they need, thus improving the maintainability and flexibility of the code.

Mindmap

Keywords

💡SOLID Principles

SOLID is an acronym for five design principles that intend to make software designs more understandable, flexible, and maintainable. In the context of the video, SOLID principles are likely discussed to emphasize good coding practices that lead to more robust and scalable applications. The script mentions 'SOLID' explicitly, indicating it as a central theme.

💡Single Responsibility Principle

This principle states that a class should have only one reason to change, meaning it should only have one job or responsibility. In the video, the concept is exemplified through the idea of a class that calculates an invoice, which is a single task and thus adheres to this principle.

💡Open/Closed Principle

This principle suggests that software entities should be open for extension but closed for modification. The script discusses this in the context of adding new features to a class without modifying its existing code, which is a core aspect of this principle.

💡Liskov Substitution Principle

This principle is about ensuring that derived classes can be substituted for their base classes without affecting the correctness of the program. The script seems to touch on this by mentioning the importance of child classes being able to replace their parent classes without issues.

💡Interface Segregation Principle

This principle argues for the segregation of an interface into client-specific interfaces, thus making it more specific to the client's needs. The script may refer to this principle when discussing the design of interfaces that are tailored to particular classes and not overly generalized.

💡Dependency Inversion Principle

This principle involves two points: high-level modules should not depend on low-level modules, and both should depend on abstractions. The script hints at this principle when it talks about classes depending on interfaces rather than concrete implementations.

💡Invoice

An invoice is a document issued by a seller to a buyer, indicating the products, quantities, and agreed prices for products or services. In the script, the invoice is used as an example to illustrate the application of the Single Responsibility Principle.

💡Class

In object-oriented programming, a class is a blueprint for creating objects. It is a template that defines the properties and methods that the object will have. The script frequently refers to classes and their responsibilities, especially in the context of the SOLID principles.

💡Method

A method is a function that is associated with an object or a class. It describes the behavior of an object. In the script, methods like calculating the total price or printing an invoice are mentioned, showing how they contribute to the functionality of a class.

💡Interface

An interface in programming defines a contract for methods that must be implemented by a class. The script discusses interfaces in the context of the Dependency Inversion Principle, emphasizing the importance of depending on abstractions rather than concrete classes.

💡Abstraction

Abstraction is a concept where you focus on the essential characteristics of an object or a class, ignoring the irrelevant details. The script touches on this concept when it talks about high-level modules depending on abstractions, which is part of the Dependency Inversion Principle.

Highlights

Introduction to the SOLID principles, which are fundamental to object-oriented design and should be well-known to developers.

Explanation of the Single Responsibility Principle, emphasizing that a class should have only one reason to change.

The importance of reducing duplicate code and the benefits it brings to maintainability and flexibility in software development.

Discussion on how the principles help in reducing complexity and making the software more understandable and flexible.

An example of applying the Single Responsibility Principle in a class design, illustrating how it simplifies the class's purpose.

The concept of Open/Closed Principle, stating that software entities should be open for extension but closed for modification.

How to apply the Open/Closed Principle to allow for extending the functionality without modifying the existing code.

Liskov Substitution Principle and its role in ensuring that derived classes can replace their base classes without affecting the correctness of the program.

The importance of creating flexible and reusable code by following the Liskov Substitution Principle.

Explanation of the Interface Segregation Principle, highlighting the need for creating narrow, client-specific interfaces.

How to avoid implementing unnecessary functions in a class by adhering to the Interface Segregation Principle.

Dependency Inversion Principle and its significance in depending on abstractions, not on concretions.

The benefits of the Dependency Inversion Principle in making the system more modular and easier to extend.

Practical examples of how the SOLID principles can be applied in real-world software development scenarios.

The impact of SOLID principles on code readability, maintainability, and the ease of adding new features to a system.

Discussion on the challenges faced when applying the SOLID principles and how to overcome them for better software design.

The role of SOLID principles in promoting good coding practices and their importance in professional software development.

Encouragement for developers to share and discuss their experiences with the SOLID principles to foster better coding practices.

Transcripts

play00:00

थे स्टेट आईएस वेलकम टो कांस्टेंट

play00:02

कॉन्टैक्ट तो आज हमारा वीडियो है यह सॉलिड

play00:05

प्रिंसिपल आफ जो कि सब को बताना चाहिए और

play00:08

हमें सबको पता है एक्चुअली तो आप अगर आप

play00:10

देखोगे पंजा डिजाइन पैटर्न के ना उसमें यह

play00:12

सब एप्लीकेबल हुए हैं बट हमें तरह से टर्म

play00:15

जान रहे हैं कि अच्छा इसको सिंगल रिस्पोंस

play00:18

रिलेटेड जख्म होते हैं इसको डिपेंडेंसी इन

play00:20

वचन बोलता है तो लेट्स ईद सिस्टम कि क्या

play00:24

है और अगर आप हमें नहीं पता है तो इस

play00:27

सिंपल एग्जांपल्स रमेश को करूंगा तो वह

play00:29

पुलिस विल हेल्प तो जो सॉलिड प्रिंसिपल

play00:33

सेंस के एक तरीके से एडवांटेज के होते हैं

play00:35

अपने एप्लीकेशन में यूज करने के इट अवार्ड

play00:39

डुप्लीकेट कोड तो जितने भी बेनेफिट्स सो

play00:41

सकते हो ना कि इटावा डुप्लिकेट कोड इजी टू

play00:44

मेंटेन अंडरस्टैंड एंड फ्लैक्सिबल

play00:46

सॉफ्टवेयर रिड्यूस कंपलेक्सिटीज मौसम है

play00:48

लेकिन कैसे वह भी ओपन एग्जांपल से देखते

play00:51

हैं तो आप देखोगे तो यह सॉलिड है न तो यह

play00:54

फाइव प्रिंसिपल्स है एस वेल एस फॉर सिंगल

play00:57

रिस्पॉन्सिबिलिटी प्रिंसिपल ठीक है इस

play01:00

शिमला ओएलईडी का सबका एक अलग कंप्लीट नेम

play01:03

है तो लड्डू 151 और पहला देखते हैं सिंगल

play01:07

रिस्पॉन्सिबिलिटी की होता है विच स्टैंड्स

play01:09

फॉर इस

play01:10

तो सिंगल रिस्पांसिबिलिटी क्या बोलता है

play01:12

अब तक लाश शोल्ड हैव ओनली वन रिलिजन टो

play01:15

चेंज इसका क्या मतलब है इसका यह मतलब है

play01:18

कि एक क्लास के पास एक रिस्पॉन्सिबिलिटी

play01:20

होनी चाहिए एक से ज्यादा नहीं और इसका मैं

play01:23

आपको मतलब समझाता वांट टो चेंज थे

play01:25

एग्जांपल लीजिए मेरे पास एक मारकर एंटी है

play01:28

ठीक है मतलब मारकर करेगा मार्केट जो है इस

play01:32

तरह से मान कर चलिए मेरे पास एक ऑपोज़िट

play01:34

है और उसमें मार्किट में क्या है मेरे पास

play01:36

नेम कि क्या नेम है मार्किट का कलर की

play01:40

मार्किट में ब्लैक है ग्रीन है यार ऑफ

play01:43

मैन्युफैक्चर और उसका प्राइस बेसिक

play01:45

ऑब्जेक्ट है मार्किट का ठीक है

play01:48

है अब मैं एक क्या कर रहा हूं उसका इनवॉइस

play01:50

बना रहा हूं तो अब देखिए यहां पर मैं

play01:51

इनवॉइस बना रहा हूं तो मैंने क्या किया

play01:53

मार कर को ऑब्जेक्ट लिया तो इनवॉइस है

play01:56

जहां तो यहां पर मज़े करना तो एसिड है जब

play02:00

है अरे सो इनवॉइस है जब मारकर और मैं तो

play02:04

इसकी क्वांटिटी निकाल है क्वांटिटी है तो

play02:07

यह मैंने कंस्ट्रक्टर बना लें तो मैं क्या

play02:09

करूं यहां पर कैलकुलेट टोटल इनवॉइस बना

play02:11

रहा तो मतलब प्राइस * क्वांटिटी तो इतना

play02:14

मैं इसकी प्राइस रिटर्न कर दूंगी मैं यह

play02:16

तुम्हारे टोटल प्राइस सॉरी यह आपके टोटल

play02:20

प्राइस हो गई ठीक है लेकिन और क्या मेथड

play02:22

मेरे पास की प्रिंट वॉइस कि जो प्राचीन

play02:25

वॉइस बनाया मैंने अगर एक मारकर ₹10 का था

play02:28

मैं दो क्वांटिटी ले रहा हूं तो यहां पर

play02:30

रिटर्न क्या कर रहा है फोन

play02:33

है तो यहां पर इसके बाद में क्या कर रहा

play02:35

हूं कि इनवॉइस को प्रिंट भी कर रहा हूं

play02:37

ठीक है और यहां पर एक और मेथड से 2डी

play02:40

फॉरमेंट बीवी में स्टोर भी करा रहा हूं

play02:42

ठीक है तो अब क्या बोलेंगे क्या यह सिंगल

play02:47

रिस्पोंस रिलेटिव प्रिंसिपल को फॉलो कर

play02:49

रहा है देखिए कैसे तो सिंगल

play02:51

रिस्पांसिबिलिटी है वह वन रीजन टो चेंज

play02:53

कैसे पासवर्ड रिसेट टो चेंज है मान कर

play02:56

चलिए आज मैं

play02:57

अपना कैलकुलेशन लॉजिक चेंज कर दो और मैं

play03:00

मांग चले GST लेकर आता हूं कि मेरे को

play03:02

प्राइस निकालते वक्त GST भी लगाना है

play03:04

डिस्काउंट पर लगाना है तो डेफिनेटली मेरी

play03:07

कैलकुलेशन लॉजिक चेंज हो जाएगी करेक्ट

play03:09

क्योंकि मेरे को प्राइस में से जो भी है

play03:12

उसमें से डिस्काउंट करना पड़ेगा फिर जो

play03:14

फोटो और क्वांटिटी में जो प्राइज उसमें

play03:16

टैक्स लगाना पड़ेगा तो मेरा कैलकुलेशन

play03:18

चेंज होगा सो इनवॉइस क्लास गेटिंग चेंज्ड

play03:22

बिकॉज अ कैलकुलेशन चेंज ना कैलकुलेशन

play03:25

लॉजिक टो वन रीजन क्या और भी कोई बिजनेस

play03:28

क्लास के चेंज होंगे अगर आपने मानवीय चली

play03:31

प्रिंटेड वॉइस है अगर आप प्रिंटिंग लॉजिक

play03:33

जैन दोस्तों ठीक है तो भी चेंज हो सकता है

play03:36

ठीक है और आज यह दूसरा रिटर्न हो गया

play03:39

गैलरी यथावत इस रिजल्ट सेव 2GB आरडीबी में

play03:44

सेट कर रहा हूं और मांगे चलो अब मुझे फाइल

play03:46

में सेव करना है तो भी मुझे क्लास है चेंज

play03:48

करना पड़ेगा आज से टू बी है तो मारने के

play03:50

लिए मुझे सेट अप टू फाइल भी करना है तो भी

play03:52

मुझे इस क्लास को चेंज करना पड़ेगा तो

play03:54

मेरे पास कितने रीजन है गैस का आंच को

play03:56

चेंज करने के 3डी वर्जन बट सिंगल

play03:59

रिस्पॉन्सिबिलिटी क्या बोलता है क्लास वह

play04:00

वांट टू चेंज और ओनली वन रिस्पांसिबिलिटी

play04:03

तो दैट्स व्हाई दिस क्लास इज नॉट फॉलोइंग

play04:06

ए सिंगल रिस्पॉन्सिबिलिटी प्रिंसिपल ठीक

play04:09

है तो आप इसको करेक्ट कैसे करेंगे तो यहां

play04:12

पर हम क्या कर सकते हैं कि ए क्लास को

play04:14

हरेक शख्स को ऐसा बना कि वह खाली एक रीजन

play04:17

उसके बाद चेंज आएगा तो मैंने इनवॉइस जो

play04:19

प्लास्टिक ऊपर उसमें खाली कैलकुलेट टोटल

play04:22

रह दिया लेकिन जो प्रिंटेड वॉइस आफ सेव

play04:26

2GB जाना उनके लिए अलग अलग लाइसेंस बना दी

play04:28

तो सेव 2GB के लिए मैंने एक डाईट प्लान

play04:31

बना दी और डाटा एक्सेस लेयर जो जिसको हम

play04:34

बोलते हैं इसका कॉमेडी में सेट करना

play04:37

इनवॉइस सेट करना ठीक है तो नॉएडा खोली

play04:40

वांट टू चेंज सेवेन वॉइस कहां पर सेव 2GB

play04:44

xm25 कहीं पर भी प्रेम अरे इनवॉइस प्रिंटर

play04:47

करके बना दिया ठीक है इसका काम है प्रिंट

play04:50

करना इंवोल्व को तो नोइज क्लास है सिंगल

play04:53

रिस्पॉन्सिबिलिटी ठीक है इनवॉइस प्रिंटर

play04:56

का काम है जो भी मेरे पासन वायर्स को

play04:57

प्रिंट करना फ्यूचर में मांगे चाहिए मुझे

play04:59

कुछ और प्रिंट करना है दूसरे टाइप का

play05:01

इनवॉइस कम है तो उसको भी मैं प्रिंट कर

play05:02

सकता हूं

play05:04

कि अ डाटाबेस का क्या दाम है एन हवाई

play05:06

अड्डों का काम न सेव करना चाइए में सेव

play05:10

करेंगे फाइल में शेयर करें और टाइम टेबल

play05:12

सेट कर लो इसको सेट करना है इसका काम है

play05:15

है और सिंपली फॉर इनवॉइस का तो आप इसको

play05:17

बोलिए बॉयज का केलकुलेटर कम समथिंग किसका

play05:21

काम है कैलकुलेटर प्राइस ठीक है और कुछ भी

play05:24

चेंज होता है इस कैलकुलेशन लॉग इन थिस

play05:27

क्लास विल चेंज डेट विल नॉट इंपैक्ट

play05:30

डिस्कस ठीक है तो इससे उनको पता चल गया कि

play05:34

सॉलिड प्रिंसिपल कहेगी ऐड से सिंगल

play05:37

रिस्पोंस ब्रिटिश क्या हुआ इजी टू मेंटेन

play05:39

हो गया

play05:40

अच्छा ठीक है इजी टू मेंटेन हो गया और

play05:42

easy-to-understand हो गया कैसे इजी टू

play05:45

मेंटेन कैसे हुआ कि अगर मेरे खाली

play05:47

कैलकुलेशन रोज में चेंज है तो मैं खाली

play05:50

कैलकुलेशन वर्ल्ड क्लास चेंज कर रहा हूं

play05:52

प्रिंटर वाली क्लास फोर 750 चेंज नहीं कर

play05:56

रहा है

play05:57

कि गर्ग सौरव सिंह धरगस पॉसिबिलिटी आफ

play06:01

प्रिंसिपल गया समझ में

play06:04

हैं नेक्स्ट देखते हैं यह ओपन

play06:07

ओपन क्लोज प्रिंसिपल टो स्टैंड फॉर ओपन

play06:10

क्लोज प्रिंसिपल अब यह क्या बोलता है यह

play06:13

बोलता है कि ओपन फॉर एक्सटेंशन बट क्लॉथस

play06:16

फॉर मोडिफिकेशन

play06:18

थे राइट तो अब इसका क्या मतलब है तो बन

play06:21

प्रीवियस वाले एग्जांपल जाता है एक अपने

play06:23

एक डांस क्लास बना ली थी वे यहां पर सिंगल

play06:27

रिस्पॉन्सिबिलिटी को फॉलो करते हुए हमने

play06:29

छोटी-छोटी क्लासेस बना लिए विशेष सिंगल

play06:31

रिस्पॉन्सबिलिटी तो हमारे पास क्लॉक बन गई

play06:33

थी एडवाइज्ड ऑफ द टाइप्स ऑफ जो कि उसका

play06:37

काम है फाइल को सेव इंवोल्व हों सेट करना

play06:39

है तो यह क्लासेज ओके आप बीवी में सेव कर

play06:41

रहा है अच्छा ठीक है डिश - आलरेडी टेस्ट

play06:44

यह फाइल टेस्ट हो चुकी है लाइव है यह और

play06:48

ट्रैफिक रियल लाइफ पिछले यह कोड आलरेडी

play06:51

लाइफ में है मान कर चलिए अब मेरे पास एक

play06:53

नई एंट्री की नीयत से दफा हो तो मैंने

play06:57

क्या किया 725 मेथड में और यह क्या है

play07:00

फाइल में सेव कर रहा है इसको

play07:05

हु इज द फॉलोइंग ओपन क्लोज प्रिंसिपल नो

play07:09

टॉर्च लाइट क्योंकि ओपन क्लोज प्रिंसिपल

play07:11

का होता है ओपन फॉर एक्सटेंशन आप इसको

play07:14

एक्सटेंड कर सकते हो बट को नोटिफिकेशंस जो

play07:17

क्लास ऑलरेडी स्टेटेड और लाइफ में है उसको

play07:21

क्यों मोड ऑफ कर रहा है एक्सटेंड कर लो

play07:23

अगर आपको कैपेबिलिटी एक्स्ट्रा चाहिए

play07:25

तरफ बढ तो आप एक्सटेंड करो लेकिन उसको

play07:29

ऑलरेडी टेस्ट वाली क्लासेस को मॉडिफाई मत

play07:31

करो ठीक है तो यहां पर मैंने क्या किया

play07:33

ऑलरेडी इस क्लास में एक और मेथड डाल दिया

play07:36

से 125 का तो यह मैं इस आलरेडी टेस्ट फाइल

play07:40

को चेंज कर रहा तो इट्स पॉइंट टू ड्रॉप्स

play07:42

तो इसको मैं कैसे इंप्रूव कर सकता हूं तो

play07:44

आप देखिए यहां पर मैंने इंटरफेस लिया एन

play07:47

हवाई अड्डों का

play07:49

कि अब यहां पर दो मैं कर सकता हूं कि इन

play07:52

वॉइस

play07:55

और जो डांटू है इसके पास दो है बीवी और

play07:58

फाइल

play08:01

अच्छा ठीक है तो 13 व अड्डों है यह भी इस

play08:04

इंटरनेशनल इवेंट कर रहा है और एक पाइप

play08:06

लाइन वाइज है यह भी रीसेंट अपडेट्स में

play08:08

प्रिवेंट करता है थोड़ी सी फूड कर रहा है

play08:10

यह सिर्फ टू फाइल कर रहा है अगर फ्यूचर

play08:12

में कोई और आता है तो मैं इसको नहीं चेंज

play08:14

करूंगा इसको नीचे करो मैं सीधा इसको

play08:16

एक्सटेंड कर लूंगा मान कर चलिए एक्स वाई

play08:18

जेड

play08:19

परसिस्टेंस कुछ भी आधा करना है कोई और मैं

play08:22

थर्ड ठीक है है या तो मान कर चलिए दोस्तों

play08:26

TV है यहां पर मैं मान कर चलिए कर रहा

play08:28

मांग डी पी ओ

play08:29

कल मुझे स्कूल सर्टिफिकेट कोर्स चेंजेस

play08:32

करने पढेंगे इधर फाइल वाले मैकेनिक करना

play08:34

पड़ेगा मस्जिद अबू धाबी में अगर एडिशनल

play08:36

अपडेट कर दूंगा मैं मैं तुझे इस तरीके से

play08:39

हम इसको फॉलो करते हैं ओपन फॉर एक्सटेंशन

play08:42

बस क्लॉथस फॉर नोटिफिकेशन ओं

play08:44

ए सिंपल एग्जांपल गए समझ में

play08:48

अच्छा लगे तो हमारा पास तीसरा आता है l

play08:52

सॉलिड में तीसरा है एल्विस - लिफ्ंिटग

play08:56

ट्यूशन प्रिंसिपल डा

play08:58

ये सब तोड़ से कॉन्पलेक्स है फ्रॉम रेस्ट

play09:00

ऑफ द क्यों यह क्या बोलता है इस क्लास बी

play09:05

इस सप्ताह आफ क्लास 8 तो यह मेरे पास

play09:07

क्लास है इसका चाइल्ड क्लास बी

play09:12

कि डैम बे शोल्ड बे एबल टो रिप्लेस थे

play09:14

ऑब्जेक्ट आफ वेज आफ बजे अलार्म रिप्लेस कर

play09:19

सकते हैं विदाउट ब्रेकिंग न बिहेवियर ऑफ द

play09:21

प्रोग्राम दिसंबर इंपॉर्टेंट विदाउट

play09:23

ब्रेकिंग अभिव्यक्त मांटेसरी मेरे पास एक

play09:26

प्रोग्राम है आलरेडी करोड और है यह क्या

play09:30

एक्सेप्ट कर रहा है कि ऑब्जेक्ट एक्सेप्ट

play09:33

कर रहेगा और फिर इसके बाद यह कुछ इस बैक

play09:37

एंप्लॉयमेंट कर रहा है मानकर चलिए अगर मैं

play09:39

इस ऑब्जेक्ट एक ही जगह यहां पर इसको पास

play09:42

को टर्न ऑफ बिर्थ तो यह जो बेस्ट ऑफ लक

play09:44

उड़न है इसको यह ब्रेड नहीं होना चाहिए

play09:46

स्टील चलना चाहिए आउटपुट डिफरेंट बट इट्स

play09:50

नॉट ब्रेक व बिहेवियर ठीक है अब वे किस

play09:54

तरीके से चेंज सप्ताह मान कर चलिए कि यहां

play09:57

पर मैंने इसको क्या बोला कि जब हम सरप्लस

play10:00

बनाते हैं ना यह स्ट्रैट एक्सटेंड द

play10:02

कैपिटल ऑफ द पेरेंट्स प्रश्न शेयर ओं

play10:05

रेडिट्ट कि टिकट खुलासे के बाद जब एक प्लस

play10:08

वन फीचर है तो इसके पास प्लस पौन इंच और

play10:11

प्लस एक और एडिशन होना चाहिए इसके वह यह

play10:14

है कि आलरेडी दो फीचर से और इवेंट में एक

play10:17

हटाकर खाली एक ही फीचर बचाएं ठीक है

play10:20

एपिसोड एक्सटेंडर कैपिटल अपहरण एंड वॉटर

play10:23

ड्रॉप डाउन

play10:25

तो अब फॉर एग्जांपल अब एग्जांपल सेवा को

play10:27

समझाता हूं मैंने इंटरप्रेस लिए बाइक का

play10:30

बाइक के पास दो मैक्डोनॉल्ड इंजन और

play10:33

एक्सीलरेट

play10:34

अच्छा ठीक है अब यहां पर मैंने एक

play10:36

ऑब्जेक्ट बनाया मोटरसाइकिल का तो यह क्लास

play10:39

हो गई मेरी बाइक

play10:42

है और इसका चाइल्ड हो गया मोटरसाइकिल व

play10:46

अच्छा ठीक है अब यहां पर क्या है दोनों

play10:49

इंजन में मैं क्या करूं इंजन को टू करो कि

play10:51

इंजन रूम गया एक प्लेट में क्या करूं मैं

play10:54

स्पीड को बढ़ा रहा हूं ठीक है तो यह मेरा

play10:56

फ्रंट इसलिए एक्जिस्टिंग कोड है और मेरा

play10:59

कोई प्रोग्राम है उसके पास ऑब्जेक्ट तरह

play11:01

बाइक का जिसमें भी मोटरसाइकिल का ऑब्जेक्ट

play11:03

है ठीक है तो अभी कोर्ट क्या बिहेव कर रहे

play11:06

कि जब भी मैं टर्न ओन इंजन करूंगा तो मेरे

play11:08

पास इंजन टर्न ऑन हो जाएगा इस पड़ाव तो

play11:11

स्पीड बढ़ जाएगी मान कर चलिए मैंने एक

play11:14

बाइसिकिल एक बार ऑब्जेक्ट बनाया यहां पर

play11:18

कि बाइसिकल

play11:20

अच्छा ठीक है कंप्लीट कर रहे बाइक को अब

play11:23

यहां पर टर्न ओन इंजन साइकिल में तो इंजन

play11:25

होता है तो यहां का यह क्या करेगा

play11:27

एक्सेप्शन थ्रो कर देगा 239 इंजन है अच्छा

play11:30

ठीक है तो अब यहां पर हमने क्या किया यहां

play11:33

पर हमने

play11:35

के बिहेवियर चेंज कर दिया मान कर चलिए आज

play11:37

कोई मेरे पास प्रोग्राम है ठीक है उसके

play11:40

पास बाइक का एक ऑब्जेक्ट आफ है अगर आज लुट

play11:44

आज तक उसके पास मोटरसाइकिल को ऑब्जेक्ट आ

play11:46

रहा है

play11:49

है और मोनू क्या कर रहा है ऑब्जेक्ट डॉट

play11:51

एन रंजन

play11:54

अब इंजन को टर्न ऑन कर रहा है और फिर कुछ

play11:56

काम कर रहा है तो उसको पता है कि मैं टर्न

play11:58

ओन इंजन करूंगा तो इंजन टाउन होगा ठीक है

play12:01

कि क्योंकि मेरे पास ऑब्जेक्ट है अगर मांग

play12:03

CR में इसको चेंज कर देता हूं बाइसिकिल के

play12:06

ऑब्जेक्ट से तो यह फंक्शनैलिटी ब्रेक हो

play12:08

जाएगी तो यहां पर मैं एक सेंट्रो कर रहा

play12:10

हूं

play12:11

है तो डीटेल्स व्हाट्सएप पर शुड एक्सटेंड

play12:14

पॉजिटिव पेरेंट्स टैंकर नीचे फेवरेट को ऑन

play12:17

कर देंगे यहां पर मैंने किया उस समय वे

play12:20

डोंट कर दिया कि Bigg Boss को टर्न ओन

play12:22

इंजन की कैपिसिटी ही नहीं दशा है इट इज द

play12:25

प्रिज़न ऑफ़ प्रोग्राम्स अरे अगर हम सब

play12:28

क्लासेस में कैपेबिलिटीज जो पेरेंट्स

play12:30

कैपिटलिज्म को कम कर देंगे

play12:33

अच्छा ठीक है तो लिस्ट ऑफ का प्रिंसिपल

play12:36

समझ आ गया क्या कहता है कि क्लास भी शुड

play12:39

बे रिप्लेसिड विद क्लास है ठीक है विदाउट

play12:41

ब्रेकिंग द ईयर और बेकिंग यह कैसे कर सकते

play12:45

हैं कि कैपेबिलिटी जो यह सब टाइप हमेशा

play12:47

इनक्रीस करें पेरेंट्स की ऑफिस को कम करें

play12:51

अच्छा तो हम चलते हैं चौथे प्रिंसिपल की

play12:53

तरफ इंटरप्रेस सेगमेंट प्रिंसिपल अब यह

play12:56

क्या होता है कि इंटरप्राइजेज शुभ सर्च द

play13:00

क्रॉनिकल्स नोड

play13:03

कि इंप्लिमेंट अननेसेसरी फंक्शन देख धुंध

play13:08

है तो इसको एग्जांपल समझते हैं तो मैंने

play13:10

यहां पर एक इंटरव्यू लिया रेस्टोरेंट

play13:12

एम्पलाई है

play13:14

कि अब मेरे पास बहुत सारे फंक्शन है एक है

play13:16

व्हाट्सएप देश मे गौतम जो है बर्तन धोने

play13:19

कस्टमर्स को साफ करना है ऑफ फूड को करना

play13:22

है तो मैंने बेटर क्लास बनाएं और इसमें

play13:26

रेस्टोरेंट इंप्लाइज को किया तो और जो

play13:29

बेटर क्लास है जब यह इंटरफेस को

play13:32

इंप्लिमेंट कर है तो इसको सारे मैसेज ओं

play13:34

एंप्लॉयमेंट करने पढेंगे तो उसने वॉइस

play13:36

डिस्प्लेसमेंट किया 100 कस्टमर

play13:38

इंप्रूवमेंट कि आपको शूट किया लेकिन क्या

play13:40

वेटर का काम है वह बर्तन धोना नहीं क्या

play13:44

वेटर का काम है बखूबी को बनाना नहीं बेटा

play13:48

का क्या समय खाली सौंफ कस्टमर्स करना तो

play13:50

यहां पर मैं क्या ब्रेक कर रहा हूं

play13:52

इंटरप्रेस सेगमेंट प्रिंसिपल को क्या

play13:54

बोलता है जो क्लाइंट है इसमें क्लाइंट्स

play13:57

हैव अ जो क्लाइंट है वेटर

play13:59

कि शुड नॉट इंप्लीमेंट अननेसेसरी फंक्शन

play14:02

डु नॉट मीट मुझे इसकी जरूरत भी नहीं थी

play14:04

WhatsApp Twitter को व्हाट्सएप शिफ्ट पर

play14:08

इंप्रूवमेंट करने की लेकिन फिर भी हम सभी

play14:10

मुझे रिमाइंड करना पड़ा बिकॉज आफ जिसे

play14:13

इंटरफेस तो इसमें से कमेंट करके मतलब है

play14:16

छोटे-छोटे टुकड़े तो इसमें क्या होता है

play14:18

इंटरफेस को इतने छोटे टुकड़ों में बांट दो

play14:20

कि जो लाइन है आपके उनको अननेसेसरी जो है

play14:23

फंक्शन इंप्लिमेंट ना करना पड़े तो

play14:26

हैं तो इस केस में रखो मैंने क्या किया कि

play14:28

मैंने इस इंटरफेस को यह जो इंटरफेस फाल

play14:31

इसको इस तरीके से भाग गया एक बेटर

play14:33

इंटरप्रेस कर दिया एक शेप इंटरप्रेस कर

play14:36

दिया वीर वह मैंने ऐसा करके सौंफ कस्टमर

play14:39

टेक आर्डर सैफ इंटरफेस के अंदर रखें कुछ

play14:42

फूड डिसाइड मैन्नू आप इस तरह से और भी कर

play14:45

सकते हो कि हेल्पर इंटरप्रेस जिसके अंदर

play14:48

आप कर सकते हो कि व्हाट डिस्टेंस अब मैं

play14:51

वेटर को इंप्लिमेंट करूं तो बैटर इसको

play14:52

इंप्लीमेंट करेगा खाली वेटर इंटरफेस को

play14:55

ठीक है और यह खाली वहीं मेथड इंप्लिमेंट

play14:58

कर है तो इसका मतलब छैना अब इसको कुक फूड

play15:00

से कोई जबरदस्ती टाइम लिमिट नहीं करना पड़

play15:02

रहा है डिसाइड मैंने जबरदस्ती में एलिमेंट

play15:04

नहीं करना पड़ रहा है तो यह मतलब है एंटर

play15:07

पर स्टेटमेंट का कि आप इंटरव्यू को इतना

play15:09

छोटे-छोटे में डिवाइड कर दो ताकि जो आपको

play15:12

क्लाइंट बना रहे हुआ था उसको अननेसेसरी

play15:14

इंटरेस्ट एंड इंप्लीमेंटेशन ना करना पड़े

play15:16

फंक्शन था

play15:18

ए क्लियर है नाइस और अब चलते आपन लास्ट

play15:22

सॉलिड प्रिंसिपल पर जो है

play15:25

डिपेंडेंसी इन वर्जन प्रिंसिपल बहुत सिंपल

play15:28

है यह क्या कहते है क्लास डिपेंड इंटरफेस

play15:31

प्रदान कंक्रीट क्लास अच्छा ठीक है इसको

play15:34

समझते क्या बोलता है यह मांगे जो मैंने

play15:36

फैब्रिक लिया यह मांगे चलो मेरे पास है एक

play15:39

ही बोर्ड इंटरफेस

play15:42

कि यह इंटरफेस

play15:45

है तो कीबोर्ड में एक है वायर

play15:49

है कीबोर्ड

play15:51

कि यह चाइल्ड क्लास है और एक इस टाइम

play15:55

पिग्मेंटेशन है अब ब्लूटूथ

play15:58

कि ब्लूटूथ कीबोर्ड अ

play16:03

का सिम लिया देख ले दो कि माउस है

play16:07

कि इंटरप्राइजेज

play16:11

ए सिंपल यहां पर मेरे पास है एक वायरलेस

play16:13

माउस

play16:16

है और एक है

play16:19

कि ब्लूटूथ माउस

play16:22

मैं तो अभी मैंने कहा कि यह एक माइक बना

play16:25

हुआ था मेरे पास लैपटॉप पर नेटवर्क आ

play16:28

उसमें मैंने क्या किया कि अ साइन कर दिया

play16:31

वाइट कीबोर्ड यह वाला

play16:34

वाइट कीबोर्ड और इसका इग्नोर न ऑब्जेक्ट

play16:37

बना दिया था माउस तो मैंने यहां पर क्या

play16:40

कि यह जो कंक्रीट लॉसेज नदी ज्यादा

play16:42

कंक्रीट क्लासेस दी ज्यादा इंटरप्रेस दबने

play16:45

इंटरफेस कोडिंग नहीं कि मैंने क्या किया

play16:47

कि कंक्रीट क्लासेज जो है कंक्रीट क्लास

play16:49

के जो ऑब्जेक्ट है उनको साइन कर दिया यहां

play16:52

पर तो दिस रॉक अगर मांगे चलिए मुझे फ्यूचर

play16:55

में मैथ्स बुक को डांस करना है ब्लूटूथ

play16:57

करना है तो मैं यहां पर नहीं कर सकता

play16:59

क्योंकि मैंने यहां पर बिल्कुल कंक्रीट

play17:02

क्लास के जो ऑब्जेक्टिव सेंड कर दिया है

play17:04

को ट्वीट नॉट फॉलिंग डिपेंडेंसी इन वजन

play17:07

प्रिंसिपल तो इसको ठीक करने के लिए मैंने

play17:10

क्या किया कि यहां पर इंटरप्रेस ऑब्जेक्ट

play17:12

लिए इंटरफेस क्लास का यहां पर मैंने वह

play17:16

लिए और यहां पर मैंने यह वाले लिए माउस और

play17:20

कीबोर्ड ना कि कंक्रीट वाले और यहां पर जो

play17:23

मैं है इनको असाइन कर रहा हूं कि इस तरीके

play17:26

से कंस्ट्रक्टर इंजेक्शन से तो यहां पर

play17:29

मैंने जब भी कोई कर सकता होगा तो अगर मैं

play17:31

यहां पर अवॉइड कीबोर्ड और वायरमैन भेजूंगा

play17:34

तो मेरे पास इन में वाइट कीबोर्ड पर मौजूद

play17:37

लेंगे अगर मैं यहां से ब्लूटूथ कीबोर्ड

play17:39

ब्लूटूथ मौजूद भेजूंगा तो यहां पर मैं

play17:41

मेरे पास ब्लूटूथ कीबोर्ड ओर माउस लेंगे

play17:43

शिमला नहीं सकता है वाइट कीबोर्ड ब्लूटूथ

play17:46

मांस है तो मैं यहां पर वाइट कीबोर्ड को

play17:48

अपडेट भेजूं या फिर ब्लूटूथ का भेजूंगा तो

play17:50

ऑटोमेटिकली मेरे जो ऑब्जेक्ट है वह

play17:53

कि कैप्लर होंगे किसी भी कांबिनेशंस को

play17:56

लेने गए ठीक है वह हॉटस्पॉट न हो जाए कि

play17:58

ऑलवेज अवॉइड ऑलवेज कीबोर्ड ऑल वर्ल्ड वाइड

play18:01

माउस

play18:03

अच्छा ठीक है समझ गया को डिपेंडेंसी का

play18:05

क्या बोलता है कि डिपेंड ओं में इंटरफेस

play18:06

प्रदान कंट्री उत्तरांचल आईएस नॉट

play18:08

डिपेंडेंट अपऑन इंटरप्राइजेज कीबोर्ड और

play18:11

माउस

play18:12

ए रदर कंक्रीट का से यहां पर मैंने गया तो

play18:16

वायर और दसवां रस

play18:19

मैं तुझे यही है सॉलिड प्रिंसिपल्स और

play18:22

इनकी वजह से उत्पन्न जो कोड लिखे है ना

play18:23

बहुत सिंपल हो जाता है कुछ नयापन हॉलीडे

play18:26

करते हैं इसको बट अट लीस्ट गुड टो नो थिस

play18:30

टाइम दिखाओ इंटरव्यू में बहुत बार पूछ

play18:32

लेते हैं ड्रैग फ्लिक सॉलिड प्रिंसिपल

play18:34

बताओ उसके तो एटलीस्ट 2009 कि कौन सही यह

play18:38

जो हमारे गुड कोडिंग है वह कौन सी किस

play18:40

कैटेगरी में आता है ओके गाइस आए हो कि

play18:43

आपको एग्जांपल से अच्छा समझाया और बहुत

play18:45

इजी लगे होंगे इस साल प्रिंसिपल अगर प्लीज

play18:48

अच्छा लगे तो प्लीज को शेयर कीजिएगा इस

play18:50

नोट कुछ सजेशन है तो प्लीज वह बताइए एंड

play18:54

थैंक यू गाइस हग डे बाय डे

Rate This

5.0 / 5 (0 votes)

Связанные теги
SOLID PrinciplesOOP ConceptsCode MaintainabilitySoftware DesignProgramming Best PracticesSingle ResponsibilityOpen/Closed PrincipleLiskov SubstitutionInterface SegregationDependency InversionDeveloper Education
Вам нужно краткое изложение на английском?