Loading lesson…
Level 1 · Apprentice0 XP
Control access to an object without the caller noticing.
Step 1 / 5
ProblemTwenty service methods each open a transaction, check a permission and log the duration before doing their real work. The real work is three lines buried in fifteen.
← → step
Before this: Decorator: wrap, don't subclass
🛠️ Your turn
Reading is not the skill, doing is. Try for ten minutes before you open the hint. Getting stuck first is what makes the solution stick.
1.Write a CachingProxy for an interface PriceLookup { fun price(sku: String): Double } that calls the real lookup once per sku. Then reproduce the Spring self-call trap: a @Transactional method called through this, and fix it by moving it to another bean.