I'm trying the Dependency Injection pattern in some new classes, more specifically in a Transaction System and stumbled into a dilemma. I have a Person class with a create_new_transaction method, and a Transaction class to represent my each transaction.
As the pattern dictates I inject the class transaction in the constructor. But I also wanted to inject the originator and receiver objects into the Transaction class so I can access their public name and account parameter. Am I hurting the design by implementing this? Is this creating high coupling between these two classes?
class Transaction(object): def __init__(self, amount, from_person, to_person): self.from = from_person self.to = to_person class Person(object): def __init__(self, name, transaction=Transaction): self._transaction = transaction self.name = name def create_new_transaction(self, amount, destiny): return self._transaction(amount, from_person=self, to_person=destiny)