exercism / exercism/problem-specifications

Robot name is ambiguous with regard to created vs booted

Offen
#1,831 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Ruby
Sterne
358
Forks
563
Ø Merge
18 Std. 41 Min.
Gemergte PRs (30 T.)
2

Beschreibung

From the [description](https://github.com/exercism/problem-specifications/blob/main/exercises/robot-name/description.md):

> When a robot comes off the factory floor, it has no name.
> The first time you turn on a robot, a random name is generated

Yet most solutions / tests I've seen never make the "states"/timeline clear... what is the equivalent of "coming off the factory floor"? Most assume it's `new Robot()` or some such, ie the instantiation of the robot instances (in OOP languages), which makes sense. This might be a lot more literal if there was a `RobotFactory` though that created the robots instead of just a regular constructor (not that I'm arguing for that).

So, is the robot also ON at that time, or is that a step performed later? Many seem to think the robot isn't "on" until first queried for it's name and so therefore:

```js
r = new Robot()
// r.name is null (but not always an easy way to query this)
r.name
// r.name has been assigned
```

I think this is ambiguous and unsatisfying though. One could obviously (via a direct access cable or some other method) query a robot name _without powering on the robot_, in case I would expect there to be no name - if it had not yet been turned on.

So I dislike the ambiguity regarding when a robot is "ON". I would suggest:

```js
r = new Robot()
// r.name is null
r.name
// r.name is null
r.boot() // or r.turnOn(), etc
// r.name has been assigned
```

Ie:

- A newly constructed robot has no name
- Querying the name does not change the name
- A robot's name is generated "The first time you turn on a robot", as the instructions say literally.
- We make this on event explicit and part of the exercise

Thoughts?

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.