I was asked the question "What Gang of Four Design Patterns are used in Entity Framework". I could not really think of any.
Can anyone help to identify some of the GOF design patterns in EF?
Looking at http://en.wikipedia.org/wiki/Design_Patterns_(book) and the GoF-patterns listed there, I came up with this list:
ObjectContext
provides a CreateObjectSet<T>
method, which creates an ObjectSet<T>
for the given type. Since those object-sets are the main approach to access the entities within a context, I would say it is also a very important pattern used in EF.ObjectContext.SaveChanges
method, you can select from different strategies that are used to determine changes made on known entities.ObjectStateManager
keeps track of changes made to the entities and can be used to access those information including the original-values.ObjectContext
provides two eventy ObjectMaterialized
and SavingChanges
. Since .NET events are an implementation of the observer-pattern, EF also qualifies for this one.I may have been very generous with naming patterns here, but with some digging you can find a lot of places where EF actually implements those patterns. But since the book is out for nearly 20 years, you can expect that some of these patterns are considered a standard, which isn't worth mentioning. For example the Observer pattern or the Iterator pattern (which I haven't mentioned, just because IQueryable implements IEnumerable).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With