Skip to content

Commit 89a356f

Browse files
committed
Its a wrap
1 parent 14832e1 commit 89a356f

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

test-pnpm/mars_rovers/README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,4 +156,42 @@ Add scenario-based tests:
156156
- Extract reusable logic (e.g. `rotate`, `nextPosition`)
157157
- Add immutability if you favour a purer style
158158
- Optionally expose state inspection for diagnostics/logging
159+
- Create a functional approach to the same Kata
159160

161+
### Summary
162+
163+
Thanks *Danil Suits* for your lovely kata. I put a lot of empasis on dicipline with RED, GREEN, REFACTOR pattern of TDD * INFINITY. I also tried harder than usual to identify the natural anti-patterns I was creating by keeping things small and simple, adding a reference to [refactoring smells](https://refactoring.guru/refactoring/smells) so you can see the anti patterns I added and tried to fix. Keep timing tight, which I didn't inbetween doing stuff and other unrelated activities. https://cuckoo.team/ is a great tool for that. If you are going to pair with someone, make sure you discuss some [principles and etiquette](https://www.thoughtworks.com/insights/blog/seven-principles-pair-programming-etiquette) around what you need to do. Two controversial points with my solution. One is *Typescript* and the other is *functional* vs *class*. I personally use both when appropriate and am not a real javascript purest or functional purest. Functional approaches shine when the state transitions are stateless and I want to you want to compose behaviour easily. Class-based approach shines when encapsulation of state and behaviour and *Object-Orientation* Models the domain well. I also find as I am in C# these days, it just feels more natural to use and swap between it.
164+
165+
Verdict
166+
167+
> **Your class-based approach is very clean and modular — not worse than functional, just different. You're modelling the domain responsibly.**
168+
169+
A little bit of a break down into how you can prevent boiling the ocean :)
170+
171+
The hard part was breaking it up to not do too much at a time, so lots of small tests driving small changes and requirments to introduce stuff.
172+
173+
`''``0:0:N`
174+
175+
`'M'``0:1:N`
176+
177+
`'MM'``0:2:N`
178+
179+
`'R'``0:0:E`
180+
181+
Directional requirments seemed easier to expand by
182+
183+
| Input | Expected Output | Notes |
184+
| ------ | --------------- | ------------------------------------ |
185+
| `R` | `0:0:E` | North → East |
186+
| `RR` | `0:0:S` | East → South |
187+
| `RRR` | `0:0:W` | South → West |
188+
| `RRRR` | `0:0:N` | Wrap-around to North (full rotation) |
189+
190+
const directions = ['N', 'E', 'S', 'W']; // indices: 0, 1, 2, 3
191+
192+
| Current index | +1 | Mod 4 (`% 4`) | New Direction |
193+
| ------------- | ---- | ------------- | ------------- |
194+
| 0 (N) | 1 | 1 | E |
195+
| 1 (E) | 2 | 2 | S |
196+
| 2 (S) | 3 | 3 | W |
197+
| 3 (W) | 4 | 0 | N (wrap) |

0 commit comments

Comments
 (0)