CSC/ECE 517 Summer 2008/wiki3 1 PF: Difference between revisions
Line 12: | Line 12: | ||
=== Why pure fabrication? === | === Why pure fabrication? === | ||
We do not want our clients to know the fine grained entities to the client, so we'll have to provide a high level view to them. To achieve this, we do not want to change the interface of the entity. Therefore, to solve this problem, we can provide an additional element that provides a distributable view to the system. It also facilitates the co-ordination of the business entities, so that they still remain independent of each other. This approach is called "Pure Fabrication", because, from the business point of view, an insignificant class was introduced to decouple the client from the business objects. Figure 1 describes this approach. | We do not want our clients to know the fine grained entities to the client, so we'll have to provide a high level view to them. To achieve this, we do not want to change the interface of the entity. Therefore, to solve this problem, we can provide an additional element that provides a distributable view to the system. It also facilitates the co-ordination of the business entities, so that they still remain independent of each other. This approach is called "Pure Fabrication", because, from the business point of view, an insignificant class was introduced to decouple the client from the business objects. Figure 1 describes this approach. | ||
[[Image:PureFabrication.jpg]] | |||
==How would you classify it == | ==How would you classify it == |
Revision as of 13:57, 24 July 2008
Pure fabrication
Sometimes it is a good idea to introduce into a system an object that has no counterpart in the real world. This is called the pure fabrication pattern. Find examples of pure fabrication, and weave them into a narrative that can teach programmers when it is helpful and when it is not helpful to fabricate objects.
Introduction
Programming all code by a design pattern can make the code more readable and easy to manipulate in the future. What do you do when you don't have any patterns that actually work in the design? A pure fabrication is a class that does not represent a concept in the problem domain. It is specially made up to achieve low coupling, high cohesion, and the reuse potential only if needed. So in code where you need to put something in and you can't come up with a pattern to match it, it may be time to just write the code and worry about a perfect solution later.
Why pure fabrication?
We do not want our clients to know the fine grained entities to the client, so we'll have to provide a high level view to them. To achieve this, we do not want to change the interface of the entity. Therefore, to solve this problem, we can provide an additional element that provides a distributable view to the system. It also facilitates the co-ordination of the business entities, so that they still remain independent of each other. This approach is called "Pure Fabrication", because, from the business point of view, an insignificant class was introduced to decouple the client from the business objects. Figure 1 describes this approach.
How would you classify it
Pure Fabrication is classified as one of the nine GRASP Patterns that help aid developers in assigning responsibilities to objects in your web applications and winform applications. Most code is created for a specific application. Plug-in and refactoring can help redesign code to be used in the next generation. At some point when your developing code you may decide that the life cycle of the code is short and so you develope code for short term. Following patterns can help make your code more reusable and readble but in some situations writing code for just that application where it doesn't follow any pattern is the best choice.
examples of code sequences that would be awkward
Conclusion
Sometimes its better to develop something that works better in your code but isn't a perfect pattern. The Pure Fabrication Pattern is where you add classes into your application to create high cohesion and low coupling. Today with code changing at a rapid pace it may be easier to design something one time and redesign it or refactor it later. Depositories and Factories are very similar to pure fabrication, they help with object persistence and object creation. They delegate object reconstitution and creation to specialized classes so domain objects are mere data containers and behaviors that act on that data.