mercredi 24 février 2016

Is there a name/pattern for a container that holds business entities?

I find myself often implementing a class that acts as a glorified container for my business entities. Usually i just suffix that class with "model", which is very undescriptive and broad.

An example (python):

class MyBusinessEntity:
    pass

class MyBusinessEntityModel:
    def __init__(self):
        self.entities = []

    def create_entity(self):
        self.entities.append(MyBusinessEntity())

    # Implement the rest of the CRUD operations

This class will act as my main data repository and will most likely use some kind of data access object for persistant storage.

Does this kind of class have a name? I came across the Repository Pattern, but i don't know if that's really the thing i am looking for.

Aucun commentaire:

Enregistrer un commentaire