Let's say we have Class A and Class B.
Class A's job is just to do X,Y,Z. The problem is it needs to be created, disposed of, and also referenced somewhere for manage these lifecycles.
Class B to the rescue. Class B kind of acts as a factory as it creates the instance but also houses it so it can kill it later.
An example of this would be managing a database connection in an application.
Aucun commentaire:
Enregistrer un commentaire