Three aspects of design
Conceptual - What are the responsibilities?
Specification - How would it be used?
Implementation - How would it fulfill it's responsibilities?
Conceptually, the responsibility of a pen is to be a writing instrument. By specification, it should be possible to be held by hand and should have a point that deliver ink to writing media. A common implementation of it is by using a plastic stick filled with carbon and a ball point.
The relationship between responsibility and implementation of a component.
Responsibility of a pen is to be a writing instrument. When the implementation is a common carbon pen, it has strong cohesion. When a spy camera is introduced into the pen, it has weak cohesion.
Strong cohesion is better, so that the implementation is simple, easy to scale, change and maintain.
The strength of the connection between specification and implementation of components.
Specification of a pen is to be able to be held by hand and have a point that deliver ink to writing media. This allows the implementation to vary between carbon pens, ink pens and all sorts of pens. That is loose coupling.
Had the specification declared the size of hands and quality of writing point and the mechanism of delivering ink, the implementation of pens would have been tightly coupled to the specification.
Loose coupling is good, so that implementation could vary independent of the specification and still the consumers of the specification could use those implementations. It is easy to scale, change and manage.
Loose coupling and strong cohesion goes hand in hand.
Separation of Concerns
Is the process of separating components so that concerns (interests or focus) doesn't overlap.
Focus of a Business Logic layer is to encapsulate business logic, Focus of a User Interface layer is to interact with a user. Separation of concerns is to avoid having user interaction related code in Business Logic layer and avoid having business knowledge in the User Interface layer.
Loose coupling and strong cohesion results in better separation of concerns.
Open - Close Principle
Open for extensibility, closed for modification.
You can create many types of pens, but they should always be things that we hold in our hands and write on a media.
Inversion of Control
Separating the controlling concern from the business concern. In software terms, it is separating the logic that control the flow of the application from business rule logic.
Pen does not have the knowledge or the ability to write. That's with the person who use it.
In a MVC implementation, the controller has the controlling logic and the Model has the business logic. In a rules engine, the rules contain the business logic and the flow has the controlling logic.
Abstractions should not depend on Details. Abstractions and Details should depend on Abstractions.
Decoupling the knowledge of implementation from the abstraction, so that the implementation could change without having to change the abstraction.
Pen should not have the knowledge of permanent markers but permanent markers should have the knowledge that it's a pen.
In software terms, it is defining a higher level component (class / sub system) without the knowledge of smaller components that make up that higher level component, so that it makes it possible to change the smaller components later, without having to change the higher level component.
How and what makes things relate to each other.
Pens, pencils and white board markers relate to each other by the fact their responsibility is to be held by hand and write on a medium.
How and what makes things change relative to each other.
Pens, pencils and white board markers vary by the medium they are used to write on and the mechanism they use to do that.