I have a function that retrieves raw data from the database and returns an object which represents this data.

Should the conversion between the raw data and the object be written in that method or should I dedicate a separate method for the conversion, according to SRP?


I would definitely go with a separate method, maybe even a separate class. The reason is not only SRP, but OCP too. Of course, if it is always the same format that the data is to be converted to and there is little chance of that format changing, then there is really no need to overdesign the code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.