Knowledge

Creational pattern

Source đź“ť

117:
design. Additionally, hard-coding does not promote reuse and makes it difficult to keep track of errors. For these reasons, creational patterns are more useful than hard-coding behaviors. Creational patterns make design become more flexible. They provide different ways to remove explicit references in the concrete classes from the code that needs to instantiate them. In other words, they create independency for objects and classes.
155: 116:
than class inheritance, emphasis shifts away from hard-coding behaviors toward defining a smaller set of basic behaviors that can be composed into more complex ones. Hard-coding behaviors are inflexible because they require overriding or re-implementing the whole thing in order to change parts of the
59:
Creational design patterns are further categorized into object-creational patterns and class-creational patterns, where object-creational patterns deal with object creation and class-creational patterns deal with class-instantiation. In greater details, object-creational patterns defer part of its
39:
in a manner suitable to the situation. The basic form of object creation could result in design problems or in added complexity to the design due to inflexibility in the creation procedures. Creational design patterns solve this problem by somehow controlling this object creation.
103:
The creational patterns aim to separate a system from how its objects are created, composed, and represented. They increase the system's flexibility in terms of the what, who, how, and when of object creation.
162:
Below is a simple class diagram that most creational patterns have in common. Note that different creational patterns require additional and different participated classes.
76:, which separates the construction of a complex object from its representation so that the same construction process can create different representations. 209:: separate the construction of a complex object from its representation so that the same construction process can create different representations 221:: tactic of delaying the creation of an object, the calculation of a value, or some other expensive process until the first time it is needed 582: 249: 88:, which specifies the kind of object to create using a prototypical instance, and creates new objects by cloning this prototype. 542: 505: 468: 431: 398: 365: 332: 299: 233:: used when the type of objects to create is determined by a prototypical instance, which is cloned to produce new objects 70:, which provides an interface for creating related or dependent objects without specifying the objects' concrete classes. 1107: 1215: 1132: 28: 48:
Creational design patterns are composed of two dominant ideas. One is encapsulating knowledge about which concrete
1080: 905: 704: 420:
Freeman, Eric; Freeman, Elisabeth; Sierra, Kathy; Bates, Bert (2004). Hendrickson, Mike; Loukides, Mike (eds.).
387:
Freeman, Eric; Freeman, Elisabeth; Sierra, Kathy; Bates, Bert (2004). Hendrickson, Mike; Loukides, Mike (eds.).
354:
Freeman, Eric; Freeman, Elisabeth; Sierra, Kathy; Bates, Bert (2004). Hendrickson, Mike; Loukides, Mike (eds.).
798: 928: 888: 575: 60:
object creation to another object, while class-creational patterns defer its object creation to subclasses.
898: 893: 49: 1173: 1011: 218: 197:: a class requests the objects it requires from a factory object instead of creating the objects directly 53: 788: 996: 991: 818: 227:: avoid expensive acquisition and release of resources by recycling objects that are no longer in use 36: 1036: 1001: 968: 618: 568: 215:: a class accepts the objects it requires from an injector instead of creating the objects directly 194: 67: 938: 910: 848: 833: 813: 749: 591: 460: 454: 94:, which ensures that a class only has one instance, and provides a global point of access to it. 915: 843: 793: 628: 200: 79: 1194: 1097: 943: 923: 868: 534: 528: 497: 491: 291: 285: 203:: centralize creation of an object of a specific type choosing one of several implementations 1006: 963: 958: 948: 858: 212: 20: 130:
Hiding the implementations of a class library or product, revealing only their interfaces.
8: 1046: 1031: 1026: 883: 768: 714: 259: 224: 1168: 1147: 1056: 953: 803: 696: 648: 264: 254: 113: 154: 838: 681: 671: 666: 638: 633: 538: 501: 464: 427: 394: 361: 328: 322: 295: 236: 230: 91: 85: 1137: 878: 823: 744: 734: 724: 719: 421: 388: 355: 1127: 1073: 1051: 828: 783: 754: 729: 709: 656: 623: 599: 206: 142:
There must be a single instance and client can access this instance at all times.
73: 32: 1112: 973: 676: 661: 63:
Five well-known design patterns that are parts of creational patterns are the
1209: 933: 778: 739: 686: 1189: 1152: 1041: 1016: 808: 560: 124:
A system should be independent of how its objects and products are created.
1142: 1117: 1102: 1021: 853: 1122: 527:
Gamma, Erich; Helm, Richard; Johnson, Ralph; Vlissides, John (1995).
490:
Gamma, Erich; Helm, Richard; Johnson, Ralph; Vlissides, John (1995).
321:
Gamma, Erich; Helm, Richard; Johnson, Ralph; Vlissides, John (1995).
284:
Gamma, Erich; Helm, Richard; Johnson, Ralph; Vlissides, John (1995).
133:
Constructing different representation of independent complex objects.
136:
A class wants its subclass to implement the object it creates.
82:, which allows a class to defer instantiation to subclasses. 526: 489: 419: 386: 353: 320: 283: 127:
A set of related objects is designed to be used together.
190:
Some examples of creational design patterns include:
145:
Instance should be extensible without being modified.
56:
of these concrete classes are created and combined.
16:
Software design pattern dealing with object creation
139:
The class instantiations are specified at run-time.
239:: restrict instantiation of a class to one object 1207: 112:As modern software engineering depends more on 576: 120:Consider applying creational patterns when: 590: 175:: Declares object interface. Returns object. 426:. California: O'Reilly Media. p. 177. 393:. California: O'Reilly Media. p. 134. 360:. California: O'Reilly Media. p. 156. 583: 569: 533:. Massachusetts: Addison-Wesley. p.  496:. Massachusetts: Addison-Wesley. p.  290:. Massachusetts: Addison-Wesley. p.  153: 52:the system uses. Another is hiding how 1208: 459:. California: O'Reilly Media. p.  452: 564: 446: 13: 14: 1227: 327:. Massachusetts: Addison-Wesley. 158:Creational Pattern class diagram. 181:: Implements object's interface. 1081:Enterprise Integration Patterns 520: 483: 413: 380: 347: 314: 277: 1: 270: 98: 35:mechanisms, trying to create 213:Dependency Injection pattern 149: 7: 1174:Portland Pattern Repository 243: 219:Lazy initialization pattern 185: 43: 10: 1232: 423:Head First Design Patterns 390:Head First Design Patterns 357:Head First Design Patterns 25:creational design patterns 1182: 1161: 1090: 1065: 982: 867: 767: 695: 647: 609: 598: 1216:Software design patterns 799:Event-based asynchronous 592:Software design patterns 195:Abstract Factory pattern 107: 68:abstract factory pattern 705:Chain of responsibility 453:Judith, Bishop (2007). 844:Scheduled-task pattern 794:Double-checked locking 456:C# 3.0 Design Patterns 201:Factory method pattern 159: 80:factory method pattern 1195:Architectural pattern 1098:Christopher Alexander 157: 1007:Dependency injection 964:Inversion of control 959:Data transfer object 859:Thread-local storage 21:software engineering 1012:Intercepting filter 260:Concurrency pattern 225:Object pool pattern 1169:The Hillside Group 954:Data access object 804:Guarded suspension 789:Binding properties 265:Structural pattern 255:Behavioral pattern 160: 114:object composition 1203: 1202: 997:Business delegate 929:Publish–subscribe 763: 762: 544:978-0-201-63361-0 507:978-0-201-63361-0 470:978-0-596-52773-0 433:978-0-596-00712-6 400:978-0-596-00712-6 367:978-0-596-00712-6 334:978-0-201-63361-0 301:978-0-201-63361-0 237:Singleton pattern 231:Prototype pattern 92:singleton pattern 86:prototype pattern 1223: 1002:Composite entity 879:Front controller 619:Abstract factory 607: 606: 585: 578: 571: 562: 561: 555: 554: 552: 551: 524: 518: 517: 515: 514: 487: 481: 480: 478: 477: 450: 444: 443: 441: 440: 417: 411: 410: 408: 407: 384: 378: 377: 375: 374: 351: 345: 344: 342: 341: 318: 312: 311: 309: 308: 281: 1231: 1230: 1226: 1225: 1224: 1222: 1221: 1220: 1206: 1205: 1204: 1199: 1178: 1157: 1148:Douglas Schmidt 1128:Ward Cunningham 1086: 1074:Design Patterns 1061: 1052:Method chaining 984: 978: 939:Service locator 870: 863: 834:Read–write lock 770: 759: 750:Template method 691: 643: 601: 594: 589: 559: 558: 549: 547: 545: 530:Design Patterns 525: 521: 512: 510: 508: 493:Design Patterns 488: 484: 475: 473: 471: 451: 447: 438: 436: 434: 418: 414: 405: 403: 401: 385: 381: 372: 370: 368: 352: 348: 339: 337: 335: 324:Design Patterns 319: 315: 306: 304: 302: 287:Design Patterns 282: 278: 273: 246: 207:Builder pattern 188: 179:ConcreteCreator 152: 110: 101: 74:builder pattern 46: 33:object creation 31:that deal with 29:design patterns 17: 12: 11: 5: 1229: 1219: 1218: 1201: 1200: 1198: 1197: 1192: 1186: 1184: 1180: 1179: 1177: 1176: 1171: 1165: 1163: 1159: 1158: 1156: 1155: 1150: 1145: 1140: 1135: 1130: 1125: 1120: 1115: 1113:John Vlissides 1110: 1105: 1100: 1094: 1092: 1088: 1087: 1085: 1084: 1077: 1069: 1067: 1063: 1062: 1060: 1059: 1054: 1049: 1044: 1039: 1034: 1029: 1024: 1019: 1014: 1009: 1004: 999: 994: 988: 986: 980: 979: 977: 976: 971: 966: 961: 956: 951: 946: 941: 936: 931: 926: 921: 913: 908: 903: 902: 901: 896: 886: 881: 875: 873: 865: 864: 862: 861: 856: 851: 846: 841: 836: 831: 826: 821: 816: 811: 806: 801: 796: 791: 786: 781: 775: 773: 765: 764: 761: 760: 758: 757: 752: 747: 742: 737: 732: 727: 722: 717: 712: 707: 701: 699: 693: 692: 690: 689: 684: 679: 674: 669: 664: 659: 653: 651: 645: 644: 642: 641: 636: 631: 629:Factory method 626: 621: 615: 613: 604: 596: 595: 588: 587: 580: 573: 565: 557: 556: 543: 519: 506: 482: 469: 445: 432: 412: 399: 379: 366: 346: 333: 313: 300: 275: 274: 272: 269: 268: 267: 262: 257: 252: 245: 242: 241: 240: 234: 228: 222: 216: 210: 204: 198: 187: 184: 183: 182: 176: 151: 148: 147: 146: 143: 140: 137: 134: 131: 128: 125: 109: 106: 100: 97: 96: 95: 89: 83: 77: 71: 45: 42: 15: 9: 6: 4: 3: 2: 1228: 1217: 1214: 1213: 1211: 1196: 1193: 1191: 1188: 1187: 1185: 1181: 1175: 1172: 1170: 1167: 1166: 1164: 1160: 1154: 1151: 1149: 1146: 1144: 1141: 1139: 1138:Robert Martin 1136: 1134: 1133:Martin Fowler 1131: 1129: 1126: 1124: 1121: 1119: 1116: 1114: 1111: 1109: 1108:Ralph Johnson 1106: 1104: 1101: 1099: 1096: 1095: 1093: 1089: 1083: 1082: 1078: 1076: 1075: 1071: 1070: 1068: 1064: 1058: 1055: 1053: 1050: 1048: 1045: 1043: 1040: 1038: 1035: 1033: 1030: 1028: 1025: 1023: 1020: 1018: 1015: 1013: 1010: 1008: 1005: 1003: 1000: 998: 995: 993: 990: 989: 987: 981: 975: 972: 970: 967: 965: 962: 960: 957: 955: 952: 950: 947: 945: 944:Active record 942: 940: 937: 935: 934:Naked objects 932: 930: 927: 925: 924:Specification 922: 920: 918: 914: 912: 909: 907: 904: 900: 897: 895: 892: 891: 890: 887: 885: 882: 880: 877: 876: 874: 872: 869:Architectural 866: 860: 857: 855: 852: 850: 847: 845: 842: 840: 837: 835: 832: 830: 827: 825: 822: 820: 817: 815: 812: 810: 807: 805: 802: 800: 797: 795: 792: 790: 787: 785: 782: 780: 779:Active object 777: 776: 774: 772: 766: 756: 753: 751: 748: 746: 743: 741: 738: 736: 733: 731: 728: 726: 723: 721: 718: 716: 713: 711: 708: 706: 703: 702: 700: 698: 694: 688: 685: 683: 680: 678: 675: 673: 670: 668: 665: 663: 660: 658: 655: 654: 652: 650: 646: 640: 637: 635: 632: 630: 627: 625: 622: 620: 617: 616: 614: 612: 608: 605: 603: 597: 593: 586: 581: 579: 574: 572: 567: 566: 563: 546: 540: 536: 532: 531: 523: 509: 503: 499: 495: 494: 486: 472: 466: 462: 458: 457: 449: 435: 429: 425: 424: 416: 402: 396: 392: 391: 383: 369: 363: 359: 358: 350: 336: 330: 326: 325: 317: 303: 297: 293: 289: 288: 280: 276: 266: 263: 261: 258: 256: 253: 251: 248: 247: 238: 235: 232: 229: 226: 223: 220: 217: 214: 211: 208: 205: 202: 199: 196: 193: 192: 191: 180: 177: 174: 171: 170: 169: 167: 163: 156: 144: 141: 138: 135: 132: 129: 126: 123: 122: 121: 118: 115: 105: 93: 90: 87: 84: 81: 78: 75: 72: 69: 66: 65: 64: 61: 57: 55: 51: 41: 38: 34: 30: 26: 22: 1190:Anti-pattern 1153:Linda Rising 1079: 1072: 1017:Lazy loading 949:Identity map 916: 610: 600:Gang of Four 548:. Retrieved 529: 522: 511:. Retrieved 492: 485: 474:. Retrieved 455: 448: 437:. Retrieved 422: 415: 404:. Retrieved 389: 382: 371:. Retrieved 356: 349: 338:. Retrieved 323: 316: 305:. Retrieved 286: 279: 189: 178: 172: 166:Participants 165: 164: 161: 119: 111: 102: 62: 58: 47: 24: 18: 1162:Communities 1143:Jim Coplien 1118:Grady Booch 1103:Erich Gamma 1047:Type tunnel 1032:Object pool 1027:Null object 1022:Mock object 884:Interceptor 854:Thread pool 769:Concurrency 715:Interpreter 250:Constructor 1057:Delegation 992:Blackboard 697:Behavioral 649:Structural 611:Creational 550:2015-05-22 513:2015-05-22 476:2015-05-22 439:2015-05-22 406:2015-05-22 373:2015-05-22 340:2015-05-22 307:2015-05-22 271:References 99:Definition 1123:Kent Beck 849:Semaphore 839:Scheduler 682:Flyweight 672:Decorator 667:Composite 639:Singleton 634:Prototype 150:Structure 54:instances 1210:Category 1183:See also 985:patterns 871:patterns 824:Proactor 771:patterns 745:Strategy 735:Observer 725:Mediator 720:Iterator 602:patterns 244:See also 186:Examples 44:Overview 1037:Servant 969:Model 2 829:Reactor 819:Monitor 784:Balking 755:Visitor 730:Memento 710:Command 657:Adapter 624:Builder 173:Creator 50:classes 37:objects 1091:People 974:Broker 677:Facade 662:Bridge 541:  504:  467:  430:  397:  364:  331:  298:  1066:Books 983:Other 919:-tier 740:State 687:Proxy 108:Usage 1042:Twin 899:MVVM 814:Lock 809:Join 539:ISBN 502:ISBN 465:ISBN 428:ISBN 395:ISBN 362:ISBN 329:ISBN 296:ISBN 27:are 911:ECS 906:ADR 894:MVP 889:MVC 461:336 168:: 19:In 1212:: 537:. 535:85 500:. 498:84 463:. 294:. 292:81 23:, 917:n 584:e 577:t 570:v 553:. 516:. 479:. 442:. 409:. 376:. 343:. 310:.

Index

software engineering
design patterns
object creation
objects
classes
instances
abstract factory pattern
builder pattern
factory method pattern
prototype pattern
singleton pattern
object composition

Abstract Factory pattern
Factory method pattern
Builder pattern
Dependency Injection pattern
Lazy initialization pattern
Object pool pattern
Prototype pattern
Singleton pattern
Constructor
Behavioral pattern
Concurrency pattern
Structural pattern
Design Patterns
81
ISBN
978-0-201-63361-0
Design Patterns

Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.

↑