Single Responsibility and Cohesion: Break Up a God Class | Java for Software Engineers | Episode 10
Description: A class that calculates, stores and formats results has several reasons to change. Refactor a Java quotation workflow around cohesive responsibilities without accidentally repeating persistence side effects.
WHAT YOU'LL LEARN
- Find distinct reasons to change rather than counting class methods.
- Preserve baseline behavior during a responsibility split.
- Verify that formatting changes cannot accidentally repeat storage side effects.
CHAPTERS
00:00 One responsibility is not the same as one method
01:00 Trace the reasons the mixed desk would change
01:55 Keep an executable baseline before refactoring
02:52 A calculator owns the pricing arithmetic
03:44 A repository owns the recording contract
04:35 A small service coordinates without owning every policy
05:28 Presentation consumes a completed value
06:16 Compare the baseline and the refactored result
07:01 Change the rate without changing the presentation algorithm
07:44 Refused operations still need explicit semantics
08:36 Do not split components more finely than the design needs
09:24 Use changes to test whether a boundary is cohesive
Java for Software Engineers | Episode 10: Single Responsibility and Cohesion: Break Up a God Class
Helpful background: SOLID overview, cohesive value objects, interfaces and composition.
Next in this course: Episode 11 - Open-Closed Principle: Extend Behavior Without Endless Conditionals
Subscribe to Think Make Explore for practical Java tutorials and software design lessons.
Example notes: Storage is in memory; the example does not implement a durable database transaction.
LEARNING REFERENCES
Single responsibility discussion: https://blog.cleancoder.com/uncle-bob/2014/05/08/SingleReponsibilityPrinciple.html
Java21 exact arithmetic: https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/Math.html#multiplyExact(long,long)
Java21 immutable list snapshots: https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/util/List.html#copyOf(java.util.Collection)
#Java #SingleResponsibility #JavaTutorial Close description
WHAT YOU'LL LEARN
- Find distinct reasons to change rather than counting class methods.
- Preserve baseline behavior during a responsibility split.
- Verify that formatting changes cannot accidentally repeat storage side effects.
CHAPTERS
00:00 One responsibility is not the same as one method
01:00 Trace the reasons the mixed desk would change
01:55 Keep an executable baseline before refactoring
02:52 A calculator owns the pricing arithmetic
03:44 A repository owns the recording contract
04:35 A small service coordinates without owning every policy
05:28 Presentation consumes a completed value
06:16 Compare the baseline and the refactored result
07:01 Change the rate without changing the presentation algorithm
07:44 Refused operations still need explicit semantics
08:36 Do not split components more finely than the design needs
09:24 Use changes to test whether a boundary is cohesive
Java for Software Engineers | Episode 10: Single Responsibility and Cohesion: Break Up a God Class
Helpful background: SOLID overview, cohesive value objects, interfaces and composition.
Next in this course: Episode 11 - Open-Closed Principle: Extend Behavior Without Endless Conditionals
Subscribe to Think Make Explore for practical Java tutorials and software design lessons.
Example notes: Storage is in memory; the example does not implement a durable database transaction.
LEARNING REFERENCES
Single responsibility discussion: https://blog.cleancoder.com/uncle-bob/2014/05/08/SingleReponsibilityPrinciple.html
Java21 exact arithmetic: https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/Math.html#multiplyExact(long,long)
Java21 immutable list snapshots: https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/util/List.html#copyOf(java.util.Collection)
#Java #SingleResponsibility #JavaTutorial Close description
