Open 51-code opened 2 weeks ago
RelpConnection would also benefit from refactoring it to be immutable. Currently the status of the connection is kept inside a variable, it should return a new RelpConnection with the updated state instead. An interface for the object would also help with unit testing in other components, where fake objects are needed.
Description
Currently opening a connection is handled in the
connect()
function. This could be refactored so that no explicit call to this function is needed. Thecommit()
function would make sure that a connection is opened before the message is sent.This would simplify using the object in other components. Now in some cases the connection has to be done in the constructor, which is bad design, but there really is no better alternative.