التسمية
في هذا الدرس 4 موضوعات
محتوى هذا الدرس مكتوب وينتظر المراجعة. يعرض المخطط أدناه ما سيغطيه، وسيُنشر بعد اعتماده.
نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.
في هذا الدرس
name things so the code reads as intent.
الموضوعات المخطط لها
- A name says what, not how:
totalWithTax, notcalc2. - Classes are nouns (
Cart); methods are verbs (addItem); booleans read as questions (isEmpty). - Avoid abbreviations and noise words like
Manager,Data,Info. - One word per idea: do not mix
get,fetch, andretrieve. - Rename with the IDE (Shift+F6 in IntelliJ), so every usage changes safely.
تفاصيل المخطط المبدئي
عرض عملي
// before
double calc(double p, int q, double d) { return p * q - d; }
// after
Money lineTotal(Money unitPrice, int quantity, Money discount) { ... }اختبر فهمك
Better name for boolean flag that says a cart has no items?
أظهر الإجابة
isEmpty.
التطبيق
طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.
تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.