Skip to main content

2 posts tagged with "polymorphism"

View All Tags

Why Create Custom Exceptions? It's Not Just About the Name!

· 10 min read
Mahmut Salman
Software Developer

"Why create InvalidCredentialsException extending RuntimeException? Isn't it just to get a descriptive name instead of generic RuntimeException?" No! The name is only a small part. The real power is type-safe error handling - allowing Spring to distinguish between different errors and handle them differently without string parsing. Let's see why custom exceptions are essential, not just fancy naming.

Utility Classes vs Interfaces: Why Static Methods Aren't Enough

· 8 min read
Mahmut Salman
Software Developer

"Can't we just create a utility class with static methods instead of using interfaces? Isn't the interface approach just fancy?" Great question! Yes, you could use utility classes - but you'd be solving only 50% of the problem. Let's see what happens in practice and why interfaces aren't fancy, they're necessary.