DEV Community

Discussion on: WHY YOU SHOULD BE FOLLOWING THE SINGLE RESPONSIBILITY PRINCIPLE

Collapse
 
andreidascalu profile image
Andrei Dascalu

I don’t see a new race condition. The simple fact some code has been segregated to functions doesn’t introduce something new. That code won’t run in parallel by merely calling the methods in sequence so that one thing could get executed out of order and without waiting.

Collapse
 
darkain profile image
Vincent Milum Jr

It isn't because of separating them out into individual functions. It is that there could be multiple invocations at once, for instance two users attempting to register at the same time with competing information. And its because of situations like this why some code is written in a more complex way to handle these situations.

Thread Thread
 
zivce profile image
Milos Zivkovic

I guess if it is put in a step-wise class; where the order is obeyed. There shouldn't be a problem. We give this user flow exclusive access to these functions. Layout like this in the article would give headache if used inappropriately.

Thread Thread
 
andreidascalu profile image
Andrei Dascalu

Yeah, but that’s not because the code gets split in functions. The exact same thing applies to the original code.
That’s a whole different discussion beyond the point of illustrating a concept.