The Separated Interface pattern defines an interface in a separate package from its implementation.

Interface Definition: An interface defines a contract or a set of methods that a class must implement, without specifying how these methods should be implemented. It focuses on what operations can be performed, not how they are performed. In many programming languages, interfaces are explicitly defined using keywords like interface (e.g., in Java or TypeScript). In Ruby, interfaces are often represented by abstract classes or modules with method definitions that subclasses or including classes must implement.

Coding Best Practices:

  1. Reduce coupling between the system’s parts.
  2. Group classes into packages and control dependencies between them.
  3. Create simple rules how classes in one package can call (or if they can call) classes in another package.
module Drawable
  def draw
    raise NotImplementedError, "You must implement the draw method"
  end
end