Factory objects have several advantages:
Separate the responsibility of complex creation into cohesive helper objects.
Hide potentially complex creation logic.
Allow introduction of performance-enhancing memory management strategies, such as object caching or recycling.
Name: | Factory |
Problem: | Who should be responsible for creating objects when there are special considerations, such as complex creation logic, a desire to separate the creation responsibilities for better cohesion, and so forth? |
Solution: (advice) | Create a Pure Fabrication object called a Factory that handles the creation. It's always used with Singleton pattern. |
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/792140/viewspace-964967/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/792140/viewspace-964967/