Skip to content

Commit

Permalink
fix: Fix minor typos (#2619)
Browse files Browse the repository at this point in the history
Signed-off-by: Marcel Ribeiro-Dantas <[email protected]>
Co-authored-by: Ilkka Seppälä <[email protected]>
  • Loading branch information
mribeirodantas and iluwatar authored Oct 14, 2023
1 parent be0d5e5 commit f79782b
Show file tree
Hide file tree
Showing 30 changed files with 43 additions and 42 deletions.
2 changes: 1 addition & 1 deletion 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 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 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
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
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
* version of the feature toggle, where the enhanced version of the welcome message which is
* personalised is turned either on or off at instance creation. This method is not as dynamic as
* the {@link User} driven version where the feature of the personalised welcome message is
* dependant on the {@link UserGroup} the {@link User} is in. So if the user is a memeber of the
* {@link UserGroup#isPaid(User)} then they get an ehanced version of the welcome message.
* dependent on the {@link UserGroup} the {@link User} is in. So if the user is a member of the
* {@link UserGroup#isPaid(User)} then they get an enhanced version of the welcome message.
*
* <p>Note that this pattern can easily introduce code complexity, and if not kept in check can
* result in redundant unmaintained code within the codebase.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import lombok.Getter;

/**
* This example of the Feature Toogle pattern is less dynamic version than {@link
* This example of the Feature Toggle pattern is less dynamic version than {@link
* com.iluwatar.featuretoggle.pattern.tieredversion.TieredFeatureToggleVersion} where the feature is
* turned on or off at the time of creation of the service. This example uses simple Java {@link
* Properties} however it could as easily be done with an external configuration file loaded by
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import com.iluwatar.featuretoggle.user.UserGroup;

/**
* This example of the Feature Toogle pattern shows how it could be implemented based on a {@link
* This example of the Feature Toggle pattern shows how it could be implemented based on a {@link
* User}. Therefore showing its use within a tiered application where the paying users get access to
* different content or better versions of features. So in this instance a {@link User} is passed in
* and if they are found to be on the {@link UserGroup#isPaid(User)} they are welcomed with a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public abstract class AbstractMessageManager implements MessageManager {
protected Map<Integer, Instance> instanceMap;

/**
* Construtor of AbstractMessageManager.
* Constructor of AbstractMessageManager.
*/
public AbstractMessageManager(Map<Integer, Instance> instanceMap) {
this.instanceMap = instanceMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public static void main(String[] args) {
}

} catch (IOException ex) {
LOGGER.error("An error occured.", ex);
LOGGER.error("An error occurred.", ex);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public AlbumListPage navigateToPage() {
try {
page = this.webClient.getPage(PAGE_URL);
} catch (IOException e) {
LOGGER.error("An error occured on navigateToPage.", e);
LOGGER.error("An error occurred on navigateToPage.", e);
}
return this;
}
Expand Down Expand Up @@ -87,7 +87,7 @@ public AlbumPage selectAlbum(String albumTitle) {
((HtmlAnchor) anchor).click();
return new AlbumPage(webClient);
} catch (IOException e) {
LOGGER.error("An error occured on selectAlbum", e);
LOGGER.error("An error occurred on selectAlbum", e);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public AlbumPage navigateToPage() {
try {
page = this.webClient.getPage(PAGE_URL);
} catch (IOException e) {
LOGGER.error("An error occured on navigateToPage.", e);
LOGGER.error("An error occurred on navigateToPage.", e);
}
return this;
}
Expand Down Expand Up @@ -151,7 +151,7 @@ public AlbumListPage cancelChanges() {
try {
cancelButton.click();
} catch (IOException e) {
LOGGER.error("An error occured on cancelChanges.", e);
LOGGER.error("An error occurred on cancelChanges.", e);
}
return new AlbumListPage(webClient);
}
Expand All @@ -167,7 +167,7 @@ public AlbumPage saveChanges() {
try {
saveButton.click();
} catch (IOException e) {
LOGGER.error("An error occured on saveChanges.", e);
LOGGER.error("An error occurred on saveChanges.", e);
}
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public LoginPage navigateToPage() {
try {
page = this.webClient.getPage(PAGE_URL);
} catch (IOException e) {
LOGGER.error("An error occured on navigateToPage.", e);
LOGGER.error("An error occurred on navigateToPage.", e);
}
return this;
}
Expand Down Expand Up @@ -111,7 +111,7 @@ public AlbumListPage login() {
try {
loginButton.click();
} catch (IOException e) {
LOGGER.error("An error occured on login.", e);
LOGGER.error("An error occurred on login.", e);
}
return new AlbumListPage(webClient);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public record Video(Integer id, String title, Integer length, String description
/**
* ToString.
*
* @return json representaion of video
* @return json representation of video
*/
@Override
public String toString() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import lombok.ToString;

/**
* A Country POJO taht represents the data that will serialize and store in database.
* A Country POJO that represents the data that will serialize and store in database.
*/
@Getter
@Setter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
class GiantViewTest {

/**
* Test dispaly giant.
* Test display giant.
*/
@Test
void testDispalyGiant() {
Expand Down
8 changes: 4 additions & 4 deletions subclass-sandbox/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public abstract class Superpower {
logger.info("Move to ( " + x + ", " + y + ", " + z + " )");
}
protected void playSound(String soundName, int volumn) {
logger.info("Play " + soundName + " with volumn " + volumn);
protected void playSound(String soundName, int volume) {
logger.info("Play " + soundName + " with volume " + volume);
}
protected void spawnParticles(String particleType, int count) {
Expand Down Expand Up @@ -88,11 +88,11 @@ Program output:
```
// Use superpower: sky launch
// Move to ( 0.0, 0.0, 20.0 )
// Play SKYLAUNCH_SOUND with volumn 1
// Play SKYLAUNCH_SOUND with volume 1
// Spawn 100 particle with type SKYLAUNCH_PARTICLE
// Use superpower: ground dive
// Move to ( 0.0, 0.0, -20.0 )
// Play GROUNDDIVE_SOUND with volumn 5
// Play GROUNDDIVE_SOUND with volume 5
// Spawn 20 particle with type GROUNDDIVE_PARTICLE
```
## Class diagram
Expand Down
2 changes: 1 addition & 1 deletion subclass-sandbox/etc/subclass-sandbox.urm.puml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package com.iluwatar.subclasssandbox {
+ Superpower()
# activate() {abstract}
# move(x : double, y : double, z : double)
# playSound(soundName : String, volumn : int)
# playSound(soundName : String, volume : int)
# spawnParticles(particleType : String, count : int)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ protected void move(double x, double y, double z) {
/**
* Play sound effect for the superpower.
* @param soundName Sound name.
* @param volumn Value of volumn.
* @param volume Value of volume.
*/
protected void playSound(String soundName, int volumn) {
logger.info("Play " + soundName + " with volumn " + volumn);
protected void playSound(String soundName, int volume) {
logger.info("Play " + soundName + " with volume " + volume);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void testMove() throws Exception {
void testPlaySound() throws Exception {
var groundDive = new GroundDive();
var outputLog = getLogContent(() -> groundDive.playSound("SOUND_NAME", 1));
var expectedLog = "Play SOUND_NAME with volumn 1";
var expectedLog = "Play SOUND_NAME with volume 1";
assertEquals(outputLog, expectedLog);
}

Expand All @@ -70,7 +70,7 @@ void testActivate() throws Exception {
final var log1 = logs[0].split("-")[1].trim() + " -" + logs[0].split("-")[2].trim();
final var expectedLog1 = "Move to ( 0.0, 0.0, -20.0 )";
final var log2 = getLogContent(logs[1]);
final var expectedLog2 = "Play GROUNDDIVE_SOUND with volumn 5";
final var expectedLog2 = "Play GROUNDDIVE_SOUND with volume 5";
final var log3 = getLogContent(logs[2]);
final var expectedLog3 = "Spawn 20 particle with type GROUNDDIVE_PARTICLE";
assertEquals(logs.length, expectedSize);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void testMove() throws Exception {
void testPlaySound() throws Exception {
var skyLaunch = new SkyLaunch();
var outputLog = getLogContent(() -> skyLaunch.playSound("SOUND_NAME", 1));
var expectedLog = "Play SOUND_NAME with volumn 1";
var expectedLog = "Play SOUND_NAME with volume 1";
assertEquals(outputLog, expectedLog);
}

Expand All @@ -69,7 +69,7 @@ void testActivate() throws Exception {
final var log1 = getLogContent(logs[0]);
final var expectedLog1 = "Move to ( 0.0, 0.0, 20.0 )";
final var log2 = getLogContent(logs[1]);
final var expectedLog2 = "Play SKYLAUNCH_SOUND with volumn 1";
final var expectedLog2 = "Play SKYLAUNCH_SOUND with volume 1";
final var log3 = getLogContent(logs[2]);
final var expectedLog3 = "Spawn 100 particle with type SKYLAUNCH_PARTICLE";
assertEquals(logs.length, expectedSize);
Expand Down
1 change: 1 addition & 0 deletions typeobjectpattern/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ As explained in the book Game Programming Patterns by Robert Nystrom, type objec
> Allowing flexible creation of new “classes” by creating a single class, each instance of which represents a different type of object
## Real World Example

Let's consider a real-world example. Say, we are working on a game which has a hero and many monsters which are going to attack the hero. These monsters have certain attributes like attack, points etc. and come in different 'breeds' like zombie or ogres. The obvious answer is to have a base Monster class which has some fields and methods, which may be overriden by subclasses like the Zombie or Ogre class. But as we continue to build the game, there may be more and more breeds of monsters added and certain attributes may need to be changed in the existing monsters too. The OOP solution of inheriting from the base class would not be an efficient method in this case.
Using the type-object pattern, instead of creating many classes inheriting from a base class, we have 1 class with a field which represents the 'type' of object. This makes the code cleaner and object instantiation also becomes as easy as parsing a json file with the object properties.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ private void processInput() {
}

/**
* Update internal status. The update method pattern invoke udpate method for
* Update internal status. The update method pattern invoke update method for
* each entity in the game.
*/
private void update() {
Expand Down

0 comments on commit f79782b

Please sign in to comment.