Loading
Split `wasAlreadyConnected` into query and command
wasAlreadyConnected() both checks state and mutates it, violating command-query separation. The function name implies a pure query but has a hidden side effect of marking the device as connected. This pattern is error-prone and makes the code harder to reason about. Split into two explicit methods: - isFirstConnection(): pure query, returns true if not yet connected - markAsConnected(): explicit state mutation Update controller.manager.js to call both methods explicitly, making the control flow clear at the call site.