Skip to content

ahmedm-gh/Design-Patterns-using-Dart

Repository files navigation

🎯
أنماط التصميم في دارت
Design Patterns in Dart

الأنماط الثلاثة والعشرون (GoF) — بأمثلة دارت عملية

The 23 Gang of Four (GoF) Patterns — with Practical Dart Examples

Dart Flutter License: MIT

📖 الشرح الكامل | Full Documentation


📖 عن المشروع | About

مرجع شامل لجميع 23 نمط تصميم GoF، كل نمط مشروح بـ:

A comprehensive reference for all 23 GoF Design Patterns, each explained with:

  • ✅ وصف واضح للنمط والمشكلة التي يحُلّها | Clear description of the pattern and its problem
  • ✅ المصطلحات بالعربية والإنجليزية | Key terminology in Arabic and English
  • ✅ أمثلة Dart عملية وقابلة للتشغيل | Practical, runnable Dart code examples
  • ✅ إرشادات "متى تستخدمه؟" | "When to use?" guidance
  • ✅ يتبع Effective Dart best practices

سواء كنت تستعد لمقابلات العمل، أو تتعلم البرمجة الكائنية، أو تبني تطبيقات Flutter/Dart — هذا المرجع يُغطّيك.

Whether you're preparing for interviews, learning OOP, or building Flutter/Dart apps — this repo has you covered.


🏗️ الأنماط | Patterns Overview

الأنماط الإنشائية — كيف نُنشئ الكائنات؟

Creational Patterns — How do we create objects?

# النمط Pattern الوصف — Description
1 المصنع المُجرَّد Abstract Factory إنشاء عائلة كائنات مترابطة — Create families of related objects
2 الباني Builder بناء كائنات مُعقَّدة خطوة بخطوة — Construct complex objects step by step
3 دالّة المصنع Factory Method ترك قرار الإنشاء للأصناف الفرعية — Let subclasses decide which class to instantiate
4 النموذج الأوَّلي Prototype نسخ كائنات بدلًا من البناء من الصفر — Clone objects instead of building from scratch
5 الكائن الوحيد Singleton ضمان نسخة واحدة فقط — Ensure a single instance globally

الأنماط البنائية — كيف نُركِّب الكائنات؟

Structural Patterns — How do we compose objects?

# النمط Pattern الوصف — Description
6 المُحوِّل Adapter جسر توافق بين واجهتين — Bridge between incompatible interfaces
7 الجسر Bridge فصل التجريد عن التنفيذ — Decouple abstraction from implementation
8 المُركَّب Composite التعامل مع بنى شجرية — Treat individual/groups uniformly (tree)
9 المُزخرِف Decorator إضافة مسؤوليات ديناميكيًا — Add responsibilities dynamically
10 الواجهة المُبسَّطة Facade تبسيط نظام فرعي مُعقَّد — Simplified interface to a complex subsystem
11 وزن الفراشة Flyweight مشاركة البيانات لتقليل الذاكرة — Share data to reduce memory
12 الوكيل Proxy التحكم في الوصول لكائن آخر — Control access to another object

الأنماط السلوكية — كيف تتواصل الكائنات؟

Behavioral Patterns — How do objects communicate?

# النمط Pattern الوصف — Description
13 سلسلة المسؤولية Chain of Responsibility تمرير الطلبات عبر سلسلة — Pass requests along a chain
14 الأمر Command تغليف الطلبات ككائنات — Encapsulate requests as objects
15 المُفسِّر Interpreter تعريف قواعد لغة وتفسيرها — Define grammar and interpret sentences
16 المُكرِّر Iterator الوصول التسلسلي للعناصر — Access elements sequentially
17 الوسيط Mediator تقليل الاقتران عبر وسيط — Reduce coupling via a mediator
18 التذكار Memento حفظ واستعادة الحالة — Capture and restore state
19 المُراقِب Observer إخطار تلقائي عند تغيُّر الحالة — Auto-notify on state changes
20 الحالة State تغيير السلوك حسب الحالة — Change behavior based on state
21 الاستراتيجية Strategy تبديل الخوارزميات أثناء التشغيل — Swap algorithms at runtime
22 أسلوب القالب Template Method هيكل ثابت مع خطوات قابلة للتخصيص — Fixed skeleton, customizable steps
23 الزائر Visitor فصل العمليات عن بنية الكائنات — Separate operations from structure

