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

العلاقات

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

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

نظرة عامة

الموضوعات

  • الارتباط (Association)
  • التجميع (aggregation)
  • التركيب (composition)
  • الاعتمادية (dependency)

تعلّم أولًا

49 دقيقة قراءة · 2 ساعة تدريب (تقدير)

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

  1. Distinguish association, aggregation, composition, and dependency, with Java examples.
  2. Draw a simple UML class diagram showing relationships and multiplicities.
  3. Implement one-to-many relationships in code.

الدروس

  1. 01كيف تتعارف الكائنات10 د قراءة
  2. 02الارتباط والتجميع والتركيب9 د قراءة
  3. 03الاعتمادية (Dependency)10 د قراءة
  4. 04مخططات فئات UML: العشرون بالمئة المفيدة10 د قراءة
  5. 05عرض عملي: رسم UML ثم برمجة Customer وAccount10 د قراءة

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

Lab

BEG-025-LAB1 · Bank Accounts v4

Outcomes: 1, 2, 3 · Time: ~1.5 h Draw the UML diagram first: Customer owns many Accounts; each Account has many Transactions (composition). Then implement it. Name each relationship type in a note. Acceptance: diagram matches code.

Exercises (assessment: diagram-from-description exercise)

IDOutcomeTask
BEG-025-EX011Classify: (a) Order has OrderLines, (b) Team has Players, (c) Printer used by a method parameter, (d) Student attends Course.
BEG-025-EX021Give Java code that shows aggregation and code that shows composition.
BEG-025-EX032Diagram from description: "A library has many books. A member can borrow many books; a book is borrowed by at most one member at a time. Each loan has a date."
BEG-025-EX043Implement Customer with a List<Account> and openAccount / accounts() that does not expose the list.
BEG-025-EX052, 3Spot the problem: Customer and Account each hold the other, but Account is never given its customer. Fix it.
أظهر الحلول
  • EX01 (a) composition; (b) aggregation; (c) dependency; (d) association. Aggregation versus association can be debated; justification matters.
  • EX02 Aggregation: a Team receives existing Player objects in add(Player p). Composition: an Order creates its OrderLine objects internally and never shares the list.
  • EX03 Boxes: Library, Book, Member, Loan. Library 1 ◇— * Book; Member 1 — * Loan; Book 1 — 0..* Loan (only one open at a time); Loan holds the date. Judged on correct multiplicities.
  • EX04 public List<Account> accounts() { return List.copyOf(accounts); } and openAccount creates and adds.
  • EX05 Set both sides in one method (openAccount creates the account with this as owner), or remove the back reference if no one needs it.
  • Outcomes 2 and 3 are also covered by the lab.

الاختبار

Outcomes: O1 relationship types · O2 UML · O3 one-to-many in code.

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

  1. 1Parts that cannot exist without the whole show:O1
  2. 2A class that only uses another as a method parameter has a:O1
  3. 3A Bank holding Customers who exist independently is best called:O1
  4. 4An Account and its Transactions (deleted together) is:O1
  5. 5A filled diamond in UML means:O2
  6. 6A dashed arrow in UML usually means:O2
  7. 7Multiplicity * means:O2
  8. 8A one-to-many link is implemented with:O3
  9. 9A risk of bidirectional links is:O3
  10. 10A good UML class box shows:O2

الجزء العملي

Diagram-from-description (BEG-025-EX03), the other exercises, and Bank Accounts v4 with a matching diagram. Pass: correct classes, relationship types, and multiplicities in the diagram, and code that matches it.

أخطاء شائعة

Bidirectional links that are never kept in sync; UML with every field listed.

التقييم

Diagram-from-description exercise.

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

Entity relationships (JNR-030) and relational modeling (BEG-049).

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