Skip to content

Commit

Permalink
Adding analyzer feedback for Squeaky Clean concept exercise
Browse files Browse the repository at this point in the history
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
  • Loading branch information
manumafe98 committed Feb 7, 2024
1 parent e5c1052 commit d666c85
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
13 changes: 4 additions & 9 deletions exercises/concept/squeaky-clean/.docs/hints.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
15 changes: 15 additions & 0 deletions exercises/concept/squeaky-clean/.meta/design.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit d666c85

Please sign in to comment.