Usually, when I teach “Abstraction” concept in my Object Oriented Design course, I define it as “Creating a model for real life objects in problem domain”. It assists you to solve the problems that you are working on it. For instance, suppose we are to create an invoice system in a clothes boutique. Based on provided requirements, the problem which should be solved with this system is reliving a hardship in invoice issuance process, to make long story short we have to fill items of an invoice by scanning a bar code then print that for customer also provide a daily sale report to the manager. In such case, we need to design a problem domain model, as it is clear one of the main domain objects here is “Cloths”. So, what are the properties of this entity? You know each cloths has characteristics including Type i.e. “T-shirt, Scarf, Skirt…” Color, Brand, a number as size, model, price and a number as count of existing items in our inventory. Then which property should be exist in our “Cloths entity” in this domain model? In order to answer this question, we should find out which problem should be solved by our product; I remind you the problem was about “Invoices issuance and provide a sale report”, Thus Do we need either color of the cloths or its type? I reckon no. The cloths in this domain only need a title or description, a price in addition to a code as product recognizer. We can see this modeling as depicted bellow.
But it is not all the story for abstraction concept; let model the invoice and its items. Here, we can suppose an invoice as an object with this properties: Date, Customer Name, Invoice number and a list of items which contains product description, Count and Fee. It looks like following image.
Now, I want to ask “Do we need a reference to the invoice for items?” the answer is dependent on our requirements at hand, Actually this is another side of abstraction I mean “Relation between objects” this relation must be exist if and only if we need them for answering a question in our domain, Is there any question in this example which should be answered by sending a message (for instance method call) to fulfilling a requirement? Despite of existing relation between these objects in the real world, we don’t need to model them here because this association relation dose not solve any problem for us.
For sum up, during modeling a problem domain in an object oriented approach to acquire a design model you should not forget that you are creating a “Model” not a “Picture” from real word. One of the main strong point of models are their ability in simplifying real world complex problems in order to make them more understandable by concentrating on most important part of domain objects besides their relationship. Applying abstraction concept to relationships of objects are usually omitted by novice developers because they try to map models to real world instead of creating a simple model in order to solving their problems.