mirror of
https://github.com/rjNemo/design-patterns
synced 2026-06-06 02:26:40 +00:00
28 lines
791 B
Python
28 lines
791 B
Python
from abc import ABC, abstractmethod
|
|
|
|
from AbstractProductA import AbstractProductA
|
|
|
|
|
|
class AbstractProductB(ABC):
|
|
"""
|
|
Here's the the base interface of another product. All products can interact
|
|
with each other, but proper interaction is possible only between products of
|
|
the same concrete variant.
|
|
"""
|
|
|
|
@abstractmethod
|
|
def useful_function_b(self) -> None:
|
|
"""
|
|
Product B is able to do its own thing...
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def another_useful_function_b(self, collaborator: AbstractProductA) -> None:
|
|
"""
|
|
...but it also can collaborate with the ProductA.
|
|
|
|
The Abstract Factory makes sure that all products it creates are of the
|
|
same variant and thus, compatible.
|
|
"""
|
|
pass
|