{"id":211899,"date":"2014-02-10T10:58:02","date_gmt":"2014-02-10T06:58:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=211899"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=211899","title":{"rendered":"<span class=\"post_title\">\u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 MVP \u0434\u043b\u044f Windows Forms<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t\u0414\u043e\u0431\u0440\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0441\u0443\u0442\u043e\u043a!<br \/>  Model-View-Presenter \u2014 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0439 \u0448\u0430\u0431\u043b\u043e\u043d \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u0421 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0432\u0437\u0433\u043b\u044f\u0434\u0430 \u0432\u0441\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0440\u043e\u0441\u0442\u043e: \u0435\u0441\u0442\u044c \u041c\u043e\u0434\u0435\u043b\u044c (Model), \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432\u0441\u044e \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0443 \u044d\u043a\u0440\u0430\u043d\u0430; \u0412\u0438\u0434\/\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 (View), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u043d\u0430\u0435\u0442, \u043a\u0430\u043a \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c \u0442\u0435 \u0438\u043b\u0438 \u0438\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435; \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u0435\u043b\u044c (Presenter), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0432\u044f\u0437\u0443\u044e\u0449\u0438\u0439 \u0437\u0432\u0435\u043d\u043e\u043c \u2014 \u0440\u0435\u0430\u0433\u0438\u0440\u0443\u0435\u0442 \u043d\u0430 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432\u043e View, \u0438\u0437\u043c\u0435\u043d\u044f\u044f Model, \u0438 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442.<br \/>  \u0421\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f, \u043a\u043e\u0433\u0434\u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0444\u043e\u0440\u043c \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u043e\u0434\u043d\u043e\u0439.<br \/>  <b>\u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u0442\u0441\u044f:<\/b><br \/>   \u2014 \u043d\u0435\u043c\u043d\u043e\u0436\u043a\u043e \u0442\u0435\u043e\u0440\u0438\u0438;<br \/>   \u2014 \u043e\u0431\u0449\u0438\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 MVP (\u0430 \u0438\u043c\u0435\u043d\u043d\u043e Passive View) \u043f\u043e\u0434 Windows Forms;<br \/>   \u2014 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u043e\u0432 \u043c\u0435\u0436\u0434\u0443 \u0444\u043e\u0440\u043c\u0430\u043c\u0438 \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, \u043c\u043e\u0434\u0430\u043b\u044c\u043d\u044b\u0435 \u043e\u043a\u043d\u0430;<br \/>   \u2014 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 IoC-\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u0430 Dependency Injection \u2014 DI (\u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u0421onstructor Injection);<br \/>   \u2014 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f MVP \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f (\u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c NUnit \u0438 NSubstitute);<br \/>   \u2014 \u0432\u0441\u0435 \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442\u044c \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043c\u0438\u043d\u0438-\u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0438 \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u0435\u0442\u0441\u044f \u0431\u044b\u0442\u044c \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u044b\u043c.<br \/>  <b>\u0412 \u0441\u0442\u0430\u0442\u044c\u0435 \u0437\u0430\u0442\u0440\u0430\u0433\u0438\u0432\u0430\u0435\u0442\u0441\u044f:<\/b><br \/>   \u2014 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u0410\u0434\u0430\u043f\u0442\u0435\u0440 (Adapter);<br \/>   \u2014 \u043f\u0440\u043e\u0441\u0442\u0435\u043d\u044c\u043a\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u041a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f (Application Controller).<br \/>  <b>\u0414\u043b\u044f \u043a\u043e\u0433\u043e \u044d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f?<\/b><br \/>  \u0413\u043b\u0430\u0432\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0434\u043b\u044f \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u0445 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u043d\u0430 Windows Forms, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043b\u044b\u0448\u0430\u043b\u0438, \u043d\u043e \u043d\u0435 \u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b\u0438, \u0438\u043b\u0438 \u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b\u0438, \u043d\u043e \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c. \u0425\u043e\u0442\u044f \u0443\u0432\u0435\u0440\u0435\u043d, \u0447\u0442\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0438\u0435\u043c\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c\u044b \u0438 \u0434\u043b\u044f WPF, \u0438 \u0434\u0430\u0436\u0435 \u0434\u043b\u044f \u0432\u0435\u0431-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h2>\u041f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0437\u0430\u0434\u0430\u0447\u0438<\/h2>\n<p>  \u041f\u0440\u0438\u0434\u0443\u043c\u0430\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443 \u2014 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c 3 \u044d\u043a\u0440\u0430\u043d\u0430:<br \/>  1) \u044d\u043a\u0440\u0430\u043d \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438;<br \/>  2) \u0433\u043b\u0430\u0432\u043d\u044b\u0439 \u044d\u043a\u0440\u0430\u043d;<br \/>  3) \u043c\u043e\u0434\u0430\u043b\u044c\u043d\u044b\u0439 \u044d\u043a\u0440\u0430\u043d \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0438\u043c\u0435\u043d\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.<br \/>  \u0414\u043e\u043b\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c\u0441\u044f \u0447\u0442\u043e-\u0442\u043e \u0432\u0440\u043e\u0434\u0435 \u044d\u0442\u043e\u0433\u043e:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/19c\/d51\/aea\/19cd51aead602bdeb3578a9686ff73a6.png\"\/><\/p>\n<h2>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u0442\u0435\u043e\u0440\u0438\u0438<\/h2>\n<p>  MVP, \u043a\u0430\u043a \u0438 \u0435\u0433\u043e \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c, MVC (Model-View-Controller) \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u043d \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0438 \u043e\u0442 \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u0435\u0435 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f. <\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/a36\/2b9\/00c\/a362b900ce13f0837c2fbeac1a3039e2.png\"\/><\/p>\n<p>  \u041d\u0430 \u043f\u0440\u043e\u0441\u0442\u043e\u0440\u0430\u0445 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0430 \u043c\u043e\u0436\u043d\u043e \u0432\u0441\u0442\u0440\u0435\u0442\u0438\u0442\u044c \u0446\u0435\u043b\u043e\u0435 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0439 MVP. \u041f\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u0443 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0430 3 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438:<br \/>   \u2014 Passive View: View \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u0443\u044e \u043b\u043e\u0433\u0438\u043a\u0443 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 (\u0441\u0442\u0440\u043e\u043a\u0438, \u0447\u0438\u0441\u043b\u0430), \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u043c \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f Presenter;<br \/>   \u2014 Presentation Model: \u0432\u043e View \u043c\u043e\u0433\u0443\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u043d\u043e \u0438 \u0431\u0438\u0437\u043d\u0435\u0441-\u043e\u0431\u044a\u0435\u043a\u0442\u044b;<br \/>   \u2014 Supervising Controller: View \u0437\u043d\u0430\u0435\u0442 \u043e \u043d\u0430\u043b\u0438\u0447\u0438\u0438 \u043c\u043e\u0434\u0435\u043b\u0438 \u0438 \u0441\u0430\u043c \u0437\u0430\u0431\u0438\u0440\u0430\u0435\u0442 \u0438\u0437 \u043d\u0435\u0435 \u0434\u0430\u043d\u043d\u044b\u0435.<\/p>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f Passive View. \u041e\u043f\u0438\u0448\u0435\u043c \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0447\u0435\u0440\u0442\u044b:<br \/>   \u2014 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f (IView), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0435\u043a\u0438\u0439 \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442 \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445;<br \/>   \u2014 \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u2014 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f IView, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0443\u043c\u0435\u0435\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c \u0441\u0430\u043c\u0443 \u0441\u0435\u0431\u044f \u0432 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0435 (\u0431\u0443\u0434\u044c \u0442\u043e Windows Forms, WPF \u0438\u043b\u0438 \u0434\u0430\u0436\u0435 \u043a\u043e\u043d\u0441\u043e\u043b\u044c) \u0438 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0437\u043d\u0430\u0435\u0442 \u043e \u0442\u043e\u043c, \u043a\u0442\u043e \u0435\u0439 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e \u0444\u043e\u0440\u043c\u044b;<br \/>   \u2014 \u041c\u043e\u0434\u0435\u043b\u044c \u2014 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0443 (\u043f\u0440\u0438\u043c\u0435\u0440\u044b: \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445, \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438, \u0441\u0435\u0440\u0432\u0438\u0441\u044b). \u041c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u0432 \u0432\u0438\u0434\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 \u0438\u043b\u0438 \u043e\u043f\u044f\u0442\u044c \u0436\u0435, \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438;<br \/>   \u2014 \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u0435\u043b\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 (IView), \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u043c, \u043f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0435\u0433\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u044f, \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442 \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044e (\u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443) \u0432\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445; \u0442\u0430\u043a\u0436\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u043c\u043e\u0434\u0435\u043b\u044c \u0438\u043b\u0438 \u043d\u0430 \u0435\u0435 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u044f \u0432 \u043d\u0435\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 View \u0438 \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0422\u0438\u043f\u0438\u0447\u043d\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u0435\u043b\u044f<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code>public class Presenter {     private readonly IView _view;     private readonly IService _service;      public Presenter(IView view, IService service)     {         _view = view;         _service = service;          _view.UserIdChanged += () =&gt; UpdateUserInfo();     }      private void UpdateUserInfo()     {         var user = _service.GetUser(_view.UserId);         _view.Username = user.Username;         _view.Age = user.Age;     } } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  \u041a\u0430\u043a\u0438\u0435 \u043f\u043b\u044e\u0441\u044b \u043d\u0430\u043c \u0434\u0430\u0435\u0442 \u043c\u0430\u043b\u0430\u044f \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0441\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u043e\u0432 (\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432, \u0441\u043e\u0431\u044b\u0442\u0438\u0439)? <br \/>  1. \u041f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e \u043c\u0435\u043d\u044f\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443 \u043b\u044e\u0431\u043e\u0433\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430, \u043d\u0435 \u043b\u043e\u043c\u0430\u044f \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0433\u043e.<br \/>  2. \u0411\u043e\u043b\u044c\u0448\u0438\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u0438 unit-\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438. \u041f\u043e\u043a\u043b\u043e\u043d\u043d\u0438\u043a\u0438 TDD \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0432 \u0432\u043e\u0441\u0442\u043e\u0440\u0433\u0435.<br \/>  \u041d\u0430\u0447\u043d\u0435\u043c!<\/p>\n<h2>\u041a\u0430\u043a \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442\u044b?<\/h2>\n<p>  \u0423\u0441\u043b\u043e\u0432\u0438\u043c\u0441\u044f, \u0447\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u0442\u044c \u0438\u0437 4\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432:<br \/>   \u2014 DomainModel \u2014 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0441\u0435\u0440\u0432\u0438\u0441\u044b \u0438 \u0432\u0441\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438, \u043e\u0434\u043d\u0438\u043c \u0441\u043b\u043e\u0432\u043e\u043c \u2014 \u043c\u043e\u0434\u0435\u043b\u044c;<br \/>   \u2014 Presentation \u2014 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043b\u043e\u0433\u0438\u043a\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u044f\u0449\u0443\u044e \u043e\u0442 \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f, \u0442.\u0435. \u0432\u0441\u0435 \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u0435\u043b\u0438, \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0439 \u0438 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b;<br \/>   \u2014 UI \u2014 Windows Forms \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043b\u0438\u0448\u044c \u0444\u043e\u0440\u043c\u044b (\u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432 \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0439) \u0438 \u043b\u043e\u0433\u0438\u043a\u0443 \u0437\u0430\u043f\u0443\u0441\u043a\u0430;<br \/>   \u2014 Tests \u2014 unit-\u0442\u0435\u0441\u0442\u044b.<\/p>\n<h2>\u0427\u0442\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u0432 Main()?<\/h2>\n<p>  \u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 Windows Forms \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code>private static void Main() {     Application.EnableVisualStyles();     Application.SetCompatibleTextRenderingDefault(false);     Application.Run(new MainForm()); \/\/ \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0437\u0430\u043f\u0443\u0441\u043a \u0444\u043e\u0440\u043c\u044b (\u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f) } <\/code><\/pre>\n<p>  \u041d\u043e \u043c\u044b \u0443\u0441\u043b\u043e\u0432\u0438\u043b\u0438\u0441\u044c, \u0447\u0442\u043e \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u0435\u043b\u0438 \u0431\u0443\u0434\u0443\u0442 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f\u043c\u0438, \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b, \u0447\u0442\u043e\u0431\u044b \u043a\u043e\u0434 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u043b \u043a\u0430\u043a-\u0442\u043e \u0442\u0430\u043a:<\/p>\n<pre><code>private static void Main() {     Application.EnableVisualStyles();     Application.SetCompatibleTextRenderingDefault(false);      var presenter = new LoginPresenter(new LoginForm(), new LoginService()); \/\/ Dependency Injection     presenter.Run(); } <\/code><\/pre>\n<p>  \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0432\u044b\u0439 \u044d\u043a\u0440\u0430\u043d:<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0411\u0430\u0437\u043e\u0432\u044b\u0435 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code>\/\/ \u043e\u0431\u0449\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0439 public interface IView {     void Show();     void Close(); } \/\/ \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u0435\u043b\u044c \u0431\u0443\u0434\u0435\u0442 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0441 \u0444\u043e\u0440\u043c\u043e\u0439 public interface ILoginView : IView {     string Username { get; }     string Password { get; }     event Action Login;      \/\/ \u0441\u043e\u0431\u044b\u0442\u0438\u0435 &quot;\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f&quot;     void ShowError(string errorMessage); } public interface IPresenter {     void Run(); } \/\/ \u0433\u043b\u0443\u043f\u0435\u0439\u0448\u0438\u0439 \u0441\u0435\u0440\u0432\u0438\u0441 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 public interface ILoginService {     bool Login(User user); \/\/ true - \u0443\u0441\u043f\u0435\u0448\u043d\u0430\u044f \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f, \u0438\u043d\u0430\u0447\u0435 false } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code>public class LoginPresenter : IPresenter {     private readonly ILoginView _view;     private readonly ILoginService _service;      public LoginPresenter(ILoginView view, ILoginService service)     {         _view = view;         _service = service;                      _view.Login += () =&gt; Login(_view.Username, _view.Password);     }      public void Run()     {         _view.Show();     }      private void Login(string username, string password)     {         if (username == null)             throw new ArgumentNullException(&quot;username&quot;);         if (password == null)             throw new ArgumentNullException(&quot;password&quot;);          var user = new User {Name = username, Password = password};         if (!_service.Login(user))         {             _view.ShowError(&quot;Invalid username or password&quot;);         }         else         {             \/\/ \u0443\u0441\u043f\u0435\u0448\u043d\u0430\u044f \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f, \u0437\u0430\u043f\u0443\u0441\u043a \u0433\u043b\u0430\u0432\u043d\u043e\u0433\u043e \u044d\u043a\u0440\u0430\u043d\u0430 (?)         }     } } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0442\u044c \u0444\u043e\u0440\u043c\u0443 \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u043d\u0435\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 ILoginView \u043d\u0435 \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u0442 \u0442\u0440\u0443\u0434\u0430, \u043a\u0430\u043a \u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e ILoginService. \u0421\u043b\u0435\u0434\u0443\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c \u043e\u0434\u043d\u0443 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c:<\/p>\n<pre><code>public partial class LoginForm : Form, ILoginView {     \/\/ ...     public new void Show()     {         Application.Run(this);     } } <\/code><\/pre>\n<p>  \u042d\u0442\u043e \u0437\u0430\u043a\u043b\u0438\u043d\u0430\u043d\u0438\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043d\u0430\u0448\u0435\u043c\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c\u0441\u044f, \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c \u0444\u043e\u0440\u043c\u0443, \u0430 \u043f\u043e \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u0438 \u0444\u043e\u0440\u043c\u044b \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435. \u041d\u043e \u043a \u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u0435\u0449\u0435 \u0432\u0435\u0440\u043d\u0435\u043c\u0441\u044f.<\/p>\n<h2>\u0410 \u0442\u0435\u0441\u0442\u044b \u0431\u0443\u0434\u0443\u0442?<\/h2>\n<p>  \u0421 \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u0435\u043b\u044f (LoginPresenter), \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u0440\u0430\u0437\u0443 \u0436\u0435 \u0435\u0433\u043e \u043e\u0442-unit-\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u043d\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044f \u043d\u0438 \u0444\u043e\u0440\u043c\u044b, \u043d\u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u044b.<br \/>  \u0414\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0442\u0435\u0441\u0442\u043e\u0432 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 NUnit \u0438 NSubstitute (\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u043e\u0432-\u0437\u0430\u0433\u043b\u0443\u0448\u0435\u043a \u043f\u043e \u0438\u0445 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430\u043c, mock).<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0422\u0435\u0441\u0442\u044b \u0434\u043b\u044f LoginPresenter<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code>[TestFixture] public class LoginPresenterTests {     private ILoginView _view;      [SetUp]     public void SetUp()     {         _view = Substitute.For&lt;ILoginView&gt;();          \/\/ \u0437\u0430\u0433\u043b\u0443\u0448\u043a\u0430 \u0434\u043b\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f         var service = Substitute.For&lt;ILoginService&gt;(); \/\/ \u0437\u0430\u0433\u043b\u0443\u0448\u043a\u0430 \u0434\u043b\u044f \u0441\u0435\u0440\u0432\u0438\u0441\u0430         service.Login(Arg.Any&lt;User&gt;())                 \/\/ \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0443\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c admin\/password             .Returns(info =&gt; info.Arg&lt;User&gt;().Name == &quot;admin&quot; && info.Arg&lt;User&gt;().Password == &quot;password&quot;);         var presenter = new LoginPresenter(_view, service);         presenter.Run();     }      [Test]     public void InvalidUser()     {         _view.Username.Returns(&quot;Vladimir&quot;);         _view.Password.Returns(&quot;VladimirPass&quot;);         _view.Login += Raise.Event&lt;Action&gt;();         _view.Received().ShowError(Arg.Any&lt;string&gt;()); \/\/ \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u044b\u0437\u0432\u0430\u0442\u044c\u0441\u044f \u0441 \u0442\u0435\u043a\u0441\u0442\u043e\u043c \u043e\u0448\u0438\u0431\u043a\u0438     }      [Test]     public void ValidUser()     {         _view.Username.Returns(&quot;admin&quot;);         _view.Password.Returns(&quot;password&quot;);         _view.Login += Raise.Event&lt;Action&gt;();         _view.DidNotReceive().ShowError(Arg.Any&lt;string&gt;()); \/\/ \u0430 \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u0441\u0435 \u041e\u041a     } } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  \u0422\u0435\u0441\u0442\u044b \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0433\u043b\u0443\u043f\u044b\u0435, \u043a\u0430\u043a \u043f\u043e\u043a\u0430 \u0438 \u0441\u0430\u043c\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435. \u041d\u043e \u0442\u0430\u043a \u0438\u043b\u0438 \u0438\u043d\u0430\u0447\u0435, \u043e\u043d\u0438 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u043f\u0440\u043e\u0439\u0434\u0435\u043d\u044b.<\/p>\n<h2>\u041a\u0442\u043e \u0438 \u043a\u0430\u043a \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442 \u0432\u0442\u043e\u0440\u043e\u0439 \u044d\u043a\u0440\u0430\u043d \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c?<\/h2>\n<p>  \u041a\u0430\u043a \u0432\u044b \u043c\u043e\u0433\u043b\u0438 \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u044f \u043d\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u043d\u0438\u043a\u0430\u043a\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u043f\u0440\u0438 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0439 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438. \u041a\u0430\u043a \u0436\u0435 \u043c\u043d\u0435 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0432\u0442\u043e\u0440\u043e\u0439 \u044d\u043a\u0440\u0430\u043d? \u041f\u0435\u0440\u0432\u043e\u0435 \u043d\u0430 \u0443\u043c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u044d\u0442\u043e:<\/p>\n<pre><code>\/\/ LoginPresenter: \u0443\u0441\u043f\u0435\u0448\u043d\u0430\u044f \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f var mainPresenter = new MainPresenter(new MainForm()); mainPresenter.Run(user); <\/code><\/pre>\n<p>  \u041d\u043e \u043c\u044b \u0443\u0441\u043b\u043e\u0432\u0438\u043b\u0438\u0441\u044c, \u0447\u0442\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u0435\u043b\u0438 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0437\u043d\u0430\u044e\u0442 \u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f\u0445 \u043a\u0440\u043e\u043c\u0435 \u0438\u0445 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432. \u0427\u0442\u043e \u0436\u0435 \u0434\u0435\u043b\u0430\u0442\u044c?<br \/>  \u041d\u0430 \u043f\u043e\u043c\u043e\u0449\u044c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u043f\u0430\u0442\u0442\u0435\u0440\u043d Application Controller (\u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u043e), \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f IoC-\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440, \u0437\u043d\u0430\u044e\u0449\u0438\u0439, \u043a\u0430\u043a \u043f\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0443 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438.<br \/>  \u041a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u0435\u043b\u044e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 (\u0441\u043d\u043e\u0432\u0430 DI) \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b:<\/p>\n<pre><code>public interface IApplicationController {     IApplicationController RegisterView&lt;TView, TImplementation&gt;()         where TImplementation : class, TView         where TView : IView;     IApplicationController RegisterService&lt;TService, TImplementation&gt;()         where TImplementation : class, TService;     void Run&lt;TPresenter&gt;()         where TPresenter : class, IPresenter; } <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433\u0430 \u0437\u0430\u043f\u0443\u0441\u043a \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0441\u0442\u0430\u043b \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<\/p>\n<pre><code>private static void Main() {     Application.EnableVisualStyles();     Application.SetCompatibleTextRenderingDefault(false);      \/\/ \u0432\u0441\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0432 \u043e\u0434\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435:     var controller = new ApplicationController(new LightInjectAdapder())         .RegisterView&lt;ILoginView, LoginForm&gt;()         .RegisterService&lt;ILoginService, StupidLoginService&gt;()         .RegisterView&lt;IMainView, MainForm&gt;();      controller.Run&lt;LoginPresenter&gt;(); } <\/code><\/pre>\n<p>  \u041f\u0430\u0440\u0443 \u0441\u043b\u043e\u0432 \u043e <code>new ApplicationController(new LightInjectAdapder())<\/code>. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 IoC-\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 LightInject, \u043d\u043e \u043d\u0435 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e, \u0430 \u0447\u0435\u0440\u0435\u0437 \u0430\u0434\u0430\u043f\u0442\u0435\u0440 (\u043f\u0430\u0442\u0442\u0435\u0440\u043d Adapter), \u0447\u0442\u043e\u0431\u044b \u0432 \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0441\u043c\u0435\u043d\u0438\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u0439, \u044f \u0441\u043c\u043e\u0433 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u043e\u0439 \u0430\u0434\u0430\u043f\u0442\u0435\u0440 \u0438 \u043d\u0435 \u043c\u0435\u043d\u044f\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430. \u0412\u0441\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0435\u0441\u0442\u044c \u0432 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 IoC-\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a, \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0443\u0442\u044c \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u043e.<br \/>  \u0420\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 <code>IPresenter&lt;TArg&gt;<\/code>, \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0449\u0438\u0439\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435\u043c, \u0447\u0442\u043e \u043c\u0435\u0442\u043e\u0434 Run \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440. \u0417\u0430\u0442\u0435\u043c \u0443\u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u043c\u0441\u044f \u043e\u0442 \u043d\u0435\u0433\u043e \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u043f\u0435\u0440\u0432\u043e\u043c\u0443 \u044d\u043a\u0440\u0430\u043d\u0443.<br \/>  \u0422\u0435\u043f\u0435\u0440\u044c, \u043d\u0435 \u0431\u0435\u0437 \u0433\u043e\u0440\u0434\u043e\u0441\u0442\u0438, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0432\u0442\u043e\u0440\u043e\u0439 \u044d\u043a\u0440\u0430\u043d, \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u044f \u0442\u0443\u0434\u0430 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f:<\/p>\n<pre><code>Controller.Run&lt;MainPresener, User&gt;(user); View.Close(); <\/code><\/pre>\n<p>  <\/p>\n<h2>\u041d\u0435\u043b\u044c\u0437\u044f \u043f\u0440\u043e\u0441\u0442\u043e \u0442\u0430\u043a \u0432\u0437\u044f\u0442\u044c \u0438 \u0437\u0430\u043a\u0440\u044b\u0442\u044c \u0444\u043e\u0440\u043c\u0443&#8230;<\/h2>\n<p>  \u041e\u0434\u0438\u043d \u0438\u0437 \u043f\u043e\u0434\u0432\u043e\u0434\u043d\u044b\u0445 \u043a\u0430\u043c\u043d\u0435\u0439 \u0441\u0432\u044f\u0437\u0430\u043d \u0441\u043e \u0441\u0442\u0440\u043e\u0447\u043a\u043e\u0439 <code>View.Close()<\/code>, \u043f\u043e\u0441\u043b\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u043b\u0430\u0441\u044c \u043f\u0435\u0440\u0432\u0430\u044f \u0444\u043e\u0440\u043c\u0430, \u0430 \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u043d\u0435\u0439 \u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435. \u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e <code>Application.Run(Form)<\/code> \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0446\u0438\u043a\u043b \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 Windows \u0438 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u0443\u044e \u0444\u043e\u0440\u043c\u0443 \u043a\u0430\u043a \u0433\u043b\u0430\u0432\u043d\u0443\u044e \u0444\u043e\u0440\u043c\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u042d\u0442\u043e \u0432\u044b\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432\u0435\u0448\u0430\u0435\u0442 <code>ExitThread<\/code> \u043d\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 <code>Form.Closed<\/code>, \u0447\u0442\u043e \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u044f \u0444\u043e\u0440\u043c\u044b.<br \/>  \u041e\u0431\u043e\u0439\u0442\u0438 \u0434\u0430\u043d\u043d\u0443\u044e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u043c\u043e\u0436\u043d\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438, \u043e\u0434\u0438\u043d \u0438\u0437 \u043d\u0438\u0445 \u2014 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043c\u0435\u0442\u043e\u0434\u0430: <code>Application.Run(ApplicationContext)<\/code>, \u0437\u0430\u0442\u0435\u043c \u0432\u043e\u0432\u0440\u0435\u043c\u044f \u043f\u043e\u0434\u043c\u0435\u043d\u044f\u044f \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>ApplicationContext.MainForm<\/code>. \u041f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u0444\u043e\u0440\u043c\u0430\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u041a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043e\u0431\u044a\u0435\u043a\u0442 (instance) ApplicationContext \u0438 \u0437\u0430\u0442\u0435\u043c \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0444\u043e\u0440\u043c\u044b (\u043e\u043f\u044f\u0442\u044c DI) \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u0435\u043b\u044f. \u041c\u0435\u0442\u043e\u0434\u044b \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0432\u044b\u0445 \u0434\u0432\u0443\u0445 \u044d\u043a\u0440\u0430\u043d\u043e\u0432 \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code>\/\/ LoginForm public new void Show() {     _context.MainForm = this;     Application.Run(_context); }  \/\/ MainForm public new void Show() {     _context.MainForm = this;     base.Show(); } <\/code><\/pre>\n<p>  <\/p>\n<h2>\u041c\u043e\u0434\u0430\u043b\u044c\u043d\u043e\u0435 \u043e\u043a\u043d\u043e<\/h2>\n<p>  \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043c\u043e\u0434\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043e\u043a\u043d\u0430 \u043d\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0437\u0430\u0442\u0440\u0443\u0434\u043d\u0435\u043d\u0438\u0439. \u041f\u043e \u043a\u043d\u043e\u043f\u043a\u0435 \u00ab\u0421\u043c\u0435\u043d\u0438\u0442\u044c \u0438\u043c\u044f\u00bb \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f <code>Controller.Run&lt;ChangeUsernamePresenter, User&gt;(user)<\/code>. \u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u044d\u0442\u043e\u0439 \u0444\u043e\u0440\u043c\u044b \u043e\u0442 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u2014 \u043e\u043d\u0430 \u043d\u0435 \u0433\u043b\u0430\u0432\u043d\u0430\u044f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0444\u043e\u0440\u043c\u0435 \u0434\u043b\u044f \u043f\u043e\u043a\u0430\u0437\u0430 \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f ApplicationContext:<\/p>\n<pre><code>public new void Show() {     ShowDialog(); } <\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u043e\u0431\u044b\u0447\u043d\u043e\u0435 \u043e\u043a\u043d\u043e, \u043c\u0435\u0442\u043e\u0434 \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c, \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u043d \u0443\u0436\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 Form.<\/p>\n<h2>\u041d\u0443 \u0438 \u043d\u0430\u043a\u0440\u0443\u0442\u0438\u043b\u0438\u2026 \u041a\u0430\u043a \u0442\u0435\u043f\u0435\u0440\u044c \u042d\u0422\u041e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c?<\/h2>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u043a\u0430\u0440\u043a\u0430\u0441 \u0433\u043e\u0442\u043e\u0432, \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0439 \u0444\u043e\u0440\u043c\u044b \u0441\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0448\u0430\u0433\u0430\u043c:  <\/p>\n<ol>\n<li>\u041f\u0438\u0448\u0435\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f, \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u041c\u043e\u0434\u0435\u043b\u0438 (\u0435\u0441\u043b\u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f).<\/li>\n<li>\u0420\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u0435\u043b\u044f, \u043f\u043e\u043f\u0443\u0442\u043d\u043e \u0440\u0435\u0448\u0438\u0432, \u0431\u0443\u0434\u0435\u043c \u043b\u0438 \u043c\u044b \u0432 \u043d\u0435\u0433\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u043b\u0438 \u043c\u043e\u0434\u0435\u043b\u044c.<\/li>\n<li>[\u041e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e] \u041f\u0438\u0448\u0435\u043c \u0442\u0435\u0441\u0442\u044b \u0434\u043b\u044f \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u0435\u043b\u044f, \u0443\u0431\u0435\u0436\u0434\u0430\u0435\u043c\u0441\u044f, \u0447\u0442\u043e \u0432\u0441\u0435 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e.<\/li>\n<li>[\u041e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e] \u0420\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u041c\u043e\u0434\u0435\u043b\u044c \u0438 \u0442\u0435\u0441\u0442\u044b \u0434\u043b\u044f \u043d\u0435\u0435.<\/li>\n<li>\u041d\u0430\u043a\u0438\u0434\u044b\u0432\u0430\u0435\u043c \u0444\u043e\u0440\u043c\u043e\u0447\u043a\u0438 \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f.<\/li>\n<\/ol>\n<p>  \u0421\u043c\u0435\u043d\u0430 IoC-\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u043d\u0430 \u0432\u0430\u0448 \u043b\u044e\u0431\u0438\u043c\u044b\u0439 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u0443\u0442\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 IContainer \u043a\u043b\u0430\u0441\u0441\u043e\u043c-\u0430\u0434\u0430\u043f\u0442\u0435\u0440\u043e\u043c.<\/p>\n<p>  \u0417\u0430\u0431\u0440\u0430\u0442\u044c \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u043c\u043e\u0436\u043d\u043e c <a href=\"https:\/\/github.com\/Dem0n13\/MVPWinFormsDemo\">Github<\/a> (\u0434\u043b\u044f \u0441\u0431\u043e\u0440\u043a\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u044b\u043a\u0430\u0447\u0430\u0442\u044c Nuget-\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438).<\/p>\n<p>  \u041d\u0430\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u043a \u0445\u043e\u0447\u0443 \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u0432\u0441\u0435, \u0447\u0442\u043e \u0437\u0434\u0435\u0441\u044c \u0431\u044b\u043b\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u043e \u2014 \u043b\u0438\u0448\u044c \u043e\u0434\u0438\u043d \u0438\u0437 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 MVP, \u043a\u043e\u0442\u043e\u0440\u044b\u0439, \u043a\u0430\u043a \u043c\u043d\u0435 \u043a\u0430\u0436\u0435\u0442\u0441\u044f, \u043e\u0431\u043b\u0430\u0434\u0430\u0435\u0442 \u043d\u0435\u043f\u043b\u043e\u0445\u043e\u0439 \u0433\u0438\u0431\u043a\u043e\u0441\u0442\u044c\u044e \u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c\u043e\u0441\u0442\u044c\u044e.<\/p>\n<h2>\u0411\u043e\u043d\u0443\u0441. \u0425\u043e\u0447\u0443 \u0435\u0449\u0435 \u043a\u0440\u0443\u0447\u0435, \u0431\u043e\u043b\u044c\u0448\u0435, \u0441\u043b\u043e\u0436\u043d\u0435\u0435!<\/h2>\n<p>  \u041d\u0430 \u044d\u0442\u043e\u043c \u044f \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u044e\u0441\u044c, \u0430 \u043f\u044b\u0442\u043b\u0438\u0432\u044b\u0435 \u0443\u043c\u044b \u043c\u043e\u0433\u0443\u0442 \u0438\u0434\u0442\u0438 \u0434\u0430\u043b\u044c\u0448\u0435:<br \/>   \u2014 \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u0435 \u041a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f (\u0443 \u043c\u0435\u043d\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442);<br \/>   \u2014 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0434\u043b\u044f \u043e\u0431\u043c\u0435\u043d\u0430 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0435\u0439 \u043c\u0435\u0436\u0434\u0443 \u0444\u043e\u0440\u043c\u0430\u043c\u0438 (\u0448\u0430\u0431\u043b\u043e\u043d Event Aggregator);<br \/>   \u2014 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0435 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0430\u043c \u043d\u0438\u0436\u0435<\/p>\n<h2>\u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438, \u0441\u0441\u044b\u043b\u043a\u0438<\/h2>\n<p>  <a href=\"http:\/\/www.rsdn.ru\/article\/patterns\/ModelViewPresenter.xml\">\u041f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u044f \u043f\u0440\u043e\u0447\u0435\u043b \u043f\u0440\u043e MVP<\/a><br \/>  <a href=\"http:\/\/martinfowler.com\/eaaDev\/PassiveScreen.html\">\u041c\u0430\u0440\u0442\u0438\u043d \u0424\u0430\u0443\u043b\u0435\u0440 \u043f\u0440\u043e Passive View<\/a><br \/>  <a href=\"http:\/\/martinfowler.com\/eaaCatalog\/applicationController.html\">\u041c\u0430\u0440\u0442\u0438\u043d \u0424\u0430\u0443\u043b\u0435\u0440 \u043f\u0440\u043e Application Controller<\/a><br \/>  <a href=\"http:\/\/lostechies.com\/derickbailey\/2009\/04\/18\/decoupling-workflow-and-forms-with-an-application-controller\/\">Application Controller \u0438 Event Aggregator<\/a><br \/>  <a href=\"http:\/\/dotnetslackers.com\/articles\/designpatterns\/The-Presenter-in-MVP-Implementations.aspx\">\u0415\u0449\u0435 \u043f\u0440\u043e Application Controller<\/a><br \/>  <a href=\"http:\/\/codebetter.com\/jeremymiller\/2007\/07\/26\/the-build-your-own-cab-series-table-of-contents\/\">\u0411\u043e\u043b\u044c\u0448\u0430\u044f \u0441\u0435\u0440\u0438\u044f \u0441\u0442\u0430\u0442\u0435\u0439 \u043f\u0440\u043e MVP \u0438 \u0432\u0441\u0435, \u0447\u0442\u043e \u0441 \u043d\u0438\u043c \u0441\u0432\u044f\u0437\u0430\u043d\u043e<\/a><br \/>  <a href=\"http:\/\/social.msdn.microsoft.com\/Forums\/en-US\/7a90333a-70ad-4fc8-ac33-affdcf75fb17\/advantages-of-the-mvp-design-pattern-with-delegates-used-my-microsoft-samples-versus-direct-call\">\u041f\u043e\u0447\u0435\u043c\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0432\u043c\u0435\u0441\u0442\u043e \u043f\u0440\u044f\u043c\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 Presenter<\/a>    \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/211899\/\"> http:\/\/habrahabr.ru\/post\/211899\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t\u0414\u043e\u0431\u0440\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0441\u0443\u0442\u043e\u043a!<br \/>  Model-View-Presenter \u2014 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0439 \u0448\u0430\u0431\u043b\u043e\u043d \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u0421 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0432\u0437\u0433\u043b\u044f\u0434\u0430 \u0432\u0441\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0440\u043e\u0441\u0442\u043e: \u0435\u0441\u0442\u044c \u041c\u043e\u0434\u0435\u043b\u044c (Model), \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432\u0441\u044e \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0443 \u044d\u043a\u0440\u0430\u043d\u0430; \u0412\u0438\u0434\/\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 (View), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u043d\u0430\u0435\u0442, \u043a\u0430\u043a \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c \u0442\u0435 \u0438\u043b\u0438 \u0438\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435; \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u0435\u043b\u044c (Presenter), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0432\u044f\u0437\u0443\u044e\u0449\u0438\u0439 \u0437\u0432\u0435\u043d\u043e\u043c \u2014 \u0440\u0435\u0430\u0433\u0438\u0440\u0443\u0435\u0442 \u043d\u0430 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432\u043e View, \u0438\u0437\u043c\u0435\u043d\u044f\u044f Model, \u0438 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442.<br \/>  \u0421\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f, \u043a\u043e\u0433\u0434\u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0444\u043e\u0440\u043c \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u043e\u0434\u043d\u043e\u0439.<br \/>  <b>\u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u0442\u0441\u044f:<\/b><br \/>   \u2014 \u043d\u0435\u043c\u043d\u043e\u0436\u043a\u043e \u0442\u0435\u043e\u0440\u0438\u0438;<br \/>   \u2014 \u043e\u0431\u0449\u0438\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 MVP (\u0430 \u0438\u043c\u0435\u043d\u043d\u043e Passive View) \u043f\u043e\u0434 Windows Forms;<br \/>   \u2014 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u043e\u0432 \u043c\u0435\u0436\u0434\u0443 \u0444\u043e\u0440\u043c\u0430\u043c\u0438 \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, \u043c\u043e\u0434\u0430\u043b\u044c\u043d\u044b\u0435 \u043e\u043a\u043d\u0430;<br \/>   \u2014 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 IoC-\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u0430 Dependency Injection \u2014 DI (\u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u0421onstructor Injection);<br \/>   \u2014 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f MVP \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f (\u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c NUnit \u0438 NSubstitute);<br \/>   \u2014 \u0432\u0441\u0435 \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442\u044c \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043c\u0438\u043d\u0438-\u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0438 \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u0435\u0442\u0441\u044f \u0431\u044b\u0442\u044c \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u044b\u043c.<br \/>  <b>\u0412 \u0441\u0442\u0430\u0442\u044c\u0435 \u0437\u0430\u0442\u0440\u0430\u0433\u0438\u0432\u0430\u0435\u0442\u0441\u044f:<\/b><br \/>   \u2014 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u0410\u0434\u0430\u043f\u0442\u0435\u0440 (Adapter);<br \/>   \u2014 \u043f\u0440\u043e\u0441\u0442\u0435\u043d\u044c\u043a\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u041a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f (Application Controller).<br \/>  <b>\u0414\u043b\u044f \u043a\u043e\u0433\u043e \u044d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f?<\/b><br \/>  \u0413\u043b\u0430\u0432\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0434\u043b\u044f \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u0445 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u043d\u0430 Windows Forms, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043b\u044b\u0448\u0430\u043b\u0438, \u043d\u043e \u043d\u0435 \u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b\u0438, \u0438\u043b\u0438 \u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b\u0438, \u043d\u043e \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c. \u0425\u043e\u0442\u044f \u0443\u0432\u0435\u0440\u0435\u043d, \u0447\u0442\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0438\u0435\u043c\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c\u044b \u0438 \u0434\u043b\u044f WPF, \u0438 \u0434\u0430\u0436\u0435 \u0434\u043b\u044f \u0432\u0435\u0431-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438.  <\/p>\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-211899","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/211899","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=211899"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/211899\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=211899"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=211899"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=211899"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}