1

The entity translator provides a function that takes one or more data contract classes as parameters and returns a specific business entity.

Within the implementation of the function, a new instance of the business entity is created and initialized using data from the data contract classes.

After a new instance of the business entity has been initialized, it is returned to the application that made the request.

source: https://msdn.microsoft.com/en-us/library/ff699418.aspx

So this description sounds very similar to a Factory method.

Would it be safe to assume that the only difference between them is the type of parameters used to create the object?

1

A Factory or Factory method is a way of creating objects without having the calling method be aware of the specific class of object that is being created or the dependencies it has. It takes away the complexity of instantiating objects for which (some of) the properties are not known at code-time but can only be known at run-time.

Your Entity Translator seems to deal with translating from data contracts to business entities. In that sense it will create objects, but that alone does not make it a Factory because a lot of OO code is mostly about creating objects. It really serves to isolate changes in the data contracts and the business from each other and centralize the logic that converts from a data contract to a business object. It removes coupling between the data contracts on one end and the application using the data contracts to create business objects and perform business logic on them on the other end.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.