TemplateMethod API Documentation

class AbstractClass[source]

Bases: ABC

Abstract class that defines the skeleton of an algorithm. Subclasses must implement specific steps of the algorithm.

template_method()[source]

Defines the algorithm’s skeleton by calling base operations, required steps, and hooks in a predefined order.

Return type:

None

base_operation1()[source]

A base operation with a default implementation.

Return type:

None

base_operation2()[source]

A base operation with a default implementation.

Return type:

None

abstractmethod required_operation1()[source]

A required operation that must be implemented by subclasses.

Return type:

None

abstractmethod required_operation2()[source]

A required operation that must be implemented by subclasses.

Return type:

None

hook()[source]

A hook that can be overridden by subclasses but provides a no-op by default.

Return type:

None

class ConcreteClass1[source]

Bases: AbstractClass

A concrete implementation of the abstract class with its own behavior.

required_operation1()[source]

A required operation that must be implemented by subclasses. In this case, this method adds its own behavior before or after calling the base implementation.

Return type:

None

required_operation2()[source]

A required operation that must be implemented by subclasses. In this case, this method adds its own behavior before or after calling the base implementation.

Return type:

None

hook()[source]

A hook that can be overridden by subclasses. This implementation provides a specific behavior.

Return type:

None

class ConcreteClass2[source]

Bases: AbstractClass

Another concrete implementation of the abstract class with its own behavior.

required_operation1()[source]

A required operation that must be implemented by subclasses. In this case, this method calls the base implementation.

Return type:

None

required_operation2()[source]

A required operation that must be implemented by subclasses. In this case, this method calls the base implementation.

Return type:

None