بيت » Inheritance (OOP programming)

Inheritance (OOP programming)

1967
  • Kristen Nygaard
  • Ole-Johan Dahl
Programmer coding inheritance in object-oriented programming at a modern office.

Inheritance is a mechanism in OOP where a new class (subclass or derived class) is based on an existing class (superclass or base class), inheriting its attributes and methods. This supports code reusability and establishes a natural hierarchy between classes. The subclass can extend or override the inherited behavior, allowing for more specific implementations while maintaining a common interface.

Inheritance facilitates an “is-a” relationship between classes. For example, a ‘Dog’ is a type of ‘Animal’. In this scenario, ‘Animal’ would be the superclass, containing general attributes and methods like ‘age’ and ‘eat()’. The ‘Dog’ class would be the subclass, inheriting these properties and adding its own specific ones, like ‘breed’ and ‘bark()’. This avoids code duplication, as the common logic is defined once in the superclass and reused by all its subclasses. Changes made to the superclass are automatically propagated to all subclasses, simplifying maintenance.

There are different types of inheritance, including single inheritance (a class inherits from only one superclass), multiple inheritance (a class inherits from more than one superclass), and multilevel inheritance (a class inherits from another class which itself is a subclass). While powerful, inheritance can also introduce complexity and tight coupling between superclasses and subclasses. Overuse can lead to deep and convoluted hierarchies that are difficult to understand and maintain. Modern design often favors composition over inheritance, where an object contains an instance of another object to achieve code reuse, representing a “has-a” relationship.

UNESCO Nomenclature: 1203
- علوم الحاسب الآلي

النوع

النظام التجريدي

الاضطراب

Substancial

الاستخدام

الاستخدام الواسع النطاق

السلائف

  • the concept of hierarchical classification in biology and philosophy
  • data structures that could contain other data structures
  • the need for code reuse in large برمجة الأنظمة
  • the design of the simula language, which introduced classes and inheritance

التطبيقات

  • غوي widget toolkits (e.g., a ‘button’ class inheriting from a ‘control’ class)
  • frameworks for web development (e.g., controller classes inheriting from a base controller)
  • game development (e.g., ‘orc’ and ‘elf’ classes inheriting from a ‘character’ class)
  • modeling biological classifications
  • creating specialized exception types in programming languages

براءات الاختراع:

NA

أفكار ابتكارات محتملة

!!مستويات !!! العضوية مطلوبة

يجب أن تكون عضوًا !!! مستويات!!! للوصول إلى هذا المحتوى.

انضم الآن

هل أنت عضو بالفعل؟ سجّل الدخول هنا
Related to: inheritance, subclass, superclass, derived class, base class, code reuse, hierarchy, is-a relationship, polymorphism, overriding.

اترك تعليقاً

لن يتم نشر عنوان بريدك الإلكتروني. الحقول الإلزامية مشار إليها بـ *

متاح للتحديات الجديدة
مهندس ميكانيكي، مشروع، هندسة العمليات أو مدير البحث والتطوير
تطوير المنتج الفعال

متاح لتحدي جديد في غضون مهلة قصيرة.
تواصل معي على LinkedIn
تكامل الإلكترونيات المعدنية والبلاستيكية، التصميم مقابل التكلفة، ممارسات التصنيع الجيدة (GMP)، بيئة العمل، الأجهزة والمواد الاستهلاكية متوسطة إلى عالية الحجم، التصنيع المرن، الصناعات الخاضعة للتنظيم، شهادات CE وFDA، التصميم بمساعدة الحاسوب (CAD)، Solidworks، الحزام الأسود من Lean Sigma، شهادة ISO 13485 الطبية

نحن نبحث عن راعي جديد

 

هل شركتك أو مؤسستك متخصصة في التقنية أو العلوم أو الأبحاث؟
> أرسل لنا رسالة <

احصل على جميع المقالات الجديدة
مجاني، لا يوجد بريد عشوائي، ولا يتم توزيع البريد الإلكتروني ولا إعادة بيعه

أو يمكنك الحصول على عضويتك الكاملة -مجانًا- للوصول إلى جميع المحتويات المحظورة >هنا<

السياق التاريخي

(إذا كان التاريخ غير معروف أو غير ذي صلة، على سبيل المثال "ميكانيكا الموائع"، يتم تقديم تقدير تقريبي لظهوره الملحوظ)

الاختراع والابتكار والمبادئ التقنية ذات الصلة

انتقل إلى الأعلى

قد يعجبك أيضاً