Hey, nice post! The SRP is definitely a super important principle to keep in mind while coding.
However, to change the context here, let me change some of this code to use a newer Java 14 feature (the version of Java that's going to release later this month).
Getters are handled automatically by records and they follow slightly different conventions. Setters don't exist, you'd instead "mutate" a record by making a new one.
The point here is that following the SRP depends on context. In older languages/versions, what might be considered breaking the SRP might not be anymore. As we move to higher level languages, the semantics improve and we can be more expressive about the code we write, which means a "single responsibility" encapsulates more than it used to.
I'm not disagreeing with your post here, just adding additional context to the discussion :)
I'm passionate about "all things web" and have architected websites & web apps using cutting-edge tech stacks. Experienced in working with popular frameworks, enhance them.
I am glad you liked the post! Thanks for the insight and definitely newer version of Java will help to reduce the verbosity. But, I am still confused how the context will impact the SRP. Can you explain with an example?
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.
Hey, nice post! The SRP is definitely a super important principle to keep in mind while coding.
However, to change the context here, let me change some of this code to use a newer Java 14 feature (the version of Java that's going to release later this month).
Instead of:
we can do:
Getters are handled automatically by
record
s and they follow slightly different conventions. Setters don't exist, you'd instead "mutate" a record by making a new one.The point here is that following the SRP depends on context. In older languages/versions, what might be considered breaking the SRP might not be anymore. As we move to higher level languages, the semantics improve and we can be more expressive about the code we write, which means a "single responsibility" encapsulates more than it used to.
I'm not disagreeing with your post here, just adding additional context to the discussion :)
And again, well done on the post!
I am glad you liked the post! Thanks for the insight and definitely newer version of Java will help to reduce the verbosity. But, I am still confused how the context will impact the SRP. Can you explain with an example?