{"id":316072,"date":"2021-01-08T03:00:16","date_gmt":"2021-01-08T03:00:16","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=316072"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=316072","title":{"rendered":"\u041a\u0430\u043a \u044f \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b MVC \u0432 JavaScript"},"content":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<h2>\u2026\u0434\u043b\u044f \u043b\u0443\u0447\u0448\u0435\u0439 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u043e\u0441\u0442\u0438 \u043a\u043e\u0434\u0430<\/h2>\n<blockquote>\n<p><strong>\u0414\u043b\u044f \u0431\u0443\u0434\u0443\u0449\u0438\u0445 \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u043e\u0432 <\/strong><a href=\"https:\/\/otus.pw\/NFmz\/\"><strong>\u043a\u0443\u0440\u0441\u0430 &#171;\u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u044b \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f&#187;<\/strong><\/a><strong> \u0438 \u0432\u0441\u0435\u0445 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0449\u0438\u0445\u0441\u044f \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0433\u043e \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0430.<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043f\u0440\u0438\u0433\u043b\u0430\u0448\u0430\u0435\u043c \u043f\u043e\u0441\u0435\u0442\u0438\u0442\u044c <\/strong><a href=\"https:\/\/otus.pw\/0BGae\/\"><strong>\u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0439 \u0432\u0435\u0431\u0438\u043d\u0430\u0440 \u043d\u0430 \u0442\u0435\u043c\u0443 &#171;\u0418\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440&#187;.<\/strong><\/a><strong> <\/strong>\u041d\u0430 \u043d\u0435\u043c \u0431\u0443\u0434\u0443\u0442 \u043e\u0431\u0441\u0443\u0436\u0434\u0430\u0442\u044c\u0441\u044f \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0448\u0430\u0431\u043b\u043e\u043d\u0430 &#171;\u0418\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440&#187;, \u0444\u043e\u0440\u043c\u044b \u0411\u0435\u043a\u0443\u0441\u0430-\u041d\u0430\u0443\u044d\u0440\u0430, \u043b\u0435\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439, \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0438 \u0441\u0435\u043c\u0430\u043d\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u043d\u0430\u043b\u0438\u0437\u044b. <\/p>\n<\/blockquote>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/fa5\/899\/86b\/fa589986b451312dd7353897b9ca2dd0\" width=\"780\" height=\"439\"><figcaption><\/figcaption><\/figure>\n<hr>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f8f\/aed\/3fe\/f8faed3fe61f6c8236ab924bf5218110.png\" width=\"1244\" height=\"615\"><figcaption><\/figcaption><\/figure>\n<h3>\u0427\u0442\u043e \u0438\u0437 \u0441\u0435\u0431\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043d\u044b\u0439 \u043f\u0430\u0442\u0442\u0435\u0440\u043d Model, View, Controller (MVC)?<\/h3>\n<p><em>\u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a: <\/em><a href=\"https:\/\/api.rubyonrails.org\/?ref=hackernoon.com\"><em><u>\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f Rails<\/u><\/em><\/a><\/p>\n<p>\u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 MVC \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u0442 \u0432\u0430\u0448 \u043a\u043e\u0434 \u043d\u0430 \u0442\u0440\u0438 (3) \u0443\u0440\u043e\u0432\u043d\u044f: \u043c\u043e\u0434\u0435\u043b\u0438 (Models), \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f (Views) \u0438 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u044b (Controllers), \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0449\u0438\u0435 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u0432\u043d\u0443\u0442\u0440\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/dc7\/07f\/7b1\/dc707f7b1908830410baacdf5814ef20\" alt=\"\u0418\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432\u0437\u044f\u0442\u043e \u0438\u0437 \u0412\u0438\u043a\u0438\u043f\u0435\u0434\u0438\u0438\" title=\"\u0418\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432\u0437\u044f\u0442\u043e \u0438\u0437 \u0412\u0438\u043a\u0438\u043f\u0435\u0434\u0438\u0438\" width=\"300\" height=\"330\"><figcaption>\u0418\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432\u0437\u044f\u0442\u043e \u0438\u0437 \u0412\u0438\u043a\u0438\u043f\u0435\u0434\u0438\u0438<\/figcaption><\/figure>\n<\/p>\n<p><strong>\u0423\u0440\u043e\u0432\u0435\u043d\u044c \u043c\u043e\u0434\u0435\u043b\u0438<\/strong><\/p>\n<p>\u0412 Ruby on Rails \u044d\u0442\u043e\u0442 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043d\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0431\u044b\u0447\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0427\u0435\u043b\u043e\u0432\u0435\u043a, \u0416\u0438\u0432\u043e\u0442\u043d\u043e\u0435, \u041a\u043d\u0438\u0433\u0438). \u041e\u0431\u044b\u0447\u043d\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u0437\u0434\u0435\u0441\u044c \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0430, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u043e\u0434\u0435\u043b\u044c \u0441\u0432\u044f\u0437\u0430\u043d\u0430 \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445, \u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u043d\u0435\u0435 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u044e\u0442\u0441\u044f \u0438\u0437 \u0441\u0442\u0440\u043e\u043a \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b.<\/p>\n<p><strong>\u0423\u0440\u043e\u0432\u0435\u043d\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f<\/strong><\/p>\n<p>\u041e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043e\u0442\u0432\u0435\u0442\u043e\u0432, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0445 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430\u043c\u0438. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u043c\u043e\u0436\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 HTML, XML, JSON \u0438 \u0442. \u0434.<\/p>\n<p><strong>\u0423\u0440\u043e\u0432\u0435\u043d\u044c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430<\/strong><\/p>\n<p>\u0412 Rails \u044d\u0442\u043e\u0442 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0441 \u043c\u043e\u0434\u0435\u043b\u044c\u044e, \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0435\u0435 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0438 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \u043d\u0430 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 HTTP-\u0437\u0430\u043f\u0440\u043e\u0441\u044b.<\/p>\n<h3>\u041a\u0430\u043a \u0431\u044b \u043f\u0430\u0442\u0442\u0435\u0440\u043d MVC \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u043b \u0432 JavaScript?<\/h3>\n<p><em>\u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a: <\/em><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Glossary\/MVC?ref=hackernoon.com\"><em><u>\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f MDN<\/u><\/em><\/a><\/p>\n<p>\u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 JavaScript \u043e\u0431\u044b\u0447\u043d\u043e \u043d\u0435 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u0430\u0437 \u0434\u0430\u043d\u043d\u044b\u0445 (\u0445\u043e\u0442\u044f \u0438 \u043c\u043e\u0436\u0435\u0442) \u0438\u043b\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 HTTP-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 (\u043e\u043f\u044f\u0442\u044c \u0436\u0435, \u043c\u043e\u0436\u0435\u0442), \u043f\u0430\u0442\u0442\u0435\u0440\u043d MVC \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u043b \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0435 \u044f\u0437\u044b\u043a\u0430.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b8c\/812\/c39\/b8c812c393578a5796dc9f798eddd9ea\" alt=\"\u0418\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432\u0437\u044f\u0442\u043e \u0441 MDN\" title=\"\u0418\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432\u0437\u044f\u0442\u043e \u0441 MDN\" width=\"1600\" height=\"1200\"><figcaption>\u0418\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432\u0437\u044f\u0442\u043e \u0441 MDN<\/figcaption><\/figure>\n<h3>\u0423\u0440\u043e\u0432\u0435\u043d\u044c \u043c\u043e\u0434\u0435\u043b\u0438<\/h3>\n<p>\u0423\u0440\u043e\u0432\u043d\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u0438 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0441\u043b\u0443\u0436\u0438\u0442\u044c \u0434\u0430\u0436\u0435 \u0447\u0442\u043e-\u0442\u043e \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0435, \u043a\u0430\u043a \u043c\u0430\u0441\u0441\u0438\u0432, \u043d\u043e \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043a\u0430\u043a\u043e\u0439-\u043d\u0438\u0431\u0443\u0434\u044c \u043a\u043b\u0430\u0441\u0441. \u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u043e\u0434\u0435\u043b\u0435\u0439, \u0438 \u044d\u0442\u0438 \u043a\u043b\u0430\u0441\u0441\u044b (\u043c\u043e\u0434\u0435\u043b\u0438) \u0431\u0443\u0434\u0443\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p>\u0412\u043e\u0437\u044c\u043c\u0435\u043c, \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 Classroom, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0435\u0442, \u043a\u0430\u043a\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u043f\u043e\u0441\u0435\u0449\u0430\u0435\u0442 \u0447\u0435\u043b\u043e\u0432\u0435\u043a. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u043c\u043e\u0434\u0435\u043b\u0438 \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0430 \u043a\u043b\u0430\u0441\u0441\u044b, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a <code>Classroom<\/code>, <code>Person<\/code> \u0438 \u043c\u043e\u0434\u0435\u043b\u044c \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c <code>Subjects<\/code>.<\/p>\n<h3>\u0411\u0430\u0437\u043e\u0432\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u043c\u043e\u0434\u0435\u043b\u0438<\/h3>\n<pre><code class=\"javascript\">class Classroom {   constructor(id, subject = 'Homeroom') {     this.id = id;     this.persons = [];     this.subject = subject;   } }<\/code><\/pre>\n<p>\u041c\u043e\u0434\u0435\u043b\u044c <code>Classroom<\/code> \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u043a\u043b\u0430\u0441\u0441\u0443. \u0421\u044e\u0434\u0430 \u0431\u0443\u0434\u0443\u0442 \u0432\u0445\u043e\u0434\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u043b\u044e\u0434\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u0447\u0438\u0441\u043b\u044f\u0442\u0441\u044f \u0432 \u044d\u0442\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435, \u043f\u0440\u0435\u0434\u043c\u0435\u0442, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0439 \u0441 \u044d\u0442\u0438\u043c \u043a\u043b\u0430\u0441\u0441\u043e\u043c, \u0438 \u0435\u0433\u043e <code>id<\/code>.<\/p>\n<pre><code class=\"javascript\">class Person {   constructor(id, firstN = 'John', lastN = 'Doe') {     this.id = id;     this.firstName = firstN;     this.lastName = lastN;     this.subjects = [];     this.classrooms = [];   } }<\/code><\/pre>\n<p>\u041c\u043e\u0434\u0435\u043b\u044c <code>Person<\/code> \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043a\u0430\u0436\u0434\u043e\u043c \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0435. \u0421\u044e\u0434\u0430 \u0431\u0443\u0434\u0443\u0442 \u0432\u0445\u043e\u0434\u0438\u0442\u044c \u0435\u0433\u043e \u0438\u043c\u044f \u0438 \u0444\u0430\u043c\u0438\u043b\u0438\u044f, \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043d \u0438\u0437\u0443\u0447\u0430\u0435\u0442, \u0438 \u043a\u043b\u0430\u0441\u0441\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043d \u043f\u043e\u0441\u0435\u0449\u0430\u0435\u0442.<\/p>\n<pre><code class=\"javascript\">const subjects = [   \"English\",   \"Math\",   \"Computer Science\",   \"Business\",   \"Finance\",   \"Home Economics\" ];<\/code><\/pre>\n<p>\u041c\u043e\u0434\u0435\u043b\u044c <code>Subjects<\/code> \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u044f \u043d\u0435 \u0441\u043e\u0431\u0438\u0440\u0430\u044e\u0441\u044c \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u0442\u044c \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c\u044e \u0434\u0438\u0441\u0446\u0438\u043f\u043b\u0438\u043d.<\/p>\n<h3>\u0423\u0440\u043e\u0432\u0435\u043d\u044c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430<\/h3>\n<p>\u041a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u043a\u043b\u0430\u0441\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0442\u0440\u0430\u043d\u0441\u043b\u0438\u0440\u0443\u0435\u0442 \u0432\u0432\u043e\u0434\u0438\u043c\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u0438.<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 Classroom \u2014 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435, \u0432\u0432\u043e\u0434\u0438\u043c\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c, \u043e\u0442 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a \u0432\u0432\u043e\u0434 \u0442\u0435\u043a\u0441\u0442\u0430 (<code>text input<\/code>) \u0438\u043b\u0438 \u0432\u044b\u0431\u043e\u0440 \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430 \u043e\u043f\u0446\u0438\u0439 (<code>select options<\/code>), \u0430 \u0442\u0430\u043a\u0436\u0435 \u043d\u0430\u0436\u0430\u0442\u0438\u044f \u043a\u043d\u043e\u043f\u043e\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438.<\/p>\n<pre><code class=\"javascript\">import classroomModel from \"..\/models\/classroom\";  class ClassroomController {   constructor() {     this.lastID = 0;     this.classrooms = [];     this.selectedClass = null;   }    selectClassroom(classroomID) {     this.selectedClass = this.classrooms     .filter(c =&gt; c.id === parseInt(classroomID, 10))[0];   }    addClassroom(subject) {     this.classrooms.push(       new classroomModel(this.lastID, subject)       );     this.lastID += 1;   }    removeClassroom(classroomID) {     this.classrooms = this.classrooms       .filter(c =&gt; c.id !== parseInt(classroomID, 10));   }    setSubject(subject, classroomID) {     const classroom = this.classrooms       .filter(c =&gt; c.id === parseInt(classroomID, 10))[0];     classroom.subject = subject;   }    addPerson(person, classroom) {     \/\/ const classroom = this.classrooms     \/\/ .filter(c =&gt; c.id === parseInt(classroomID, 10))[0];     if (!person) return;     classroom.addPerson(person);   }    removePerson(person, classroomID) {     const classroom = this.classrooms     .filter(c =&gt; c.id === parseInt(classroomID, 10))[0];     classroom.removePerson(person);   } }<\/code><\/pre>\n<p>\u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 <code>ClassroomController<\/code> \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u043a\u0430\u043a \u0442\u0430\u0431\u043b\u0438\u0446\u0443 (\u0435\u0441\u043b\u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c \u0441 \u0442\u0435\u043c, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 Rails), \u0438 \u043a\u0430\u0436\u0434\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0432 \u044d\u0442\u043e\u0439 \u00ab\u0442\u0430\u0431\u043b\u0438\u0446\u0435\u00bb \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u0443\u044e \u0441 \u043a\u0430\u0436\u0434\u044b\u043c \u0443\u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0430.<\/p>\n<p>\u042d\u0442\u043e\u0442 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u0438\u043c\u0435\u0435\u0442 \u0442\u0440\u0438 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435: \u00ab<code>lastID<\/code>\u00bb (\u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u043e\u0431\u044a\u0435\u043a\u0442 \u043a\u043b\u0430\u0441\u0441\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a \u043c\u0430\u0441\u0441\u0438\u0432\u0443 \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f), \u00ab<code>classrooms<\/code>\u00bb (\u043c\u0430\u0441\u0441\u0438\u0432 \u0432\u0441\u0435\u0445 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043a\u043b\u0430\u0441\u0441\u0430) \u0438 \u00ab<code>selectedClass<\/code>\u00bb.<\/p>\n<h3>\u0423\u0440\u043e\u0432\u0435\u043d\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f<\/h3>\n<p>\u042d\u0442\u043e\u0442 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u042d\u0442\u043e\u0442 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043a\u043b\u0430\u0441\u0441\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u0432\u0438\u0434\u0435\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0441 \u043d\u0438\u043c\u0438.<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 Classroom \u2014 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/Document_Object_Model\/Introduction?ref=hackernoon.com\"><u>DOM<\/u><\/a><u> <\/u><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/Document_Object_Model\/Introduction?ref=hackernoon.com\"><u>(\u043e\u0431\u044a\u0435\u043a\u0442\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430)<\/u>,<\/a> \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a \u043a\u043d\u043e\u043f\u043a\u0438, \u0438\u043d\u043f\u0443\u0442\u044b \u0438 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u044b (&lt;div\/&gt;, &lt;span\/ &gt;, &lt;p\/&gt;\u2026 \u0438 \u0442. \u0434.) \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043b\u044e\u0434\u0435\u0439 \u0438 \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u0438 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0441 \u043d\u0438\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/3e9\/031\/9ed\/3e90319ed824d31df7ad62e463ec06a7\" width=\"748\" height=\"767\"><figcaption><\/figcaption><\/figure>\n<pre><code class=\"javascript\">import classroomController from \"..\/controllers\/classroom\"; import subjects from \"..\/models\/subjects\";  class ClassroomView {   constructor(appDiv) {     this.classroomController = new classroomController();     this.classroomSectionDiv = document.createElement('div');     this.classroomsDiv = document.createElement('div');     this.addclassBtn = document.createElement('button');     this.selectSubjectInput = document.createElement('select');      this.classroomSectionDiv.classList.add('classroom-section');     this.classroomsDiv.classList.add('classroom-container');     this.selectSubjectInput.innerHTML = subjects.map((option, index) =&gt; (       `&lt;option key=${index} value=${option}&gt;${option.toUpperCase()}&lt;\/option&gt;`     ));     this.addclassBtn.textContent = 'New Class';     this.addclassBtn.addEventListener('click', () =&gt; this.addClassroom());     this.classroomSectionDiv.append(       this.classroomsDiv, this.selectSubjectInput,       this.addclassBtn,       );     appDiv.appendChild(this.classroomSectionDiv);   }    updateView() {     const { classroomController, classroomsDiv } = this;     const allClassrooms = classroomController.classrooms.map(       c =&gt; {         const removeBtn = document.createElement('button');         const classDiv = document.createElement('div');         classDiv.classList.add('classroom');         if (classroomController.selectedClass === c) {           classDiv.classList.add('selected');         }         classDiv.addEventListener('click', () =&gt; this.selectClassroom(classDiv.getAttribute('data-classroom-id')));         classDiv.setAttribute('data-classroom-id', c.id);         removeBtn.addEventListener('click', () =&gt; this.removeClassroom(removeBtn.getAttribute('data-classroom-id')));         removeBtn.setAttribute('data-classroom-id', c.id);         removeBtn.classList.add('remove-btn');         removeBtn.textContent= 'remove';         const allPersons = c.persons.map(p =&gt; (           `&lt;div class=\"person-inline\"&gt;             &lt;span class=\"fname\"&gt;${p.firstName}&lt;\/span&gt;             &lt;span class=\"lname\"&gt;${p.lastName}&lt;\/span&gt;             &lt;span class=\"${p.occupation}\"&gt;${p.occupation}&lt;\/span&gt;           &lt;\/div&gt;`         ));         classDiv.innerHTML = `&lt;div class=\"m-b\"&gt;             &lt;span class=\"id\"&gt;${c.id}&lt;\/span&gt;             &lt;span class=\"subject\"&gt;${c.subject}&lt;\/span&gt;&lt;\/div&gt;             &lt;div class=\"all-persons\"&gt;${allPersons.join('')}&lt;\/div&gt;`;         classDiv.appendChild(removeBtn);         return classDiv;       }     );     classroomsDiv.innerHTML='';     allClassrooms.map(div =&gt; classroomsDiv.append(div));   }      selectClassroom(classroomID) {     const { classroomController } = this;     classroomController.selectClassroom(classroomID);      this.updateView();   }    addClassroom() {     const {       classroomController,       selectSubjectInput,     } = this;     const subjectChosen = selectSubjectInput.value;     classroomController.addClassroom(subjectChosen);     this.updateView();   }    removeClassroom(classroomID) {     const { classroomController } = this;     classroomController.removeClassroom(classroomID);     this.updateView();   }    addPerson(person, classroomID) {     const { classroomController } = this;     classroomController.addPerson(person, classroomID);     this.updateView();   } }<\/code><\/pre>\n<p>\u041a\u043b\u0430\u0441\u0441 <code>ClassroomView<\/code> \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u0432\u044f\u0437\u0430\u043d\u0430 \u0441 <code>ClassroomController<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0443\u0440\u043e\u0432\u043d\u044e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043e\u0431\u0449\u0430\u0442\u044c\u0441\u044f \u0441 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u043c.<\/p>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f <code>updateView()<\/code> \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c. \u042d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 \u0432 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b DOM \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u043c\u0438 \u0438\u0437 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438.<\/p>\n<p>\u0412\u0441\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u044e\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438\u0437 UI \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 DOM \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442 \u0438\u0445 \u043a\u0430\u043a \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430. \u0424\u0443\u043d\u043a\u0446\u0438\u0438 <code>selectClassroom()<\/code>, <code>addClassroom()<\/code> \u0438 <code>removeClassroom()<\/code> \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043a \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c DOM \u0447\u0435\u0440\u0435\u0437 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>updateView()<\/code> \u043a\u0430\u043a \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0447\u0435\u0440\u0435\u0437 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>addEventListener()<\/code>.<\/p>\n<h3>\u0414\u043e\u0441\u0442\u0443\u043f \u043a\u043e \u0432\u0441\u0435\u043c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430\u043c \u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f<\/h3>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0434\u0432\u0430 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430, <code>ClassroomController<\/code> \u0438 <code>PersonController<\/code> (<a href=\"https:\/\/codesandbox.io\/s\/school-is-in-session-699ko?file=%2Fsrc%2Fcontrollers%2Fperson.js&amp;ref=hackernoon.com\"><u>\u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432 \u043f\u043e\u043b\u043d\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435<\/u><\/a>), \u0443 \u043d\u0430\u0441 \u0442\u0430\u043a\u0436\u0435 \u0431\u044b\u043b\u043e \u0431\u044b \u0434\u0432\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f, \u0438 \u0435\u0441\u043b\u0438 \u0431\u044b \u043c\u044b \u0445\u043e\u0442\u0435\u043b\u0438, \u0447\u0442\u043e\u0431\u044b \u044d\u0442\u0438 \u0434\u0432\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043c\u043e\u0433\u043b\u0438 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0434\u0440\u0443\u0433 \u0441 \u0434\u0440\u0443\u0433\u043e\u043c, \u043d\u0430\u043c \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0431\u044b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0435\u0434\u0438\u043d\u043e\u0435 \u0432\u0441\u0435\u043e\u0431\u044a\u0435\u043c\u043b\u044e\u0449\u0435\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435. \u041c\u044b \u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u043d\u0430\u0437\u0432\u0430\u0442\u044c \u044d\u0442\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 <code>AppView<\/code>.<\/p>\n<pre><code class=\"javascript\">import classroomView from '.\/classroom'; import personView from '.\/person';  class AppView {   constructor(appDiv) {     this.classroomView = new classroomView(appDiv);     this.personView = new personView(appDiv);     this.addPersonToClassBtn = document.createElement('button');      this.addPersonToClassBtn.textContent = 'Add selected Person to Selected Class';     this.addPersonToClassBtn.addEventListener('click', () =&gt; this.addPersonToClass());     appDiv.appendChild(this.addPersonToClassBtn);   }    addPersonToClass() {     const { classroomView, personView } = this;     const { classroomController } = classroomView;     const { personController } = personView;     const selectedClassroom = classroomController.selectedClass;     const selectedPerson = personController.selectedPerson;     classroomView.addPerson(selectedPerson, selectedClassroom);     personView.updateView();   } }<\/code><\/pre>\n<p>\u041a\u043b\u0430\u0441\u0441 <code>AppView<\/code> \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043a\u0430\u043a \u0441 <code>ClassroomView<\/code>, \u0442\u0430\u043a \u0438 \u0441 <code>PersonView<\/code>. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043e\u043d \u0438\u043c\u0435\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u044d\u0442\u0438\u043c \u0434\u0432\u0443\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f\u043c, \u043e\u043d \u0442\u0430\u043a\u0436\u0435 \u0438\u043c\u0435\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u0438 \u043a \u0438\u0445 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430\u043c.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/8da\/2c3\/55a\/8da2c355ab63c3523369758656b709a4\" width=\"420\" height=\"111\"><figcaption><\/figcaption><\/figure>\n<p>\u041a\u043d\u043e\u043f\u043a\u0430 \u0432\u044b\u0448\u0435 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f <code>AppView<\/code>. \u041e\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f <code>selectedClassroom<\/code> \u0438 <code>selectedPerson<\/code> \u0438\u0437 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u0432 \u0438 \u043f\u0440\u0438 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>addPerson()<\/code> \u0432 <code>ClassroomView<\/code>.<\/p>\n<p><a href=\"https:\/\/codesandbox.io\/s\/school-is-in-session-699ko?file=%2Fsrc%2Fcontrollers%2Fperson.js&amp;ref=hackernoon.com\"><em><u>\u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 Classroom, \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u0435 \u0432 CodeSandBox \u043f\u043e \u044d\u0442\u043e\u0439 \u0441\u0441\u044b\u043b\u043a\u0435<\/u><\/em><\/a><em><u>.<\/u><\/em><\/p>\n<h3>\u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b MVC<\/h3>\n<p><em>\u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438:<u> <\/u><\/em><a href=\"https:\/\/www.brainvire.com\/six-benefits-of-using-mvc-model-for-effective-web-application-development\/?ref=hackernoon.com\"><em><u>Brainvire<\/u><\/em><\/a><em><u>, <\/u><\/em><a href=\"https:\/\/www.c-sharpcorner.com\/blogs\/advantage-and-disadvantage-of-asp-net-mvc1?ref=hackernoon.com\"><em><u>c-sharpcorner<\/u><\/em><\/a><em><u>, <\/u><\/em><a href=\"https:\/\/stackoverflow.com\/questions\/102558\/biggest-advantage-to-using-asp-net-mvc-vs-web-forms?ref=hackernoon.com\"><em><u>StackOverflow<\/u><\/em><\/a><em><u>, <\/u><\/em><a href=\"https:\/\/en.wikipedia.org\/wiki\/Model%E2%80%93view%E2%80%93controller?ref=hackernoon.com\"><em><u>Wikipedia<\/u><\/em><\/a><\/p>\n<p><strong>1. \u0420\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043e\u0431\u044f\u0437\u0430\u043d\u043d\u043e\u0441\u0442\u0435\u0439<\/strong><\/p>\n<p>\u0412\u0435\u0441\u044c \u043a\u043e\u0434, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0439 \u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u043c, \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c. \u0412\u0441\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u0441\u044f \u0432 \u043c\u043e\u0434\u0435\u043b\u0438, \u0430 \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u0438\u0437\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430.<\/p>\n<p><strong>2. \u041e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430<\/strong><\/p>\n<p>\u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u043e\u0434\u0435\u043b\u044c MVC \u0447\u0435\u0442\u043a\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u0442 \u043f\u0440\u043e\u0435\u043a\u0442 \u043d\u0430 \u0442\u0440\u0438 (3) \u0443\u0440\u043e\u0432\u043d\u044f, \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0449\u0435 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c \u0438 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0438 \u043c\u0435\u0436\u0434\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c\u0438.<\/p>\n<p><strong>3. \u041f\u0440\u043e\u0441\u0442\u043e\u0442\u0430 \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438<\/strong><\/p>\n<p>\u041c\u043e\u0436\u043d\u043e \u043b\u0435\u0433\u043a\u043e \u0432\u043d\u043e\u0441\u0438\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u0443\u0440\u043e\u0432\u043d\u0435, \u043d\u0435 \u0437\u0430\u0442\u0440\u0430\u0433\u0438\u0432\u0430\u044f \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0443\u0440\u043e\u0432\u043d\u0438.<\/p>\n<p><strong>4. \u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0447\u0435\u0440\u0435\u0437 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 (TDD)<\/strong><\/p>\n<p>\u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0447\u0435\u0442\u043a\u043e\u043c\u0443 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u044e \u043e\u0431\u044f\u0437\u0430\u043d\u043d\u043e\u0441\u0442\u0435\u0439 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e.<\/p>\n<hr>\n<blockquote>\n<p><a href=\"https:\/\/otus.pw\/NFmz\/\"><strong>\u0423\u0437\u043d\u0430\u0442\u044c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435<\/strong><\/a><strong> \u043e \u043a\u0443\u0440\u0441\u0435 &#171;\u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u044b \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f&#187;.<\/p>\n<p><\/strong><a href=\"https:\/\/otus.pw\/0BGae\/\"><strong>\u0417\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f<\/strong><\/a><strong> \u043d\u0430 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0439 \u0432\u0435\u0431\u0438\u043d\u0430\u0440 \u043d\u0430 \u0442\u0435\u043c\u0443 &#171;\u0418\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440&#187;.<\/strong><\/p>\n<\/blockquote>\n<p>\u041f\u0440\u044f\u043c\u043e \u0441\u0435\u0439\u0447\u0430\u0441 \u0432 OTUS \u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0442 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0435 \u043d\u043e\u0432\u043e\u0433\u043e\u0434\u043d\u0438\u0435 \u0441\u043a\u0438\u0434\u043a\u0438 \u043d\u0430 \u0432\u0441\u0435 \u043a\u0443\u0440\u0441\u044b. \u041e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441 \u043f\u043e\u043b\u043d\u044b\u043c \u0441\u043f\u0438\u0441\u043a\u043e\u043c \u043a\u0443\u0440\u0441\u043e\u0432 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 \u043d\u0438\u0436\u0435. \u0422\u0430\u043a\u0436\u0435 \u0443 \u0432\u0441\u0435\u0445 \u0436\u0435\u043b\u0430\u044e\u0449\u0438\u0445 \u0435\u0441\u0442\u044c \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u0430\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0430\u0434\u0440\u0435\u0441\u0430\u0442\u0443&nbsp;<a href=\"https:\/\/otus.ru\/gifts\/?utm_source=habr&amp;utm_medium=affilate&amp;utm_campaign=otus&amp;utm_term=new_yea_gifts_21.12.2020\">\u043f\u043e\u0434\u0430\u0440\u043e\u0447\u043d\u044b\u0439 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442 \u043d\u0430 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u0432 OTUS<\/a>.<\/p>\n<p><em>\u041a\u0441\u0442\u0430\u0442\u0438, \u043e &#171;\u043a\u0440\u0430\u0441\u0438\u0432\u043e\u0439 \u0443\u043f\u0430\u043a\u043e\u0432\u043a\u0435&#187; \u043e\u043d\u043b\u0430\u0439\u043d-\u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432 \u043c\u044b&nbsp;<\/em><a href=\"https:\/\/habr.com\/ru\/company\/otus\/blog\/533778\/\"><em>\u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435<\/em><\/a><em>.<\/em><\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/714\/ae5\/2ac\/714ae52ac4f7556fa6ee9926e0ea65b2.jpg\" width=\"780\" height=\"300\"><figcaption><\/figcaption><\/figure>\n<p><a href=\"https:\/\/otus.pw\/EipQ\/\"><strong>\u0417\u0410\u0411\u0420\u0410\u0422\u042c \u0421\u041a\u0418\u0414\u041a\u0423<\/strong><\/a><\/p>\n<\/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=\"https:\/\/habr.com\/ru\/company\/otus\/blog\/535784\/\"> https:\/\/habr.com\/ru\/company\/otus\/blog\/535784\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<h2>\u2026\u0434\u043b\u044f \u043b\u0443\u0447\u0448\u0435\u0439 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u043e\u0441\u0442\u0438 \u043a\u043e\u0434\u0430<\/h2>\n<blockquote>\n<p><strong>\u0414\u043b\u044f \u0431\u0443\u0434\u0443\u0449\u0438\u0445 \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u043e\u0432 <\/strong><a href=\"https:\/\/otus.pw\/NFmz\/\"><strong>\u043a\u0443\u0440\u0441\u0430 &#171;\u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u044b \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f&#187;<\/strong><\/a><strong> \u0438 \u0432\u0441\u0435\u0445 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0449\u0438\u0445\u0441\u044f \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0433\u043e \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0430.<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043f\u0440\u0438\u0433\u043b\u0430\u0448\u0430\u0435\u043c \u043f\u043e\u0441\u0435\u0442\u0438\u0442\u044c <\/strong><a href=\"https:\/\/otus.pw\/0BGae\/\"><strong>\u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0439 \u0432\u0435\u0431\u0438\u043d\u0430\u0440 \u043d\u0430 \u0442\u0435\u043c\u0443 &#171;\u0418\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440&#187;.<\/strong><\/a><strong> <\/strong>\u041d\u0430 \u043d\u0435\u043c \u0431\u0443\u0434\u0443\u0442 \u043e\u0431\u0441\u0443\u0436\u0434\u0430\u0442\u044c\u0441\u044f \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0448\u0430\u0431\u043b\u043e\u043d\u0430 &#171;\u0418\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440&#187;, \u0444\u043e\u0440\u043c\u044b \u0411\u0435\u043a\u0443\u0441\u0430-\u041d\u0430\u0443\u044d\u0440\u0430, \u043b\u0435\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439, \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0438 \u0441\u0435\u043c\u0430\u043d\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u043d\u0430\u043b\u0438\u0437\u044b. <\/p>\n<\/blockquote>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<hr>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<h3>\u0427\u0442\u043e \u0438\u0437 \u0441\u0435\u0431\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043d\u044b\u0439 \u043f\u0430\u0442\u0442\u0435\u0440\u043d Model, View, Controller (MVC)?<\/h3>\n<p><em>\u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a: <\/em><a href=\"https:\/\/api.rubyonrails.org\/?ref=hackernoon.com\"><em><u>\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f Rails<\/u><\/em><\/a><\/p>\n<p>\u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 MVC \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u0442 \u0432\u0430\u0448 \u043a\u043e\u0434 \u043d\u0430 \u0442\u0440\u0438 (3) \u0443\u0440\u043e\u0432\u043d\u044f: \u043c\u043e\u0434\u0435\u043b\u0438 (Models), \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f (Views) \u0438 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u044b (Controllers), \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0449\u0438\u0435 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u0432\u043d\u0443\u0442\u0440\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b.<\/p>\n<figure class=\"\"><figcaption>\u0418\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432\u0437\u044f\u0442\u043e \u0438\u0437 \u0412\u0438\u043a\u0438\u043f\u0435\u0434\u0438\u0438<\/figcaption><\/figure>\n<\/p>\n<p><strong>\u0423\u0440\u043e\u0432\u0435\u043d\u044c \u043c\u043e\u0434\u0435\u043b\u0438<\/strong><\/p>\n<p>\u0412 Ruby on Rails \u044d\u0442\u043e\u0442 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043d\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0431\u044b\u0447\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0427\u0435\u043b\u043e\u0432\u0435\u043a, \u0416\u0438\u0432\u043e\u0442\u043d\u043e\u0435, \u041a\u043d\u0438\u0433\u0438). \u041e\u0431\u044b\u0447\u043d\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u0437\u0434\u0435\u0441\u044c \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0430, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u043e\u0434\u0435\u043b\u044c \u0441\u0432\u044f\u0437\u0430\u043d\u0430 \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445, \u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u043d\u0435\u0435 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u044e\u0442\u0441\u044f \u0438\u0437 \u0441\u0442\u0440\u043e\u043a \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b.<\/p>\n<p><strong>\u0423\u0440\u043e\u0432\u0435\u043d\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f<\/strong><\/p>\n<p>\u041e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043e\u0442\u0432\u0435\u0442\u043e\u0432, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0445 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430\u043c\u0438. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u043c\u043e\u0436\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 HTML, XML, JSON \u0438 \u0442. \u0434.<\/p>\n<p><strong>\u0423\u0440\u043e\u0432\u0435\u043d\u044c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430<\/strong><\/p>\n<p>\u0412 Rails \u044d\u0442\u043e\u0442 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0441 \u043c\u043e\u0434\u0435\u043b\u044c\u044e, \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0435\u0435 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0438 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \u043d\u0430 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 HTTP-\u0437\u0430\u043f\u0440\u043e\u0441\u044b.<\/p>\n<h3>\u041a\u0430\u043a \u0431\u044b \u043f\u0430\u0442\u0442\u0435\u0440\u043d MVC \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u043b \u0432 JavaScript?<\/h3>\n<p><em>\u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a: <\/em><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Glossary\/MVC?ref=hackernoon.com\"><em><u>\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f MDN<\/u><\/em><\/a><\/p>\n<p>\u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 JavaScript \u043e\u0431\u044b\u0447\u043d\u043e \u043d\u0435 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u0430\u0437 \u0434\u0430\u043d\u043d\u044b\u0445 (\u0445\u043e\u0442\u044f \u0438 \u043c\u043e\u0436\u0435\u0442) \u0438\u043b\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 HTTP-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 (\u043e\u043f\u044f\u0442\u044c \u0436\u0435, \u043c\u043e\u0436\u0435\u0442), \u043f\u0430\u0442\u0442\u0435\u0440\u043d MVC \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u043b \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0435 \u044f\u0437\u044b\u043a\u0430.<\/p>\n<figure class=\"full-width\"><figcaption>\u0418\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432\u0437\u044f\u0442\u043e \u0441 MDN<\/figcaption><\/figure>\n<h3>\u0423\u0440\u043e\u0432\u0435\u043d\u044c \u043c\u043e\u0434\u0435\u043b\u0438<\/h3>\n<p>\u0423\u0440\u043e\u0432\u043d\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u0438 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0441\u043b\u0443\u0436\u0438\u0442\u044c \u0434\u0430\u0436\u0435 \u0447\u0442\u043e-\u0442\u043e \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0435, \u043a\u0430\u043a \u043c\u0430\u0441\u0441\u0438\u0432, \u043d\u043e \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043a\u0430\u043a\u043e\u0439-\u043d\u0438\u0431\u0443\u0434\u044c \u043a\u043b\u0430\u0441\u0441. \u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u043e\u0434\u0435\u043b\u0435\u0439, \u0438 \u044d\u0442\u0438 \u043a\u043b\u0430\u0441\u0441\u044b (\u043c\u043e\u0434\u0435\u043b\u0438) \u0431\u0443\u0434\u0443\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p>\u0412\u043e\u0437\u044c\u043c\u0435\u043c, \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 Classroom, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0435\u0442, \u043a\u0430\u043a\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u043f\u043e\u0441\u0435\u0449\u0430\u0435\u0442 \u0447\u0435\u043b\u043e\u0432\u0435\u043a. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u043c\u043e\u0434\u0435\u043b\u0438 \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0430 \u043a\u043b\u0430\u0441\u0441\u044b, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a <code>Classroom<\/code>, <code>Person<\/code> \u0438 \u043c\u043e\u0434\u0435\u043b\u044c \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c <code>Subjects<\/code>.<\/p>\n<h3>\u0411\u0430\u0437\u043e\u0432\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u043c\u043e\u0434\u0435\u043b\u0438<\/h3>\n<pre><code class=\"javascript\">class Classroom {   constructor(id, subject = 'Homeroom') {     this.id = id;     this.persons = [];     this.subject = subject;   } }<\/code><\/pre>\n<p>\u041c\u043e\u0434\u0435\u043b\u044c <code>Classroom<\/code> \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u043a\u043b\u0430\u0441\u0441\u0443. \u0421\u044e\u0434\u0430 \u0431\u0443\u0434\u0443\u0442 \u0432\u0445\u043e\u0434\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u043b\u044e\u0434\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u0447\u0438\u0441\u043b\u044f\u0442\u0441\u044f \u0432 \u044d\u0442\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435, \u043f\u0440\u0435\u0434\u043c\u0435\u0442, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0439 \u0441 \u044d\u0442\u0438\u043c \u043a\u043b\u0430\u0441\u0441\u043e\u043c, \u0438 \u0435\u0433\u043e <code>id<\/code>.<\/p>\n<pre><code class=\"javascript\">class Person {   constructor(id, firstN = 'John', lastN = 'Doe') {     this.id = id;     this.firstName = firstN;     this.lastName = lastN;     this.subjects = [];     this.classrooms = [];   } }<\/code><\/pre>\n<p>\u041c\u043e\u0434\u0435\u043b\u044c <code>Person<\/code> \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043a\u0430\u0436\u0434\u043e\u043c \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0435. \u0421\u044e\u0434\u0430 \u0431\u0443\u0434\u0443\u0442 \u0432\u0445\u043e\u0434\u0438\u0442\u044c \u0435\u0433\u043e \u0438\u043c\u044f \u0438 \u0444\u0430\u043c\u0438\u043b\u0438\u044f, \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043d \u0438\u0437\u0443\u0447\u0430\u0435\u0442, \u0438 \u043a\u043b\u0430\u0441\u0441\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043d \u043f\u043e\u0441\u0435\u0449\u0430\u0435\u0442.<\/p>\n<pre><code class=\"javascript\">const subjects = [   \"English\",   \"Math\",   \"Computer Science\",   \"Business\",   \"Finance\",   \"Home Economics\" ];<\/code><\/pre>\n<p>\u041c\u043e\u0434\u0435\u043b\u044c <code>Subjects<\/code> \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u044f \u043d\u0435 \u0441\u043e\u0431\u0438\u0440\u0430\u044e\u0441\u044c \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u0442\u044c \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c\u044e \u0434\u0438\u0441\u0446\u0438\u043f\u043b\u0438\u043d.<\/p>\n<h3>\u0423\u0440\u043e\u0432\u0435\u043d\u044c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430<\/h3>\n<p>\u041a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u043a\u043b\u0430\u0441\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0442\u0440\u0430\u043d\u0441\u043b\u0438\u0440\u0443\u0435\u0442 \u0432\u0432\u043e\u0434\u0438\u043c\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u0438.<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 Classroom \u2014 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435, \u0432\u0432\u043e\u0434\u0438\u043c\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c, \u043e\u0442 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a \u0432\u0432\u043e\u0434 \u0442\u0435\u043a\u0441\u0442\u0430 (<code>text input<\/code>) \u0438\u043b\u0438 \u0432\u044b\u0431\u043e\u0440 \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430 \u043e\u043f\u0446\u0438\u0439 (<code>select options<\/code>), \u0430 \u0442\u0430\u043a\u0436\u0435 \u043d\u0430\u0436\u0430\u0442\u0438\u044f \u043a\u043d\u043e\u043f\u043e\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438.<\/p>\n<pre><code class=\"javascript\">import classroomModel from \"..\/models\/classroom\";  class ClassroomController {   constructor() {     this.lastID = 0;     this.classrooms = [];     this.selectedClass = null;   }    selectClassroom(classroomID) {     this.selectedClass = this.classrooms     .filter(c =&gt; c.id === parseInt(classroomID, 10))[0];   }    addClassroom(subject) {     this.classrooms.push(       new classroomModel(this.lastID, subject)       );     this.lastID += 1;   }    removeClassroom(classroomID) {     this.classrooms = this.classrooms       .filter(c =&gt; c.id !== parseInt(classroomID, 10));   }    setSubject(subject, classroomID) {     const classroom = this.classrooms       .filter(c =&gt; c.id === parseInt(classroomID, 10))[0];     classroom.subject = subject;   }    addPerson(person, classroom) {     \/\/ const classroom = this.classrooms     \/\/ .filter(c =&gt; c.id === parseInt(classroomID, 10))[0];     if (!person) return;     classroom.addPerson(person);   }    removePerson(person, classroomID) {     const classroom = this.classrooms     .filter(c =&gt; c.id === parseInt(classroomID, 10))[0];     classroom.removePerson(person);   } }<\/code><\/pre>\n<p>\u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 <code>ClassroomController<\/code> \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u043a\u0430\u043a \u0442\u0430\u0431\u043b\u0438\u0446\u0443 (\u0435\u0441\u043b\u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c \u0441 \u0442\u0435\u043c, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 Rails), \u0438 \u043a\u0430\u0436\u0434\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0432 \u044d\u0442\u043e\u0439 \u00ab\u0442\u0430\u0431\u043b\u0438\u0446\u0435\u00bb \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u0443\u044e \u0441 \u043a\u0430\u0436\u0434\u044b\u043c \u0443\u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0430.<\/p>\n<p>\u042d\u0442\u043e\u0442 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u0438\u043c\u0435\u0435\u0442 \u0442\u0440\u0438 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435: \u00ab<code>lastID<\/code>\u00bb (\u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u043e\u0431\u044a\u0435\u043a\u0442 \u043a\u043b\u0430\u0441\u0441\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a \u043c\u0430\u0441\u0441\u0438\u0432\u0443 \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f), \u00ab<code>classrooms<\/code>\u00bb (\u043c\u0430\u0441\u0441\u0438\u0432 \u0432\u0441\u0435\u0445 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043a\u043b\u0430\u0441\u0441\u0430) \u0438 \u00ab<code>selectedClass<\/code>\u00bb.<\/p>\n<h3>\u0423\u0440\u043e\u0432\u0435\u043d\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f<\/h3>\n<p>\u042d\u0442\u043e\u0442 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u042d\u0442\u043e\u0442 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043a\u043b\u0430\u0441\u0441\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u0432\u0438\u0434\u0435\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0441 \u043d\u0438\u043c\u0438.<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 Classroom \u2014 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/Document_Object_Model\/Introduction?ref=hackernoon.com\"><u>DOM<\/u><\/a><u> <\/u><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/Document_Object_Model\/Introduction?ref=hackernoon.com\"><u>(\u043e\u0431\u044a\u0435\u043a\u0442\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430)<\/u>,<\/a> \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a \u043a\u043d\u043e\u043f\u043a\u0438, \u0438\u043d\u043f\u0443\u0442\u044b \u0438 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u044b (&lt;div\/&gt;, &lt;span\/ &gt;, &lt;p\/&gt;\u2026 \u0438 \u0442. \u0434.) \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043b\u044e\u0434\u0435\u0439 \u0438 \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u0438 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0441 \u043d\u0438\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<pre><code class=\"javascript\">import classroomController from \"..\/controllers\/classroom\"; import subjects from \"..\/models\/subjects\";  class ClassroomView {   constructor(appDiv) {     this.classroomController = new classroomController();     this.classroomSectionDiv = document.createElement('div');     this.classroomsDiv = document.createElement('div');     this.addclassBtn = document.createElement('button');     this.selectSubjectInput = document.createElement('select');      this.classroomSectionDiv.classList.add('classroom-section');     this.classroomsDiv.classList.add('classroom-container');     this.selectSubjectInput.innerHTML = subjects.map((option, index) =&gt; (       `&lt;option key=${index} value=${option}&gt;${option.toUpperCase()}&lt;\/option&gt;`     ));     this.addclassBtn.textContent = 'New Class';     this.addclassBtn.addEventListener('click', () =&gt; this.addClassroom());     this.classroomSectionDiv.append(       this.classroomsDiv, this.selectSubjectInput,       this.addclassBtn,       );     appDiv.appendChild(this.classroomSectionDiv);   }    updateView() {     const { classroomController, classroomsDiv } = this;     const allClassrooms = classroomController.classrooms.map(       c =&gt; {         const removeBtn = document.createElement('button');         const classDiv = document.createElement('div');         classDiv.classList.add('classroom');         if (classroomController.selectedClass === c) {           classDiv.classList.add('selected');         }         classDiv.addEventListener('click', () =&gt; this.selectClassroom(classDiv.getAttribute('data-classroom-id')));         classDiv.setAttribute('data-classroom-id', c.id);         removeBtn.addEventListener('click', () =&gt; this.removeClassroom(removeBtn.getAttribute('data-classroom-id')));         removeBtn.setAttribute('data-classroom-id', c.id);         removeBtn.classList.add('remove-btn');         removeBtn.textContent= 'remove';         const allPersons = c.persons.map(p =&gt; (           `&lt;div class=\"person-inline\"&gt;             &lt;span class=\"fname\"&gt;${p.firstName}&lt;\/span&gt;             &lt;span class=\"lname\"&gt;${p.lastName}&lt;\/span&gt;             &lt;span class=\"${p.occupation}\"&gt;${p.occupation}&lt;\/span&gt;           &lt;\/div&gt;`         ));         classDiv.innerHTML = `&lt;div class=\"m-b\"&gt;             &lt;span class=\"id\"&gt;${c.id}&lt;\/span&gt;             &lt;span class=\"subject\"&gt;${c.subject}&lt;\/span&gt;&lt;\/div&gt;             &lt;div class=\"all-persons\"&gt;${allPersons.join('')}&lt;\/div&gt;`;         classDiv.appendChild(removeBtn);         return classDiv;       }     );     classroomsDiv.innerHTML='';     allClassrooms.map(div =&gt; classroomsDiv.append(div));   }      selectClassroom(classroomID) {     const { classroomController } = this;     classroomController.selectClassroom(classroomID);      this.updateView();   }    addClassroom() {     const {       classroomController,       selectSubjectInput,     } = this;     const subjectChosen = selectSubjectInput.value;     classroomController.addClassroom(subjectChosen);     this.updateView();   }    removeClassroom(classroomID) {     const { classroomController } = this;     classroomController.removeClassroom(classroomID);     this.updateView();   }    addPerson(person, classroomID) {     const { classroomController } = this;     classroomController.addPerson(person, classroomID);     this.updateView();   } }<\/code><\/pre>\n<p>\u041a\u043b\u0430\u0441\u0441 <code>ClassroomView<\/code> \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u0432\u044f\u0437\u0430\u043d\u0430 \u0441 <code>ClassroomController<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0443\u0440\u043e\u0432\u043d\u044e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043e\u0431\u0449\u0430\u0442\u044c\u0441\u044f \u0441 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u043c.<\/p>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f <code>updateView()<\/code> \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c. \u042d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 \u0432 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b DOM \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u043c\u0438 \u0438\u0437 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438.<\/p>\n<p>\u0412\u0441\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u044e\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438\u0437 UI \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 DOM \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442 \u0438\u0445 \u043a\u0430\u043a \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430. \u0424\u0443\u043d\u043a\u0446\u0438\u0438 <code>selectClassroom()<\/code>, <code>addClassroom()<\/code> \u0438 <code>removeClassroom()<\/code> \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043a \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c DOM \u0447\u0435\u0440\u0435\u0437 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>updateView()<\/code> \u043a\u0430\u043a \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0447\u0435\u0440\u0435\u0437 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>addEventListener()<\/code>.<\/p>\n<h3>\u0414\u043e\u0441\u0442\u0443\u043f \u043a\u043e \u0432\u0441\u0435\u043c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430\u043c \u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f<\/h3>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0434\u0432\u0430 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430, <code>ClassroomController<\/code> \u0438 <code>PersonController<\/code> (<a href=\"https:\/\/codesandbox.io\/s\/school-is-in-session-699ko?file=%2Fsrc%2Fcontrollers%2Fperson.js&amp;ref=hackernoon.com\"><u>\u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432 \u043f\u043e\u043b\u043d\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435<\/u><\/a>), \u0443 \u043d\u0430\u0441 \u0442\u0430\u043a\u0436\u0435 \u0431\u044b\u043b\u043e \u0431\u044b \u0434\u0432\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f, \u0438 \u0435\u0441\u043b\u0438 \u0431\u044b \u043c\u044b \u0445\u043e\u0442\u0435\u043b\u0438, \u0447\u0442\u043e\u0431\u044b \u044d\u0442\u0438 \u0434\u0432\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043c\u043e\u0433\u043b\u0438 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c <\/p>\n<\/hr>\n<\/blockquote>\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-316072","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/316072","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=316072"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/316072\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=316072"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=316072"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=316072"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}