From f79782bea95d976d821929ddb07c8d46df456f86 Mon Sep 17 00:00:00 2001 From: Marcel Ribeiro-Dantas Date: Sat, 14 Oct 2023 12:59:21 -0300 Subject: [PATCH] fix: Fix minor typos (#2619) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcel Ribeiro-Dantas Co-authored-by: Ilkka Seppälä --- README.md | 2 +- .../information/microservice/InformationController.java | 2 +- .../com/iluwatar/caching/database/DbManagerFactory.java | 2 +- .../src/main/java/com/iluwatar/circuitbreaker/App.java | 2 +- .../circuitbreaker/DefaultCircuitBreakerTest.java | 2 +- commander/README.md | 2 +- currying/README.md | 2 +- .../java/com/iluwatar/datamapper/DataMapperException.java | 2 +- .../src/main/java/com/iluwatar/embedded/value/App.java | 4 ++-- .../src/main/java/com/iluwatar/event/queue/Audio.java | 2 +- fanout-fanin/README.md | 2 +- .../src/main/java/com/iluwatar/fanout/fanin/Consumer.java | 2 +- .../src/main/java/com/iluwatar/featuretoggle/App.java | 4 ++-- .../propertiesversion/PropertiesFeatureToggleVersion.java | 2 +- .../pattern/tieredversion/TieredFeatureToggleVersion.java | 2 +- .../iluwatar/leaderelection/AbstractMessageManager.java | 2 +- .../src/main/java/com/iluwatar/pageobject/App.java | 2 +- .../main/java/com/iluwatar/pageobject/AlbumListPage.java | 4 ++-- .../src/main/java/com/iluwatar/pageobject/AlbumPage.java | 6 +++--- .../src/main/java/com/iluwatar/pageobject/LoginPage.java | 4 ++-- .../src/main/java/com/iluwatar/partialresponse/Video.java | 2 +- .../main/java/com/iluwatar/serializedentity/Country.java | 2 +- .../java/com/iluwatar/servicetoworker/GiantViewTest.java | 2 +- subclass-sandbox/README.md | 8 ++++---- subclass-sandbox/etc/subclass-sandbox.urm.puml | 2 +- .../java/com/iluwatar/subclasssandbox/Superpower.java | 6 +++--- .../java/com/iluwatar/subclasssandbox/GroundDiveTest.java | 4 ++-- .../java/com/iluwatar/subclasssandbox/SkyLaunchTest.java | 4 ++-- typeobjectpattern/README.md | 1 + .../src/main/java/com/iluwatar/updatemethod/World.java | 2 +- 30 files changed, 43 insertions(+), 42 deletions(-) diff --git a/README.md b/README.md index 377729b96..181a983c7 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ - diff --git a/aggregator-microservices/information-microservice/src/main/java/com/iluwatar/information/microservice/InformationController.java b/aggregator-microservices/information-microservice/src/main/java/com/iluwatar/information/microservice/InformationController.java index 7a1706cac..88d11e5f4 100644 --- a/aggregator-microservices/information-microservice/src/main/java/com/iluwatar/information/microservice/InformationController.java +++ b/aggregator-microservices/information-microservice/src/main/java/com/iluwatar/information/microservice/InformationController.java @@ -34,7 +34,7 @@ import org.springframework.web.bind.annotation.RestController; public class InformationController { /** - * Endpoint to retrieve a product's informations. + * Endpoint to retrieve a product's information. * * @return product inventory. */ diff --git a/caching/src/main/java/com/iluwatar/caching/database/DbManagerFactory.java b/caching/src/main/java/com/iluwatar/caching/database/DbManagerFactory.java index 85c2baead..ee7a4a04b 100644 --- a/caching/src/main/java/com/iluwatar/caching/database/DbManagerFactory.java +++ b/caching/src/main/java/com/iluwatar/caching/database/DbManagerFactory.java @@ -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 { /** diff --git a/circuit-breaker/src/main/java/com/iluwatar/circuitbreaker/App.java b/circuit-breaker/src/main/java/com/iluwatar/circuitbreaker/App.java index dca327406..6db5ad936 100644 --- a/circuit-breaker/src/main/java/com/iluwatar/circuitbreaker/App.java +++ b/circuit-breaker/src/main/java/com/iluwatar/circuitbreaker/App.java @@ -29,7 +29,7 @@ import lombok.extern.slf4j.Slf4j; /** *

* 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 diff --git a/circuit-breaker/src/test/java/com/iluwatar/circuitbreaker/DefaultCircuitBreakerTest.java b/circuit-breaker/src/test/java/com/iluwatar/circuitbreaker/DefaultCircuitBreakerTest.java index 817a1e7d0..465371a3a 100644 --- a/circuit-breaker/src/test/java/com/iluwatar/circuitbreaker/DefaultCircuitBreakerTest.java +++ b/circuit-breaker/src/test/java/com/iluwatar/circuitbreaker/DefaultCircuitBreakerTest.java @@ -74,7 +74,7 @@ class DefaultCircuitBreakerTest { } }; 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(); diff --git a/commander/README.md b/commander/README.md index 334bc4463..472370f4b 100644 --- a/commander/README.md +++ b/commander/README.md @@ -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 diff --git a/currying/README.md b/currying/README.md index 044c5df03..9f32c9066 100644 --- a/currying/README.md +++ b/currying/README.md @@ -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) diff --git a/data-mapper/src/main/java/com/iluwatar/datamapper/DataMapperException.java b/data-mapper/src/main/java/com/iluwatar/datamapper/DataMapperException.java index 0d96a9b3c..3e5419286 100644 --- a/data-mapper/src/main/java/com/iluwatar/datamapper/DataMapperException.java +++ b/data-mapper/src/main/java/com/iluwatar/datamapper/DataMapperException.java @@ -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 diff --git a/embedded-value/src/main/java/com/iluwatar/embedded/value/App.java b/embedded-value/src/main/java/com/iluwatar/embedded/value/App.java index 3a5162960..37ec26179 100644 --- a/embedded-value/src/main/java/com/iluwatar/embedded/value/App.java +++ b/embedded-value/src/main/java/com/iluwatar/embedded/value/App.java @@ -62,7 +62,7 @@ public class App { // 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()); @@ -95,7 +95,7 @@ public class App { 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 { diff --git a/event-queue/src/main/java/com/iluwatar/event/queue/Audio.java b/event-queue/src/main/java/com/iluwatar/event/queue/Audio.java index f668b61c7..242e6fbdd 100644 --- a/event-queue/src/main/java/com/iluwatar/event/queue/Audio.java +++ b/event-queue/src/main/java/com/iluwatar/event/queue/Audio.java @@ -144,7 +144,7 @@ public class Audio { 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) { diff --git a/fanout-fanin/README.md b/fanout-fanin/README.md index 9f48160f9..5d519528c 100644 --- a/fanout-fanin/README.md +++ b/fanout-fanin/README.md @@ -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** diff --git a/fanout-fanin/src/main/java/com/iluwatar/fanout/fanin/Consumer.java b/fanout-fanin/src/main/java/com/iluwatar/fanout/fanin/Consumer.java index acb1f2a05..90b7c6385 100644 --- a/fanout-fanin/src/main/java/com/iluwatar/fanout/fanin/Consumer.java +++ b/fanout-fanin/src/main/java/com/iluwatar/fanout/fanin/Consumer.java @@ -30,7 +30,7 @@ import lombok.Getter; /** - * 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 diff --git a/feature-toggle/src/main/java/com/iluwatar/featuretoggle/App.java b/feature-toggle/src/main/java/com/iluwatar/featuretoggle/App.java index 1f5359e19..421f86e4c 100644 --- a/feature-toggle/src/main/java/com/iluwatar/featuretoggle/App.java +++ b/feature-toggle/src/main/java/com/iluwatar/featuretoggle/App.java @@ -39,8 +39,8 @@ import lombok.extern.slf4j.Slf4j; * 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. * *

Note that this pattern can easily introduce code complexity, and if not kept in check can * result in redundant unmaintained code within the codebase. diff --git a/feature-toggle/src/main/java/com/iluwatar/featuretoggle/pattern/propertiesversion/PropertiesFeatureToggleVersion.java b/feature-toggle/src/main/java/com/iluwatar/featuretoggle/pattern/propertiesversion/PropertiesFeatureToggleVersion.java index e70a581a6..ce7886a10 100644 --- a/feature-toggle/src/main/java/com/iluwatar/featuretoggle/pattern/propertiesversion/PropertiesFeatureToggleVersion.java +++ b/feature-toggle/src/main/java/com/iluwatar/featuretoggle/pattern/propertiesversion/PropertiesFeatureToggleVersion.java @@ -30,7 +30,7 @@ import java.util.Properties; 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 diff --git a/feature-toggle/src/main/java/com/iluwatar/featuretoggle/pattern/tieredversion/TieredFeatureToggleVersion.java b/feature-toggle/src/main/java/com/iluwatar/featuretoggle/pattern/tieredversion/TieredFeatureToggleVersion.java index f846f990c..74eb44340 100644 --- a/feature-toggle/src/main/java/com/iluwatar/featuretoggle/pattern/tieredversion/TieredFeatureToggleVersion.java +++ b/feature-toggle/src/main/java/com/iluwatar/featuretoggle/pattern/tieredversion/TieredFeatureToggleVersion.java @@ -29,7 +29,7 @@ import com.iluwatar.featuretoggle.user.User; 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 diff --git a/leader-election/src/main/java/com/iluwatar/leaderelection/AbstractMessageManager.java b/leader-election/src/main/java/com/iluwatar/leaderelection/AbstractMessageManager.java index eab9787d8..82f89f89c 100644 --- a/leader-election/src/main/java/com/iluwatar/leaderelection/AbstractMessageManager.java +++ b/leader-election/src/main/java/com/iluwatar/leaderelection/AbstractMessageManager.java @@ -37,7 +37,7 @@ public abstract class AbstractMessageManager implements MessageManager { protected Map instanceMap; /** - * Construtor of AbstractMessageManager. + * Constructor of AbstractMessageManager. */ public AbstractMessageManager(Map instanceMap) { this.instanceMap = instanceMap; diff --git a/page-object/sample-application/src/main/java/com/iluwatar/pageobject/App.java b/page-object/sample-application/src/main/java/com/iluwatar/pageobject/App.java index ef18ea418..0913af68e 100644 --- a/page-object/sample-application/src/main/java/com/iluwatar/pageobject/App.java +++ b/page-object/sample-application/src/main/java/com/iluwatar/pageobject/App.java @@ -83,7 +83,7 @@ public final class App { } } catch (IOException ex) { - LOGGER.error("An error occured.", ex); + LOGGER.error("An error occurred.", ex); } } diff --git a/page-object/test-automation/src/main/java/com/iluwatar/pageobject/AlbumListPage.java b/page-object/test-automation/src/main/java/com/iluwatar/pageobject/AlbumListPage.java index 7ea05d6c8..83917be91 100644 --- a/page-object/test-automation/src/main/java/com/iluwatar/pageobject/AlbumListPage.java +++ b/page-object/test-automation/src/main/java/com/iluwatar/pageobject/AlbumListPage.java @@ -59,7 +59,7 @@ public class AlbumListPage extends Page { 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; } @@ -87,7 +87,7 @@ public class AlbumListPage extends Page { ((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); } } } diff --git a/page-object/test-automation/src/main/java/com/iluwatar/pageobject/AlbumPage.java b/page-object/test-automation/src/main/java/com/iluwatar/pageobject/AlbumPage.java index 52af79599..625293a7a 100644 --- a/page-object/test-automation/src/main/java/com/iluwatar/pageobject/AlbumPage.java +++ b/page-object/test-automation/src/main/java/com/iluwatar/pageobject/AlbumPage.java @@ -61,7 +61,7 @@ public class AlbumPage extends Page { 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; } @@ -151,7 +151,7 @@ public class AlbumPage extends Page { 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); } @@ -167,7 +167,7 @@ public class AlbumPage extends Page { try { saveButton.click(); } catch (IOException e) { - LOGGER.error("An error occured on saveChanges.", e); + LOGGER.error("An error occurred on saveChanges.", e); } return this; } diff --git a/page-object/test-automation/src/main/java/com/iluwatar/pageobject/LoginPage.java b/page-object/test-automation/src/main/java/com/iluwatar/pageobject/LoginPage.java index d2c963031..f87b58e76 100644 --- a/page-object/test-automation/src/main/java/com/iluwatar/pageobject/LoginPage.java +++ b/page-object/test-automation/src/main/java/com/iluwatar/pageobject/LoginPage.java @@ -60,7 +60,7 @@ public class LoginPage extends Page { 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; } @@ -111,7 +111,7 @@ public class LoginPage extends Page { 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); } diff --git a/partial-response/src/main/java/com/iluwatar/partialresponse/Video.java b/partial-response/src/main/java/com/iluwatar/partialresponse/Video.java index 5c71f9bb3..28604ca0a 100644 --- a/partial-response/src/main/java/com/iluwatar/partialresponse/Video.java +++ b/partial-response/src/main/java/com/iluwatar/partialresponse/Video.java @@ -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() { diff --git a/serialized-entity/src/main/java/com/iluwatar/serializedentity/Country.java b/serialized-entity/src/main/java/com/iluwatar/serializedentity/Country.java index e1eb3c22a..6ef08e83b 100644 --- a/serialized-entity/src/main/java/com/iluwatar/serializedentity/Country.java +++ b/serialized-entity/src/main/java/com/iluwatar/serializedentity/Country.java @@ -31,7 +31,7 @@ import lombok.Setter; 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 diff --git a/service-to-worker/src/test/java/com/iluwatar/servicetoworker/GiantViewTest.java b/service-to-worker/src/test/java/com/iluwatar/servicetoworker/GiantViewTest.java index 579f991a9..8f5f3bb35 100644 --- a/service-to-worker/src/test/java/com/iluwatar/servicetoworker/GiantViewTest.java +++ b/service-to-worker/src/test/java/com/iluwatar/servicetoworker/GiantViewTest.java @@ -37,7 +37,7 @@ import org.junit.jupiter.api.Test; class GiantViewTest { /** - * Test dispaly giant. + * Test display giant. */ @Test void testDispalyGiant() { diff --git a/subclass-sandbox/README.md b/subclass-sandbox/README.md index d76c149ee..7a4587e3d 100644 --- a/subclass-sandbox/README.md +++ b/subclass-sandbox/README.md @@ -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) { @@ -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 diff --git a/subclass-sandbox/etc/subclass-sandbox.urm.puml b/subclass-sandbox/etc/subclass-sandbox.urm.puml index a1f863b69..9c9fda599 100644 --- a/subclass-sandbox/etc/subclass-sandbox.urm.puml +++ b/subclass-sandbox/etc/subclass-sandbox.urm.puml @@ -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) } } diff --git a/subclass-sandbox/src/main/java/com/iluwatar/subclasssandbox/Superpower.java b/subclass-sandbox/src/main/java/com/iluwatar/subclasssandbox/Superpower.java index d3472323e..4e520f397 100644 --- a/subclass-sandbox/src/main/java/com/iluwatar/subclasssandbox/Superpower.java +++ b/subclass-sandbox/src/main/java/com/iluwatar/subclasssandbox/Superpower.java @@ -53,10 +53,10 @@ public abstract class Superpower { /** * 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); } /** diff --git a/subclass-sandbox/src/test/java/com/iluwatar/subclasssandbox/GroundDiveTest.java b/subclass-sandbox/src/test/java/com/iluwatar/subclasssandbox/GroundDiveTest.java index 05104fa29..03c6b2e5c 100644 --- a/subclass-sandbox/src/test/java/com/iluwatar/subclasssandbox/GroundDiveTest.java +++ b/subclass-sandbox/src/test/java/com/iluwatar/subclasssandbox/GroundDiveTest.java @@ -48,7 +48,7 @@ class GroundDiveTest { 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); } @@ -70,7 +70,7 @@ class GroundDiveTest { 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); diff --git a/subclass-sandbox/src/test/java/com/iluwatar/subclasssandbox/SkyLaunchTest.java b/subclass-sandbox/src/test/java/com/iluwatar/subclasssandbox/SkyLaunchTest.java index 0a199c20e..87cee4f3c 100644 --- a/subclass-sandbox/src/test/java/com/iluwatar/subclasssandbox/SkyLaunchTest.java +++ b/subclass-sandbox/src/test/java/com/iluwatar/subclasssandbox/SkyLaunchTest.java @@ -47,7 +47,7 @@ class SkyLaunchTest { 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); } @@ -69,7 +69,7 @@ class SkyLaunchTest { 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); diff --git a/typeobjectpattern/README.md b/typeobjectpattern/README.md index 742792a8f..b8d984f4d 100644 --- a/typeobjectpattern/README.md +++ b/typeobjectpattern/README.md @@ -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. diff --git a/update-method/src/main/java/com/iluwatar/updatemethod/World.java b/update-method/src/main/java/com/iluwatar/updatemethod/World.java index f2da8b9f8..5335b23f1 100644 --- a/update-method/src/main/java/com/iluwatar/updatemethod/World.java +++ b/update-method/src/main/java/com/iluwatar/updatemethod/World.java @@ -74,7 +74,7 @@ public class World { } /** - * 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() {