[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

[Fake it ‘til you make it] SOLID OOP – S stands for “Not my fucking job”

You’re knee-deep into your interview now, with your interviewer absolutely wowed by your grasp of the Liskov Substitution Principle. You allow yourself to breathe and think “I’ve got it, this job’s mine”. Your interviewer senses this moment of weakness, and hoping to catch you off-guard she asks, “How about the other SOLID principles?” What do you do? You tell her “S stands for ‘Not my fucking job!'”
Continue reading

[Pinoy in Germany] Anniversary Homesickness

I’ve been in Germany for almost five months now. It’s great to be with my wife again. I’m more comfortable in my skin here with her, than I was back in the Philippines when we were apart. The climate here is colder, which I prefer over the oppressive heat we often experience. Still, this place doesn’t feel like home yet. I’ve been here long enough to miss a lot of things from the Philippines. It’s also our fourth wedding anniversary – the first we’re celebrating here in Germany – and I am spending it alone. I think I’ve earned the right to feel homesick for a little bit.

Continue reading

[Fake it ‘til you make it] The L in SOLID OOP

Landing a job can be quite hard, as I can attest from both sides of the table. I’m currently on the lookout for a job, and sadly I could not even land an interview. Should I get one though, I am pretty sure I would do well, and you can too. From my years of experience interviewing candidates, I believe I’ve developed a technique that’s guaranteed to help you seem like you really know about a topic, even though you don’t. I’ll demonstrate these techniques to you now, in the context of object-oriented programming.
Continue reading