From 82fcbeaee531ffaa79bc98724db257f393e17a18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ilkka=20Sepp=C3=A4l=C3=A4?= Date: Sun, 20 Aug 2023 10:51:29 +0300 Subject: [PATCH] docs: Abstract Document readme improvements (#2569) * readme improvements * fix typo --- abstract-document/README.md | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/abstract-document/README.md b/abstract-document/README.md index de36b733e056..fddb12c6a883 100644 --- a/abstract-document/README.md +++ b/abstract-document/README.md @@ -8,7 +8,8 @@ tag: ## Intent -Use dynamic properties and achieve flexibility of untyped languages while keeping type-safety. +The "Abstract Document" design pattern is a structural design pattern that aims to provide a consistent way to handle +hierarchical and tree-like data structures by defining a common interface for various document types. ## Explanation @@ -18,7 +19,7 @@ set of interfaces. Real world example -> 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. +> 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. In plain words @@ -175,11 +176,28 @@ And finally here's how we construct and use the `Car` in a full example. ## Applicability -Use the Abstract Document Pattern when +This pattern is particularly useful in scenarios where you have different types of documents that share some common +attributes or behaviors, but also have unique attributes or behaviors specific to their individual types. Here are +some scenarios where the Abstract Document design pattern can be applicable: -* There is a need to add new properties on the fly -* You want a flexible way to organize domain in tree like structure -* You want more loosely coupled system +* 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. + +* 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 Abstract Document 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. + +* 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. + +* Medical Records Systems: In healthcare, patient records might include various types of data such as demographics, medical history, test results, and prescriptions. The Abstract Document pattern can help manage shared attributes like patient ID and date of birth, while accommodating specialized attributes like test results or prescribed medications. + +* Configuration Management: When dealing with configuration settings for software applications, there can be different types of configuration elements, each with its own set of attributes. The Abstract Document pattern can be used to manage these configuration elements while ensuring a consistent way to access and manipulate their attributes. + +* Educational Platforms: 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. + +* Project Management Tools: In project management applications, you could have different types of tasks like to-do items, milestones, and issues. The Abstract Document pattern could be used to handle general attributes like task name and assignee, while allowing for specific attributes like milestone date or issue priority. + +The key idea behind the Abstract Document design pattern is to provide a flexible and extensible way to manage different +types of documents or entities with shared and distinct attributes. By defining a common interface and implementing it +across various document types, you can achieve a more organized and consistent approach to handling complex data +structures. ## Credits