{"id":364917,"date":"2024-05-21T02:27:19","date_gmt":"2024-05-21T02:27:19","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=364917"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2024-05-21T02:27:19","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=364917","title":{"rendered":"<span>\u0421\u0442\u043e \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u0432 \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043a\u043e\u0440\u043f\u043e\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c. \u0427\u0430\u0441\u0442\u044c \u043f\u0435\u0440\u0432\u0430\u044f<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0435\u0440\u0438\u0438 \u0441\u0442\u0430\u0442\u0435\u0439 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043e \u043e\u043a\u043e\u043b\u043e \u0441\u043e\u0442\u043d\u0438 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u0432 \u0438\u0437 \u0442\u0430\u043a\u0438\u0445 \u0441\u0431\u043e\u0440\u043d\u0438\u043a\u043e\u0432, \u043a\u0430\u043a  \u00ab\u041f\u0430\u0442\u0442\u0435\u0440\u043d\u044b \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u043e-\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f\u00bb, \u00ab\u0428\u0430\u0431\u043b\u043e\u043d\u044b \u043a\u043e\u0440\u043f\u043e\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439\u00bb, \u00ab\u041f\u0430\u0442\u0442\u0435\u0440\u043d\u044b \u0438\u0433\u0440\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f\u00bb, \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u043d\u043e\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b \u0438 \u043c\u043d\u043e\u0433\u0438\u0445 \u0434\u0440\u0443\u0433\u0438\u0445. \u041f\u0435\u0440\u0432\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043e\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0432\u0441\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b \u0438\u0437 \u00ab\u0411\u0430\u043d\u0434\u044b \u0447\u0435\u0442\u044b\u0440\u0451\u0445\u00bb, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0442\u0430\u043a\u0438\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b, \u043a\u0430\u043a \u00ab\u0421\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f\u00bb \u0438 \u00ab\u041f\u0440\u043e\u0441\u0442\u0430\u044f \u0444\u0430\u0431\u0440\u0438\u043a\u0430\u00bb.<\/p>\n<h2>\u041f\u0430\u0442\u0442\u0435\u0440\u043d (\u0448\u0430\u0431\u043b\u043e\u043d)<\/h2>\n<p>\u041f\u0430\u0442\u0442\u0435\u0440\u043d\u044b (\u0448\u0430\u0431\u043b\u043e\u043d\u044b) \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u2014 \u044d\u0442\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0447\u0438\u0442\u0430\u044e\u0442\u0441\u044f \u0445\u043e\u0440\u043e\u0448\u0438\u043c \u0442\u043e\u043d\u043e\u043c \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432. \u0418\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c, \u043d\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u0432\u044b\u0441\u0438\u0442\u044c \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u043e\u0434\u0430. \u0418\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u0447\u0442\u043e \u0441\u0430\u043c\u043e\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434 \u043f\u043e\u0447\u0442\u0438 \u0432\u0441\u0435\u0433\u0434\u0430 \u0445\u0443\u0436\u0435, \u0447\u0435\u043c \u0442\u043e\u0442 \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043c\u0435\u0441\u044f\u0446\u0430\u043c\u0438, \u0433\u043e\u0434\u0430\u043c\u0438 \u0438 \u0434\u0435\u0441\u044f\u0442\u0438\u043b\u0435\u0442\u0438\u044f\u043c\u0438.<\/p>\n<h2>\u041f\u043e\u0440\u043e\u0436\u0434\u0430\u044e\u0449\u0438\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b<\/h2>\n<p>\u041f\u043e\u0440\u043e\u0436\u0434\u0430\u044e\u0449\u0438\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b &#8212; \u044d\u0442\u043e \u0442\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0442 \u0437\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0442\u0435\u0445 \u0438\u043b\u0438 \u0438\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432. \u041e\u043d\u0438 \u043f\u043e\u043c\u043e\u0433\u0430\u044e\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u0438 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e \u043e\u0431\u0449\u0430\u043b\u0438\u0441\u044c \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0438\u0445 \u0440\u0430\u0431\u043e\u0442\u043e\u0439.  <\/p>\n<h2>\u041f\u0440\u043e\u0441\u0442\u0430\u044f \u0444\u0430\u0431\u0440\u0438\u043a\u0430 (Simple Factory)<\/h2>\n<p>\u041f\u0430\u0442\u0442\u0435\u0440\u043d \u00ab\u041f\u0440\u043e\u0441\u0442\u0430\u044f \u0444\u0430\u0431\u0440\u0438\u043a\u0430\u00bb &#8212; \u044d\u0442\u043e \u043f\u043e\u0440\u043e\u0436\u0434\u0430\u044e\u0449\u0438\u0439 \u043f\u0430\u0442\u0442\u0435\u0440\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0434\u0440\u0443\u0433\u0438\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0442\u043e\u0433\u043e \u0438\u043b\u0438 \u0438\u043d\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430. \u041e\u0441\u043d\u043e\u0432\u043d\u044b\u043c \u0435\u0451 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0430. \u041d\u043e \u0435\u0441\u0442\u044c \u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u043a: \u043e\u043d\u0430 \u0445\u043e\u0440\u043e\u0448\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u0438\u043f\u043e\u0432 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u044b\u043c \u0438 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u043c.<\/p>\n<figure class=\"bordered full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/783\/829\/961\/78382996116e09d44c645e4eba93a47a.jpeg\" alt=\"\u041b\u0438\u0441\u0442\u044b \u0431\u0443\u043c\u0430\u0433\u0438\" title=\"\u041b\u0438\u0441\u0442\u044b \u0431\u0443\u043c\u0430\u0433\u0438\" width=\"1500\" height=\"1500\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/783\/829\/961\/78382996116e09d44c645e4eba93a47a.jpeg\" data-blurred=\"true\"\/><\/p>\n<div><figcaption>\u041b\u0438\u0441\u0442\u044b \u0431\u0443\u043c\u0430\u0433\u0438<\/figcaption><\/div>\n<\/figure>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u0444\u0430\u0431\u0440\u0438\u043a\u0443 \u043f\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0441\u0442\u0432\u043e \u043b\u0438\u0441\u0442\u043e\u0432 \u0431\u0443\u043c\u0430\u0433\u0438. \u0412\u0441\u0435\u0433\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 8 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u0432, \u0430 \u0438\u0445 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0435 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430 \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0440\u0430\u0432\u0434\u0430\u0442\u044c.<\/p>\n<pre><code class=\"cs\">enum PaperFormat {     A0, A1, A2, A3, A4, A5, A6, A7, A8 }  interface IPaper { }  class PaperA0 : IPaper { }  class PaperA1 : IPaper { }  class PaperA2 : IPaper { }  class PaperA3 : IPaper { }  class PaperA4 : IPaper { }  class PaperA5 : IPaper { }  class PaperA6 : IPaper { }    class PaperA7 : IPaper { }  class PaperA8 : IPaper { }  interface IPaperFactory {     IPaper CreatePaper(PaperFormat paperFormat); }  class PaperFactory : IPaperFactory {     public IPaper CreatePaper(PaperFormat paperFormat)     {         switch (paperFormat)         {             case PaperFormat.A0:                 return new PaperA0();             case PaperFormat.A1:                 return new PaperA1();             case PaperFormat.A2:                 return new PaperA2();             case PaperFormat.A3:                 return new PaperA3();             case PaperFormat.A4:                 return new PaperA4();             case PaperFormat.A5:                 return new PaperA5();             case PaperFormat.A6:                 return new PaperA6();             case PaperFormat.A7:                 return new PaperA7();             case PaperFormat.A8:                 return new PaperA8();             default:                  return new PaperA5();         }     } }  private static void Main(string[] args) {     IPaperFactory paperFactory = new PaperFactory();      IPaper paperA2 = paperFactory.CreatePaper(PaperFormat.A2); }<\/code><\/pre>\n<h2>\u0424\u0430\u0431\u0440\u0438\u0447\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 (Factory Method)<\/h2>\n<p>\u041f\u0430\u0442\u0442\u0435\u0440\u043d \u00ab\u0424\u0430\u0431\u0440\u0438\u0447\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434\u00bb &#8212; \u044d\u0442\u043e \u043f\u043e\u0440\u043e\u0436\u0434\u0430\u044e\u0449\u0438\u0439 \u043f\u0430\u0442\u0442\u0435\u0440\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0434\u0440\u0443\u0433\u0438\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u043d\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0437\u0430 \u0435\u0433\u043e \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u043c\u0438. \u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0435 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043d\u043e\u0432\u044b\u0435 \u0442\u0438\u043f\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0431\u0435\u0437 \u043d\u0430\u0440\u0443\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0430 \u00ab\u0421\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u043e\u0442\u043a\u0440\u044b\u0442\u044b \u0434\u043b\u044f \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f, \u043d\u043e \u0437\u0430\u043a\u0440\u044b\u0442\u044b \u0434\u043b\u044f \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438\u00bb. \u041d\u043e \u0435\u0441\u0442\u044c \u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u043a: \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u043c \u043d\u0430 \u0444\u043e\u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0444\u0430\u0431\u0440\u0438\u043a\u0438.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/818\/39a\/2b0\/81839a2b03cbc1d37f01ef48176ba976.png\" alt=\"\u0411\u043b\u043e\u043a\u0438 \u0432 \u00ab\u041c\u0430\u0439\u043d\u043a\u0440\u0430\u0444\u0442\u00bb\" title=\"\u0411\u043b\u043e\u043a\u0438 \u0432 \u00ab\u041c\u0430\u0439\u043d\u043a\u0440\u0430\u0444\u0442\u00bb\" width=\"1920\" height=\"1080\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/818\/39a\/2b0\/81839a2b03cbc1d37f01ef48176ba976.png\"\/><\/p>\n<div><figcaption>\u0411\u043b\u043e\u043a\u0438 \u0432 \u00ab\u041c\u0430\u0439\u043d\u043a\u0440\u0430\u0444\u0442\u00bb<\/figcaption><\/div>\n<\/figure>\n<p>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0432 \u0438\u0433\u0440\u0435 \u00abMinecraft\u00bb &#8212; \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440. \u0412 \u044d\u0442\u043e\u0439 \u0438\u0433\u0440\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0435 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0431\u043b\u043e\u043a\u043e\u0432. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0444\u0430\u0431\u0440\u0438\u043a\u0438 \u043c\u043e\u0436\u0435\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 \u0438\u0433\u0440\u044b \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0442\u044f\u0436\u0451\u043b\u043e\u0439, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0431\u043b\u043e\u043a\u043e\u0432 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043c\u043d\u043e\u0433\u043e, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u0431\u043b\u043e\u043a\u0438. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0443\u0434\u043e\u0431\u043d\u0435\u0439 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0444\u0430\u0431\u0440\u0438\u0447\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434.<\/p>\n<pre><code class=\"cs\">abstract class Block { }  abstract class Creator {     public Creator() { }      abstract public Block Create(); }  class Ground : Block { }  class GroundCreator : Creator  {      public GroundCreator() { }      public override Block Create()     {         return new Ground();     } }  class Wood : Block { }  class WoodCreator : Creator {     public WoodCreator() { }      public override Block Create()     {         return new Wood();     } }  class Stone : Block { }  class StoneCreator : Creator {     public StoneCreator() { }      public override Block Create()     {         return new Stone();     } }  class Bricks : Block { }  class BricksCreator : Creator {     public BricksCreator() { }      public override Block Create()     {         return new Bricks();     } }  private static void Main(string[] args) {     WoodCreator woodCreator = new WoodCreator();      Block wood = woodCreator.Create();      StoneCreator stoneCreator = new StoneCreator();      Block stone = stoneCreator.Create(); }<\/code><\/pre>\n<h2>\u0410\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u0430\u044f \u0444\u0430\u0431\u0440\u0438\u043a\u0430 (Abstract Factory)<\/h2>\n<p>\u041f\u0430\u0442\u0442\u0435\u0440\u043d \u00ab\u0410\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u0430\u044f \u0444\u0430\u0431\u0440\u0438\u043a\u0430\u00bb &#8212; \u044d\u0442\u043e \u043f\u043e\u0440\u043e\u0436\u0434\u0430\u044e\u0449\u0438\u0439 \u043f\u0430\u0442\u0442\u0435\u0440\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u0435\u043c\u0435\u0439\u0441\u0442\u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432. \u041e\u0441\u043d\u043e\u0432\u043d\u044b\u043c \u0435\u0451 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e \u0444\u0430\u043a\u0442, \u0447\u0442\u043e \u0435\u0451 \u0443\u0434\u043e\u0431\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0439 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u0433\u0434\u0435 \u0432 \u043a\u0430\u0436\u0434\u043e\u0439 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0435 \u0442\u0438\u043f\u044b. \u0422\u0430\u043a\u0436\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043b\u0435\u0433\u043a\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u043e\u0432\u0443\u044e \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u044e. \u041d\u043e \u0435\u0441\u0442\u044c \u0438 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u043a: \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u0442 \u043a \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u043c \u0432 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0438 \u043a\u043b\u0430\u0441\u0441\u043e\u0432.<\/p>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u0444\u0430\u0431\u0440\u0438\u043a\u0443 \u043c\u043e\u0440\u043e\u0436\u0435\u043d\u043e\u0433\u043e. \u041c\u043e\u0440\u043e\u0436\u0435\u043d\u043e\u0435 \u0431\u044b\u0432\u0430\u0435\u0442 \u0441\u043b\u0438\u0432\u043e\u0447\u043d\u044b\u043c, \u0432\u0430\u043d\u0438\u043b\u044c\u043d\u044b\u043c, \u0448\u043e\u043a\u043e\u043b\u0430\u0434\u043d\u044b\u043c, \u0444\u0440\u0443\u043a\u0442\u043e\u0432\u044b\u043c \u0438 \u043e\u0440\u0435\u0445\u043e\u0432\u044b\u043c. \u0422\u043e \u0435\u0441\u0442\u044c \u043a\u0430\u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u043f\u044f\u0442\u044c \u0442\u0438\u043f\u043e\u0432. \u041d\u043e \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0440\u043e\u0436\u0435\u043d\u043e\u0435 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0441\u0442\u0440\u0430\u043d\u0430\u043c\u0438: \u0440\u043e\u0441\u0441\u0438\u0439\u0441\u043a\u043e\u0435, \u043a\u0438\u0442\u0430\u0439\u0441\u043a\u043e\u0435, \u0442\u0430\u0439\u0441\u043a\u043e\u0435. \u0418\u0442\u043e\u0433\u043e \u0438\u043c\u0435\u0435\u043c \u0442\u0440\u0438 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438, \u0430 \u0432 \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0437 \u043d\u0438\u0445 \u043f\u043e \u043f\u044f\u0442\u044c \u0442\u0438\u043f\u043e\u0432. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0443\u0434\u043e\u0431\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u0443\u044e \u0444\u0430\u0431\u0440\u0438\u043a\u0443.<\/p>\n<pre><code class=\"cs\">abstract class IceCreamFactory {     public abstract Creamy GetCreamy();     public abstract Vanilla GetVanilla();     public abstract Chocolate GetChocolate();     public abstract Fruit GetFruit();     public abstract Walnut GetWalnut(); }  class RussianFactory : IceCreamFactory {     public override Chocolate GetChocolate()     {         return new RussianChocolate();     }      public override Creamy GetCreamy()     {         return new RussianCreamy();     }      public override Fruit GetFruit()     {         return new RussianFruit();     }      public override Vanilla GetVanilla()     {         return new RussianVanilla();     }      public override Walnut GetWalnut()     {         return new RussianWalnut();     } }  class ChineseFactory : IceCreamFactory {     public override Chocolate GetChocolate()     {         return new ChineseChocolate();     }      public override Creamy GetCreamy()     {         return new ChineseCreamy();     }      public override Fruit GetFruit()     {         return new ChineseFruit();     }      public override Vanilla GetVanilla()     {         return new ChineseVanilla();     }      public override Walnut GetWalnut()     {         return new ChineseWalnut();     } }  class ThaiFactory : IceCreamFactory {     public override Chocolate GetChocolate()     {         return new ThaiChocolate();     }      public override Creamy GetCreamy()     {         return new ThaiCreamy();     }      public override Fruit GetFruit()     {         return new ThaiFruit();     }      public override Vanilla GetVanilla()     {         return new ThaiVanilla();     }      public override Walnut GetWalnut()     {         return new ThaiWalnut();     } }  #region Abstract Items abstract class Creamy { }  abstract class Vanilla { }  abstract class Chocolate { }  abstract class Fruit { }  abstract class Walnut { } #endregion  #region Russian Items class RussianCreamy : Creamy { }  class RussianVanilla : Vanilla { }  class RussianChocolate : Chocolate { }  class RussianFruit : Fruit { }  class RussianWalnut : Walnut { } #endregion  #region Chinese Items class ChineseCreamy : Creamy { }  class ChineseVanilla : Vanilla { }  class ChineseChocolate : Chocolate { }  class ChineseFruit : Fruit { }  class ChineseWalnut : Walnut { } #endregion  #region Thai Items class ThaiCreamy : Creamy { }  class ThaiVanilla : Vanilla { }  class ThaiChocolate : Chocolate { }  class ThaiFruit : Fruit { }  class ThaiWalnut : Walnut { } #endregion  class IceCreamManager {     public IceCreamFactory GetRussianFactory()     {         return new RussianFactory();     }      public IceCreamFactory GetChineseFactory()     {         return new ChineseFactory();     }      public IceCreamFactory GetThaiFactory()     {         return new ThaiFactory();     } }  private static void Main(string[] args) {     IceCreamManager manager = new IceCreamManager();      IceCreamFactory russianFactory = manager.GetRussianFactory(); }<\/code><\/pre>\n<h2>\u0421\u0442\u0440\u043e\u0438\u0442\u0435\u043b\u044c (Builder)<\/h2>\n<p>\u041f\u0430\u0442\u0442\u0435\u0440\u043d \u00ab\u0421\u0442\u0440\u043e\u0438\u0442\u0435\u043b\u044c\u00bb &#8212; \u044d\u0442\u043e \u043f\u043e\u0440\u043e\u0436\u0434\u0430\u044e\u0449\u0438\u0439 \u043f\u0430\u0442\u0442\u0435\u0440\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432. \u041e\u043d \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043d\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u044d\u0442\u0430\u043f\u044b. \u0421\u0442\u0440\u043e\u0438\u0442\u0435\u043b\u044c \u0445\u043e\u0440\u043e\u0448\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u0442\u0435\u0445 \u0441\u043b\u0443\u0447\u0430\u0435\u0432, \u043a\u043e\u0433\u0434\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0432\u0430\u0440\u0438\u0430\u0446\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0435\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f.<\/p>\n<p>\u041f\u0430\u0442\u0442\u0435\u0440\u043d \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u043d\u0451\u043d \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043e\u043d\u043e \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0442\u0430\u043a\u0438\u0445 \u0447\u0430\u0441\u0442\u0435\u0439, \u043a\u0430\u043a \u0442\u0435\u043a\u0441\u0442, \u0444\u043e\u0440\u043c\u0430, \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c.<\/p>\n<pre><code class=\"cs\">private enum MessageForm {     Square,     Circle }  private abstract class AbstractBuilder {     public abstract void SetText(string text);     public abstract void SetImage(string image);     public abstract void SetLength(int length);     public abstract void SetForm(MessageForm form);      public abstract Message Build(); }  private class Message {     public string Text { get; set; }     public string Image { get; set; }     public int Length { get; set; }     public MessageForm Form { get; set; } }  private class MessageBuilder : AbstractBuilder {     private readonly Message message = new Message();      public override void SetForm(MessageForm form)     {         this.message.Form = form;     }      public override void SetImage(string image)     {         this.message.Image = image;     }      public override void SetLength(int length)     {         this.message.Length = length;     }      public override void SetText(string text)     {         this.message.Text = text;     }      public override Message Build()     {         return this.message;     } }  private static void Main(string[] args) {     AbstractBuilder builder = new MessageBuilder();      builder.SetText(\"\u041d\u043e\u0432\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435\");      builder.SetLength(2);      Message message = builder.Build(); }<\/code><\/pre>\n<h2>\u041f\u0440\u043e\u0442\u043e\u0442\u0438\u043f (Prototype)<\/h2>\n<p>\u041f\u0430\u0442\u0442\u0435\u0440\u043d \u00ab\u041f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u00bb &#8212; \u044d\u0442\u043e \u043f\u043e\u0440\u043e\u0436\u0434\u0430\u044e\u0449\u0438\u0439 \u043f\u0430\u0442\u0442\u0435\u0440\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u043a\u043b\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432. \u0421 \u0435\u0433\u043e \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043d\u043e\u0432\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0441\u0442\u0430\u0440\u044b\u0445. \u041e\u043d \u0445\u043e\u0440\u043e\u0448\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442, \u043a\u043e\u0433\u0434\u0430 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0442\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u043c, \u0447\u0435\u043c \u0438\u0445 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435.<\/p>\n<pre><code class=\"cs\">interface IBlock {     int Side { get; set; }     IBlock Clone(); }  class Water : IBlock {     public Water(Color color, int side)     {         this.Color = color;         this.Side = side;     }      public Color Color { get; set; }      public int Side { get; set; }      public IBlock Clone()     {         return new Water(this.Color, this.Side);     }      public override string ToString()     {         return $\"\u0426\u0432\u0435\u0442 - {this.Color}; \u0421\u0442\u043e\u0440\u043e\u043d\u0430 - {this.Side}\";     } }  class Air : IBlock {     public Air(int side)     {         this.Side = side;     }      public int Side { get; set; }      public IBlock Clone()     {         return new Air(this.Side);     }      public override string ToString()     {         return $\"\u0421\u0442\u043e\u0440\u043e\u043d\u0430 - {this.Side}\";     } }  private static void Main(string[] args) {     IBlock water = new Water(new Color(), 10);      IBlock waterCloned = water.Clone(); }<\/code><\/pre>\n<h2>\u041e\u0434\u0438\u043d\u043e\u0447\u043a\u0430 (Singleton)<\/h2>\n<p>\u041f\u0430\u0442\u0442\u0435\u0440\u043d \u00ab\u041e\u0434\u0438\u043d\u043e\u0447\u043a\u0430\u00bb &#8212; \u044d\u0442\u043e \u043f\u0430\u0442\u0442\u0435\u0440\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445. \u041e\u043d \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442, \u0447\u0442\u043e \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u043e\u0431\u044a\u0435\u043a\u0442, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043a \u044d\u0442\u043e\u043c\u0443 \u043e\u0431\u044a\u0435\u043a\u0442\u0443 \u0435\u0434\u0438\u043d\u0443\u044e \u0442\u043e\u0447\u043a\u0443 \u0434\u043e\u0441\u0442\u0443\u043f\u0430. \u041e\u0431\u044b\u0447\u043d\u043e \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445, \u0433\u0434\u0435 \u043a \u043e\u0434\u043d\u043e\u043c\u0443 \u0438 \u0442\u043e\u043c\u0443 \u0436\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0443 \u043c\u043e\u0436\u0435\u0442 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u0441\u0440\u0430\u0437\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u0435\u0433\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0430\u044f \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0430.<\/p>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043c\u0438\u0440 \u0432 \u041c\u0430\u0439\u043d\u043a\u0440\u0430\u0444\u0442\u0435. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c, \u0447\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0438 \u0447\u0442\u043e \u0435\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0451\u043c\u043a\u0438\u043c.<\/p>\n<pre><code class=\"cs\">class World {     private static World instance;      private static object instance_lock = new object();     public string Name { get; private set; }     public int Version { get; private set; }      protected World(string name, int version)     {         this.Name = name;         this.Version = version;     }      public static World GetInstance(string name, int version)     {         lock (instance_lock)         {             if (instance == null)             {                 instance = new World(name, version);             }         }          return instance;     } }   private static void Main() {     World world = World.GetInstance(\"\u041c\u043e\u0439 \u043c\u0438\u0440\", 1);      Console.WriteLine(world.Name);      Console.Read(); }<\/code><\/pre>\n<h2>\u041f\u0430\u0442\u0442\u0435\u0440\u043d\u044b \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f<\/h2>\n<p>\u041f\u043e\u0440\u043e\u0436\u0434\u0430\u044e\u0449\u0438\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b &#8212; \u044d\u0442\u043e \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442, \u043a\u0430\u043a \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0441\u0435\u0431\u044f \u0432\u0435\u0434\u0443\u0442 \u0438 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0442 \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438. \u0418\u0445 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a \u0434\u043b\u044f \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043e\u0431\u044f\u0437\u0430\u043d\u043d\u043e\u0441\u0442\u0435\u0439, \u0442\u0430\u043a \u0438 \u0434\u043b\u044f \u0440\u0435\u0430\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0431\u0435\u0437 \u043e\u0448\u0438\u0431\u043e\u043a. <\/p>\n<h2>\u0421\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f (Strategy)<\/h2>\n<p>\u041f\u0430\u0442\u0442\u0435\u0440\u043d \u00ab\u0421\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f\u00bb &#8212; \u044d\u0442\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u0430\u0442\u0442\u0435\u0440\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u0441\u043c\u0435\u043d\u0443 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430. \u0421\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0439 \u043a \u043d\u0435\u0439. \u041f\u0430\u0442\u0442\u0435\u0440\u043d \u0445\u043e\u0440\u043e\u0448\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u0442\u0435\u0445 \u0441\u043b\u0443\u0447\u0430\u0435\u0432, \u043a\u043e\u0433\u0434\u0430 \u0438\u0434\u0435\u044f \u043e\u0434\u043d\u0430, \u0430 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0439 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e.<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0434\u043b\u044f \u0442\u0430\u043a\u0438\u0445 \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u0432, \u043a\u0430\u043a txt, xml \u0438 json. \u0412\u043e \u0432\u0441\u0435\u0445 \u0442\u0440\u0451\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0441\u0443\u0442\u044c \u043e\u0434\u043d\u0430, \u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u043d\u0438\u0445 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0442\u0441\u044f. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0443\u0434\u043e\u0431\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u044e \u043a \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e, \u0430 \u043a \u043d\u0435\u0439 \u0442\u0440\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u0432.<\/p>\n<pre><code class=\"cs\">interface ILogger {     void Log(); }  class TxtLogger : ILogger {     \/\/ Implementation of logging in txt format     public void Log() { }  }  class XmlLogger : ILogger {     \/\/ Implementation of logging in xml format     public void Log() { }  }  class JsonLogger : ILogger {     \/\/ Implementation of logging in json format     public void Log() { }  }  class Context {     public ILogger Logger { get; set; }      public Context(ILogger logger)     {         this.Logger = logger;     }      public void ExecuteLogging()     {         this.Logger.Log();     } }  private static void Main(string[] args) {     ILogger logger = new XmlLogger();      Context context = new Context(logger);      context.ExecuteLogging(); }<\/code><\/pre>\n<h2>\u041d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u0435\u043b\u044c (Observer)<\/h2>\n<p>\u041f\u0430\u0442\u0442\u0435\u0440\u043d \u00ab\u041d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u0435\u043b\u044c\u00bb &#8212; \u044d\u0442\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u0430\u0442\u0442\u0435\u0440\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u00ab\u041f\u043e\u0434\u043f\u0438\u0441\u043a\u0438-\u043e\u0442\u043f\u0438\u0441\u043a\u0438\u00bb. \u041e\u043d \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0443\u0435\u0442 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043f\u043e \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0443 \u00ab\u041e\u0434\u0438\u043d \u043a\u043e \u043c\u043d\u043e\u0433\u0438\u043c\u00bb. \u041a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043e\u0446\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u0441\u0435\u0442\u044c \u00abYouTube\u00bb, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u044f \u043a\u0430\u043a \u0431\u043b\u043e\u0433\u0435\u0440\u043e\u0432, \u0442\u0430\u043a \u0438 \u043f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a\u043e\u0432.<\/p>\n<p>\u041f\u0430\u0442\u0442\u0435\u0440\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f, \u043a\u043e\u0433\u0434\u0430:<\/p>\n<ul>\n<li>\n<p>\u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u0433\u0434\u0435 \u0432\u0441\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0432 \u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f\u0445<\/p>\n<\/li>\n<li>\n<p>\u0438\u043c\u0435\u0435\u0442\u0441\u044f \u043e\u0431\u044a\u0435\u043a\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442 \u0440\u0430\u0441\u0441\u044b\u043b\u043a\u0443, \u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0442 \u044d\u0442\u0443 \u0440\u0430\u0441\u0441\u044b\u043b\u043a\u0443.<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"cs\">private interface IObservable {     void AddObserver(IObserver observer);     void RemoveObserver(IObserver observer);     void NotifyObservers(); }  private interface IObserver {     void Update(); }  private class Subscriber : IObserver {     public void Update()     {         \/\/ Update profile of subscriber     } }  private class Blogger : IObservable {     private readonly List&lt;IObserver> observers;      public Blogger()     {         this.observers = new List&lt;IObserver>();     }      public void AddObserver(IObserver observer)     {         this.observers.Add(observer);     }      public void NotifyObservers()     {         foreach (IObserver observer in this.observers)         {             observer.Update();         }     }      public void RemoveObserver(IObserver observer)     {         _ = this.observers.Remove(observer);     } }  private static void Main(string[] args) {     IObserver subscriberA = new Subscriber();      IObserver subscriberB = new Subscriber();      IObservable blogger = new Blogger();      blogger.AddObserver(subscriberA);      blogger.AddObserver(subscriberB);      blogger.NotifyObservers(); }<\/code><\/pre>\n<h2>\u041a\u043e\u043c\u0430\u043d\u0434\u0430 (Command)<\/h2>\n<p>\u041f\u0430\u0442\u0442\u0435\u0440\u043d \u00ab\u041a\u043e\u043c\u0430\u043d\u0434\u0430\u00bb &#8212; \u044d\u0442\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u0430\u0442\u0442\u0435\u0440\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u0438\u0440\u0443\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0432 \u0432\u0438\u0434\u0435 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430.<\/p>\n<p>\u041f\u0430\u0442\u0442\u0435\u0440\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445:<\/p>\n<ul>\n<li>\n<p>\u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0445 \u043e\u0442\u043c\u0435\u043d\u044b,<\/p>\n<\/li>\n<li>\n<p>\u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0432 \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 \u0434\u0440\u0443\u0433\u0438\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f<\/p>\n<\/li>\n<li>\n<p>\u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043b\u043e\u0433\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u0430 \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u0434\u043b\u044f \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u044b<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"cs\">private abstract class Command {     public abstract void Run();     public abstract void Back(); }  private class MatrixCommand : Command {     private readonly char operation;     private readonly int[][] matrix;     private readonly MatrixCalculator calculator;      public MatrixCommand(char operation, int[][] matrix, MatrixCalculator calculator)     {         this.operation = operation;         this.matrix = matrix;         this.calculator = calculator;     }      public override void Back()     {         char action = Undo(this.operation);          this.calculator.Operation(action, this.matrix);     }      public override void Run()     {         this.calculator.Operation(this.operation, this.matrix);     }      private char Undo(char operation)     {         switch (operation)         {             case '+':                 return '-';             case '-':                 return '+';             default:                 throw new ArgumentException();         }     } }  private class MatrixCalculator {     private readonly int[][] matrixA;      public MatrixCalculator(int rows, int cols)     {         this.matrixA = new int[rows][];          for (int row = 0; row &lt; rows; row++)         {             this.matrixA[row] = new int[cols];         }     }      private void Operation(int[][] matrixB, Func&lt;int, int, int> func)     {         for (int row = 0; row &lt; matrixB.Length; row++)         {             for (int col = 0; col &lt; matrixB[0].Length; col++)             {                 this.matrixA[row][col] = func(this.matrixA[row][col], matrixB[row][col]);             }         }     }      public void Operation(char operation, int[][] matrixB)     {         switch (operation)         {             case '+':                 Operation(matrixB, (x, y) => x + y);                 break;             case '-':                 Operation(matrixB, (x, y) => x - y);                 break;         }     } }  public class Client {     private readonly MatrixCalculator calculator;     private readonly List&lt;Command> commands;      private int current;      public Client(int rows, int cols)     {         this.calculator = new MatrixCalculator(rows, cols);         this.commands = new List&lt;Command>();         this.current = 0;     }      public void Compute(char operation, int[][] matrix)     {         Command command = new MatrixCommand(operation, matrix, this.calculator);          command.Run();          this.commands.Add(command);          this.current++;     }      public void Back()     {         Command command = this.commands[--this.current];          command.Back();     } }  static void Main() {     Client client = new Client(2, 2);      int[][] matrix = new int[2][]     {         new int[2] { 1, 0 },         new int[2] {0, 4}     };      client.Compute('+', matrix);      client.Back(); }<\/code><\/pre>\n<h2>\u0428\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 (Template Method)<\/h2>\n<p>\u041f\u0430\u0442\u0442\u0435\u0440\u043d \u00ab\u0428\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434\u00bb &#8212; \u044d\u0442\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u0430\u0442\u0442\u0435\u0440\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u043e\u0431\u0449\u0438\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c, \u043d\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0448\u0430\u0433\u0438.<\/p>\n<p>\u041f\u0430\u0442\u0442\u0435\u0440\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u0441\u043b\u0443\u0447\u0430\u044f\u0445, \u043a\u043e\u0433\u0434\u0430<\/p>\n<ul>\n<li>\n<p>\u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0448\u0430\u0433\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b,<\/p>\n<\/li>\n<li>\n<p>\u043f\u0440\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u0434\u0430<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"cs\">abstract class Profile {     public void Init()     {         GetData();         SaveData();         ShowData();     }      public virtual void GetData()      {         Console.WriteLine(\"\u041e\u0431\u0440\u0430\u0449\u0430\u0435\u043c\u0441\u044f \u043a API\");     }      public virtual void SaveData()      {         Console.WriteLine(\"\u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0432 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u0443\u044e \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445\");     }      public virtual void ShowData()      {         Console.WriteLine(\"\u041f\u043e\u0434\u0433\u043e\u0442\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\");     } }  \/\/ \u041f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u043b\u044f \u0433\u043e\u0441\u0442\u044f class Guest : Profile { }  \/\/ \u041f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u043b\u044f \u0430\u0434\u043c\u0438\u043d\u0430 class Admin : Profile { }  static void Main() {      }<\/code><\/pre>\n<h2>\u0418\u0442\u0435\u0440\u0430\u0442\u043e\u0440 (Iterator)<\/h2>\n<p>\u041f\u0430\u0442\u0442\u0435\u0440\u043d \u00ab\u0418\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u00bb &#8212; \u044d\u0442\u043e \u043f\u0430\u0442\u0442\u0435\u0440\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0431\u0435\u0437 \u0440\u0430\u0441\u043a\u0440\u044b\u0442\u0438\u044f \u0435\u0433\u043e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b.<\/p>\n<pre><code class=\"cs\">private interface IProductIterator {     bool HasNext();     Product Next(); }  private interface IProductNumerable {     IProductIterator GetProductNumerator();     int Count { get; }     Product this[int index] { get; } }  private class Product {     public int Id { get; set; }     public string Name { get; set; } }  private class Shop : IProductNumerable {     private readonly Product[] products;     public Shop()     {         this.products = new Product[]         {             new Product { Id = 1, Name = \"\u041a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\"},             new Product { Id = 2, Name = \"\u041f\u0440\u043e\u0432\u043e\u0434\"}         };     }      public Product this[int index] => this.products[index];      public int Count => this.products.Length;      public IProductIterator GetProductNumerator()     {         return new ShopNumerator(this);     } }  private class ShopNumerator : IProductIterator {     private readonly IProductNumerable productNumerable;     private int index = 0;      public ShopNumerator(IProductNumerable productNumerable)     {         this.productNumerable = productNumerable;     }      public bool HasNext()     {         return this.index &lt; this.productNumerable.Count;     }      public Product Next()     {         return this.productNumerable[this.index++];     } }  private static void Main() {     Shop shop = new Shop();      IProductIterator iterator = shop.GetProductNumerator();      while (iterator.HasNext())     {         Console.WriteLine(iterator.Next().Name);     }      Console.Read(); }<\/code><\/pre>\n<h2>\u0421\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 (State)<\/h2>\n<p>\u041f\u0430\u0442\u0442\u0435\u0440\u043d \u00ab\u0421\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435\u00bb &#8212; \u044d\u0442\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u0430\u0442\u0442\u0435\u0440\u043d, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u0431\u044a\u0435\u043a\u0442 \u043c\u0435\u043d\u044f\u0435\u0442 \u0441\u0432\u043e\u0451 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f.<\/p>\n<p>\u041f\u0430\u0442\u0442\u0435\u0440\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f, \u043a\u043e\u0433\u0434\u0430:<\/p>\n<ul>\n<li>\n<p>\u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435\u043c<\/p>\n<\/li>\n<li>\n<p>\u0438\u043c\u0435\u0435\u0442\u0441\u044f \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0443\u0441\u043b\u043e\u0432\u043d\u044b\u0445 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u0441\u043b\u043e\u0436\u043d\u044f\u044e\u0442 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 \u043a\u043e\u0434\u0430<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"cs\">enum PageState {     Done,     Null,     Error,     Load }  abstract class State {     public abstract void Handle(Page page); }  class Done : State {     public override void Handle(Page page)     {         \/\/ \u0414\u0430\u043d\u043d\u044b\u0435 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u044b. \u041f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u0443\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443         Console.WriteLine(\"\u0421\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u0430\");     } }  class Null : State {     public override void Handle(Page page)     {         \/\/ \u0418\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439 \u043d\u0435\u0442, \u043d\u043e \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0435\u0442. \u041f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435         Console.WriteLine(\"\u041d\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0445\");     } }  class Error : State {     public override void Handle(Page page)     {         \/\/ \u0412 \u0445\u043e\u0434\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u0438 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f. \u041f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435         Console.WriteLine(\"\u041e\u0448\u0438\u0431\u043a\u0430\");     } }  class Load : State {     public override void Handle(Page page)     {         \/\/ \u0417\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435. \u041f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044e \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438         Console.WriteLine(\"\u0417\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b\");         page.State = new Done();     } }  class Page {     public State State { get; set; }     public Page(State state)     {         this.State = state;     }      public void Request()     {         this.State.Handle(this);     } }  private static void Main() {     Page page = new Page(new Load());      page.Request();      page.Request();      Console.Read(); }<\/code><\/pre>\n<h2>\u0426\u0435\u043f\u043e\u0447\u043a\u0430 \u043e\u0431\u044f\u0437\u0430\u043d\u043d\u043e\u0441\u0442\u0435\u0439 (Chain of responsibility)<\/h2>\n<p>\u041f\u0430\u0442\u0442\u0435\u0440\u043d \u00ab\u0426\u0435\u043f\u043e\u0447\u043a\u0430 \u043e\u0431\u044f\u0437\u0430\u043d\u043d\u043e\u0441\u0442\u0435\u0439\u00bb &#8212; \u044d\u0442\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u0430\u0442\u0442\u0435\u0440\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u0436\u0451\u0441\u0442\u043a\u043e\u0439 \u043f\u0440\u0438\u0432\u044f\u0437\u043a\u0438 \u043c\u0435\u0436\u0434\u0443 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u0435\u043b\u0435\u043c \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u0435\u043b\u0435\u043c. \u0421\u0443\u0442\u044c \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u0443\u0437\u0435\u043b \u043b\u0438\u0431\u043e \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441, \u043b\u0438\u0431\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442 \u0435\u0433\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u0443\u0437\u043b\u0443.<\/p>\n<p>\u041f\u0430\u0442\u0442\u0435\u0440\u043d \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f, \u043a\u043e\u0433\u0434\u0430:<\/p>\n<ul>\n<li>\n<p>\u0438\u043c\u0435\u0435\u0442\u0441\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0433\u0443\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441,<\/p>\n<\/li>\n<li>\n<p>\u043d\u0430\u0431\u043e\u0440 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0437\u0430\u0434\u0430\u0451\u0442\u0441\u044f \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438<\/p>\n<\/li>\n<li>\n<p>\u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043e\u0434\u043d\u043e\u043c\u0443 \u0438\u0437 \u0438\u043c\u0435\u044e\u0449\u0438\u0445\u0441\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"cs\">class Receiver {     public bool OpenWithWord { get; set; }      public bool OpenWithNotepad { get; set; }     public bool OpenWithPdfReader { get; set; }      public bool OpenWithGoogleChrome { get; set; }      public Receiver(bool openWithWord, bool openWithNotepad, bool openWithPdfReader, bool openWithGoogleChrome)     {         this.OpenWithWord = openWithWord;         this.OpenWithNotepad = openWithNotepad;         this.OpenWithPdfReader = openWithPdfReader;         this.OpenWithGoogleChrome = openWithGoogleChrome;     } } abstract class FileReader {     public FileReader Successor { get; set; }     public abstract void Handle(Receiver receiver); }  class WordReader : FileReader {     public override void Handle(Receiver receiver)     {         if (receiver.OpenWithWord == true)             Console.WriteLine(\"\u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0444\u0430\u0439\u043b \u0432 Word\");         else if (Successor != null)             Successor.Handle(receiver);     } }  class NotepadReader : FileReader {     public override void Handle(Receiver receiver)     {         if (receiver.OpenWithNotepad == true)             Console.WriteLine(\"\u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0444\u0430\u0439\u043b \u0432 Notepad\");         else if (Successor != null)             Successor.Handle(receiver);     } }  class PdfReader : FileReader {     public override void Handle(Receiver receiver)     {         if (receiver.OpenWithPdfReader == true)             Console.WriteLine(\"\u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0444\u0430\u0439\u043b \u0432 PDF Reader\");         else if (Successor != null)             Successor.Handle(receiver);     } }  class GoogleChrome : FileReader {     public override void Handle(Receiver receiver)     {         if (receiver.OpenWithGoogleChrome == true)             Console.WriteLine(\"\u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0444\u0430\u0439\u043b \u0432 Google Chrome\");         else if (Successor != null)             Successor.Handle(receiver);     } }  private static void Main() {     Receiver receiver = new Receiver(false, false, true, false);      WordReader wordReader = new WordReader();      NotepadReader notepadReader = new NotepadReader();      PdfReader pdfReader = new PdfReader();      GoogleChrome googleChrome = new GoogleChrome();      wordReader.Successor = notepadReader;      notepadReader.Successor = pdfReader;      pdfReader.Successor = notepadReader;      wordReader.Handle(receiver);      Console.Read(); }<\/code><\/pre>\n<h2>\u0418\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440 (Interpreter)<\/h2>\n<p>\u041f\u0430\u0442\u0442\u0435\u0440\u043d \u00ab\u0418\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440\u00bb &#8212; \u044d\u0442\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u0430\u0442\u0442\u0435\u0440\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439. \u041e\u0431\u044b\u0447\u043d\u043e \u043e\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0442\u0435\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0447\u0430\u0441\u0442\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0442\u0441\u044f.<\/p>\n<p>\u041f\u0430\u0442\u0442\u0435\u0440\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f, \u043a\u043e\u0433\u0434\u0430:<\/p>\n<ul>\n<li>\n<p>\u0438\u043c\u0435\u0435\u0442\u0441\u044f \u043c\u043d\u043e\u0433\u043e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0447\u0430\u0441\u0442\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0442\u0441\u044f<\/p>\n<\/li>\n<li>\n<p>\u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u044f\u0437\u044b\u043a\u0430<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"cs\">private class Context {     private readonly Dictionary&lt;string, int> variables;     public Context()     {         this.variables = new Dictionary&lt;string, int>();     }     public int GetVariable(string name)     {         return this.variables[name];     }      public void SetVariable(string name, int value)     {         if (this.variables.ContainsKey(name))         {             this.variables[name] = value;         }         else         {             this.variables.Add(name, value);         }     } }  private interface IExpression {     int Interpret(Context context); }  private class VariableExpression : IExpression {     private readonly string name;     public VariableExpression(string variableName)     {         this.name = variableName;     }     public int Interpret(Context context)     {         return context.GetVariable(this.name);     } }  private class FactorialExpression : IExpression {     private readonly string name;     public FactorialExpression(string variableName)     {         this.name = variableName;     }      public int Interpret(Context context)     {         int sum = new int();          int value = context.GetVariable(this.name);          sum++;          for (int i = 2; i &lt;= value; i++)         {             sum *= i;         }          return sum;     } }  private class LogExpression : IExpression {     private readonly IExpression bottomExpression;     private readonly IExpression topExpression;      public LogExpression(IExpression bottomExpression, IExpression topExpression)     {         this.bottomExpression = bottomExpression;         this.topExpression = topExpression;     }      public int Interpret(Context context)     {         return (int)Math.Log(this.topExpression.Interpret(context), this.bottomExpression.Interpret(context));     } }  private class AddExpression : IExpression {     private readonly IExpression leftExpression;     private readonly IExpression rightExpression;      public AddExpression(IExpression left, IExpression right)     {         this.leftExpression = left;         this.rightExpression = right;     }      public int Interpret(Context context)     {         return this.leftExpression.Interpret(context) + this.rightExpression.Interpret(context);     } }  private class SubtractExpression : IExpression {     private readonly IExpression leftExpression;     private readonly IExpression rightExpression;      public SubtractExpression(IExpression left, IExpression right)     {         this.leftExpression = left;         this.rightExpression = right;     }      public int Interpret(Context context)     {         return this.leftExpression.Interpret(context) - this.rightExpression.Interpret(context);     } }  private class MultiplyExpression : IExpression {     private readonly IExpression leftExpression;     private readonly IExpression rightExpression;      public MultiplyExpression(IExpression leftExpression, IExpression rightExpression)     {         this.leftExpression = leftExpression;         this.rightExpression = rightExpression;     }      public int Interpret(Context context)     {         return this.leftExpression.Interpret(context) * this.rightExpression.Interpret(context);     } }  private class DivideExpression : IExpression {     private readonly IExpression leftExpression;     private readonly IExpression rightExpression;      public DivideExpression(IExpression leftExpression, IExpression rightExpression)     {         this.leftExpression = leftExpression;         this.rightExpression = rightExpression;     }      public int Interpret(Context context)     {         return this.leftExpression.Interpret(context) \/ this.rightExpression.Interpret(context);     } }  private static void Main() {     Context context = new Context();      int x = 10;     int y = 5;     int z = 3;     int w = 15;      context.SetVariable(\"x\", x);     context.SetVariable(\"y\", y);     context.SetVariable(\"z\", z);     context.SetVariable(\"w\", w);      IExpression expression = new AddExpression(         new LogExpression(new VariableExpression(\"y\"), new VariableExpression(\"w\")),         new VariableExpression(\"z\"));      Console.WriteLine(expression.Interpret(context));      Console.Read(); }<\/code><\/pre>\n<h2>\u0425\u0440\u0430\u043d\u0438\u0442\u0435\u043b\u044c (Memento)<\/h2>\n<p>\u041f\u0430\u0442\u0442\u0435\u0440\u043d \u00ab\u0425\u0440\u0430\u043d\u0438\u0442\u0435\u043b\u044c\u00bb &#8212; \u044d\u0442\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u0430\u0442\u0442\u0435\u0440\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u044b\u043d\u0435\u0441\u0442\u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0437\u0430 \u0435\u0433\u043e \u043f\u0440\u0435\u0434\u0435\u043b\u044b \u0441 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0431\u0435\u0437 \u043d\u0430\u0440\u0443\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0430 \u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u044f\u0446\u0438\u0438.<\/p>\n<p>\u041f\u0430\u0442\u0442\u0435\u0440\u043d \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442 \u0432 \u0441\u043b\u0443\u0447\u0430\u044f\u0445, \u043a\u043e\u0433\u0434\u0430:<\/p>\n<ul>\n<li>\n<p>\u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0435\u0433\u043e \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c<\/p>\n<\/li>\n<li>\n<p>\u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0431\u0435\u0437 \u043d\u0430\u0440\u0443\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0430 \u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u044f\u0446\u0438\u0438<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"cs\">private class Player {     private string name = \"Stieve\";     private int health = 100;      public void Upgrade()     {         this.health += 50;     }      public PlayerMemento SaveState()     {         return new  PlayerMemento(name, health);     }      public void RestoreState(PlayerMemento memento)     {         this.name = memento.Name;         this.health = memento.Health;     } }  private class PlayerMemento {     public string Name { get; private set; }     public int Health { get; private set; }      public PlayerMemento(string name, int health)     {         this.Name = name;         this.Health = health;     } }  private class GameHistory {     public List&lt;PlayerMemento> History { get; private set; }      public GameHistory()     {         this.History = new List&lt;PlayerMemento>();     } }  private static void Main() {     Player player = new Player();      GameHistory history = new GameHistory();      history.History.Add(player.SaveState());      player.Upgrade();      player.RestoreState(history.History.Last());      Console.Read(); }<\/code><\/pre>\n<h2>\u041f\u043e\u0441\u0440\u0435\u0434\u043d\u0438\u043a (Mediator)<\/h2>\n<p>\u041f\u0430\u0442\u0442\u0435\u0440\u043d \u00ab\u041f\u043e\u0441\u0440\u0435\u0434\u043d\u0438\u043a\u00bb &#8212; \u044d\u0442\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u0430\u0442\u0442\u0435\u0440\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0443 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0431\u0435\u0437 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0441\u0441\u044b\u043b\u0430\u0442\u044c \u0434\u0440\u0443\u0433 \u043d\u0430 \u0434\u0440\u0443\u0433\u0430.<\/p>\n<p>\u041f\u0430\u0442\u0442\u0435\u0440\u043d \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u0441\u043b\u0443\u0447\u0430\u044f\u0445, \u043a\u043e\u0433\u0434\u0430:<\/p>\n<ul>\n<li>\n<p>\u0438\u043c\u0435\u0435\u0442\u0441\u044f \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u0430 \u0441\u0432\u044f\u0437\u0438 \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438 \u0441\u043b\u043e\u0436\u043d\u044b \u0438 \u0437\u0430\u043f\u0443\u0442\u0430\u043d\u044b<\/p>\n<\/li>\n<li>\n<p>\u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442, \u043d\u043e \u044d\u0442\u043e \u043e\u0441\u043b\u043e\u0436\u043d\u044f\u0435\u0442\u0441\u044f \u0441\u0432\u044f\u0437\u044f\u043c\u0438 \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"cs\">private abstract class Mediator {     public abstract void Send(string message, Colleague colleague); }  private abstract class Colleague {     protected Mediator mediator;      public Colleague(Mediator mediator)     {         this.mediator = mediator;     }      public virtual void Send(string message)     {         this.mediator.Send(message, this);     }     public abstract void Notify(string message); }  private class Manager : Mediator {     public Colleague Customer { get; set; }     public Colleague Leader { get; set; }     public Colleague Architector { get; set; }     public Colleague BuildersTeam { get; set; }     public override void Send(string message, Colleague colleague)     {         if (this.Customer == colleague)         {             this.Leader.Notify(message);         }          else if (this.Leader == colleague)         {             this.Architector.Notify(message);         }          else if (this.Architector == colleague)         {             this.BuildersTeam.Notify(message);         }          else if (this.BuildersTeam == colleague)         {             this.Customer.Notify(message);         }     } }  private class Customer : Colleague {     public Customer(Mediator mediator) : base(mediator)     {     }      public override void Notify(string message)     {         Console.WriteLine(\"\u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044f: \" + message);     } }  private class Leader : Colleague {     public Leader(Mediator mediator) : base(mediator)     {     }      public override void Notify(string message)     {         Console.WriteLine(\"\u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u043e\u0440\u0430: \" + message);     } }  private class Architector : Colleague {     public Architector(Mediator mediator) : base(mediator)     {      }      public override void Notify(string message)     {         Console.WriteLine(\"\u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0441\u0442\u0440\u043e\u0438\u0442\u0435\u043b\u044f: \" + message);     } }  private class BuildersTeam : Colleague {     public BuildersTeam(Mediator mediator) : base(mediator)     {     }      public override void Notify(string message)     {         Console.WriteLine(\"\u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0437\u0430\u043a\u0430\u0437\u0447\u0438\u043a\u0430: \" + message);     } }  private static void Main() {     Manager manager = new Manager();      Colleague customer = new Customer(manager);     Colleague leader = new Leader(manager);     Colleague architector = new Architector(manager);     Colleague builders = new BuildersTeam(manager);      manager.Customer = customer;     manager.Leader = leader;     manager.Architector = architector;     manager.BuildersTeam = builders;      customer.Send(\"\u0421\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0430\u0440\u043a\");      leader.Send(\"\u0421\u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0430\u0440\u043a\");      architector.Send(\"\u041f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043f\u0430\u0440\u043a\");      builders.Send(\"\u041f\u0430\u0440\u043a \u0433\u043e\u0442\u043e\u0432\");      Console.Read(); }<\/code><\/pre>\n<h2>\u041f\u043e\u0441\u0435\u0442\u0438\u0442\u0435\u043b\u044c (Visitor)<\/h2>\n<p>\u041f\u0430\u0442\u0442\u0435\u0440\u043d \u00ab\u041f\u043e\u0441\u0435\u0442\u0438\u0442\u0435\u043b\u044c\u00bb &#8212; \u044d\u0442\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u0430\u0442\u0442\u0435\u0440\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043a \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0431\u0435\u0437 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u043a\u043b\u0430\u0441\u0441\u044b.<\/p>\n<p>\u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442\u0441\u044f \u0434\u0432\u0435 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0438 \u043a\u043b\u0430\u0441\u0441\u043e\u0432. \u041e\u0434\u043d\u0430 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e, \u0430 \u0434\u0440\u0443\u0433\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u044d\u0442\u0443 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e.<\/p>\n<pre><code class=\"cs\">\/\/ \u0410\u0431\u0441\u0440\u0430\u043a\u0446\u0438\u044f \u043f\u043e\u0441\u0435\u0442\u0438\u0442\u0435\u043b\u044f interface IVisitor {     void Serialize(ILog log); }  \/\/ \u041f\u043e\u0441\u0435\u0442\u0438\u0442\u0435\u043b\u044c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0432 html class HtmlSerializer : IVisitor {     public void Serialize(ILog log)     {         \/\/ Serialize text to html     } }  \/\/ \u041f\u043e\u0441\u0435\u0442\u0438\u0442\u0435\u043b\u044c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0432 xml class XmlSerializer : IVisitor {     public void Serialize(ILog log)     {         \/\/ Serialize text to xml     } }  \/\/ \u041f\u043e\u0441\u0435\u0442\u0438\u0442\u0435\u043b\u044c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0432 json class JsonSerializer : IVisitor {     public void Serialize(ILog log)     {         \/\/ Serialize text to json     } }  \/\/ \u0410\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430 interface ILog {     string Location { get; set; }     string Message { get; set; }     string DateTime { get; set; }     string StackTrace { get; set; }     void Log(IVisitor visitor); }  \/\/ \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430 class Error : ILog {     public bool IsFatal { get; set; }     public string Location { get; set; }     public string Message { get; set; }     public string DateTime { get; set; }     public string StackTrace { get; set; }      public void Log(IVisitor visitor)      {          visitor.Serialize(this);     } }  \/\/ \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430 class Warn : ILog {     public string Location { get; set; }     public string Message { get; set; }     public string DateTime { get; set; }     public string StackTrace { get; set; }      public void Log(IVisitor visitor)     {         visitor.Serialize(this);     } }  \/\/ \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430 class Info : ILog {     public string Location { get; set; }     public string Message { get; set; }     public string DateTime { get; set; }     public string StackTrace { get; set; }      public void Log(IVisitor visitor)     {         visitor.Serialize(this);     } }  \/\/ \u041d\u0435\u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c class Logger {     List&lt;ILog> logs = new List&lt;ILog>();     public void Add(ILog log)     {         logs.Add(log);     }      public void Remove(ILog log)     {         logs.Remove(log);     }      public void Log(IVisitor visitor)     {         foreach (ILog log in logs)         {             log.Log(visitor);         }     } }  private static void Main() {     Logger logger = new Logger();      logger.Add(new Warn());      logger.Add(new Info());      logger.Log(new XmlSerializer());      Console.Read(); }<\/code><\/pre>\n<h2>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043d\u044b\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b<\/h2>\n<p>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043d\u044b\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b &#8212; \u044d\u0442\u043e \u0442\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442 \u0442\u043e, \u043a\u0430\u043a \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0432 \u043a\u043e\u0434\u0435. \u041e\u043d\u0438 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442, \u043a\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u00ab\u0441\u043e\u0431\u0438\u0440\u0430\u044e\u0442\u0441\u044f\u00bb \u0432 \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0435.  <\/p>\n<h2>\u0414\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 (Decorator)<\/h2>\n<p>\u041f\u0430\u0442\u0442\u0435\u0440\u043d \u00ab\u0414\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u00bb &#8212; \u044d\u0442\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043d\u044b\u0439 \u043f\u0430\u0442\u0442\u0435\u0440\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u043a \u043e\u0431\u044a\u0435\u043a\u0442\u0443 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c.<\/p>\n<p>\u041f\u0430\u0442\u0442\u0435\u0440\u043d \u0445\u043e\u0440\u043e\u0448\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0432 \u0441\u043b\u0443\u0447\u0430\u044f\u0445, \u043a\u043e\u0433\u0434\u0430:<\/p>\n<ul>\n<li>\n<p>\u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043a \u043e\u0431\u044a\u0435\u043a\u0442\u0443 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438<\/p>\n<\/li>\n<li>\n<p>\u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0435\u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0434\u043b\u044f \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0438, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043e\u043d\u0430 \u0443\u0436\u0435 \u0440\u0430\u0437\u0440\u043e\u0441\u043b\u0430\u0441\u044c<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"cs\">abstract class Phone {     public string Name { get; protected set; }      public Phone(string name)     {         this.Name = name;     }      public abstract int GetCost(); }  class Smartphone : Phone {     public Smartphone() : base(\"\u0422\u0435\u043b\u0435\u0444\u043e\u043d \u0441 \u041e\u0421 Android\")     {     }      public override int GetCost()     {         return 5000;     } }  class Iphone : Phone {     public Iphone() : base(\"\u0422\u0435\u043b\u0435\u0444\u043e\u043d \u0441 \u041e\u0421 IOS\")     {     }      public override int GetCost()     {         return 15000;     } }  abstract class PhoneDecorator : Phone {     protected Phone phone;     protected PhoneDecorator(string name, Phone phone) : base(name)     {         this.phone = phone;     } }  class PhoneWithMemoryCard : PhoneDecorator {     public PhoneWithMemoryCard(Phone phone) : base(phone.Name + \" \u0441 \u043a\u0430\u0440\u0442\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438\", phone)     {     }      public override int GetCost()     {         return phone.GetCost() + 1000;     } }  class PhoneWithCover : PhoneDecorator {     public PhoneWithCover(Phone phone) : base(phone.Name + \" \u0441 \u0447\u0435\u0445\u043b\u043e\u043c\", phone)     {     }      public override int GetCost()     {         return phone.GetCost() + 500;     } }  private static void Main() {     Phone smartphone = new Smartphone();      smartphone = new PhoneWithCover(smartphone);      smartphone = new PhoneWithMemoryCard(smartphone);      Console.WriteLine(smartphone.GetCost());      Console.Read(); }<\/code><\/pre>\n<h2>\u0410\u0434\u0430\u043f\u0442\u0435\u0440 (Adapter)<\/h2>\n<p>\u041f\u0430\u0442\u0442\u0435\u0440\u043d \u00ab\u0410\u0434\u0430\u043f\u0442\u0435\u0440\u00bb &#8212; \u044d\u0442\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043d\u044b\u0439 \u043f\u0430\u0442\u0442\u0435\u0440\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0435\u0448\u0430\u0435\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u0441 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u044c\u044e. \u041a\u0430\u043a \u043f\u0440\u0438\u043c\u0435\u0440 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u0441\u043e\u0432\u0435\u0442\u0441\u043a\u0443\u044e \u0432\u0438\u043b\u043a\u0443 \u0438 \u0435\u0432\u0440\u043e\u043f\u0435\u0439\u0441\u043a\u0443\u044e \u0440\u043e\u0437\u0435\u0442\u043a\u0443. \u0421\u0430\u043c\u0438 \u043f\u043e \u0441\u0435\u0431\u0435 \u043e\u043d\u0438 \u043d\u0435\u0441\u043e\u0435\u0434\u0438\u043d\u0438\u043c\u044b. \u041d\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0430\u0434\u0430\u043f\u0442\u0435\u0440 \u043b\u0435\u0433\u043a\u043e \u0440\u0435\u0448\u0430\u0435\u0442 \u044d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443.<\/p>\n<p>\u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0434\u0432\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438:<\/p>\n<ul>\n<li>\n<p>\u0443\u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441 \u0410 \u043e\u0442 \u043a\u043b\u0430\u0441\u0441\u0430 \u0412 \u0438\u043b\u0438 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442, \u0447\u0442\u043e\u0431\u044b \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u0438,<\/p>\n<\/li>\n<li>\n<p>\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441 \u0410 \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 \u0412 \u043a\u0430\u043a \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0438\u043b\u0438 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442, \u0447\u0442\u043e\u0431\u044b \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u0438<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"cs\">private interface IDetectorA {     bool Detect(int value); }  private class DetectorA : IDetectorA {     public bool Detect(int value)     {         return value > 0;     } }  private enum Result {     High,     Medium,     Low,     Null }  private interface IDetectorB {     Result Detect(int value); }  private class DetectorB : IDetectorB {     public Result Detect(int value)     {         if (value &lt;= 0)         {             return Result.Null;         }          else if (value &lt;= 10)         {             return Result.Low;         }          else         {             return value &lt;= 20 ? Result.Medium : Result.High;         }     } }  private class Adapter : IDetectorA {     private readonly DetectorB detectorB;      public Adapter(DetectorB detectorB)     {         this.detectorB = detectorB;     }      public bool Detect(int value)     {         Result result = this.detectorB.Detect(value);          return result != Result.Null;     } }  private static void Main() {     DetectorB detectorB = new DetectorB();      Adapter adapter = new Adapter(detectorB);      adapter.Detect(0);      _ = Console.Read(); }<\/code><\/pre>\n<h2>\u0424\u0430\u0441\u0430\u0434 (Facade)<\/h2>\n<p>\u041f\u0430\u0442\u0442\u0435\u0440\u043d \u00ab\u0424\u0430\u0441\u0430\u0434\u00bb &#8212; \u044d\u0442\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043d\u044b\u0439 \u043f\u0430\u0442\u0442\u0435\u0440\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043a\u0440\u044b\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043e\u0442 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. <\/p>\n<p>\u041f\u0430\u0442\u0442\u0435\u0440\u043d \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445:<\/p>\n<ul>\n<li>\n<p>\u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u0441\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439,<\/p>\n<\/li>\n<li>\n<p>\u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u043c\u0435\u0436\u0434\u0443 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u043c \u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439,<\/p>\n<\/li>\n<li>\n<p>\u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043f\u043e\u0434\u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0432 \u0441\u043b\u043e\u0436\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435.<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"cs\">class RestApi {     public void GetData()     {         \/\/ \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0442 \u0441\u0435\u0440\u0432\u0435\u0440\u0430     } }  class SqliteDB {     public void SaveData()     {         \/\/ \u0421\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445     } }  class Presentation {     public void LoadData()     {         \/\/ \u0417\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430     }      public void ShowContent()     {         \/\/ \u041f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u043a\u043e\u043d\u0442\u0435\u043d\u0442     } }  class UIFacade {     RestApi restApi;     SqliteDB sqliteDB;     Presentation presentation;      public UIFacade(RestApi restApi, SqliteDB sqliteDB, Presentation presentation)     {         this.restApi = restApi;         this.sqliteDB = sqliteDB;         this.presentation = presentation;     }      public void Continue()     {         restApi.GetData();         sqliteDB.SaveData();         presentation.LoadData();         presentation.ShowContent();     } }  class User {     public void OpenPage(UIFacade facade)      {         facade.Continue();     } }<\/code><\/pre>\n<h2>\u041a\u043e\u043c\u043f\u043e\u043d\u043e\u0432\u0449\u0438\u043a (Composite)<\/h2>\n<p>\u041f\u0430\u0442\u0442\u0435\u0440\u043d \u00ab\u041a\u043e\u043c\u043f\u043e\u043d\u043e\u0432\u0449\u0438\u043a\u00bb &#8212; \u044d\u0442\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043d\u044b\u0439 \u043f\u0430\u0442\u0442\u0435\u0440\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0441 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438 \u043f\u043e \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0443 \u00ab\u0447\u0430\u0441\u0442\u044c-\u0446\u0435\u043b\u043e\u0435\u00bb. \u041e\u043d \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0434\u0440\u0435\u0432\u043e\u0432\u0438\u0434\u043d\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043a\u0430\u043a \u0441 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438, \u0442\u0430\u043a \u0438 \u0433\u0440\u0443\u043f\u043f\u0430\u043c\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432.<\/p>\n<p>\u041f\u0430\u0442\u0442\u0435\u0440\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445:<\/p>\n<ul>\n<li>\n<p>\u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438 \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u0434\u0440\u0435\u0432\u043e\u0432\u0438\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b,<\/p>\n<\/li>\n<li>\n<p>\u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043a\u0430\u043a \u0441 \u0433\u0440\u0443\u043f\u043f\u0430\u043c\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u0442\u0430\u043a \u0438 \u0441 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438.<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"cs\"> public abstract class Component     {         protected string name;          public Component(string name)         {             this.name = name;         }          public virtual void Add(Component component)         {          }          public virtual void Remove(Component component)         {          }          public override string ToString()         {             return this.name;         }     }      internal class Folder : Component     {         private List&lt;Component> components = new();          public Folder(string name) : base(name)         {          }          public List&lt;Component> GetComponents()         {             return this.components;         }          public FolderMemento SaveState()         {             return new FolderMemento(this.name, this.components);         }          public void RestoreState(FolderMemento memento)         {             this.name = memento.Name;             this.components = memento.Components;         }          public override void Add(Component component)         {             this.components.Add(component);         }          public override void Remove(Component component)         {             _ = this.components.Remove(component);         }          public override string ToString()         {             List&lt;string> list = new();              foreach (Component component in this.components)             {                 list.Add(component.ToString());             }              return string.Join(\", \", list.ToArray());         }     }      internal class File : Component     {         public File(string name) : base(name)         {          }     }<\/code><\/pre>\n<h2>\u0417\u0430\u043c\u0435\u0441\u0442\u0438\u0442\u0435\u043b\u044c (Proxy)<\/h2>\n<p>\u041f\u0430\u0442\u0442\u0435\u0440\u043d \u00ab\u0417\u0430\u043c\u0435\u0441\u0442\u0438\u0442\u0435\u043b\u044c\u00bb &#8212; \u044d\u0442\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435\u0441\u0451\u0442 \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0437\u0430 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0434\u0440\u0443\u0433\u0438\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u043c. <\/p>\n<p>\u041e\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u0441\u043b\u0443\u0447\u0430\u044f\u0445, \u043a\u043e\u0433\u0434\u0430:<\/p>\n<ul>\n<li>\n<p>\u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043e\u0431\u044a\u0435\u043a\u0442\u0443 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043f\u0440\u0430\u0432 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 (\u0417\u0430\u0449\u0438\u0449\u0430\u044e\u0449\u0438\u0439 \u0437\u0430\u043c\u0435\u0441\u0442\u0438\u0442\u0435\u043b\u044c),<\/p>\n<\/li>\n<li>\n<p>\u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f\u043e\u043c \u043a \u043e\u0431\u044a\u0435\u043a\u0442\u0443, \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 (\u0412\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0439 \u0437\u0430\u043c\u0435\u0441\u0442\u0438\u0442\u0435\u043b\u044c),<\/p>\n<\/li>\n<li>\n<p>\u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u043c \u0441 \u0443\u0447\u0451\u0442\u043e\u043c \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438 (\u0423\u043c\u043d\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438),<\/p>\n<\/li>\n<li>\n<p>\u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0438\u0442\u044c \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043f\u043e \u0441\u0435\u0442\u0438 \u0438 \u0441\u043d\u0438\u0437\u0438\u0442\u044c \u043d\u0430\u043a\u043b\u0430\u0434\u043d\u044b\u0435 \u0438\u0437\u0434\u0435\u0440\u0436\u043a\u0438 (\u0423\u0434\u0430\u043b\u0451\u043d\u043d\u044b\u0439 \u0437\u0430\u043c\u0435\u0441\u0442\u0438\u0442\u0435\u043b\u044c).<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"cs\">\/\/ \u0410\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430 public interface IMath {     double Add(double x, double y);     double Sub(double x, double y);     double Mul(double x, double y);     double Div(double x, double y); }  \/\/ \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430 public class Math : IMath {     public double Add(double x, double y) => x + y;     public double Sub(double x, double y) => x - y;     public double Mul(double x, double y) => x * y;     public double Div(double x, double y) => x \/ y; }  \/\/ \u041f\u0440\u043e\u043a\u0441\u0438 \u0434\u043b\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430 public class MathProxy : IMath {     private readonly Math math = new Math();     public double Add(double x, double y)     {         return this.math.Add(x, y);     }     public double Sub(double x, double y)     {         return this.math.Sub(x, y);     }     public double Mul(double x, double y)     {         return this.math.Mul(x, y);     }     public double Div(double x, double y)     {         return this.math.Div(x, y);     } }  private static void Main() {     MathProxy proxy = new MathProxy();      Console.WriteLine(\"4 + 2 = \" + proxy.Add(4, 2));     Console.WriteLine(\"4 - 2 = \" + proxy.Sub(4, 2));     Console.WriteLine(\"4 * 2 = \" + proxy.Mul(4, 2));     Console.WriteLine(\"4 \/ 2 = \" + proxy.Div(4, 2));      Console.Read(); }<\/code><\/pre>\n<h2>\u041c\u043e\u0441\u0442 (Bridge)<\/h2>\n<p>\u041f\u0430\u0442\u0442\u0435\u0440\u043d \u00ab\u041c\u043e\u0441\u0442\u00bb &#8212; \u044d\u0442\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043d\u044b\u0439 \u043f\u0430\u0442\u0442\u0435\u0440\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u0442\u0434\u0435\u043b\u0438\u0442\u044c \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u044e \u043e\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u043c\u0435\u043d\u044f\u0442\u044c \u0438\u0445 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u0434\u0440\u0443\u0433 \u043e\u0442 \u0434\u0440\u0443\u0433\u0430. \u0421\u0443\u0442\u044c \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0438 \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0432 \u0432\u0438\u0434\u0435 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0439.<\/p>\n<p>\u041f\u0430\u0442\u0442\u0435\u0440\u043d \u0445\u043e\u0440\u043e\u0448\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0434\u043b\u044f \u0442\u0435\u0445 \u0441\u043b\u0443\u0447\u0430\u0435\u0432, \u043a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u0436\u0451\u0441\u0442\u043a\u043e\u0439 \u0441\u0432\u044f\u0437\u0438 \u043c\u0435\u0436\u0434\u0443 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0435\u0439 \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439, \u0430 \u0442\u0430\u043a\u0436\u0435, \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u043c\u0435\u043d\u044f\u0442\u044c \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u044e \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u0434\u0440\u0443\u0433 \u043e\u0442 \u0434\u0440\u0443\u0433\u0430.<\/p>\n<pre><code class=\"cs\">\/\/ \u0410\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u044f \u043a\u0440\u0430\u0441\u0438\u0442\u0435\u043b\u044f public abstract class Color {     public abstract void PaintOver(); }  \/\/ \u041a\u0440\u0430\u0441\u043d\u044b\u0439 \u043a\u0440\u0430\u0441\u0438\u0442\u0435\u043b\u044c public class Red : Color {     public override void PaintOver()     {         \/\/ \u041e\u043a\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u043c \u0432 \u043a\u0440\u0430\u0441\u043d\u044b\u0439     } }  \/\/ \u0417\u0435\u043b\u0451\u043d\u044b\u0439 \u043a\u0440\u0430\u0441\u0438\u0442\u0435\u043b\u044c public class Green : Color {     public override void PaintOver()     {         \/\/ \u041e\u043a\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u043c \u0432 \u0437\u0435\u043b\u0451\u043d\u044b\u0439     } }  \/\/ \u0421\u0438\u043d\u0438\u0439 \u043a\u0440\u0430\u0441\u0438\u0442\u0435\u043b\u044c public class Blue : Color {     public override void PaintOver()     {         \/\/ \u041e\u043a\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u043c \u0432 \u0441\u0438\u043d\u0438\u0439     } }  \/\/ \u0410\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u0442\u0440\u043e\u0442\u0443\u0430\u0440\u043d\u043e\u0439 \u043f\u043b\u0438\u0442\u043a\u0438 public abstract class Tile {     protected Color color { get; set; }      public Tile(Color color)     {         this.color = color;     }      public abstract void ApplyColor(); }  \/\/ \u041a\u0440\u0443\u0433\u043b\u0430\u044f \u043f\u043b\u0438\u0442\u043a\u0430 public class RoundTile : Tile {     public RoundTile(Color color) : base(color)     {     }      public override void ApplyColor()     {         this.color.PaintOver();     } }  \/\/ \u041a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u0430\u044f \u043f\u043b\u0438\u0442\u043a\u0430 public class SquareTile : Tile {     public SquareTile(Color color) : base(color)     {     }      public override void ApplyColor()     {         this.color.PaintOver();     } }  \/\/ \u041f\u0440\u044f\u043c\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u0430\u044f \u043f\u043b\u0438\u0442\u043a\u0430 public class RectangleTile : Tile {     public RectangleTile(Color color) : base(color)     {     }      public override void ApplyColor()     {         this.color.PaintOver(); ;     } }  private static void Main() {     RoundTile roundTileBlue = new RoundTile(new Blue());      RoundTile roundTileGreen = new RoundTile(new Green());      Console.Read(); }<\/code><\/pre>\n<h2>\u041f\u0440\u0438\u0441\u043f\u043e\u0441\u043e\u0431\u043b\u0435\u043d\u0435\u0446 (Flyweight)<\/h2>\n<p>\u041f\u0430\u0442\u0442\u0435\u0440\u043d \u00ab\u041f\u0440\u0438\u0441\u043f\u043e\u0441\u043e\u0431\u043b\u0435\u043d\u0435\u0446\u00bb &#8212; \u044d\u0442\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043d\u044b\u0439 \u043f\u0430\u0442\u0442\u0435\u0440\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0441\u0440\u0430\u0437\u0443 \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430\u0445. \u041e\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0434\u043b\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043f\u0430\u043c\u044f\u0442\u044c\u044e.<\/p>\n<p>\u041e\u0431\u044b\u0447\u043d\u044b\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0430 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0432 \u0442\u0435\u043a\u0441\u0442\u0430\u0445. \u0418\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u0447\u0442\u043e \u043d\u0430 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u043e\u0434\u043d\u0438 \u0438 \u0442\u0435 \u0436\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u044b \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0442\u0441\u044f. \u041d\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u0442\u0438\u0447\u043d\u043e, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043f\u0430\u043c\u044f\u0442\u0438 &#8212; \u044d\u0442\u043e \u0434\u043e\u043b\u0433\u0430\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438\u043c\u0435\u0435\u0442 \u0441\u043c\u044b\u0441\u043b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u044b \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u043c\u0435\u0441\u0442\u0430\u0445.<\/p>\n<pre><code class=\"cs\">\/\/ \u0410\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430 abstract class Symvol {     protected char value;      public abstract void Write(); }  \/\/ \u0421\u0438\u043c\u0432\u043e\u043b \u0410 class SymvolA : Symvol {     public SymvolA()     {         this.value = 'A';     }      public override void Write()     {         Console.WriteLine(this.value);     } }  \/\/ \u0421\u0438\u043c\u0432\u043e\u043b B class SymvolB : Symvol {     public SymvolB()     {         this.value = 'B';     }      public override void Write()     {         Console.WriteLine(this.value);     } }  \/\/ \u0424\u0430\u0431\u0440\u0438\u043a\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430\u0445 class SymvolFactory {     Dictionary&lt;string, Symvol> symvols = new Dictionary&lt;string, Symvol>();      public SymvolFactory()     {         symvols.Add(\"A\", new SymvolA());         symvols.Add(\"B\", new SymvolB());     }      public Symvol GetSymvol(string key)     {         if (symvols.ContainsKey(key))         {             return symvols[key];         }          else         {             return null;         }     } }  static void Main() {      SymvolFactory symvolFactory = new SymvolFactory();      Console.WriteLine(symvolFactory.GetSymvol(\"A\"));      Console.Read(); }<\/code><\/pre>\n<h2>\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b<\/h2>\n<h2>\u0421\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f (Specification)<\/h2>\n<p>\u041f\u0430\u0442\u0442\u0435\u0440\u043d \u00ab\u0421\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f\u00bb &#8212; \u044d\u0442\u043e \u043f\u0430\u0442\u0442\u0435\u0440\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u0432\u044b\u0431\u043e\u0440\u043a\u0443 \u0438 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044e \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c\u0438 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0438. \u041e\u043d \u0441\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043a \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0441 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u043c\u0438 \u0432 \u0432\u0438\u0434\u0435 \u043b\u044f\u043c\u0431\u0434\u0430-\u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439.<\/p>\n<p>\u0412 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445 \u0447\u0430\u0441\u0442\u043e \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430, \u0447\u0442\u043e \u043e\u0434\u043d\u0438 \u0438 \u0442\u0435 \u0436\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u043e\u0442\u0431\u043e\u0440\u0430 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043c\u043e\u0433\u0443\u0442 \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u043d\u0430\u0440\u0443\u0448\u0430\u0435\u0442 \u043f\u0440\u0438\u043d\u0446\u0438\u043f &#171;\u041d\u0435 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0439\u0441\u044f&#187;. \u041f\u0430\u0442\u0442\u0435\u0440\u043d \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u043f\u043e\u0432\u0442\u043e\u0440\u0435\u043d\u0438\u0439 \u0438 \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430 \u0443\u0441\u043b\u043e\u0432\u0438\u0439. <\/p>\n<pre><code class=\"cs\">\/\/ \u0410\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u044f \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 public abstract class Specification&lt;T> {     public abstract Expression&lt;Func&lt;T, bool>> ToExpression();      public bool IsSatisfiedBy(T entity)     {         Func&lt;T, bool> predicate = ToExpression().Compile();         return predicate(entity);     } }  \/\/ \u0421\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u0434\u043b\u044f \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0446\u0438\u0442\u0430\u0442 public class QuotValidateSpecification : Specification&lt;Quot> {     public QuotValidateSpecification()      {      }      public override Expression&lt;Func&lt;Quot, bool>> ToExpression()     {         return quot => quot.Author.Length > 0 &amp;&amp; quot.Text.Length > 0;     } }  \/\/ \u0421\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u0434\u043b\u044f \u043e\u0442\u0431\u043e\u0440\u0430 \u0446\u0438\u0442\u0430\u0442 public class QuotSearchSpecification : Specification&lt;Quot> {     public override Expression&lt;Func&lt;Quot, bool>> ToExpression()     {         return quot => true;     } }  \/\/ \u041f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0446\u0438\u0442\u0430\u0442 public class GetQuotValidator {     public bool IsValid(Quot value)     {         QuotSearchSpecification specification = new();          bool isOk = specification.IsSatisfiedBy(value);          return isOk;     } }  public sealed class Quot {     public int Id {get; set;}     public string Author { get; set; }     public string Text { get; set; }     public bool Removed { get; set; } }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/785476\/\"> https:\/\/habr.com\/ru\/articles\/785476\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0435\u0440\u0438\u0438 \u0441\u0442\u0430\u0442\u0435\u0439 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043e \u043e\u043a\u043e\u043b\u043e \u0441\u043e\u0442\u043d\u0438 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u0432 \u0438\u0437 \u0442\u0430\u043a\u0438\u0445 \u0441\u0431\u043e\u0440\u043d\u0438\u043a\u043e\u0432, \u043a\u0430\u043a  \u00ab\u041f\u0430\u0442\u0442\u0435\u0440\u043d\u044b \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u043e-\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f\u00bb, \u00ab\u0428\u0430\u0431\u043b\u043e\u043d\u044b \u043a\u043e\u0440\u043f\u043e\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439\u00bb, \u00ab\u041f\u0430\u0442\u0442\u0435\u0440\u043d\u044b \u0438\u0433\u0440\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f\u00bb, \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u043d\u043e\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b \u0438 \u043c\u043d\u043e\u0433\u0438\u0445 \u0434\u0440\u0443\u0433\u0438\u0445. \u041f\u0435\u0440\u0432\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043e\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0432\u0441\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b \u0438\u0437 \u00ab\u0411\u0430\u043d\u0434\u044b \u0447\u0435\u0442\u044b\u0440\u0451\u0445\u00bb, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0442\u0430\u043a\u0438\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b, \u043a\u0430\u043a \u00ab\u0421\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f\u00bb \u0438 \u00ab\u041f\u0440\u043e\u0441\u0442\u0430\u044f \u0444\u0430\u0431\u0440\u0438\u043a\u0430\u00bb.<\/p>\n<h2>\u041f\u0430\u0442\u0442\u0435\u0440\u043d (\u0448\u0430\u0431\u043b\u043e\u043d)<\/h2>\n<p>\u041f\u0430\u0442\u0442\u0435\u0440\u043d\u044b (\u0448\u0430\u0431\u043b\u043e\u043d\u044b) \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u2014 \u044d\u0442\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0447\u0438\u0442\u0430\u044e\u0442\u0441\u044f \u0445\u043e\u0440\u043e\u0448\u0438\u043c \u0442\u043e\u043d\u043e\u043c \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432. \u0418\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c, \u043d\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u0432\u044b\u0441\u0438\u0442\u044c \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u043e\u0434\u0430. \u0418\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u0447\u0442\u043e \u0441\u0430\u043c\u043e\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434 \u043f\u043e\u0447\u0442\u0438 \u0432\u0441\u0435\u0433\u0434\u0430 \u0445\u0443\u0436\u0435, \u0447\u0435\u043c \u0442\u043e\u0442 \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043c\u0435\u0441\u044f\u0446\u0430\u043c\u0438, \u0433\u043e\u0434\u0430\u043c\u0438 \u0438 \u0434\u0435\u0441\u044f\u0442\u0438\u043b\u0435\u0442\u0438\u044f\u043c\u0438.<\/p>\n<h2>\u041f\u043e\u0440\u043e\u0436\u0434\u0430\u044e\u0449\u0438\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b<\/h2>\n<p>\u041f\u043e\u0440\u043e\u0436\u0434\u0430\u044e\u0449\u0438\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b &#8212; \u044d\u0442\u043e \u0442\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0442 \u0437\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0442\u0435\u0445 \u0438\u043b\u0438 \u0438\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432. \u041e\u043d\u0438 \u043f\u043e\u043c\u043e\u0433\u0430\u044e\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u0438 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e \u043e\u0431\u0449\u0430\u043b\u0438\u0441\u044c \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0438\u0445 \u0440\u0430\u0431\u043e\u0442\u043e\u0439.  <\/p>\n<h2>\u041f\u0440\u043e\u0441\u0442\u0430\u044f \u0444\u0430\u0431\u0440\u0438\u043a\u0430 (Simple Factory)<\/h2>\n<p>\u041f\u0430\u0442\u0442\u0435\u0440\u043d \u00ab\u041f\u0440\u043e\u0441\u0442\u0430\u044f \u0444\u0430\u0431\u0440\u0438\u043a\u0430\u00bb &#8212; \u044d\u0442\u043e \u043f\u043e\u0440\u043e\u0436\u0434\u0430\u044e\u0449\u0438\u0439 \u043f\u0430\u0442\u0442\u0435\u0440\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0434\u0440\u0443\u0433\u0438\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0442\u043e\u0433\u043e \u0438\u043b\u0438 \u0438\u043d\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430. \u041e\u0441\u043d\u043e\u0432\u043d\u044b\u043c \u0435\u0451 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0430. \u041d\u043e \u0435\u0441\u0442\u044c \u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u043a: \u043e\u043d\u0430 \u0445\u043e\u0440\u043e\u0448\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u0438\u043f\u043e\u0432 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u044b\u043c \u0438 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u043c.<\/p>\n<figure class=\"bordered full-width\">\n<div><figcaption>\u041b\u0438\u0441\u0442\u044b \u0431\u0443\u043c\u0430\u0433\u0438<\/figcaption><\/div>\n<\/figure>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u0444\u0430\u0431\u0440\u0438\u043a\u0443 \u043f\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0441\u0442\u0432\u043e \u043b\u0438\u0441\u0442\u043e\u0432 \u0431\u0443\u043c\u0430\u0433\u0438. \u0412\u0441\u0435\u0433\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 8 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u0432, \u0430 \u0438\u0445 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0435 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430 \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0440\u0430\u0432\u0434\u0430\u0442\u044c.<\/p>\n<pre><code class=\"cs\">enum PaperFormat {     A0, A1, A2, A3, A4, A5, A6, A7, A8 }  interface IPaper { }  class PaperA0 : IPaper { }  class PaperA1 : IPaper { }  class PaperA2 : IPaper { }  class PaperA3 : IPaper { }  class PaperA4 : IPaper { }  class PaperA5 : IPaper { }  class PaperA6 : IPaper { }    class PaperA7 : IPaper { }  class PaperA8 : IPaper { }  interface IPaperFactory {     IPaper CreatePaper(PaperFormat paperFormat); }  class PaperFactory : IPaperFactory {     public IPaper CreatePaper(PaperFormat paperFormat)     {         switch (paperFormat)         {             case PaperFormat.A0:                 return new PaperA0();             case PaperFormat.A1:                 return new PaperA1();             case PaperFormat.A2:                 return new PaperA2();             case PaperFormat.A3:                 return new PaperA3();             case PaperFormat.A4:                 return new PaperA4();             case PaperFormat.A5:                 return new PaperA5();             case PaperFormat.A6:                 return new PaperA6();             case PaperFormat.A7:                 return new PaperA7();             case PaperFormat.A8:                 return new PaperA8();             default:                  return new PaperA5();         }     } }  private static void Main(string[] args) {     IPaperFactory paperFactory = new PaperFactory();      IPaper paperA2 = paperFactory.CreatePaper(PaperFormat.A2); }<\/code><\/pre>\n<h2>\u0424\u0430\u0431\u0440\u0438\u0447\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 (Factory Method)<\/h2>\n<p>\u041f\u0430\u0442\u0442\u0435\u0440\u043d \u00ab\u0424\u0430\u0431\u0440\u0438\u0447\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434\u00bb &#8212; \u044d\u0442\u043e \u043f\u043e\u0440\u043e\u0436\u0434\u0430\u044e\u0449\u0438\u0439 \u043f\u0430\u0442\u0442\u0435\u0440\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0434\u0440\u0443\u0433\u0438\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u043d\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0437\u0430 \u0435\u0433\u043e \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u043c\u0438. \u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0435 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043d\u043e\u0432\u044b\u0435 \u0442\u0438\u043f\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0431\u0435\u0437 \u043d\u0430\u0440\u0443\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0430 \u00ab\u0421\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u043e\u0442\u043a\u0440\u044b\u0442\u044b \u0434\u043b\u044f \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f, \u043d\u043e \u0437\u0430\u043a\u0440\u044b\u0442\u044b \u0434\u043b\u044f \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438\u00bb. \u041d\u043e \u0435\u0441\u0442\u044c \u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u043a: \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u043c \u043d\u0430 \u0444\u043e\u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0444\u0430\u0431\u0440\u0438\u043a\u0438.<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u0411\u043b\u043e\u043a\u0438 \u0432 \u00ab\u041c\u0430\u0439\u043d\u043a\u0440\u0430\u0444\u0442\u00bb<\/figcaption><\/div>\n<\/figure>\n<p>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0432 \u0438\u0433\u0440\u0435 \u00abMinecraft\u00bb &#8212; \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440. \u0412 \u044d\u0442\u043e\u0439 \u0438\u0433\u0440\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0435 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0431\u043b\u043e\u043a\u043e\u0432. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0444\u0430\u0431\u0440\u0438\u043a\u0438 \u043c\u043e\u0436\u0435\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 \u0438\u0433\u0440\u044b \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0442\u044f\u0436\u0451\u043b\u043e\u0439, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0431\u043b\u043e\u043a\u043e\u0432 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043c\u043d\u043e\u0433\u043e, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u0431\u043b\u043e\u043a\u0438. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0443\u0434\u043e\u0431\u043d\u0435\u0439 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0444\u0430\u0431\u0440\u0438\u0447\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434.<\/p>\n<pre><code class=\"cs\">abstract class Block { }  abstract class Creator {     public Creator() { }      abstract public Block Create(); }  class Ground : Block { }  class GroundCreator : Creator  {      public GroundCreator() { }      public override Block Create()     {         return new Ground();     } }  class Wood : Block { }  class WoodCreator : Creator {     public WoodCreator() { }      public override Block Create()     {         return new Wood();     } }  class Stone : Block { }  class StoneCreator : Creator {     public StoneCreator() { }      public override Block Create()     {         return new Stone();     } }  class Bricks : Block { }  class BricksCreator : Creator {     public BricksCreator() { }      public override Block Create()     {         return new Bricks();     } }  private static void Main(string[] args) {     WoodCreator woodCreator = new WoodCreator();      Block wood = woodCreator.Create();      StoneCreator stoneCreator = new StoneCreator();      Block stone = stoneCreator.Create(); }<\/code><\/pre>\n<h2>\u0410\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u0430\u044f \u0444\u0430\u0431\u0440\u0438\u043a\u0430 (Abstract Factory)<\/h2>\n<p>\u041f\u0430\u0442\u0442\u0435\u0440\u043d \u00ab\u0410\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u0430\u044f \u0444\u0430\u0431\u0440\u0438\u043a\u0430\u00bb &#8212; \u044d\u0442\u043e \u043f\u043e\u0440\u043e\u0436\u0434\u0430\u044e\u0449\u0438\u0439 \u043f\u0430\u0442\u0442\u0435\u0440\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u0435\u043c\u0435\u0439\u0441\u0442\u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432. \u041e\u0441\u043d\u043e\u0432\u043d\u044b\u043c \u0435\u0451 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e \u0444\u0430\u043a\u0442, \u0447\u0442\u043e \u0435\u0451 \u0443\u0434\u043e\u0431\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0439 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u0433\u0434\u0435 \u0432 \u043a\u0430\u0436\u0434\u043e\u0439 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0435 \u0442\u0438\u043f\u044b. \u0422\u0430\u043a\u0436\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043b\u0435\u0433\u043a\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u043e\u0432\u0443\u044e \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u044e. \u041d\u043e \u0435\u0441\u0442\u044c \u0438 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u043a: \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u0442 \u043a \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u043c \u0432 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0438 \u043a\u043b\u0430\u0441\u0441\u043e\u0432.<\/p>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u0444\u0430\u0431\u0440\u0438\u043a\u0443 \u043c\u043e\u0440\u043e\u0436\u0435\u043d\u043e\u0433\u043e. \u041c\u043e\u0440\u043e\u0436\u0435\u043d\u043e\u0435 \u0431\u044b\u0432\u0430\u0435\u0442 \u0441\u043b\u0438\u0432\u043e\u0447\u043d\u044b\u043c, \u0432\u0430\u043d\u0438\u043b\u044c\u043d\u044b\u043c, \u0448\u043e\u043a\u043e\u043b\u0430\u0434\u043d\u044b\u043c, \u0444\u0440\u0443\u043a\u0442\u043e\u0432\u044b\u043c \u0438 \u043e\u0440\u0435\u0445\u043e\u0432\u044b\u043c. \u0422\u043e \u0435\u0441\u0442\u044c \u043a\u0430\u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u043f\u044f\u0442\u044c \u0442\u0438\u043f\u043e\u0432. \u041d\u043e \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0440\u043e\u0436\u0435\u043d\u043e\u0435 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0441\u0442\u0440\u0430\u043d\u0430\u043c\u0438: \u0440\u043e\u0441\u0441\u0438\u0439\u0441\u043a\u043e\u0435, \u043a\u0438\u0442\u0430\u0439\u0441\u043a\u043e\u0435, \u0442\u0430\u0439\u0441\u043a\u043e\u0435. \u0418\u0442\u043e\u0433\u043e \u0438\u043c\u0435\u0435\u043c \u0442\u0440\u0438 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438, \u0430 \u0432 \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0437 \u043d\u0438\u0445 \u043f\u043e \u043f\u044f\u0442\u044c \u0442\u0438\u043f\u043e\u0432. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0443\u0434\u043e\u0431\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u0443\u044e \u0444\u0430\u0431\u0440\u0438\u043a\u0443.<\/p>\n<pre><code class=\"cs\">abstract class IceCreamFactory {     public abstract Creamy GetCreamy();     public abstract Vanilla GetVanilla();     public abstract Chocolate GetChocolate();     public abstract Fruit GetFruit();     public abstract Walnut GetWalnut(); }  class RussianFactory : IceCreamFactory {     public override Chocolate GetChocolate()     {         return new RussianChocolate();     }      public override Creamy GetCreamy()     {         return new RussianCreamy();     }      public override Fruit GetFruit()     {         return new RussianFruit();     }      public override Vanilla GetVanilla()     {         return new RussianVanilla();     }      public override Walnut GetWalnut()     {         return new RussianWalnut();     } }  class ChineseFactory : IceCreamFactory {     public override Chocolate GetChocolate()     {         return new ChineseChocolate();     }      public override Creamy GetCreamy()     {         return new ChineseCreamy();     }      public override Fruit GetFruit()     {         return new ChineseFruit();     }      public override Vanilla GetVanilla()     {         return new ChineseVanilla();     }      public override Walnut GetWalnut()     {         return new ChineseWalnut();     } }  class ThaiFactory : IceCreamFactory {     public override Chocolate GetChocolate()     {         return new ThaiChocolate();     }      public override Creamy GetCreamy()     {         return new ThaiCreamy();     }      public override Fruit GetFruit()     {         return new ThaiFruit();     }      public override Vanilla GetVanilla()     {         return new ThaiVanilla();     }      public override Walnut GetWalnut()     {         return new ThaiWalnut();     } }  #region Abstract Items abstract class Creamy { }  abstract class Vanilla { }  abstract class Chocolate { }  abstract class Fruit { }  abstract class Walnut { } #endregion  #region Russian Items class RussianCreamy : Creamy { }  class RussianVanilla : Vanilla { }  class RussianChocolate : Chocolate { }  class RussianFruit : Fruit { }  class RussianWalnut : Walnut { } #endregion  #region Chinese Items class ChineseCreamy : Creamy { }  class ChineseVanilla : Vanilla { }  class ChineseChocolate : Chocolate { }  class ChineseFruit : Fruit { }  class ChineseWalnut : Walnut { } #endregion  #region Thai Items class ThaiCreamy : Creamy { }  class ThaiVanilla : Vanilla { }  class ThaiChocolate : Chocolate { }  class ThaiFruit : Fruit { }  class ThaiWalnut : Walnut { } #endregion  class IceCreamManager {     public IceCreamFactory GetRussianFactory()     {         return new RussianFactory();     }      public IceCreamFactory GetChineseFactory()     {         return new ChineseFactory();     }      public IceCreamFactory GetThaiFactory()     {         return new ThaiFactory();     } }  private static void Main(string[] args) {     IceCreamManager manager = new IceCreamManager();      IceCreamFactory russianFactory = manager.GetRussianFactory(); }<\/code><\/pre>\n<h2>\u0421\u0442\u0440\u043e\u0438\u0442\u0435\u043b\u044c (Builder)<\/h2>\n<p>\u041f\u0430\u0442\u0442\u0435\u0440\u043d \u00ab\u0421\u0442\u0440\u043e\u0438\u0442\u0435\u043b\u044c\u00bb &#8212; \u044d\u0442\u043e \u043f\u043e\u0440\u043e\u0436\u0434\u0430\u044e\u0449\u0438\u0439 \u043f\u0430\u0442\u0442\u0435\u0440\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432. \u041e\u043d \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043d\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u044d\u0442\u0430\u043f\u044b. \u0421\u0442\u0440\u043e\u0438\u0442\u0435\u043b\u044c \u0445\u043e\u0440\u043e\u0448\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u0442\u0435\u0445 \u0441\u043b\u0443\u0447\u0430\u0435\u0432, \u043a\u043e\u0433\u0434\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0432\u0430\u0440\u0438\u0430\u0446\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0435\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f.<\/p>\n<p>\u041f\u0430\u0442\u0442\u0435\u0440\u043d \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u043d\u0451\u043d \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043e\u043d\u043e \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0442\u0430\u043a\u0438\u0445 \u0447\u0430\u0441\u0442\u0435\u0439, \u043a\u0430\u043a \u0442\u0435\u043a\u0441\u0442, \u0444\u043e\u0440\u043c\u0430, \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c.<\/p>\n<pre><code class=\"cs\">private enum MessageForm {     Square,     Circle }  private abstract class AbstractBuilder {     public abstract void SetText(string text);     public abstract void SetImage(string image);     public abstract void SetLength(int length);     public abstract void SetForm(MessageForm form);      public abstract Message Build(); }  private class Message {     public string Text { get; set; }     public string Image { get; set; }     public int Length { get; set; }     public MessageForm Form { get; set; } }  private class MessageBuilder : AbstractBuilder {     private readonly Message message = new Message();      public override void SetForm(MessageForm form)     {         this.message.Form = form;     }      public override void SetImage(string image)     {         this.message.Image = image;     }      public override void SetLength(int length)     {         this.message.Length = length;     }      public override void SetText(string text)     {         this.message.Text = text;     }      public override Message Build()     {         return<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-364917","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/364917","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=364917"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/364917\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=364917"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=364917"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=364917"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}