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

الحزم والتنظيم

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

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

نظرة عامة

الموضوعات

  • الحزم (Packages)
  • الاستيراد (imports)
  • الرؤية (visibility)
  • تصميم فئات متماسكة

تعلّم أولًا

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

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

  1. Organize classes into packages that match folder structure and use imports correctly.
  2. Use package-private visibility to hide implementation classes.
  3. Group classes by feature rather than by technical type, and justify it.

الدروس

  1. 01الحزم والمجلدات12 د قراءة
  2. 02الاستيراد وتعارض الأسماء11 د قراءة
  3. 03الوصول على مستوى الحزمة (Package-private): المُعدِّل المنسي12 د قراءة
  4. 04التقسيم حسب الميزة مقابل حسب الطبقة11 د قراءة
  5. 05عرض عملي: إعادة تنظيم الحسابات المصرفية في حزم حسب الميزة11 د قراءة

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

Lab

BEG-027-LAB1 · Bank Accounts v5

Outcomes: 1, 2, 3 · Time: ~1.5 h Reorganize Bank Accounts into feature packages (account, customer, notification) with a minimal public surface. Write two sentences justifying feature over layer packaging. Acceptance: only intended classes are public.

Exercises (assessment: refactoring exercise)

IDOutcomeTask
BEG-027-EX011Give the folder path and package line for class Invoice in package com.acme.billing.
BEG-027-EX021Fix the clash: your code needs both java.util.Date and java.sql.Date.
BEG-027-EX032A class RateTable is used only by Account. Which modifier should it have and why?
BEG-027-EX043Group these into packages by feature: OrderController, OrderService, OrderRepository, UserController, UserService.
BEG-027-EX051, 2, 3Refactoring exercise: take a provided project in the default package and reorganize it with a small public surface.
أظهر الحلول
  • EX01 com/acme/billing/Invoice.java with package com.acme.billing;.
  • EX02 Import one (import java.util.Date;) and write java.sql.Date in full where needed.
  • EX03 Package-private (no modifier): only its package needs it, and hiding it keeps the public surface small.
  • EX04 order/ (the three Order classes) and user/ (UserController, UserService). Justification: related code together, helpers can be package-private.
  • EX05 Graded on: correct package lines and folders, compiles and runs, helpers package-private, no use of the default package.

الاختبار

Outcomes: O1 packages and imports · O2 package-private · O3 feature vs layer.

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

  1. 1The package com.acme.app maps to the folder:O1
  2. 2The package statement must be:O1
  3. 3Which package needs no import?O1
  4. 4Two classes with the same simple name from different packages:O1
  5. 5A class declared with no access modifier is visible:O2
  6. 6A good reason to use package-private:O2
  7. 7The public surface of a package should be:O2
  8. 8Package by feature puts together:O3
  9. 9A benefit of feature packages:O3
  10. 10Using the default package for a real project is:O1

الجزء العملي

Refactoring exercise BEG-027-EX05, the other exercises, and Bank Accounts v5. Pass: project compiles in feature packages and only intended classes are public.

أخطاء شائعة

One giant default package; everything public.

التقييم

Refactoring exercise.

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

Modular monoliths (MID-059) start here.

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