Funny
EN
CodeSOD: Connection State
['Remy Porter']
The Daily WTF
class ConferenceService { public bool IsCalling () { try { return m_ConnectionService.Core.State.IsWebRTCConnected; } catch { return false ; } } }This is for a web conferencing tool, which uses WebRTC to set up connections between clients in the chat.
If anything throws an exception, we know we can just return false.
We're talking about a state machine here, though admittedly with two states under discussion (connected/disconnected), though there are probably more not being checked here.
This information should be managed via a state machine, not via boolean flags stuffed deep in an object chain.
But folks definitely should think more carefully about how they manage state.