Skip to content

Commit de5a93c

Browse files
committed
docs: update .editorconfig and reformat readmes
1 parent dfd34d8 commit de5a93c

File tree

31 files changed

+388
-986
lines changed

31 files changed

+388
-986
lines changed

Diff for: .editorconfig

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ end_of_line = lf
3131
indent_size = 4
3232
indent_style = space
3333
insert_final_newline = false
34-
max_line_length = 120
34+
max_line_length = off
3535
tab_width = 4
3636
ij_continuation_indent_size = 8
3737
ij_formatter_off_tag = @formatter:off
@@ -355,6 +355,7 @@ ij_markdown_format_tables = true
355355
ij_markdown_insert_quote_arrows_on_wrap = true
356356
ij_markdown_keep_indents_on_empty_lines = false
357357
ij_markdown_keep_line_breaks_inside_text_blocks = true
358+
ij_markdown_max_line_length = off
358359
ij_markdown_max_lines_around_block_elements = 1
359360
ij_markdown_max_lines_around_header = 1
360361
ij_markdown_max_lines_between_paragraphs = 1

Diff for: abstract-document/README.md

+15-44
Original file line numberDiff line numberDiff line change
@@ -10,35 +10,27 @@ tag:
1010

1111
## Intent
1212

13-
The Abstract Document design pattern is a structural design pattern that aims to provide a consistent way to handle
14-
hierarchical and tree-like data structures by defining a common interface for various document types. It separates the
15-
core document structure from specific data formats, enabling dynamic updates and simplified maintenance.
13+
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. It separates the core document structure from specific data formats, enabling dynamic updates and simplified maintenance.
1614

1715
## Explanation
1816

19-
The Abstract Document pattern enables handling additional, non-static properties. This pattern uses concept of traits to
20-
enable type safety and separate properties of different classes into set of interfaces.
17+
The Abstract Document pattern enables handling additional, non-static properties. This pattern uses concept of traits to enable type safety and separate properties of different classes into set of interfaces.
2118

2219
Real world example
2320

24-
> Consider a car that consists of multiple parts. However, we don't know if the specific car really has all the parts,
25-
> or just some of them. Our cars are dynamic and extremely flexible.
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.
2622
2723
In plain words
2824

2925
> Abstract Document pattern allows attaching properties to objects without them knowing about it.
3026
3127
Wikipedia says
3228

33-
> An object-oriented structural design pattern for organizing objects in loosely typed key-value stores and exposing the
34-
> data using typed views. The purpose of the pattern is to achieve a high degree of flexibility between components in a
35-
> strongly typed language where new properties can be added to the object-tree on the fly, without losing the support of
36-
> type-safety. The pattern makes use of traits to separate different properties of a class into different interfaces.
29+
> An object-oriented structural design pattern for organizing objects in loosely typed key-value stores and exposing the data using typed views. The purpose of the pattern is to achieve a high degree of flexibility between components in a strongly typed language where new properties can be added to the object-tree on the fly, without losing the support of type-safety. The pattern makes use of traits to separate different properties of a class into different interfaces.
3730
3831
**Programmatic Example**
3932

40-
Let's first define the base classes `Document` and `AbstractDocument`. They basically make the object hold a property
41-
map and any amount of child objects.
33+
Let's first define the base classes `Document` and `AbstractDocument`. They basically make the object hold a property map and any amount of child objects.
4234

4335
```java
4436
public interface Document {
@@ -84,8 +76,7 @@ public abstract class AbstractDocument implements Document {
8476
}
8577
```
8678

87-
Next we define an enum `Property` and a set of interfaces for type, price, model and parts. This allows us to create
88-
static looking interface to our `Car` class.
79+
Next we define an enum `Property` and a set of interfaces for type, price, model and parts. This allows us to create static looking interface to our `Car` class.
8980

