[FITYMI] Interface Segregation Principle (ISP) and a Purely Hypothetical Social Commentary

I just came from a trip to Spain (which I will probably post about next week) and I have exactly one day to write this piece before my scheduled release. Since I’m rushing, might as well go all the way. Here’s the TL;DR version of this post:

ISP stands for Interface Segregation Principle, and it’s the I in SOLID OOP. This principle simply says that clients – meaning your classes – should not be forced to depend on interfaces they don’t use. If you have a group of methods defined in an interface, and you find that a class you’re creating needs to use some – but not all – of those methods, then you probably need to split that interface instead of forcing your new class to use it. This makes your code more organized, and just makes more sense.

For example, from our last post if we somehow defined an ICanAct interface with the methods “act” and “eat” (because most actors eat), then this interface would apply to James and Nadine, but not to my butt. We should split this interface to something like ICanAct or IActor with the method “act”, and ICanEat or IEater with the method “eat”. James and Nadine will implement both interfaces, while my butt would implement only IActor.

Continue reading

Advertisements

[PiG] My Public Hair: The Best Birthday Gift

 

Ever since I played the Witcher 3, I’ve wanted to have Geralt of Rivia hair: white, shoulder-length, in a half-ponytail. After consulting with various hair stylists and many different salons in the Philippines, I found out that it would be very difficult to turn my hair as white as Geralt’s. It would require bleaching at least three times, which may turn my jet black hair into maybe some variant of blonde. Oh well, at least shoulder-length in a half-pony is still achievable. With this objective in mind, I began intentionally letting my hair grow-out around November of last year.

What does this have to do with birthdays? Whose birthday? Was there really a birthday? I promise it’s coming. Just read on.

Continue reading

[FITYMI] A Dip in the Dependency Inversion Principle – SOLID OOP

By this time you should have already landed that job you were interviewing for. You should have also (hopefully) realized that this series is not just about faking interviews, but about learning. Learning does not stop after you graduate from school. It does not stop after getting a job. Your boss will surely squeeze the most out of you, so you better make sure you’re up to snuff. It’s time to get trippy with the Dependency Inversion Principle and complete the L. S. D. of SOLID OOP.

Continue reading

[Pinoy in Germany] Fun for a Foreigner

A couple of weeks ago I was struck by a bout of homesickness, which may have given the wrong impression about living conditions here in Hamburg. While I do appreciate the outpouring of support, it would be unfair of me to leave it at that. Hamburg is not a grim place. You don’t need to worry about my physical, mental, or emotional health (yet). And there’s fun to be had around many a corner. Here are some of my simple pleasures.

Continue reading