IS-A

IS-A

This IS-A post about the IS-A concept/test. No worries it should be a short one 😉

What is the IS-A?

In object oriented design (and programming) the IS-A concept is a “test” to see if an abstraction is a sub-type of another.

So if we have something like:

PlantUML Syntax:<br />
Car ^– BMW3<br />
Car ^– ShelbyGT<br />
Person ^– Driver<br />
Person ^– Spectator<br />
Hide methods<br />
Hide fields<br />
Hide circle<br />

We could ask:
IS BMW3 A Car? Well yes, yes it is! You can clearly see it in the diagram
IS BMW3 A Driver? Nope… the diagram clearly shows that: Driver IS-A Person

This is visible on the UML representation due to the hollow pointed arrow, however I do have to point out that If you didn’t catch THAT, I would recommend that you read through the post on Class Diagrams.

Confusion

One detail that often gets misspoken and, to be fair, most of the people don’t even realize it, is the fact that people use the term type of or instance of  in place of the IS-A.

You might be thinking: “But… isn’t that the same?” and I would be answering “Yeahmmm… kinda!” (And yes I would be answering telepathically since you were just thinking about it).

You see we are talking about systems in a higher level. We are not thinking about with which language are we going to program it, or which database should we use. So to use terms such instace of would be to be getting ahead of ourselves. The IS-A is a much higher level concept that just talks about the relationship between two types.

Liskov Substitution Principle (LSP)

I won’t get into much depth here since this should be granted a post of its own, however I’d like to point out that the LSP does relate directly to the concept described in this post. If you want to know more about the LSP, which was named after Barbara Liskov, I recommend checking the original article by Bob C. Martin, although, just as a heads up, the article is very C++ oriented.

But this being an important concept part of the SOLID Principles (it is the L), you should have no problem finding more about it on your language of choice.

Leave your opinion, start a discussion, share an experience or just a compliment...

%d bloggers like this: