The before code has classes with draw methods but no enforced contract. The after code defines an abstract interface Drawable requiring draw method, a base class Shape implementing it, and Circle and Square inherit Shape overriding draw. This clarifies relationships and enforces method implementation.
### Before: No clear interface or inheritance
class Circle:
def draw(self):
print("Drawing circle")
class Square:
def draw(self):
print("Drawing square")
### After: Using interface and inheritance notation
from abc import ABC, abstractmethod
class Drawable(ABC):
@abstractmethod
def draw(self):
pass
class Shape(Drawable):
def draw(self):
print("Drawing shape")
class Circle(Shape):
def draw(self):
print("Drawing circle")
class Square(Shape):
def draw(self):
print("Drawing square")