Currently developing futuristic smart-device, IoT connected, highway construction site safety system in EU.
Used to work on infrastructure, application architecture and cloud engineering.
thank you for your feedback. I didn't want to be too critical. What I see as one weak point is (and it has already been mentioned in previous post) that now you tightly coupled everything together.
Now your factory pattern is strictly part of User class and User is not based on any Interface thus it is not replaceable by any mock/stub implementation for testing.
More test friendly solution (the same applies and also answers your question about DI / IoT) would be to base it on an Interface. This way your method can be safely called from production code and at the same time from a test routine by injecting production code or test stub - to be able to test domain specific behavior without uploading an avatar image to production servers.
I know in the end this makes a lot of boilerplate but if your project ever grows to size when changing one thing might have any impact on other parts of code, especially in a team of multiple developers, you'd rather have tests ready to discover it before deployment.
I hope you find this argument reasonable.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hi,
thank you for your feedback. I didn't want to be too critical. What I see as one weak point is (and it has already been mentioned in previous post) that now you tightly coupled everything together.
Now your factory pattern is strictly part of User class and User is not based on any Interface thus it is not replaceable by any mock/stub implementation for testing.
More test friendly solution (the same applies and also answers your question about DI / IoT) would be to base it on an Interface. This way your method can be safely called from production code and at the same time from a test routine by injecting production code or test stub - to be able to test domain specific behavior without uploading an avatar image to production servers.
I know in the end this makes a lot of boilerplate but if your project ever grows to size when changing one thing might have any impact on other parts of code, especially in a team of multiple developers, you'd rather have tests ready to discover it before deployment.
I hope you find this argument reasonable.