You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: abstract-document/README.md
+24-6Lines changed: 24 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,8 @@ tag:
8
8
9
9
## Intent
10
10
11
-
Use dynamic properties and achieve flexibility of untyped languages while keeping type-safety.
11
+
The "Abstract Document" design pattern is a structural design pattern that aims to provide a consistent way to handle
12
+
hierarchical and tree-like data structures by defining a common interface for various document types.
12
13
13
14
## Explanation
14
15
@@ -18,7 +19,7 @@ set of interfaces.
18
19
19
20
Real world example
20
21
21
-
> Consider a car that consists of multiple parts. However we don't know if the specific car really has all the parts, or just some of them. Our cars are dynamic and extremely flexible.
22
+
> Consider a car that consists of multiple parts. However, we don't know if the specific car really has all the parts, or just some of them. Our cars are dynamic and extremely flexible.
22
23
23
24
In plain words
24
25
@@ -175,11 +176,28 @@ And finally here's how we construct and use the `Car` in a full example.
175
176
176
177
## Applicability
177
178
178
-
Use the Abstract Document Pattern when
179
+
This pattern is particularly useful in scenarios where you have different types of documents that share some common
180
+
attributes or behaviors, but also have unique attributes or behaviors specific to their individual types. Here are
181
+
some scenarios where the Abstract Document design pattern can be applicable:
179
182
180
-
* There is a need to add new properties on the fly
181
-
* You want a flexible way to organize domain in tree like structure
182
-
* You want more loosely coupled system
183
+
* Content Management Systems (CMS): In a CMS, you might have various types of content such as articles, images, videos, etc. Each type of content could have shared attributes like creation date, author, and tags, while also having specific attributes like image dimensions for images or video duration for videos.
184
+
185
+
* File Systems: If you're designing a file system where different types of files need to be managed, such as documents, images, audio files, and directories, the AbstractDocument pattern can help provide a consistent way to access attributes like file size, creation date, etc., while allowing for specific attributes like image resolution or audio duration.
186
+
187
+
*E-commerce Systems:An e-commerce platform might have different product types such as physical products, digital downloads, and subscriptions. Each type could share common attributes like name, price, and description, while having unique attributes like shipping weight for physical products or download link for digital products.
188
+
189
+
*MedicalRecordsSystems:In healthcare, patient records might include various types of data such as demographics, medical history, test results, and prescriptions. TheAbstractDocument pattern can help manage shared attributes like patient ID and date of birth, while accommodating specialized attributes like test results or prescribed medications.
190
+
191
+
*ConfigurationManagement:When dealing with configuration settings for software applications, there can be different types of configuration elements, each with its own set of attributes. TheAbstractDocument pattern can be used to manage these configuration elements while ensuring a consistent way to access and manipulate their attributes.
192
+
193
+
*EducationalPlatforms:Educational systems might have various types of learning materials such as text-based content, videos, quizzes, and assignments. Common attributes like title, author, and publication date can be shared, while unique attributes like video duration or assignment due dates can be specific to each type.
194
+
195
+
*ProjectManagementTools:In project management applications, you could have different types of tasks like to-do items, milestones, and issues. TheAbstractDocument pattern could be used to handle general attributes like task name and assignee, while allowing for specific attributes like milestone date or issue priority.
196
+
197
+
The key idea behind the AbstractDocument design pattern is to provide a flexible and extensible way to manage different
198
+
types of documents or entities with shared and distinct attributes. By defining a common interfaceand implementing it
199
+
across various document types, you can achieve a more organized and consistent approach to handling complex data
0 commit comments