From d666c853e5da145689ea34bef34952747a6135a4 Mon Sep 17 00:00:00 2001 From: manumafe98 Date: Wed, 7 Feb 2024 14:17:48 -0300 Subject: [PATCH 1/2] Adding analyzer feedback for Squeaky Clean concept exercise Updating design.md with the analyzer recommendations Updating hints to not be as specific and tell directly the methods to the student Update reference resolution to use isWhitespace --- exercises/concept/squeaky-clean/.docs/hints.md | 13 ++++--------- exercises/concept/squeaky-clean/.meta/design.md | 15 +++++++++++++++ .../.meta/src/reference/java/SqueakyClean.java | 2 +- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/exercises/concept/squeaky-clean/.docs/hints.md b/exercises/concept/squeaky-clean/.docs/hints.md index 7981ff47e..c9eddf47e 100644 --- a/exercises/concept/squeaky-clean/.docs/hints.md +++ b/exercises/concept/squeaky-clean/.docs/hints.md @@ -3,29 +3,24 @@ ## 1. Replace any spaces encountered with underscores - [This tutorial][chars-tutorial] is useful. -- [Reference documentation][chars-docs] for `char`s is here. - You can retrieve `char`s from a string using the [charAt][char-at] method. - You should use a [`StringBuilder`][string-builder] to build the output string. -- See [this method][iswhitespace] for detecting spaces. Remember it is a static method. +- Check the [Character][chars-docs] documentation for a method to detect whitespaces. Remember it is a static method. - `char` literals are enclosed in single quotes. ## 2. Convert kebab-case to camel-case -- See [this method][toupper] to convert a character to upper case. +- Check the [Character][chars-docs] documentation for a method to convert a character to upper case. ## 3. Convert leetspeak to normal text -- See [this method][isdigit] for detecting numbers. +- Check the [Character][chars-docs] documentation for a method to detect when a character is a digit. ## 4. Omit characters that are not letters -- See [this method][isletter] to check if a character is a letter. +- Check the [Character][chars-docs] documentation for a method to detect when a character is a letter. [chars-docs]: https://docs.oracle.com/en/java/javase/14/docs/api/java.base/java/lang/Character.html [chars-tutorial]: https://docs.oracle.com/javase/tutorial/java/data/characters.html [char-at]: https://docs.oracle.com/en/java/javase/14/docs/api/java.base/java/lang/String.html#charAt(int) [string-builder]: https://docs.oracle.com/en/java/javase/14/docs/api/java.base/java/lang/StringBuilder.html -[iswhitespace]: https://docs.oracle.com/en/java/javase/14/docs/api/java.base/java/lang/Character.html#isWhitespace(char) -[toupper]: https://docs.oracle.com/en/java/javase/14/docs/api/java.base/java/lang/Character.html#toUpperCase(char) -[isletter]: https://docs.oracle.com/en/java/javase/14/docs/api/java.base/java/lang/Character.html#isLetter(char) -[isdigit]: https://docs.oracle.com/en/java/javase/14/docs/api/java.base/java/lang/Character.html#isDigit(char) diff --git a/exercises/concept/squeaky-clean/.meta/design.md b/exercises/concept/squeaky-clean/.meta/design.md index 4ea5e8475..07eef80ae 100644 --- a/exercises/concept/squeaky-clean/.meta/design.md +++ b/exercises/concept/squeaky-clean/.meta/design.md @@ -27,3 +27,18 @@ - `strings`: know of the `string` type that will be iterated over and accessed by index. - `for-loop` for loops (rather than foreach) are the best means of highlighting the relationship between strings and `char`s + +## Analyzer + +This exercise could benefit from the following rules in the [analyzer]: + +- `actionable`: If the solution did not use `Character.isWhitespace`, instruct the student to do so, because this concept intends to teach the character concept and methods. +- `actionable`: If the solution did not use `Character.isDigit`, instruct the student to do so. +- `actionable`: If the solution did not use `Character.isLetter`, instruct the student to do so. +- `actionable`: If the solution did not use `Character.toUpperCase`, instruct the student to do so. +- `informative`: If the solution uses string concatenation instead of `StringBuilder`, inform the student that this cause a small performance and memory penalty compared to `StringBuilder`. + +If the solution does not receive any of the above feedback, it must be exemplar. +Leave a `celebratory` comment to celebrate the success! + +[analyzer]: https://github.com/exercism/java-analyzer diff --git a/exercises/concept/squeaky-clean/.meta/src/reference/java/SqueakyClean.java b/exercises/concept/squeaky-clean/.meta/src/reference/java/SqueakyClean.java index e88e02316..961174021 100644 --- a/exercises/concept/squeaky-clean/.meta/src/reference/java/SqueakyClean.java +++ b/exercises/concept/squeaky-clean/.meta/src/reference/java/SqueakyClean.java @@ -24,7 +24,7 @@ static String clean(String identifier) { boolean kebab = false; for (int i = 0; i < identifier.length(); i++) { final char ch = identifier.charAt(i); - if (Character.isSpaceChar(ch)) { + if (Character.isWhitespace(ch)) { cleanIdentifier.append("_"); } else if (Character.isDigit(ch)) { cleanIdentifier.append(SqueakyClean.replaceDigit(ch)); From e2ceb2b39de230a80c811243a8f97e5901e6cb9c Mon Sep 17 00:00:00 2001 From: manumafe98 Date: Thu, 8 Feb 2024 10:04:06 -0300 Subject: [PATCH 2/2] Applying suggestion --- exercises/concept/squeaky-clean/.docs/hints.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/exercises/concept/squeaky-clean/.docs/hints.md b/exercises/concept/squeaky-clean/.docs/hints.md index c9eddf47e..804bf6d8f 100644 --- a/exercises/concept/squeaky-clean/.docs/hints.md +++ b/exercises/concept/squeaky-clean/.docs/hints.md @@ -10,15 +10,15 @@ ## 2. Convert kebab-case to camel-case -- Check the [Character][chars-docs] documentation for a method to convert a character to upper case. +- Check the [Character][chars-docs] documentation for a method to convert a character to upper case. Remember it is a static method. ## 3. Convert leetspeak to normal text -- Check the [Character][chars-docs] documentation for a method to detect when a character is a digit. +- Check the [Character][chars-docs] documentation for a method to detect when a character is a digit. Remember it is a static method. ## 4. Omit characters that are not letters -- Check the [Character][chars-docs] documentation for a method to detect when a character is a letter. +- Check the [Character][chars-docs] documentation for a method to detect when a character is a letter. Remember it is a static method. [chars-docs]: https://docs.oracle.com/en/java/javase/14/docs/api/java.base/java/lang/Character.html [chars-tutorial]: https://docs.oracle.com/javase/tutorial/java/data/characters.html