Object Oriented OOP البرمجة الشيئية إعداد : م. محمد رمضان
OOP depends upon Library, Functions which means Structured Programming.
تعتمد على وجود مكتبات ودوال ويعنى بها البرمجة الشيئية أو وجود أشياء عدة يتم برمجتها.
When can we say that this Language is Fully OOP?
متى نقول على لغة أنها تدعم البرمجة الشيئية بشكل كامل؟
There are 4 conditions to say that any language is fully OOP, these are
يجب توافر 4 شروط لكى نحكم على أى لغة بأنها تدعم البرمجة الشيئية بشكل كامل وهم
1 . Encapsulation
2. Abstraction
3. Inheritance
4. Polymorphism 1. Encapsulation
It means gathering things together in one place, like a capsule.
هو تجميع أشياء معا فى مكان واحد وكأنه كبسولة.
a. Class creation with all functions "methods" and variables that are related to each other.
مثل عمل Class به كل الدوال والمتغيرات التى لها علاقة ببعضها البعض.
b. Authorizations can be made upon these classes by using private / public methods.
يمكن عمل تحديد لصلاحيات الدوال حيث يتم استخدام دوال بشكل عام أو تحديد دوال خاصة.
2. Abstraction
It means NOT distinguished function in the class, with no code inside.
هو تجريد الدوال فى ال class من أى كود .
Also means, making the hierarchy of the method or function, return type and parameter list.
أيضا يعنى تحديد الشكل العام للدالة من عدد ونوع الباراميتر وأيضا نوعها.
3. Inheritance
Gathering the same properties and methods in one class and make the other classes as Childs and so they can inherit from the parent class and use its methods or properties.
هو تجميع الخواص والدوال المتشابهة معا فى class واحد وجعل ال classes الأخرى التى لها نفس الصفات تورث هذه الخواص والدوال من الclass الأب.
When you make a Human class that has all properties of Users, Customers, Suppliers or any other persons in your system, it's the inheritance in our language but not in the programming language, because the class Human will not has a meaning by itself.
مثل عندما نجعل class Human له خواص الإنسان وجعل باقى ال classes ترث منه هذه الصفات ولكن هذا فى لغتنا وليس فى لغة البرمجة لأن class Human وحدة سوف لا يكون له معنى.
So the real meaning of inheritance is: the existence of a class that has properties and methods shared with other classes and in the same time should has a meaning itself.
لذلك المعنى الحقيقى للوراثة فى لغات البرمجة هو وجود class له خواص عامة وترث منه classes أخرى هذه الصفات ولكن فى نفس الوقت يجب أن يكون لهذا الclass الأب معنى واستخدام.
4. Polymorphism
It means differences in the outer shape of things.
يعنى تعدد الاختلافات فى الشكل الخارجى للأشياء.
a. Override: Changing the return type or parameter list or both and keep the name.
هو وجود دوال لها نفس الاسم ولكن تختلف فى عدد البارامتر أو تختلف حسب نوعها.
It will result in 2 or more methods with the same name but have a different code.
ينتج عنها أكثر من دالة بنفس الاسم ولكن بكود مختلف.
b. Overload: Changing the Code itself without changing the return type or parameter list
هو كتابة الدالة الأصلية بنفس الاسم ولكن يتغيير الكود
It will result in the same method with a new code and forgetting the old one.
ينتج عن ذلك دالة اخرى بكود مختلف ولكن بنفس الاسم ويتم تجاهل الدالة الأولى تماما[/left]