انتقل إلى المحتوى
أمين أبوزيد
BEG-019

مقدمة في البرمجة كائنية التوجه (OOP)

  • 5 درس
  • 58 دقيقة قراءة
  • 1.5 ساعة تدريب (تقدير)
في هذه الصفحة 8 موضوعات

نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.

نظرة عامة

الموضوعات

  • البرمجة الإجرائية مقابل البرمجة كائنية التوجه
  • الكائنات
  • الفئات
  • الحالة (state)
  • السلوك

تعلّم أولًا

58 دقيقة قراءة · 1.5 ساعة تدريب (تقدير)

مخرجات التعلم

  1. Contrast a procedural solution with an object-oriented one for the same problem.
  2. Identify objects, their state, and their behavior in a plain-language description.
  3. Explain the difference between a class and an object.

الدروس

  1. 01عندما يتوقف الكود الإجرائي عن التوسّع12 د قراءة
  2. 02الكائنات: الحالة + السلوك11 د قراءة
  3. 03الفئات كمخططات11 د قراءة
  4. 04إيجاد الكائنات في وصف المشكلة12 د قراءة
  5. 05عرض عملي: إعادة كتابة بنك إجرائي على هيئة كائنات12 د قراءة

المختبر والتمارين

Lab

BEG-019-LAB1 · Noun and verb hunt

Outcomes: 1, 2, 3 · Time: ~1 h From a one-page description of a bank (provided by the instructor), list candidate classes (nouns), their state, and their behaviors (verbs). Justify each choice and say which nouns you rejected and why. Acceptance: reasonable candidates with justification.

Exercises (assessment: quiz plus the noun/verb analysis)

IDOutcomeTask
BEG-019-EX011Write two or three sentences on what goes wrong when you store 500 accounts in parallel arrays.
BEG-019-EX021Sketch (in words) how the same deposit looks procedurally and object-oriented.
BEG-019-EX032For a library book, list three pieces of state and three behaviors.
BEG-019-EX042Underline nouns and verbs: "A student enrolls in a course. The teacher grades the exam."
BEG-019-EX053Explain class vs object using a cookie cutter and cookies (or your own analogy).
BEG-019-EX063Say whether each is a class or an object: Account, Ana's account, Customer, the customer named Omar.
أظهر الحلول
  • EX01 Related values are split across arrays, easy to get out of sync, and any code can change any value with no protection; adding a field means editing everything.
  • EX02 Procedural: deposit(balances, 3, 50). OO: account.deposit(50); the account owns its balance.
  • EX03 For example state: title, author, isBorrowed. Behavior: borrow, return, describe.
  • EX04 Nouns: student, course, teacher, exam. Verbs: enrolls, grades.
  • EX05 The cutter is the class (shape defined once); each cookie is an object with its own state (e.g., icing).
  • EX06 Class, object, class, object.
  • Outcome 2 is also covered by the lab; all outcomes also appear in the quiz.

الاختبار

Outcomes: O1 procedural vs OO · O2 state and behavior · O3 class vs object.

اختبار ذاتي لك: لا توجد درجات، ولا يُحفظ أو يُرسل أي شيء. اختر إجابة ثم تحقق منها، ويمكنك المحاولة مرة أخرى كما تشاء.

  1. 1A main problem of parallel arrays for accounts is:O1
  2. 2OOP groups together:O1
  3. 3Adding a currency field in the array version most likely requires:O1
  4. 4The balance of an account is:O2
  5. 5"Deposit" is:O2
  6. 6Two accounts built from the same class:O2
  7. 7A class is best described as:O3
  8. 8An object is also called a(n):O3
  9. 9How many objects can one class create?O3
  10. 10When hunting nouns in a description, you should:O2

الجزء العملي

Complete the noun/verb analysis (BEG-019-LAB1) and the six exercises. Pass: quiz 7/10 and an analysis with justified candidates, rejecting at least one noun.

أخطاء شائعة

A class per noun, including irrelevant ones; behavior separated from the data it acts on.

التقييم

Quiz plus the noun/verb analysis.

الصلة بالمسار الوظيفي

The start of domain modeling (MID-060, SRA-003).

اكتب للبحث في المستويات والمراحل والوحدات والدروس.