Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
iluwatar authored Oct 22, 2023
2 parents e6703e8 + b71eea4 commit e5ac596
Show file tree
Hide file tree
Showing 49 changed files with 919 additions and 65 deletions.
84 changes: 83 additions & 1 deletion .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -2641,7 +2641,89 @@
"contributions": [
"doc",
"code"
]
]
},
{
"login": "Upendra-Allagadda",
"name": "Allagadda Sai Upendranath",
"avatar_url": "https://avatars.githubusercontent.com/u/25962010?v=4",
"profile": "https://github.com/Upendra-Allagadda",
"contributions": [
"doc"
]
},
{
"login": "mathbraga",
"name": "Matheus Braga",
"avatar_url": "https://avatars.githubusercontent.com/u/31048764?v=4",
"profile": "https://www.linkedin.com/in/mobraga/",
"contributions": [
"translation",
"doc"
]
},
{
"login": "satyabarghav",
"name": "Appari Satya Barghav",
"avatar_url": "https://avatars.githubusercontent.com/u/36763910?v=4",
"profile": "https://github.com/satyabarghav",
"contributions": [
"doc"
]
},
{
"login": "mribeirodantas",
"name": "Marcel Ribeiro-Dantas",
"avatar_url": "https://avatars.githubusercontent.com/u/1023197?v=4",
"profile": "http://mribeirodantas.me",
"contributions": [
"doc"
]
},
{
"login": "hamexhanif",
"name": "Muhammad Hanif Amrullah",
"avatar_url": "https://avatars.githubusercontent.com/u/74542852?v=4",
"profile": "https://github.com/hamexhanif",
"contributions": [
"translation"
]
},
{
"login": "JackH408",
"name": "JackH408",
"avatar_url": "https://avatars.githubusercontent.com/u/141727294?v=4",
"profile": "https://github.com/JackH408",
"contributions": [
"doc"
]
},
{
"login": "versus2004",
"name": "Shubham",
"avatar_url": "https://avatars.githubusercontent.com/u/132815243?v=4",
"profile": "https://github.com/versus2004",
"contributions": [
"translation"
]
},
{
"login": "inishantjain",
"name": "Nishant Jain",
"avatar_url": "https://avatars.githubusercontent.com/u/121454072?v=4",
"profile": "https://github.com/inishantjain",
"contributions": [
"doc"
]
},
{
"login": "hallowshaw",
"name": "Rhitam Chaudhury",
"avatar_url": "https://avatars.githubusercontent.com/u/90751158?v=4",
"profile": "https://github.com/hallowshaw",
"contributions": [
"doc"
]
}
],
"contributorsPerLine": 7,
Expand Down
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!-- the line below needs to be an empty line C: (its because kramdown isnt
<!-- the line below needs to be an empty line C: (its because kramdown isn't
that smart and dearly wants an empty line before a heading to be able to
display it as such, e.g. website) -->

Expand All @@ -10,7 +10,7 @@
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=iluwatar_java-design-patterns&metric=coverage)](https://sonarcloud.io/dashboard?id=iluwatar_java-design-patterns)
[![Join the chat at https://gitter.im/iluwatar/java-design-patterns](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/iluwatar/java-design-patterns?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-289-orange.svg?style=flat-square)](#contributors-)
[![All Contributors](https://img.shields.io/badge/all_contributors-299-orange.svg?style=flat-square)](#contributors-)
<!-- ALL-CONTRIBUTORS-BADGE:END -->

<br/>
Expand Down Expand Up @@ -448,6 +448,17 @@ This project is licensed under the terms of the MIT license.
<td align="center" valign="top" width="14.28%"><a href="https://github.com/sanchitbansal10"><img src="https://avatars.githubusercontent.com/u/16536741?v=4?s=100" width="100px;" alt="Sanchit Bansal"/><br /><sub><b>Sanchit Bansal</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=sanchitbansal10" title="Documentation">📖</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/mm-saiful6854"><img src="https://avatars.githubusercontent.com/u/48361160?v=4?s=100" width="100px;" alt="Md Saiful Islam"/><br /><sub><b>Md Saiful Islam</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=mm-saiful6854" title="Documentation">📖</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/AddeusExMachina"><img src="https://avatars.githubusercontent.com/u/39912670?v=4?s=100" width="100px;" alt="Antonio Addeo"/><br /><sub><b>Antonio Addeo</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=AddeusExMachina" title="Documentation">📖</a> <a href="https://github.com/iluwatar/java-design-patterns/commits?author=AddeusExMachina" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/Upendra-Allagadda"><img src="https://avatars.githubusercontent.com/u/25962010?v=4?s=100" width="100px;" alt="Allagadda Sai Upendranath"/><br /><sub><b>Allagadda Sai Upendranath</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=Upendra-Allagadda" title="Documentation">📖</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://www.linkedin.com/in/mobraga/"><img src="https://avatars.githubusercontent.com/u/31048764?v=4?s=100" width="100px;" alt="Matheus Braga"/><br /><sub><b>Matheus Braga</b></sub></a><br /><a href="#translation-mathbraga" title="Translation">🌍</a> <a href="https://github.com/iluwatar/java-design-patterns/commits?author=mathbraga" title="Documentation">📖</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/satyabarghav"><img src="https://avatars.githubusercontent.com/u/36763910?v=4?s=100" width="100px;" alt="Appari Satya Barghav"/><br /><sub><b>Appari Satya Barghav</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=satyabarghav" title="Documentation">📖</a></td>
<td align="center" valign="top" width="14.28%"><a href="http://mribeirodantas.me"><img src="https://avatars.githubusercontent.com/u/1023197?v=4?s=100" width="100px;" alt="Marcel Ribeiro-Dantas"/><br /><sub><b>Marcel Ribeiro-Dantas</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=mribeirodantas" title="Documentation">📖</a></td>
</tr>
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/hamexhanif"><img src="https://avatars.githubusercontent.com/u/74542852?v=4?s=100" width="100px;" alt="Muhammad Hanif Amrullah"/><br /><sub><b>Muhammad Hanif Amrullah</b></sub></a><br /><a href="#translation-hamexhanif" title="Translation">🌍</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/JackH408"><img src="https://avatars.githubusercontent.com/u/141727294?v=4?s=100" width="100px;" alt="JackH408"/><br /><sub><b>JackH408</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=JackH408" title="Documentation">📖</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/versus2004"><img src="https://avatars.githubusercontent.com/u/132815243?v=4?s=100" width="100px;" alt="Shubham"/><br /><sub><b>Shubham</b></sub></a><br /><a href="#translation-versus2004" title="Translation">🌍</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/inishantjain"><img src="https://avatars.githubusercontent.com/u/121454072?v=4?s=100" width="100px;" alt="Nishant Jain"/><br /><sub><b>Nishant Jain</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=inishantjain" title="Documentation">📖</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/hallowshaw"><img src="https://avatars.githubusercontent.com/u/90751158?v=4?s=100" width="100px;" alt="Rhitam Chaudhury"/><br /><sub><b>Rhitam Chaudhury</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=hallowshaw" title="Documentation">📖</a></td>
</tr>
</tbody>
</table>
Expand Down
2 changes: 2 additions & 0 deletions adapter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ Use the Adapter pattern when
* [Dzone](https://dzone.com/articles/adapter-design-pattern-in-java)
* [Refactoring Guru](https://refactoring.guru/design-patterns/adapter/java/example)
* [Baeldung](https://www.baeldung.com/java-adapter-pattern)
* [GeeksforGeeks](https://www.geeksforgeeks.org/adapter-pattern/)


## Consequences
Class and object adapters have different trade-offs. A class adapter
Expand Down
2 changes: 1 addition & 1 deletion adapter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt).
The MIT License
Copyright © 2014-2022 Ilkka Seppälä
Copyright © 2014-2023 Ilkka Seppälä
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
public class InformationController {

/**
* Endpoint to retrieve a product's informations.
* Endpoint to retrieve a product's information.
*
* @return product inventory.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
package com.iluwatar.caching.database;

/**
* Creates the database connection accroding the input parameter.
* Creates the database connection according the input parameter.
*/
public final class DbManagerFactory {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
/**
* <p>
* The intention of the Circuit Builder pattern is to handle remote failures robustly, which is to
* mean that if a service is dependant on n number of other services, and m of them fail, we should
* mean that if a service is dependent on n number of other services, and m of them fail, we should
* be able to recover from that failure by ensuring that the user can still use the services that
* are actually functional, and resources are not tied up by uselessly by the services which are not
* working. However, we should also be able to detect when any of the m failing services become
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public String call() throws RemoteServiceException {
}
};
var circuitBreaker = new DefaultCircuitBreaker(mockService, 1, 1, 100);
//Call with the paramater start_time set to huge amount of time in past so that service
//Call with the parameter start_time set to huge amount of time in past so that service
//replies with "Ok". Also, state is CLOSED in start
var serviceStartTime = System.nanoTime() - 60 * 1000 * 1000 * 1000;
var response = circuitBreaker.attemptRequest();
Expand Down
2 changes: 1 addition & 1 deletion commander/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ This pattern can be used when we need to make commits into 2 (or more) databases

## Explanation
Handling distributed transactions can be tricky, but if we choose to not handle it carefully, there could be unwanted consequences. Say, we have an e-commerce website which has a Payment microservice and a Shipping microservice. If the shipping is available currently but payment service is not up, or vice versa, how would we deal with it after having already received the order from the user?
We need a mechanism in place which can handle these kinds of situations. We have to direct the order to either one of the services (in this example, shipping) and then add the order into the database of the other service (in this example, payment), since two databses cannot be updated atomically. If currently unable to do it, there should be a queue where this request can be queued, and there has to be a mechanism which allows for a failure in the queueing as well. All this needs to be done by constant retries while ensuring idempotence (even if the request is made several times, the change should only be applied once) by a commander class, to reach a state of eventual consistency.
We need a mechanism in place which can handle these kinds of situations. We have to direct the order to either one of the services (in this example, shipping) and then add the order into the database of the other service (in this example, payment), since two databases cannot be updated atomically. If currently unable to do it, there should be a queue where this request can be queued, and there has to be a mechanism which allows for a failure in the queueing as well. All this needs to be done by constant retries while ensuring idempotence (even if the request is made several times, the change should only be applied once) by a commander class, to reach a state of eventual consistency.

## Credits

Expand Down
2 changes: 1 addition & 1 deletion crtp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,5 +134,5 @@ Use the Curiously Recurring Template Pattern when

## Credits

* [How do I decrypt "Enum<E extends Enum<E>>"?](http://www.angelikalanger.com/GenericsFAQ/FAQSections/TypeParameters.html#FAQ106)
* [How do I decrypt "Enum<E extends Enum\<E>>"?](http://www.angelikalanger.com/GenericsFAQ/FAQSections/TypeParameters.html#FAQ106)
* Chapter 5 Generics, Item 30 in [Effective Java](https://www.amazon.com/gp/product/0134685997/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=0134685997&linkCode=as2&tag=javadesignpat-20&linkId=4e349f4b3ff8c50123f8147c828e53eb)
2 changes: 1 addition & 1 deletion currying/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ Cons
* As shown in the programmatic example above, curried functions with several parameters have a cumbersome type signature (in Java).

## Related patterns
* [Builder patter](https://java-design-patterns.com/patterns/builder/)
* [Builder pattern](https://java-design-patterns.com/patterns/builder/)

## Credits
* [Currying in Java](https://www.baeldung.com/java-currying)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
package com.iluwatar.datamapper;

/**
* Using Runtime Exception for avoiding dependancy on implementation exceptions. This helps in
* Using Runtime Exception for avoiding dependency on implementation exceptions. This helps in
* decoupling.
*
* @author amit.dixit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public static void main(String[] args) throws Exception {

// Create table for orders - Orders(id, name, orderedBy, city, state, pincode).
// We can see that table is different from the Order object we have.
// We're mapping ShippingAddress into city, state, pincode colummns of the database and not creating a separate table.
// We're mapping ShippingAddress into city, state, pincode columns of the database and not creating a separate table.
if (dataSource.createSchema()) {
LOGGER.info("TABLE CREATED");
LOGGER.info("Table \"Orders\" schema:\n" + dataSource.getSchema());
Expand Down Expand Up @@ -95,7 +95,7 @@ public static void main(String[] args) throws Exception {
dataSource.removeOrder(1);
LOGGER.info("\nOrders Query: {}", dataSource.queryOrders().collect(Collectors.toList()) + "\n");

//After successfull demonstration of the pattern, drop the table
//After successful demonstration of the pattern, drop the table
if (dataSource.deleteSchema()) {
LOGGER.info("TABLE DROPPED");
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ private void update() {
clip.open(audioStream);
clip.start();
} catch (LineUnavailableException e) {
LOGGER.trace("Error occoured while loading the audio: The line is unavailable", e);
LOGGER.trace("Error occurred while loading the audio: The line is unavailable", e);
} catch (IOException e) {
LOGGER.trace("Input/Output error while loading the audio", e);
} catch (IllegalArgumentException e) {
Expand Down
9 changes: 9 additions & 0 deletions facade/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,15 @@ subsystem independence and portability.
If subsystems are dependent, then you can simplify the dependencies between them by making them
communicate with each other solely through their facades.

## Tutorials

*[DigitalOcean](https://www.digitalocean.com/community/tutorials/facade-design-pattern-in-java)
* [Refactoring Guru](https://refactoring.guru/design-patterns/facade)
* [GeekforGeeks](https://www.geeksforgeeks.org/facade-design-pattern-introduction/)
* [Tutorialspoint](https://www.tutorialspoint.com/design_pattern/facade_pattern.htm)



## Credits

* [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)
Expand Down
4 changes: 2 additions & 2 deletions factory/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public class CopperCoin implements Coin {
}
```

Enumeration above represents types of coins that we support (`GoldCoin` and `CopperCoin`).
Enumeration below represents types of coins that we support (`GoldCoin` and `CopperCoin`).

```java
@RequiredArgsConstructor
Expand Down Expand Up @@ -110,7 +110,7 @@ This is a gold coin.

## Applicability

Use the factory pattern when you only care about the creation of a object, not how to create
Use the factory pattern when you only care about the creation of an object, not how to create
and manage it.

Pros
Expand Down
2 changes: 1 addition & 1 deletion fanout-fanin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ service has received the requests. Now the caller will not wait or expect the re

Meanwhile, the pattern service will invoke the requests that have come. The requests might complete at different time.
These requests will be processed in different instances of the same function in different machines or services. As the
requests get completed, a callback service everytime is called that transforms the result into a common single object format
requests get completed, a callback service every time is called that transforms the result into a common single object format
that gets pushed to a consumer. The caller will be at the other end of the consumer receiving the result.

**Programmatic Example**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@


/**
* Consumer or callback class that will be called everytime a request is complete This will
* Consumer or callback class that will be called every time a request is complete This will
* aggregate individual result to form a final result.
*/
@Getter
Expand Down
Loading

0 comments on commit e5ac596

Please sign in to comment.