Skip to content

Commit b951c11

Browse files
Add existing analyzer comments (#2691)
* lasagna: Add existing analyzer comments to .meta/design.md * leap: Add existing analyzer comments to .meta/design.md * two-fer: Add existing analyzer comments to .meta/design.md * hamming: Add existing analyzer comments to .meta/design.md
1 parent cbf6377 commit b951c11

File tree

4 files changed

+59
-1
lines changed

4 files changed

+59
-1
lines changed

exercises/concept/lasagna/.meta/design.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,13 @@ This exercise does not require any specific representation logic to be added to
4747

4848
## Analyzer
4949

50-
This exercise does not require any specific logic to be added to the [analyzer][analyzer]:
50+
This exercise could benefit from the following rules in the [analyzer]:
51+
52+
- `actionable`: If the student did not reuse the implementation of the `expectedMinutesInOven` method in the `remainingMinutesInOven` method, instruct them to do so.
53+
Explain that reusing existing code instead of copy-pasting can help make code easier to maintain.
54+
- `actionable`: If the student did not reuse the implementation of the `preparationTimeInMinutes` method in the `totalTimeInMinutes` method, instruct them to do so.
55+
Explain that reusing existing code instead of copy-pasting can help make code easier to maintain.
56+
- `actionable`: If the student left any `// TODO: ...` comments in the code, instruct them to remove these.
5157

5258
[analyzer]: https://github.com/exercism/java-analyzer
5359
[representer]: https://github.com/exercism/java-representer
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Design
2+
3+
## Analyzer
4+
5+
This exercise could benefit from the following rules in the [analyzer]:
6+
7+
- `actionable`: If the solution calculates the Hamming distance each time `getHammingDistance()` is called,
8+
instruct the student to calculate the Hamming distance once in the constructor.
9+
Explain how this is more efficient.
10+
- `actionable`: If the solution hard-codes the DNA cells as character literals (`A`, `C`, `G`, `T`) when comparing strands,
11+
inform the student that their solution should be able to calculate the Hamming distance between any two strings,
12+
regardless of their contents.
13+
- `informative`: If the solution uses `Instream.reduce()`, inform the student that it can be simplified to `Instream.filter().count()`.
14+
15+
[analyzer]: https://github.com/exercism/java-analyzer
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Design
2+
3+
## Analyzer
4+
5+
This exercise could benefit from the following rules in the [analyzer]:
6+
7+
- `essential`: Verify that the solution does not use `java.time.Year.isLeap(int)` or `new java.util.GregorianCalendar().isLeapYear(int)`.
8+
- `essential`: Verify that the solution does not contain hard-coded years used in the tests.
9+
- `actionable`: If the solution uses conditional statements like `if/else` or ternary expressions, instruct the student to use simple boolean logic instead.
10+
- `actionable`: If the solution contains more than 3 checks, instruct the student that their solution can be simplified.
11+
12+
[analyzer]: https://github.com/exercism/java-analyzer
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Design
2+
3+
## Analyzer
4+
5+
This exercise could benefit from the following rules in the [analyzer]:
6+
7+
- `essential`: Verify that the solution does not hard-code the names used by the tests (`Alice`, `Bob`).
8+
- `actionable`: If the solution contains more than one `return` statement, instruct the student to try and only use one.
9+
Using multiple `return` statements in this exercise could be an indication of code duplication, as it probably contains the sentence twice:
10+
11+
```java
12+
String twofer(String name) {
13+
if (name == null) {
14+
return "One for you, one for me."
15+
}
16+
17+
return "One for " + name + ", one for me."
18+
}
19+
```
20+
21+
- `actionable`: If the solution uses an `if` statement, instruct the student to use a ternary expression instead.
22+
- `actionable`: If the solution uses `String.format`, instruct the student to use simple string concatenation instead.
23+
Explain that `String.format` is significantly slower than concatenating strings and should be used in more complex scenarios.
24+
25+
[analyzer]: https://github.com/exercism/java-analyzer

0 commit comments

Comments
 (0)