travis-ci/travis-worker — comment on commit dd066256825365e1a3dd5602f62c4016c0288109
File:  line 0
By svenfuchs:

re 4: "Lazy initialization is another name for race conditions" ... that really depends on how you design an object, if you share it etc. If you set an ivar `@connection` in a method `connect` that is called somewhere and then use the ivar next then that's not a better situation. Besides, I'd just point out that we have this code (which uses lazy initialization super heavily) running for months without any of these issues.

re 1: Single responsibility. The worker should deal with managing things that have a similar level of abstraction. Implementation details about closing connections, channels, queues for a particular messaging technology are not on the same level of abstraction as methods like :prepare, :work, :finish (i.e. manage other objects that belong to our domain layer). Same thing put differently: when I look at the Worker class I want to be able to easily read through what the Worker does in order to prepare, run and finish a Job. I don't want to look at details of how a certain messaging protocol needs to be managed.

re 3: I don't particularly care a lot about what famous people say if it's a bikeshed color. Our entire codebase follows this style, so let's stick to it. The reason why I favor it (which doesn't mean others need to) is that it makes it very easy to spot the break between public api and protected/private stuff. A single extra line with the same indentation doesn't serve that purpose.