⭐ أنماط إضافية (خارج GoF) | Additional Patterns (Beyond GoF)

⚠️ الأنماط التالية ليست من الـ 23 GoF — هي أنماط حديثة ومُكمِّلة.

⚠️ These are NOT GoF patterns — they are modern, complementary patterns.

إنشائية إضافية | Additional Creational

# النمط Pattern الأصل — Origin
24 تجمُّع الكائنات Object Pool كلاسيكي (1990s)
25 حقن الاعتمادية Dependency Injection Fowler (2004)
26 المُتعدِّد Multiton امتداد Singleton

بنائية إضافية | Additional Structural

# النمط Pattern الأصل — Origin
27 كائن الامتداد Extension Object Gamma (1996) / Dart 2.7
28 كائن القيمة Value Object Evans DDD (2003)

سلوكية إضافية | Additional Behavioral

# النمط Pattern الأصل — Origin
29 الكائن الفارغ Null Object Woolf (1998)
30 المواصفة Specification Evans & Fowler (2005)
31 مُحدِّد الخدمات Service Locator Fowler (2004)
32 المستودع Repository Evans DDD (2003)

🚀 البداية السريعة | Quick Start

كل نمط له ملف Dart مستقل في lib/ مُنظَّم حسب الفئة، يمكنك تشغيله مباشرة:

Each pattern has a standalone Dart file in lib/, organized by category, you can run directly:

# الإنشائية | Creational
dart run lib/creational/singleton.dart
dart run lib/creational/builder.dart
dart run lib/creational/factory_method.dart

# البنائية | Structural
dart run lib/structural/adapter.dart
dart run lib/structural/decorator.dart

# السلوكية | Behavioral
dart run lib/behavioral/observer.dart
dart run lib/behavioral/strategy.dart
dart run lib/behavioral/repository.dart
# ... etc.

📊 الملخص | Summary

الأنماط الأساسية (GoF 23) | Core Patterns

الفئة — Category العدد — Count
الإنشائية — Creational 5
البنائية — Structural 7
السلوكية — Behavioral 11
الإجمالي — Total 23

الأنماط الإضافية (خارج GoF) | Additional Patterns

الفئة — Category العدد — Count
الإنشائية — Creational 3
البنائية — Structural 2
السلوكية — Behavioral 4
الإجمالي — Total 9

✅ Effective Dart

يتبع هذا المشروع إرشادات Effective Dart:

This project follows Effective Dart guidelines:

  • 📏 Style: final class, interface class, const constructors
  • 📝 Documentation: /// doc comments for all public APIs
  • 🔧 Usage: initializing formals, => for simple members, const where possible
  • 🏛️ Design: class modifiers, final fields, sealed/interface types

🤝 المساهمة | Contributing

المساهمات والمقترحات مرحّب بها! لا تتردد في فتح PR أو issue.

Contributions, issues, and feature requests are welcome! Feel free to open a PR or issue.


الرخصة: هذا المشروع مُرخَّص تحت رخصة MIT.

License This project is licensed under the MIT License.


إذا وجدته هذه المقالة مفيدة، من فضلك لا تنسَ النجمة!

If you found this helpful, please give it a star!

About

A comprehensive bilingual (Arabic/English) guide to all 23 classic Design Patterns, explained and implemented in Dart. دليل شامل مزدوج اللغة (عربي/إنجليزي) لجميع أنماط التصميم الكلاسيكية الـ23، مع شرح وتطبيق باستخدام Dart.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages