Abstraction or Inheritance use case?

I'm modeling a UDP communication server in VisualBasic.NET. In my system I have 3 types of messages: basic, advanced and full messages.

Basic message is composed of: ID, Version and Serial Number. Advanced message is composed of: basic message + NSeq, IDMsg, Size and CRC. Full message is composed of: advanced message + Timestamp.

Each message have it own set of methods, but there are some method that are common to all kinds of messages.

In this case should I use inheritance since advanced and full messages all have the same proprieties of basic message, or should I go for an abstraction? I think these two concepts are not very clear after all.


  • If the implementation of the common functionality is the same, use inheritence.

    If you have common operations among objects but each has its own implementation then you can use Interfaces to treat the instances polymorphicly.