9081
```java
9182
public enum Property {
@@ -180,38 +171,21 @@ And finally here's how we construct and use the `Car` in a full example.
180171
181172
## Applicability
182173
183-
This pattern is particularly useful in scenarios where you have different types of documents that share some common
184-
attributes or behaviors, but also have unique attributes or behaviors specific to their individual types. Here are some
185-
scenarios where the Abstract Document design pattern can be applicable:
174+
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:
186175
187-
* Content Management Systems (CMS): In a CMS, you might have various types of content such as articles, images, videos,
188-
etc. Each type of content could have shared attributes like creation date, author, and tags, while also having
189-
specific attributes like image dimensions for images or video duration for videos.
176+
* 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.
190177
191-
* File Systems: If you're designing a file system where different types of files need to be managed, such as documents,
192-
images, audio files, and directories, the Abstract Document pattern can help provide a consistent way to access
193-
attributes like file size, creation date, etc., while allowing for specific attributes like image resolution or audio
194-
duration.
178+
* 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.
195179

196-
* E-commerce Systems: An e-commerce platform might have different product types such as physical products, digital
197-
downloads, and subscriptions. Each type could share common attributes like name, price, and description, while having
198-
unique attributes like shipping weight for physical products or download link for digital products.
180+
* 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.
199181

200-
* Medical Records Systems: In healthcare, patient records might include various types of data such as demographics,
201-
medical history, test results, and prescriptions. The Abstract Document pattern can help manage shared attributes like
202-
patient ID and date of birth, while accommodating specialized attributes like test results or prescribed medications.
182+
* 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.
203183

204-
* Configuration Management: When dealing with configuration settings for software applications, there can be different
205-
types of configuration elements, each with its own set of attributes. The Abstract Document pattern can be used to
206-
manage these configuration elements while ensuring a consistent way to access and manipulate their attributes.
184+
* 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.
207185

208-
* Educational Platforms: Educational systems might have various types of learning materials such as text-based content,
209-
videos, quizzes, and assignments. Common attributes like title, author, and publication date can be shared, while
210-
unique attributes like video duration or assignment due dates can be specific to each type.
186+
* 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.
211187

212-
* Project Management Tools: In project management applications, you could have different types of tasks like to-do
213-
items, milestones, and issues. The Abstract Document pattern could be used to handle general attributes like task name
214-
and assignee, while allowing for specific attributes like milestone date or issue priority.
188+
* 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.
215189

216190
* Documents have diverse and evolving attribute structures.
217191

@@ -221,10 +195,7 @@ scenarios where the Abstract Document design pattern can be applicable:
221195

222196
* Maintainability and flexibility are critical for the codebase.
223197

224-
The key idea behind the Abstract Document design pattern is to provide a flexible and extensible way to manage different
225-
types of documents or entities with shared and distinct attributes. By defining a common interface and implementing it
226-
across various document types, you can achieve a more organized and consistent approach to handling complex data
227-
structures.
198+
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.
228199

229200
## Consequences
230201

Diff for: abstract-factory/README.md

+11-24
Original file line numberDiff line numberDiff line change
@@ -14,32 +14,25 @@ Kit
1414

1515
## Intent
1616

17-
The Abstract Factory design pattern provides a way to create families of related objects without specifying their
18-
concrete classes. This allows for code that is independent of the specific classes of objects it uses, promoting
19-
flexibility and maintainability.
17+
The Abstract Factory design pattern provides a way to create families of related objects without specifying their concrete classes. This allows for code that is independent of the specific classes of objects it uses, promoting flexibility and maintainability.
2018

2119
## Explanation
2220

2321
Real-world example
2422

25-
> To create a kingdom we need objects with a common theme. The elven kingdom needs an elven king, elven castle, and
26-
> elven army whereas the orcish kingdom needs an orcish king, orcish castle, and orcish army. There is a dependency
27-
> between the objects in the kingdom.
23+
> To create a kingdom we need objects with a common theme. The elven kingdom needs an elven king, elven castle, and elven army whereas the orcish kingdom needs an orcish king, orcish castle, and orcish army. There is a dependency between the objects in the kingdom.
2824
2925
In plain words
3026

31-
> A factory of factories; a factory that groups the individual but related/dependent factories together without
32-
> specifying their concrete classes.
27+
> A factory of factories; a factory that groups the individual but related/dependent factories together without specifying their concrete classes.
3328
3429
Wikipedia says
3530

36-
> The abstract factory pattern provides a way to encapsulate a group of individual factories that have a common theme
37-
> without specifying their concrete classes
31+
> The abstract factory pattern provides a way to encapsulate a group of individual factories that have a common theme without specifying their concrete classes
3832
3933
**Programmatic Example**
4034

41-
Translating the kingdom example above. First of all, we have some interfaces and implementation for the objects in the
42-
kingdom.
35+
Translating the kingdom example above. First of all, we have some interfaces and implementation for the objects in the kingdom.
4336

4437
```java
4538
public interface Castle {
@@ -134,8 +127,7 @@ public class OrcKingdomFactory implements KingdomFactory {
134127
}
135128
```
136129

137-
Now we have the abstract factory that lets us make a family of related objects i.e. elven kingdom factory creates elven
138-
castle, king and army, etc.
130+
Now we have the abstract factory that lets us make a family of related objects i.e. elven kingdom factory creates elven castle, king and army, etc.
139131

140132
```java
141133
var factory=new ElfKingdomFactory();
@@ -156,11 +148,7 @@ This is the elven castle!
156148
This is the elven Army!
157149
```
158150

159-
Now, we can design a factory for our different kingdom factories. In this example, we created `FactoryMaker`,
160-
responsible for returning an instance of either `ElfKingdomFactory` or `OrcKingdomFactory`. The client can
161-
use `FactoryMaker` to create the desired concrete factory which, in turn, will produce different concrete objects (
162-
derived from `Army`, `King`, `Castle`). In this example, we also used an enum to parameterize which type of kingdom
163-
factory the client will ask for.
151+
Now, we can design a factory for our different kingdom factories. In this example, we created `FactoryMaker`, responsible for returning an instance of either `ElfKingdomFactory` or `OrcKingdomFactory`. The client can use `FactoryMaker` to create the desired concrete factory which, in turn, will produce different concrete objects (derived from `Army`, `King`, `Castle`). In this example, we also used an enum to parameterize which type of kingdom factory the client will ask for.
164152

165153
```java
166154
public static class FactoryMaker {
@@ -203,8 +191,7 @@ Use the Abstract Factory pattern when
203191
* The system should be independent of how its products are created, composed, and represented
204192
* The system should be configured with one of the multiple families of products
205193
* The family of related product objects is designed to be used together, and you need to enforce this constraint
206-
* You want to provide a class library of products, and you want to reveal just their interfaces, not their
207-
implementations
194+
* You want to provide a class library of products, and you want to reveal just their interfaces, not their implementations
208195
* The lifetime of the dependency is conceptually shorter than the lifetime of the consumer.
209196
* You need a run-time value to construct a particular dependency
210197
* You want to decide which product to call from a family at runtime.
@@ -214,8 +201,7 @@ Use the Abstract Factory pattern when
214201

215202
Example use cases
216203

217-
* Selecting to call to the appropriate implementation of FileSystemAcmeService or DatabaseAcmeService or
218-
NetworkAcmeService at runtime.
204+
* Selecting to call to the appropriate implementation of FileSystemAcmeService or DatabaseAcmeService or NetworkAcmeService at runtime.
219205
* Unit test case writing becomes much easier
220206
* UI tools for different OS
221207

@@ -258,4 +244,5 @@ Trade-offs
258244
* [Design Patterns: Elements of Reusable Object-Oriented Software](https://www.amazon.com/gp/product/0201633612/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=0201633612&linkCode=as2&tag=javadesignpat-20&linkId=675d49790ce11db99d90bde47f1aeb59)
259245
* [Head First Design Patterns: A Brain-Friendly Guide](https://www.amazon.com/gp/product/0596007124/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=0596007124&linkCode=as2&tag=javadesignpat-20&linkId=6b8b6eea86021af6c8e3cd3fc382cb5b)
260246
* [Java Design Patterns: A Hands-On Experience with Real-World Examples](https://amzn.to/3HWNf4U)
261-
* [Design Patterns in Java](https://amzn.to/3Syw0vC)
247+
* [Design Patterns in Java](https://amzn.to/3Syw0vC)
248+
*

Diff for: active-object/README.md

+6-13
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,17 @@ tag:
88

99
## Intent
1010

11-
The Active Object design pattern provides a safe and reliable way to implement asynchronous behavior in concurrent
12-
systems. It achieves this by encapsulating tasks within objects that have their own thread and message queue. This
13-
separation keeps the main thread responsive and avoids issues like direct thread manipulation or shared state access.
11+
The Active Object design pattern provides a safe and reliable way to implement asynchronous behavior in concurrent systems. It achieves this by encapsulating tasks within objects that have their own thread and message queue. This separation keeps the main thread responsive and avoids issues like direct thread manipulation or shared state access.
1412

1513
## Explanation
1614

17-
The class that implements the active object pattern will contain a self-synchronization mechanism without using '
18-
synchronized' methods.
15+
The class that implements the active object pattern will contain a self-synchronization mechanism without using 'synchronized' methods.
1916

2017
Real-world example
2118

22-
> The Orcs are known for their wildness and untameable soul. It seems like they have their own thread of control based
23-
> on previous behavior.
19+
> The Orcs are known for their wildness and untameable soul. It seems like they have their own thread of control based on previous behavior.
2420
25-
To implement a creature that has its own thread of control mechanism and expose its API only and not the execution
26-
itself, we can use the Active Object pattern.
21+
To implement a creature that has its own thread of control mechanism and expose its API only and not the execution itself, we can use the Active Object pattern.
2722

2823
**Programmatic Example**
2924

@@ -83,8 +78,7 @@ public abstract class ActiveCreature {
8378
}
8479
```
8580

86-
We can see that any class that will extend the ActiveCreature class will have its own thread of control to invoke and
87-
execute methods.
81+
We can see that any class that will extend the ActiveCreature class will have its own thread of control to invoke and execute methods.
8882

8983
For example, the Orc class:
9084

@@ -98,8 +92,7 @@ public class Orc extends ActiveCreature {
9892
}
9993
```
10094

101-
Now, we can create multiple creatures such as Orcs, tell them to eat and roam, and they will execute it on their own
102-
thread of control:
95+
Now, we can create multiple creatures such as Orcs, tell them to eat and roam, and they will execute it on their own thread of control:
10396

10497
```java
10598
public static void main(String[]args){

0 commit comments

Comments
 (0)