- Creational
- Structural
- Behavioral
Singleton
- requiring only one instance! For example only one (single) object may access text file or some resources at the time.
- create sealed class that cant' be instantiated. Through one static public method (usually called Singleton) provide access to instance of of class. Ensure thread safe using lock and static object.
Factory
- objects that are heavily used and frequently instantiated in various places. We expect that object creation may be affected in future by some other parameters. So we dedicate special class.
- create static class with static method to handle object creation.
Unit of work
- we need to combine many CRUD operations on different related entities in on single unit of work (transaction). Either it goes all or nothing.
Repository
Use a repository to separate the logic that retrieves the data and maps it to the entity model from the business logic that acts on the model. The business logic should be agnostic to the type of data that comprises the data source layer. For example, the data source layer can be a database, a SharePoint list, or a Web service.
No comments:
Post a Comment