Загрузил l0cki

programmnyy-pattern-proektirovaniya-arhitekturnogo-karkasa-model-view-controller-pri-razrabotke-veb-prilozheniy-sistem-monitoringa-spetstransporta-aeroporta

реклама
2015
ɇȺɍɑɇɕɃ ȼȿɋɌɇɂɄ ɆȽɌɍ ȽȺ
ʋ 220
ɍȾɄ 004.05:656.052.1
ɉɊɈȽɊȺɆɆɇɕɃ ɉȺɌɌȿɊɇ ɉɊɈȿɄɌɂɊɈȼȺɇɂə
ȺɊɏɂɌȿɄɌɍɊɇɈȽɈ ɄȺɊɄȺɋȺ MODEL-VIEW-CONTROLLER
ɉɊɂ ɊȺɁɊȺȻɈɌɄȿ ȼȿȻ-ɉɊɂɅɈɀȿɇɂɃ ɋɂɋɌȿɆ ɆɈɇɂɌɈɊɂɇȽȺ
ɋɉȿɐɌɊȺɇɋɉɈɊɌȺ ȺɗɊɈɉɈɊɌȺ
Ȼ.ɉ. ȿɅɂɋȿȿȼ, Ⱥ.ȼ. ɌȺɊȺɋȿɇɄɈ, Ɉ.Ⱥ. ȽɈɊȻȺɑȿȼ, Ʌɘ ȾɀɈɇȾȺ
ȼ ɪɚɛɨɬɟ ɪɚɫɫɦɨɬɪɟɧɵ ɩɚɬɬɟɪɧɵ ɩɪɨɟɤɬɢɪɨɜɚɧɢɹ MODEL-VIEW-CONTROLLER (MVC), ɢ MODEL-VIEWPRESENTER (MVP), ɫɩɨɫɨɛɵ ɜɡɚɢɦɨɞɟɣɫɬɜɢɹ ɢ ɪɨɥɢ ɤɚɠɞɨɝɨ ɤɨɦɩɨɧɟɧɬɚ ɚɪɯɢɬɟɤɬɭɪɧɵɯ ɤɚɪɤɚɫɨɜ, ɜɨɡɦɨɠɧɨɫɬɢ
ɩɪɢɦɟɧɟɧɢɹ ɫɟɪɜɢɫɨɜ ɩɪɢ ɪɚɡɪɚɛɨɬɤɟ ɩɪɢɥɨɠɟɧɢɹ. ɉɪɢɜɟɞɟɧɵ ɞɢɚɝɪɚɦɦɵ ɩɚɪɵ http-ɡɚɩɪɨɫ-ɨɬɜɟɬ ɩɪɢ ɢɫɩɨɥɶɡɨɜɚɧɢɢ ɫɟɪɜɢɫɨɜ ɢ ɛɟɡ ɧɢɯ. Ɉɩɢɫɚɧɵ ɨɫɧɨɜɧɵɟ ɜɨɡɦɨɠɧɨɫɬɢ ɮɪɟɣɦɜɨɪɤɚ AngularJS. ɉɨɤɚɡɚɧɚ ɫɬɪɭɤɬɭɪɚ ɜɡɚɢɦɨɞɟɣɫɬɜɢɹ ɤɨɦɩɨɧɟɧɬɨɜ ɜɟɛ-ɩɪɢɥɨɠɟɧɢɹ ɩɪɢ ɢɫɩɨɥɶɡɨɜɚɧɢɢ ɮɪɟɣɦɜɨɪɤɚ.
Ʉɥɸɱɟɜɵɟ ɫɥɨɜɚ: ɩɚɬɬɟɪɧ, ɜɟɛ-ɩɪɢɥɨɠɟɧɢɟ, ɫɟɪɜɢɫ, JavaScript, MVC, MVP, AngularJS.
ȼȼȿȾȿɇɂȿ
ɋɬɪɟɦɢɬɟɥɶɧɵɣ ɪɨɫɬ ɫɟɬɢ ɂɧɬɟɪɧɟɬ - ɷɬɨ, ɩɨ ɦɟɧɶɲɟɣ ɦɟɪɟ, ɱɚɫɬɢɱɧɚɹ ɡɚɫɥɭɝɚ ɟɟ ɢɫɩɨɥɶɡɨɜɚɧɢɹ ɜ ɤɚɱɟɫɬɜɟ ɢɧɫɬɪɭɦɟɧɬɚ ɥɢɱɧɨɣ ɩɭɛɥɢɤɚɰɢɢ. ɂɡɧɚɱɚɥɶɧɨ ɞɚɧɧɵɟ, ɤɨɬɨɪɵɦɢ ɥɸɞɢ ɨɛɦɟɧɢɜɚɥɢɫɶ ɩɨ ɫɟɬɢ, ɫɨɫɬɨɹɥɢ ɜ ɨɫɧɨɜɧɨɦ ɢɡ ɫɬɚɬɢɱɟɫɤɨɣ ɢɧɮɨɪɦɚɰɢɢ, ɯɪɚɧɹɳɟɣɫɹ ɜ ɮɚɣɥɚɯ.
Ɏɚɣɥɵ ɦɨɠɧɨ ɛɵɥɨ ɪɟɞɚɤɬɢɪɨɜɚɬɶ, ɧɨ ɞɟɣɫɬɜɢɬɟɥɶɧɨ ɞɢɧɚɦɢɱɟɫɤɢɯ ɢɧɮɨɪɦɚɰɢɨɧɧɵɯ ɫɥɭɠɛ
ɛɵɥɨ ɦɚɥɨ.
ɋɢɬɭɚɰɢɹ ɤɚɱɟɫɬɜɟɧɧɨ ɢɡɦɟɧɢɥɚɫɶ ɫ ɩɨɹɜɥɟɧɢɟɦ ɞɢɧɚɦɢɱɟɫɤɨɣ ɫɟɬɢ, ɹɜɥɹɸɳɟɣɫɹ ɪɟɡɭɥɶɬɚɬɨɦ ɪɚɡɜɢɬɢɹ ɞɢɧɚɦɢɱɟɫɤɢɯ ɫɥɭɠɛ. ɉɨɹɜɢɥɢɫɶ ɧɨɜɵɟ ɫɟɪɜɢɫɵ - ɨɬ CGI ɫɤɪɢɩɬɨɜ ɞɥɹ ɩɨɢɫɤɨɜɵɯ ɦɚɲɢɧ ɞɨ ɩɚɤɟɬɨɜ ɩɪɨɝɪɚɦɦ, ɫɨɟɞɢɧɹɜɲɢɯ ɜɟɛ-ɩɪɢɥɨɠɟɧɢɹ ɫ ɪɟɥɹɰɢɨɧɧɵɦɢ ɛɚɡɚɦɢ
ɞɚɧɧɵɯ. ɋɬɚɥɨ ɧɟɞɨɫɬɚɬɨɱɧɵɦ ɫɨɡɞɚɧɢɟ ɜɟɛ-ɫɚɣɬɚ - ɜɨɡɧɢɤɥɚ ɧɟɨɛɯɨɞɢɦɨɫɬɶ ɩɪɨɟɤɬɢɪɨɜɚɬɶ
ɜɟɛ-ɩɪɢɥɨɠɟɧɢɟ [1].
ȼɟɛ-ɩɪɢɥɨɠɟɧɢɟ - ɨɫɨɛɵɣ ɜɢɞ ɩɪɨɝɪɚɦɦɧɨɝɨ ɩɪɨɞɭɤɬɚ, ɤɨɬɨɪɵɣ ɞɨɫɬɭɩɟɧ ɩɨɥɶɡɨɜɚɬɟɥɹɦ
ɩɨ ɫɟɬɢ, ɢɫɩɨɥɶɡɭɟɬ ɛɪɚɭɡɟɪ ɜ ɤɚɱɟɫɬɜɟ ɤɥɢɟɧɬɚ ɢ ɫɨɫɬɨɢɬ ɢɡ ɧɚɛɨɪɚ ɤɥɢɟɧɬ-ɫɟɪɜɟɪɧɵɯ ɫɰɟɧɚɪɢɟɜ, HTML-ɫɬɪɚɧɢɰ ɢ ɞɪɭɝɢɯ ɪɟɫɭɪɫɨɜ, ɤɨɬɨɪɵɟ ɦɨɝɭɬ ɛɵɬɶ ɪɚɫɩɪɟɞɟɥɟɧɵ ɦɟɠɞɭ ɧɟɫɤɨɥɶɤɢɦɢ
ɫɟɪɜɟɪɚɦɢ. ɋɚɦɨ ɩɪɢɥɨɠɟɧɢɟ ɞɨɫɬɭɩɧɨ ɩɨɥɶɡɨɜɚɬɟɥɹɦ ɩɨ ɨɩɪɟɞɟɥɟɧɧɨɦɭ ɩɭɬɢ ɜɧɭɬɪɢ
ɜɟɛ-ɫɟɪɜɟɪɚ.
Ʉ ɨɫɧɨɜɧɵɦ ɩɪɟɢɦɭɳɟɫɬɜɚɦ ɜɟɛ-ɩɪɢɥɨɠɟɧɢɣ ɦɨɠɧɨ ɨɬɧɟɫɬɢ ɤɪɨɫɫ-ɩɥɚɬɮɨɪɦɟɧɧɭɸ
ɫɨɜɦɟɫɬɢɦɨɫɬɶ ɢ ɜɨɡɦɨɠɧɨɫɬɶ ɨɛɧɨɜɥɹɬɶ ɢ ɩɨɞɞɟɪɠɢɜɚɬɶ ɩɪɢɥɨɠɟɧɢɟ ɛɟɡ ɭɫɬɚɧɨɜɤɢ ɩɪɨɝɪɚɦɦɧɨɝɨ ɨɛɟɫɩɟɱɟɧɢɹ ɧɚ ɤɥɢɟɧɬɫɤɢɟ ɭɫɬɪɨɣɫɬɜɚ.
1. ɉɈɋɌȺɇɈȼɄȺ ɁȺȾȺɑɂ
ɇɚ ɧɚɱɚɥɶɧɨɣ ɫɬɚɞɢɢ ɪɚɡɪɚɛɨɬɤɢ ɩɪɨɝɪɚɦɦɧɵɯ ɩɪɢɥɨɠɟɧɢɣ ɫɬɨɢɬ ɡɚɞɚɱɚ ɜɵɛɨɪɚ ɚɪɯɢɬɟɤɬɭɪɵ. Ⱥɪɯɢɬɟɤɬɭɪɚ ɩɪɨɝɪɚɦɦɧɨɝɨ ɨɛɟɫɩɟɱɟɧɢɹ ɜ ɬɪɚɞɢɰɢɨɧɧɨɦ ɫɦɵɫɥɟ ɜɤɥɸɱɚɟɬ ɨɩɪɟɞɟɥɟɧɢɟ ɜɫɟɯ ɦɨɞɭɥɟɣ ɩɪɨɝɪɚɦɦ, ɢɯ ɢɟɪɚɪɯɢɢ ɢ ɫɨɩɪɹɠɟɧɢɹ ɦɟɠɞɭ ɧɢɦɢ ɢ ɞɚɧɧɵɦɢ.
Ɉɫɧɨɜɧɵɦɢ ɤɪɢɬɟɪɢɹɦɢ ɩɪɢ ɜɵɛɨɪɟ ɚɪɯɢɬɟɤɬɭɪɵ ɜɟɛ-ɩɪɢɥɨɠɟɧɢɹ ɫɢɫɬɟɦɵ ɦɨɧɢɬɨɪɢɧɝɚ
ɫɩɟɰɬɪɚɧɫɩɨɪɬɚ ɚɷɪɨɩɨɪɬɚ ɹɜɥɹɸɬɫɹ ɜɨɡɦɨɠɧɨɫɬɶ ɦɨɞɭɥɶɧɨɣ ɪɚɡɪɚɛɨɬɤɢ, ɫɨɩɪɨɜɨɠɞɟɧɢɹ, ɞɨɤɭɦɟɧɬɚɰɢɢ ɢ ɫɬɪɭɤɬɭɪɢɡɚɰɢɢ ɤɨɞɚ.
2. ɉȺɌɌȿɊɇ MVC
Ɋɚɡɪɚɛɚɬɵɜɚɟɦɚɹ ɜ ɆȽɌɍ ȽȺ ɫɢɫɬɟɦɚ ɦɨɧɢɬɨɪɢɧɝɚ ɫɩɟɰɬɪɚɧɫɩɨɪɬɚ ɚɷɪɨɩɨɪɬɚ - ɷɬɨ ɞɢɧɚɦɢɱɟɫɤɨɟ ɩɪɢɥɨɠɟɧɢɟ, ɤɨɬɨɪɨɟ ɢɫɩɨɥɶɡɭɟɬ JavaScript ɢ AJAX ɞɥɹ ɨɪɝɚɧɢɡɚɰɢɢ HTTP ɡɚɩɪɨ-
138
Ȼ.ɉ. ȿɥɢɫɟɟɜ, Ⱥ.ȼ. Ɍɚɪɚɫɟɧɤɨ, Ɉ.Ⱥ. Ƚɨɪɛɚɱɟɜ, Ʌɸ Ⱦɠɨɧɞɚ
ɫɨɜ ɤ ɜɟɛ-ɫɟɪɜɟɪɭ. ȼɟɛ-ɩɪɢɥɨɠɟɧɢɟ, ɜ ɨɬɥɢɱɢɟ ɨɬ ɫɬɚɬɢɱɟɫɤɢɯ HTML ɫɬɪɚɧɢɰ, ɦɨɠɟɬ ɞɢɧɚɦɢɱɟɫɤɢ ɩɪɟɞɫɬɚɜɥɹɬɶ ɤɨɧɬɟɧɬ ɫ ɭɱɟɬɨɦ ɩɚɪɚɦɟɬɪɨɜ ɡɚɩɪɨɫɚ, ɞɟɣɫɬɜɢɹ ɩɨɥɶɡɨɜɚɬɟɥɹ ɢ ɧɚɫɬɪɨɟɤ ɛɟɡɨɩɚɫɧɨɫɬɢ.
Ʉɚɤ ɩɪɚɜɢɥɨ, ɜɟɛ-ɩɪɢɥɨɠɟɧɢɟ ɫɨɫɬɨɢɬ ɢɡ ɧɟɫɤɨɥɶɤɢɯ ɩɨɞɩɪɢɥɨɠɟɧɢɣ. Ɍɚ ɱɚɫɬɶ ɩɪɢɥɨɠɟɧɢɹ ɫɢɫɬɟɦɵ ɦɨɧɢɬɨɪɢɧɝɚ, ɤɨɬɨɪɭɸ ɜɢɞɹɬ ɨɛɵɱɧɵɟ ɩɨɥɶɡɨɜɚɬɟɥɢ ɨɛɥɚɞɚɟɬ ɞɨɫɬɚɬɨɱɧɨ ɧɚɝɪɭɠɟɧɧɵɦ ɢɧɬɟɪɮɟɣɫɨɦ, ɫɨɫɬɨɹɳɢɦ ɢɡ ɪɚɡɥɢɱɧɵɯ ɦɨɞɭɥɟɣ. ɋɪɟɞɢ ɨɫɧɨɜɧɵɯ ɦɨɠɧɨ ɨɬɦɟɬɢɬɶ ɦɨɞɭɥɶ ɞɥɹ ɨɬɨɛɪɚɠɟɧɢɹ ɬɪɚɧɫɩɨɪɬɧɵɯ ɫɪɟɞɫɬɜ ɧɚ ɰɢɮɪɨɜɨɣ ɤɚɪɬɟ, ɦɨɞɭɥɶ ɞɥɹ ɫɨɡɞɚɧɢɹ ɢ ɤɨɪɪɟɤɬɢɪɨɜɚɧɢɹ ɡɨɧ ɢ ɤɨɪɢɞɨɪɨɜ, ɦɨɞɭɥɶ ɮɨɪɦɢɪɨɜɚɧɢɹ ɨɬɱɟɬɨɜ. ȼɫɟ ɷɬɢ ɦɨɞɭɥɢ ɨɛɥɚɞɚɸɬ ɫɨɛɫɬɜɟɧɧɵɦɢ ɞɚɧɧɵɦɢ ɢ ɭɩɪɚɜɥɹɸɳɟɣ ɥɨɝɢɤɨɣ.
ɉɪɢ ɩɪɨɟɤɬɢɪɨɜɚɧɢɢ ɩɨɞɨɛɧɵɯ ɩɪɢɥɨɠɟɧɢɣ ɧɟɨɛɯɨɞɢɦɨ ɩɨɞɨɛɪɚɬɶ ɩɨɞɯɨɞɹɳɢɟ ɨɛɴɟɤɬɵ, ɨɬɧɟɫɬɢ ɢɯ ɤ ɪɚɡɥɢɱɧɵɦ ɤɥɚɫɫɚɦ, ɫɨɛɥɸɞɚɹ ɪɚɡɭɦɧɭɸ ɫɬɟɩɟɧɶ ɞɟɬɚɥɢɡɚɰɢɢ, ɨɩɪɟɞɟɥɢɬɶ ɢɧɬɟɪɮɟɣɫɵ ɤɥɚɫɫɨɜ ɢ ɭɫɬɚɧɨɜɢɬɶ ɫɭɳɟɫɬɜɟɧɧɵɟ ɨɬɧɨɲɟɧɢɹ ɦɟɠɞɭ ɤɥɚɫɫɚɦɢ.
ɉɚɬɬɟɪɧɵ ɢɥɢ ɲɚɛɥɨɧɵ ɩɪɨɟɤɬɢɪɨɜɚɧɢɹ ɞɚɸɬ ɜɨɡɦɨɠɧɨɫɬɶ ɩɨɜɬɨɪɧɨ ɢɫɩɨɥɶɡɨɜɚɬɶ
ɬɟ ɪɟɲɟɧɢɹ, ɤɨɬɨɪɵɟ ɨɤɚɡɚɥɢɫɶ ɭɞɚɱɧɵɦɢ ɜ ɩɪɨɲɥɨɦ ɢ ɭɩɪɨɳɚɸɬ ɩɨɜɬɨɪɧɨɟ ɢɫɩɨɥɶɡɨɜɚɧɢɟ
ɭɞɚɱɧɵɯ ɩɪɨɟɤɬɧɵɯ ɢ ɚɪɯɢɬɟɤɬɭɪɧɵɯ ɪɟɲɟɧɢɣ. ɉɪɟɞɫɬɚɜɥɟɧɢɟ ɩɪɨɲɟɞɲɢɯ ɩɪɨɜɟɪɤɭ
ɜɪɟɦɟɧɟɦ ɦɟɬɨɞɢɤ ɜ ɜɢɞɟ ɩɚɬɬɟɪɧɨɜ ɩɪɨɟɤɬɢɪɨɜɚɧɢɹ ɨɛɥɟɝɱɚɟɬ ɞɨɫɬɭɩ ɤ ɧɢɦ ɫɨ ɫɬɨɪɨɧɵ ɪɚɡɪɚɛɨɬɱɢɤɨɜ ɧɨɜɵɯ ɫɢɫɬɟɦ. ɉɚɬɬɟɪɧɵ ɞɚɸɬ ɪɚɡɪɚɛɨɬɱɢɤɭ ɜɨɡɦɨɠɧɨɫɬɶ ɛɵɫɬɪɟɟ ɧɚɣɬɢ «ɩɪɚɜɢɥɶɧɵɣ
ɩɭɬɶ» Ɂɞɟɫɶ ɩɨɞ ɩɚɬɬɟɪɧɚɦɢ ɩɪɨɟɤɬɢɪɨɜɚɧɢɹ ɩɨɧɢɦɚɟɬɫɹ ɨɩɢɫɚɧɢɟ ɜɡɚɢɦɨɞɟɣɫɬɜɢɹ
ɨɛɴɟɤɬɨɜ ɢ ɤɥɚɫɫɨɜ, ɚɞɚɩɬɢɪɨɜɚɧɧɵɯ ɞɥɹ ɪɟɲɟɧɢɹ ɨɛɳɟɣ ɡɚɞɚɱɢ ɩɪɨɟɤɬɢɪɨɜɚɧɢɹ ɜ ɤɨɧɤɪɟɬɧɨɦ
ɤɨɧɬɟɤɫɬɟ [2].
Ⱥɪɯɢɬɟɤɬɭɪɧɵɣ ɩɚɬɬɟɪɧ Model-view-controller (MVC) ɩɪɟɞɩɨɥɚɝɚɟɬ ɪɚɡɞɟɥɟɧɢɟ ɞɚɧɧɵɯ
ɩɪɢɥɨɠɟɧɢɹ, ɩɨɥɶɡɨɜɚɬɟɥɶɫɤɨɝɨ ɢɧɬɟɪɮɟɣɫɚ ɢ ɭɩɪɚɜɥɹɸɳɟɣ ɥɨɝɢɤɢ ɧɚ ɬɪɢ ɨɬɞɟɥɶɧɵɯ ɤɨɦɩɨɧɟɧɬɚ: Ɇɨɞɟɥɶ, ɉɪɟɞɫɬɚɜɥɟɧɢɟ ɢ Ʉɨɧɬɪɨɥɥɟɪ – ɬɚɤ, ɱɬɨ ɦɨɞɢɮɢɤɚɰɢɹ ɤɚɠɞɨɝɨ ɤɨɦɩɨɧɟɧɬɚ ɦɨɠɟɬ ɨɫɭɳɟɫɬɜɥɹɬɶɫɹ ɧɟɡɚɜɢɫɢɦɨ.
ȼɩɟɪɜɵɟ ɩɨɧɹɬɢɟ MVC ɜɨɡɧɢɤɥɨ ɜ ɹɡɵɤɟ Smalltalk-80 ɩɪɢ ɩɨɞɯɨɞɟ ɤ ɪɚɡɪɚɛɨɬɤɟ
ɦɧɨɝɨɭɪɨɜɧɟɜɵɯ ɝɪɚɮɢɱɟɫɤɢɯ ɩɨɥɶɡɨɜɚɬɟɥɶɫɤɢɯ ɢɧɬɟɪɮɟɣɫɨɜ ɜ ɤɨɧɰɟ 1970-ɯ, ɧɚɱɚɥɟ 1980-ɯ.
ȼ ɞɚɥɶɧɟɣɲɟɦ ɩɚɬɬɟɪɧ ɡɚɪɟɤɨɦɟɧɞɨɜɚɥ ɫɟɛɹ ɤɚɤ ɭɞɚɱɧɚɹ ɚɪɯɢɬɟɤɬɭɪɚ ɩɪɨɝɪɚɦɦɧɨɝɨ
ɨɛɟɫɩɟɱɟɧɢɹ.
ȼ ɧɚɫɬɨɹɳɟɟ ɜɪɟɦɹ ɩɚɬɬɟɪɧ MVC ɞɨɫɬɭɩɟɧ ɞɥɹ ɦɧɨɝɢɯ ɹɡɵɤɨɜ ɩɪɨɝɪɚɦɦɢɪɨɜɚɧɢɹ ɢ ɯɨɪɨɲɨ ɩɪɨɹɜɢɥ ɫɟɛɹ ɜ ɬɚɤɢɯ ɮɪɟɣɦɜɨɪɤɚɯ, ɤɚɤ Apache Struts ɞɥɹ Java, Maypole ɞɥɹ Perl ɢ Rails
ɞɥɹ Ruby.
ɏɨɬɹ ɛɨɥɶɲɢɧɫɬɜɨ ɫɨɜɪɟɦɟɧɧɵɯ ɮɪɟɣɦɜɨɪɤɨɜ ɩɵɬɚɸɬɫɹ ɪɚɡɜɢɜɚɬɶ ɩɚɪɚɞɢɝɦɵ MVC,
ɞɥɹ ɥɭɱɲɟɝɨ ɫɨɨɬɜɟɬɫɬɜɢɹ ɩɨɬɪɟɛɧɨɫɬɹɦ ɪɚɡɜɢɬɢɹ ɜɟɛ-ɩɪɢɥɨɠɟɧɢɣ, ɨɫɬɚɟɬɫɹ ɨɞɢɧ ɮɪɟɣɦɜɨɪ,
ɤɨɬɨɪɵɣ ɩɪɢɞɟɪɠɢɜɚɟɬɫɹ ɤɥɚɫɫɢɱɟɫɤɨɝɨ ɩɚɬɬɟɪɧɚ, ɨɩɢɫɚɧɧɨɝɨ ɜ Smalltalk-80 Maria.js ɉɢɬɟɪɚ Ɇɢɲɨ.
Ɇɨɞɟɥɶ, ɤɚɤ ɩɟɪɜɵɣ ɤɨɦɩɨɧɟɧɬ ɲɚɛɥɨɧɚ, ɨɛɪɚɛɚɬɵɜɚɟɬ ɫɨɫɬɨɹɧɢɟ ɩɪɢɥɨɠɟɧɢɹ ɢ ɦɨɠɟɬ
ɫɨɞɟɪɠɚɬɶ ɜ ɫɟɛɟ ɥɸɛɵɟ ɞɚɧɧɵɟ, ɧɚɩɪɢɦɟɪ, ɦɚɫɫɢɜ ɤɨɨɪɞɢɧɚɬ. Ⱦɚɧɧɵɣ ɤɨɦɩɨɧɟɧɬ ɧɟ ɢɦɟɟɬ ɢɧɮɨɪɦɚɰɢɢ ɨ ɫɨɫɬɨɹɧɢɢ HTML- ɢɥɢ ɜɟɛ-ɫɟɪɜɟɪɨɜ, ɟɝɨ ɡɚɞɚɱɚ - ɨɛɟɫɩɟɱɢɬɶ ɜɨɡɦɨɠɧɨɫɬɶ ɡɚɩɪɨɫɚ
ɫɨɫɬɨɹɧɢɹ ɨɛɴɟɤɬɚ ɢ ɨɩɪɟɞɟɥɢɬɶ ɩɭɬɢ ɟɝɨ ɢɡɦɟɧɟɧɢɹ.
ȼɬɨɪɨɣ ɤɨɦɩɨɧɟɧɬ - ɉɪɟɞɫɬɚɜɥɟɧɢɟ, ɤɨɬɨɪɨɟ ɨɬɨɛɪɚɠɚɟɬ ɩɨɥɶɡɨɜɚɬɟɥɶɫɤɢɣ ɢɧɬɟɪɮɟɣɫ.
ȼ ɩɪɢɥɨɠɟɧɢɢ, ɤɚɤ ɩɪɚɜɢɥɨ, ɢɫɩɨɥɶɡɭɟɬɫɹ ɧɟɫɤɨɥɶɤɨ ɉɪɟɞɫɬɚɜɥɟɧɢɣ. Ɉɫɧɨɜɧɚɹ ɮɭɧɤɰɢɹ ɉɪɟɞɫɬɚɜɥɟɧɢɹ - ɡɚɩɪɨɫ ɞɚɧɧɵɯ ɢɡ Ɇɨɞɟɥɢ, ɛɟɡ ɜɨɡɦɨɠɧɨɫɬɢ ɢɡɦɟɧɟɧɢɹ ɟɺ ɫɨɫɬɨɹɧɢɹ. ȼ ɜɟɛɩɪɢɥɨɠɟɧɢɹɯ ɧɚ ɛɚɡɟ MVC ɉɪɟɞɫɬɚɜɥɟɧɢɟ ɫɨɡɞɚɟɬɫɹ ɫ ɢɫɩɨɥɶɡɨɜɚɧɢɟɦ HTML, ɤɨɬɨɪɨɟ ɜ ɤɨɧɟɱɧɨɦ ɢɬɨɝɟ ɥɢɛɨ ɨɬɨɛɪɚɠɚɟɬɫɹ ɤɚɤ ɩɨɥɧɨɰɟɧɧɚɹ ɫɬɪɚɧɢɰɚ, ɥɢɛɨ ɩɨɞɫɬɚɜɥɹɟɬɫɹ ɜ ɬɪɟɛɭɟɦɨɟ ɦɟɫɬɨ
ɧɚ ɫɬɪɚɧɢɰɟ.
ȼɫɟ ɞɟɣɫɬɜɢɹ ɩɨɥɶɡɨɜɚɬɟɥɹ, ɤɨɬɨɪɵɟ ɨɧ ɩɪɨɢɡɜɨɞɢɬ ɜ ɉɪɟɞɫɬɚɜɥɟɧɢɢ ɨɛɪɚɛɚɬɵɜɚɸɬɫɹ ɬɪɟɬɶɢɦ ɤɨɦɩɨɧɟɧɬɨɦ MVC - Ʉɨɧɬɪɨɥɥɟɪɨɦ. Ɉɧ ɩɨɥɭɱɚɟɬ ɡɚɩɪɨɫ ɩɨɥɶɡɨɜɚɬɟɥɹ
(HTTP-ɡɚɩɪɨɫ), ɨɛɪɚɛɚɬɵɜɚɟɬ ɟɝɨ ɢ ɩɟɪɟɜɨɞɢɬ ɜ ɩɨɫɥɟɞɨɜɚɬɟɥɶɧɨɫɬɶ ɞɟɣɫɬɜɢɣ, ɤɨɬɨɪɵɟ
ɞɨɥɠɧɚ ɢɫɩɨɥɧɢɬɶ Ɇɨɞɟɥɶ. Ʉɪɨɦɟ ɬɨɝɨ, ɤɨɧɬɪɨɥɥɟɪ ɜɵɛɢɪɚɟɬ ɩɨɞɯɨɞɹɳɢɣ ɪɟɠɢɦ ɞɥɹ ɨɛɪɚɛɨɬɤɢ ɨɬɜɟɬɚ Ɇɨɞɟɥɢ.
ɉɪɨɝɪɚɦɦɧɵɣ ɩɚɬɬɟɪɧ ɩɪɨɟɤɬɢɪɨɜɚɧɢɹ ɚɪɯɢɬɟɤɬɭɪɧɨɝɨ ɤɚɪɤɚɫɚ...
139
ɋɥɟɞɭɸɳɚɹ ɮɭɧɤɰɢɹ Ʉɨɧɬɪɨɥɥɟɪɚ - ɜɵɛɨɪ ɫɨɨɬɜɟɬɫɬɜɭɸɳɟɣ ɫɬɪɚɧɢɰɵ (ɉɪɟɞɫɬɚɜɥɟɧɢɹ),
ɜ ɡɚɜɢɫɢɦɨɫɬɢ ɨɬ ɫɬɚɬɭɫɚ, ɤɨɬɨɪɵɣ ɜɨɡɜɪɚɳɚɟɬ Ɇɨɞɟɥɶ. ȼɟɞɶ ɜ ɡɚɜɢɫɢɦɨɫɬɢ ɨɬ ɬɨɝɨ, ɢɦɟɟɬ ɥɢ
Ɇɨɞɟɥɶ ɡɚɩɪɚɲɢɜɚɟɦɵɟ ɞɚɧɧɵɟ ɢɥɢ ɧɟɬ, ɩɨɥɶɡɨɜɚɬɟɥɸ ɧɟɨɛɯɨɞɢɦɨ ɥɢɛɨ ɨɬɨɛɪɚɡɢɬɶ ɢɯ, ɥɢɛɨ
ɭɜɟɞɨɦɢɬɶ ɨɛ ɨɲɢɛɤɟ. ɗɬɚ ɮɭɧɤɰɢɹ ɩɨɥɟɡɧɚ ɧɟ ɬɨɥɶɤɨ ɩɪɢ ɪɚɡɪɚɛɨɬɤɟ ɫɥɨɠɧɵɯ ɩɪɢɥɨɠɟɧɢɣ ɫ
ɛɨɥɶɲɢɦ ɤɨɥɢɱɟɫɬɜɨɦ ɫɬɪɚɧɢɰ, ɧɨ ɢ ɞɥɹ ɩɪɨɫɬɵɯ ɨɞɧɨɫɬɪɚɧɢɱɧɵɯ ɩɪɢɥɨɠɟɧɢɣ. ɋ ɩɨɦɨɳɶɸ
Ʉɨɧɬɪɨɥɥɟɪɚ ɦɨɠɧɨ ɨɛɪɚɛɚɬɵɜɚɬɶ, ɧɚɩɪɢɦɟɪ, ɬɚɤɢɟ ɞɟɣɫɬɜɢɹ, ɤɚɤ ɚɭɬɟɧɬɢɮɢɤɚɰɢɢ ɢ ɭɩɪɚɜɥɟɧɢɹ ɫɟɫɫɢɹɦɢ.
3. ɉȺɌɌȿɊɇ MVP
Ⱥɪɯɢɬɟɤɬɭɪɧɵɣ ɩɚɬɬɟɪɧ Model-View-Presenter (MVP) ɹɜɥɹɟɬɫɹ ɩɪɨɢɡɜɨɞɧɵɦ ɨɬ MVC,
ɤɨɬɨɪɵɣ ɮɨɤɭɫɢɪɭɟɬɫɹ ɧɚ ɭɥɭɱɲɟɧɢɢ ɥɨɝɢɤɢ ɩɪɟɞɫɬɚɜɥɟɧɢɹ. ɉɚɬɬɟɪɧ ɜɨɡɧɢɤ ɜ ɤɨɦɩɚɧɢɢ
Taligent ɜ ɧɚɱɚɥɟ 1990-ɯ ɝɨɞɨɜ, ɤɨɝɞɚ ɨɧɢ ɪɚɛɨɬɚɥɢ ɧɚɞ ɛɢɛɥɢɨɬɟɤɚɦɢ CommonPoint ɞɥɹ C ++.
ɇɟɫɦɨɬɪɹ ɧɚ ɬɨ, ɱɬɨ ɢ MVC ɢ MVP ɪɚɡɞɟɥɹɸɬ ɡɚɞɚɱɢ ɦɟɠɞɭ ɧɟɫɤɨɥɶɤɢɦɢ ɤɨɦɩɨɧɟɧɬɚɦɢ, ɫɭɳɟɫɬɜɭɸɬ ɧɟɤɨɬɨɪɵɟ ɮɭɧɞɚɦɟɧɬɚɥɶɧɵɟ ɪɚɡɥɢɱɢɹ ɦɟɠɞɭ ɧɢɦɢ.
Ʉɨɦɩɨɧɟɧɬ Presenter ɫɨɞɟɪɠɢɬ ɛɢɡɧɟɫ-ɥɨɝɢɤɭ ɩɨɥɶɡɨɜɚɬɟɥɶɫɤɨɝɨ ɢɧɬɟɪɮɟɣɫɚ. ȼ ɨɬɥɢɱɢɟ
ɨɬ MVC, ɜɵɡɨɜɵ ɨɬ ɉɪɟɞɫɬɚɜɥɟɧɢɹ ɞɟɥɟɝɢɪɨɜɚɧɵ Presenter, ɤɨɬɨɪɵɣ ɢɡɜɥɟɤɚɟɬ ɞɚɧɧɵɟ ɢɡ
Ɇɨɞɟɥɢ ɢ ɮɨɪɦɚɬɢɪɭɟɬ ɢɯ ɞɥɹ ɨɬɨɛɪɚɠɟɧɢɹ ɜ ɉɪɟɞɫɬɚɜɥɟɧɢɢ. ɇɚɢɛɨɥɟɟ ɪɚɫɩɪɨɫɬɪɚɧɟɧɧɨɣ ɪɟɚɥɢɡɚɰɢɟɣ MVP ɹɜɥɹɟɬɫɹ ɢɫɩɨɥɶɡɨɜɚɧɢɟ ɩɚɫɫɢɜɧɨɝɨ ɉɪɟɞɫɬɚɜɥɟɧɢɹ, ɩɪɚɤɬɢɱɟɫɤɢ ɧɟ ɫɨɞɟɪɠɚɳɟɝɨ ɥɨɝɢɤɢ. Ɇɨɞɟɥɢ MVP ɩɨɱɬɢ ɢɞɟɧɬɢɱɧɵ MVC ɦɨɞɟɥɹɦ, ɢ ɬɟ, ɢ ɞɪɭɝɢɟ ɨɛɪɚɛɚɬɵɜɚɸɬ
ɞɚɧɧɵɟ ɩɪɢɥɨɠɟɧɢɹ. Presenter ɜɵɫɬɭɩɚɟɬ ɜ ɪɨɥɢ ɩɨɫɪɟɞɧɢɤɚ ɦɟɠɞɭ ɦɨɞɟɥɹɦɢ, ɩɪɢ ɢɯ ɩɨɥɧɨɣ
ɢɡɨɥɹɰɢɢ ɨɬɧɨɫɢɬɟɥɶɧɨ ɞɪɭɝ ɞɪɭɝɚ. Ɉɧ ɷɮɮɟɤɬɢɜɧɨ ɫɜɹɡɵɜɚɟɬ ɦɨɞɟɥɢ ɉɪɟɞɫɬɚɜɥɟɧɢɟɦ, ɬɨ ɟɫɬɶ
ɛɟɪɟɬ ɬɟ ɮɭɧɤɰɢɢ, ɤɨɬɨɪɵɟ ɪɚɧɟɟ ɜɵɩɨɥɧɹɥɢ ɤɨɧɬɪɨɥɥɟɪɵ ɜ MVC. Ʉɚɤ ɫɥɟɞɫɬɜɢɟ Presenter ɹɜɥɹɟɬɫɹ ɰɟɧɬɪɚɥɶɧɵɦ ɡɜɟɧɨɦ ɩɚɬɬɟɪɧɚ MVP, ɪɟɚɥɢɡɭɸɳɢɦ ɥɨɝɢɤɭ ɉɪɟɞɫɬɚɜɥɟɧɢɣ, ɤɪɨɦɟ ɬɨɝɨ, ɨɧ
ɨɬɜɟɱɚɟɬ ɡɚ ɭɩɪɚɜɥɟɧɢɟ ɫɨɛɵɬɢɹɦɢ ɩɨɥɶɡɨɜɚɬɟɥɶɫɤɨɝɨ ɢɧɬɟɪɮɟɣɫɚ (ɧɚɩɪɢɦɟɪ, mouseDown,
keyDown).
ȼɵɡɵɜɚɟɦɵɣ ɱɟɪɟɡ ɉɪɟɞɫɬɚɜɥɟɧɢɟ, Presenter ɜɵɩɨɥɧɹɟɬ ɥɸɛɭɸ ɪɚɛɨɬɭ ɫ ɡɚɩɪɨɫɚɦɢ ɩɨɥɶɡɨɜɚɬɟɥɹ ɢ ɩɟɪɟɞɚɱɟɣ ɞɚɧɧɵɯ ɨɛɪɚɬɧɨ. Ɋɚɛɨɬɚ ɩɨɞɪɚɡɭɦɟɜɚɟɬ ɢɡɜɥɟɱɟɧɢɟ, ɦɚɧɢɩɭɥɢɪɨɜɚɧɢɟ ɢ
ɨɩɪɟɞɟɥɟɧɢɟ ɬɨɝɨ, ɤɚɤ ɞɚɧɧɵɟ ɞɨɥɠɧɵ ɛɵɬɶ ɨɬɨɛɪɚɠɟɧɵ ɜ ɉɪɟɞɫɬɚɜɥɟɧɢɢ. ȼ ɧɟɤɨɬɨɪɵɯ ɪɟɚɥɢɡɚɰɢɹɯ, Presenter ɜɡɚɢɦɨɞɟɣɫɬɜɭɟɬ ɫɨ ɫɥɭɠɛɚɦɢ ɫɨɯɪɚɧɟɧɢɹ ɞɚɧɧɵɯ (Ɇɨɞɟɥɢ). Ɇɨɞɟɥɢ ɦɨɝɭɬ
ɜɵɡɜɚɬɶ ɫɨɛɵɬɢɹ, ɧɚ ɤɨɬɨɪɵɟ Presenter ɦɨɠɟɬ ɩɨɞɩɢɫɵɜɚɬɶɫɹ, ɞɥɹ ɩɨɫɥɟɞɭɸɳɟɝɨ ɨɛɧɨɜɥɟɧɢɹ
ɉɪɟɞɫɬɚɜɥɟɧɢɹ.
ɉɪɟɢɦɭɳɟɫɬɜɨ ɜɵɲɟɨɩɢɫɚɧɧɨɝɨ ɨɬɥɢɱɢɹ ɨɬ MVC ɫɨɫɬɨɢɬ ɜ ɬɨɦ, ɱɬɨ ɨɧɨ ɭɜɟɥɢɱɢɜɚɟɬ ɬɟɫɬɢɪɭɟɦɨɫɬɶ ɩɪɢɥɨɠɟɧɢɹ ɢ ɨɛɟɫɩɟɱɢɜɚɟɬ ɛɨɥɟɟ ɱɟɬɤɨɟ ɪɚɡɞɟɥɟɧɢɟ ɦɟɠɞɭ ɉɪɟɞɫɬɚɜɥɟɧɢɟɦ ɢ
Ɇɨɞɟɥɶɸ. ɇɨ ɨɬɫɭɬɫɬɜɢɟ ɩɪɢɜɹɡɤɢ ɞɚɧɧɵɯ ɜ ɫɬɪɭɤɬɭɪɟ ɩɚɬɬɟɪɧɚ ɨɡɧɚɱɚɟɬ ɬɨ, ɱɬɨ ɷɬɨ ɫɬɚɧɨɜɢɬɫɹ
ɨɬɞɟɥɶɧɨ ɡɚɞɚɱɟɣ, ɨ ɤɨɬɨɪɨɣ ɫɬɨɢɬ ɩɨɡɚɛɨɬɢɬɶɫɹ ɩɪɢ ɪɚɡɪɚɛɨɬɤɟ ɩɪɢɥɨɠɟɧɢɹ.
Ʉɚɤ ɩɪɚɜɢɥɨ, MVP ɱɚɳɟ ɢɫɩɨɥɶɡɭɟɬɫɹ ɜ ɩɪɢɥɨɠɟɧɢɹɯ ɤɨɪɩɨɪɚɬɢɜɧɨɝɨ ɭɪɨɜɧɹ,
ɝɞɟ ɧɟɨɛɯɨɞɢɦɨ ɤɚɤ ɦɨɠɧɨ ɛɨɥɶɲɟ ɢɫɩɨɥɶɡɨɜɚɬɶ ɥɨɝɢɤɭ Presenter. Ɇɨɠɟɬ ɨɤɚɡɚɬɶɫɹ,
ɱɬɨ MVC ɧɟ ɫɨɜɫɟɦ ɩɨɞɯɨɞɢɬ ɞɥɹ ɩɪɢɥɨɠɟɧɢɣ ɫ ɨɱɟɧɶ ɫɥɨɠɧɵɦɢ ɩɨɥɶɡɨɜɚɬɟɥɶɫɤɢɦ ɢɧɬɟɪɮɟɣɫɨɦ, ɩɪɟɞɩɨɥɚɝɚɸɳɢɦ ɜɡɚɢɦɨɞɟɣɫɬɜɢɟ ɧɟɫɤɨɥɶɤɢɯ ɉɪɟɞɫɬɚɜɥɟɧɢɣ, ɬɚɤ ɤɚɤ ɨɪɝɚɧɢɡɚɰɢɹ ɜɡɚɢɦɨɞɟɣɫɬɜɢɹ ɥɨɠɢɬɫɹ ɧɚ ɧɟɫɤɨɥɶɤɨ ɤɨɧɬɪɨɥɥɟɪɨɜ. ȼ MVP ɜɫɹ ɩɨɞɨɛɧɚɹ ɫɥɨɠɧɚɹ ɥɨɝɢɤɚ
ɦɨɠɟɬ ɛɵɬɶ ɢɧɤɚɩɫɭɥɢɪɨɜɚɧɚ ɜ Presenter, ɤɨɬɨɪɵɣ ɦɨɠɟɬ ɡɧɚɱɢɬɟɥɶɧɨ ɩɪɨɳɟ ɜ ɧɚɩɢɫɚɧɢɢ ɢ ɫɨɩɪɨɜɨɠɞɟɧɢɢ.
ȼ ɡɚɜɢɫɢɦɨɫɬɢ ɨɬ ɪɟɚɥɢɡɚɰɢɢ MVP ɦɨɠɟɬ ɛɵɬɶ ɛɨɥɟɟ ɥɟɝɤɢɦ ɩɪɢ ɚɜɬɨɦɚɬɢɱɟɫɤɨɦ
ɦɨɞɭɥɶɧɨɦ ɬɟɫɬɢɪɨɜɚɧɢɢ, ɱɟɦ MVC. Presenter ɦɨɠɟɬ ɫɨɞɟɪɠɚɬɶ ɜ ɫɟɛɟ ɫɪɚɡɭ
ɜɟɫɶ ɢɧɬɟɪɮɟɣɫ ɢ ɩɨɷɬɨɦɭ ɟɝɨ ɦɨɠɧɨ ɩɪɨɬɟɫɬɢɪɨɜɚɬɶ ɧɟɡɚɜɢɫɢɦɨ ɨɬ ɞɪɭɝɢɯ
ɤɨɦɩɨɧɟɧɬɨɜ. ɇɨ ɜɫɟ ɷɬɨ ɡɚɜɢɫɢɬ ɨɬ ɜɵɛɪɚɧɧɨɝɨ ɹɡɵɤɚ, ɧɚ ɤɨɬɨɪɨɦ ɨɫɭɳɟɫɬɜɥɹɟɬɫɹ
ɪɟɚɥɢɡɚɰɢɹ MVP.
ȼ ɰɟɥɨɦ, ɨɫɧɨɜɧɵɟ ɩɪɨɛɥɟɦɵ MVC ɫɤɨɪɟɟ ɜɫɟɝɨ ɫɩɪɚɜɟɞɥɢɜɵ ɞɥɹ MVP,
ɭɱɢɬɵɜɚɹ, ɱɬɨ ɪɚɡɥɢɱɢɹ ɦɟɠɞɭ ɧɢɦɢ, ɜ ɨɫɧɨɜɧɨɦ, ɫɟɦɚɧɬɢɱɟɫɤɢɟ. ɂ ɟɫɥɢ ɩɪɢ ɪɚɡɪɚɛɨɬɤɟ ɩɪɢ-
140
Ȼ.ɉ. ȿɥɢɫɟɟɜ, Ⱥ.ȼ. Ɍɚɪɚɫɟɧɤɨ, Ɉ.Ⱥ. Ƚɨɪɛɚɱɟɜ, Ʌɸ Ⱦɠɨɧɞɚ
ɥɨɠɟɧɢɹ ɚɤɤɭɪɚɬɧɨ ɨɬɞɟɥɹɬɶ ɩɪɨɛɥɟɦɵ ɩɪɢ ɧɚɩɢɫɚɧɢɢ Ɇɨɞɟɥɢ, ɉɪɟɞɫɬɚɜɥɟɧɢɹ ɢ
Ʉɨɧɬɪɨɥɥɟɪɚ ɢɥɢ Presenter ɦɨɠɧɨ ɫɦɟɥɨ ɩɨɥɚɝɚɬɶɫɹ ɧɚ ɬɟ ɩɪɟɢɦɭɳɟɫɬɜɚ, ɤɨɬɨɪɵɟ ɞɚɸɬ ɨɛɚ
ɩɚɬɬɟɪɧɚ.
4. MVC ȾɅə ȼȿȻ-ɉɊɂɅɈɀȿɇɂɃ
ɑɬɨɛɵ ɩɪɢɦɟɧɢɬɶ MVC ɞɥɹ ɜɟɛ-ɩɪɢɥɨɠɟɧɢɣ, ɚɜɬɨɪɵ ɢɫɩɨɥɶɡɨɜɚɥɢ ɤɨɦɛɢɧɚɰɢɸ ɫɤɪɢɩɬɨɜ, ɫɟɪɜɟɪɧɵɯ ɤɨɦɩɨɧɟɧɬɨɜ ɢ ɨɛɵɱɧɵɯ ɨɛɴɟɤɬɨɜ ɞɥɹ ɪɟɚɥɢɡɚɰɢɢ ɪɚɡɥɢɱɧɵɯ ɤɨɦɩɨɧɟɧɬɨɜ ɜ
ɪɚɦɤɚɯ ɩɪɢɥɨɠɟɧɢɹ.
ɇɚ ɪɢɫ. 1 ɩɪɟɞɫɬɚɜɥɟɧɚ ɜɪɟɦɟɧɧɚɹ ɞɢɚɝɪɚɦɦɚ ɩɚɪɵ ɡɚɩɪɨɫ-ɨɬɜɟɬ ɧɚ ɩɪɢɦɟɪɟ ɡɚɩɪɨɫɚ
ɫɩɢɫɤɚ ɚɤɬɢɜɧɨɝɨ ɫɩɟɚɰɚɜɬɨɬɪɚɧɫɩɨɪɬɚ.
Ɋɢɫ. 1. ȼɪɟɦɟɧɧɚɹ ɞɢɚɝɪɚɦɦɚ ɩɚɪɵ ɡɚɩɪɨɫ-ɨɬɜɟɬ
5. ɋȿɊȼɂɋɕ
ɉɪɢ ɪɚɡɪɚɛɨɬɤɟ ɜɟɛ-ɩɪɢɥɨɠɟɧɢɹ ɜɨɡɧɢɤɚɸɬ ɫɢɬɭɚɰɢɢ, ɤɨɝɞɚ Ɇɨɞɟɥɶ ɢ Ʉɨɧɬɪɨɥɥɟɪ ɜɡɚɢɦɨɞɟɣɫɬɜɭɸɬ ɞɨɫɬɚɬɨɱɧɨ ɬɟɫɧɨ ɢ ɩɪɚɤɬɢɱɟɫɤɢ ɧɟɜɨɡɦɨɠɧɨ ɪɚɡɞɟɥɢɬɶ ɤɨɞ ɧɚ ɞɜɚ ɤɨɦɩɨɧɟɧɬɚ.
Ⱦɥɹ ɢɫɤɥɸɱɟɧɢɹ ɷɬɨɝɨ ɷɮɮɟɤɬɚ ɢɫɩɨɥɶɡɭɸɬ ɫɯɟɦɭ, ɩɪɢ ɤɨɬɨɪɨɣ Ʉɨɧɬɪɨɥɥɟɪ ɩɪɟɞɨɫɬɚɜɥɹɟɬ ɦɢɧɢɦɚɥɶɧɵɟ ɞɟɣɫɬɜɢɹ, ɧɚɩɪɢɦɟɪ, ɬɨɥɶɤɨ ɨɛɪɚɛɨɬɤɭ HTTP-ɡɚɩɪɨɫɨɜ ɢ ɩɟɪɟɞɚɱɭ ɪɟɡɭɥɶɬɚɬɚ
ɜ Ɇɨɞɟɥɶ. ȼ ɷɬɨɦ ɫɥɭɱɚɟ Ɇɨɞɟɥɶ ɦɨɠɟɬ ɫɨɞɟɪɠɚɬɶ ɜ ɫɟɛɟ ɧɟɨɛɯɨɞɢɦɵɟ ɦɟɬɨɞɵ ɨɛɪɚɛɨɬɤɢ ɪɟɡɭɥɶɬɚɬɨɜ ɢ ɮɨɪɦɚɬɢɪɨɜɚɧɢɹ ɜɵɯɨɞɧɵɯ ɞɚɧɧɵɯ.
ȼ ɤɚɱɟɫɬɜɟ ɚɥɶɬɟɪɧɚɬɢɜɵ ɞɚɧɧɨɦɭ ɪɟɲɟɧɢɸ ɩɪɟɞɩɨɥɚɝɚɟɬɫɹ ɨɬɞɟɥɢɬɶ ɨɬ ɫɜɹɡɤɢ ɆɨɞɟɥɶɄɨɧɬɪɨɥɥɟɪ ɬɚɤ ɧɚɡɵɜɚɟɦɵɣ ɋɟɪɜɢɫ.
ɋɟɪɜɢɫɵ, ɜɵɫɬɭɩɚɸɬ ɜ ɪɨɥɢ ɛɢɛɥɢɨɬɟɤ ɦɧɨɝɨɤɪɚɬɧɨɝɨ ɢɫɩɨɥɶɡɨɜɚɧɢɹ ɤɨɞɚ ɞɥɹ ɞɪɭɝɢɯ
ɤɨɦɩɨɧɟɧɬɨɜ ɩɪɢɥɨɠɟɧɢɹ. Ɉɧɢ ɨɛɟɫɩɟɱɢɜɚɸɬ ɩɪɢɥɨɠɟɧɢɟ ɫɤɜɨɡɧɵɦ ɮɭɧɤɰɢɨɧɚɥɨɦ,
ɧɚɩɪɢɦɟɪ, ɥɨɝɢɪɨɜɚɧɢɟɦ, ɨɛɪɚɛɨɬɤɨɣ ɨɲɢɛɨɤ, ɩɪɨɜɟɪɤɨɣ ɩɪɚɜ ɞɨɫɬɭɩɚ, ɨɛɦɟɧɨɦ ɫɨɨɛɳɟɧɢɣ
ɢ ɤɷɲɢɪɨɜɚɧɢɟɦ. ɋɟɪɜɢɫɵ ɦɨɝɭɬ ɫɨɞɟɪɠɚɬɶ ɤɨɞ ɞɥɹ ɡɚɩɪɨɫɚ ɢ ɯɪɚɧɟɧɢɹ ɞɚɧɧɵɯ ɫ ɜɧɟɲɧɢɯ
ɫɟɪɜɟɪɨɜ. Ɉɧɢ ɬɚɤɠɟ ɦɨɝɭɬ ɜɤɥɸɱɚɬɶ ɜ ɫɟɛɹ ɮɭɧɤɰɢɨɧɚɥɶɧɵɟ ɜɨɡɦɨɠɧɨɫɬɢ ɞɥɹ
ɫɨɪɬɢɪɨɜɤɢ, ɮɢɥɶɬɪɚɰɢɢ ɢ ɩɪɟɨɛɪɚɡɨɜɚɧɢɹ ɞɚɧɧɵɯ ɜ ɪɚɡɥɢɱɧɵɟ ɮɨɪɦɚɬɵ ɩɨ ɦɟɪɟ
ɧɟɨɛɯɨɞɢɦɨɫɬɢ [3].
ɇɚ ɪɢɫ. 2 ɩɪɟɞɫɬɚɜɥɟɧɚ ɜɪɟɦɟɧɧɚɹ ɞɢɚɝɪɚɦɦɚ ɩɚɪɵ ɡɚɩɪɨɫ-ɨɬɜɟɬ ɧɚ ɩɪɢɦɟɪɟ ɡɚɩɪɨɫɚ
ɫɩɢɫɤɚ ɚɤɬɢɜɧɨɝɨ ɫɩɟɚɰɬɪɚɧɫɩɨɪɬɚ ɫ ɢɫɩɨɥɶɡɨɜɚɧɢɟɦ ɫɟɪɜɢɫɚ ɞɥɹ ɪɚɛɨɬɵ ɫ ɞɚɧɧɵɦɢ ɩɨ
ɬɪɚɧɫɩɨɪɬɭ.
ɉɪɨɝɪɚɦɦɧɵɣ ɩɚɬɬɟɪɧ ɩɪɨɟɤɬɢɪɨɜɚɧɢɹ ɚɪɯɢɬɟɤɬɭɪɧɨɝɨ ɤɚɪɤɚɫɚ...
141
Ɋɢɫ. 2. ȼɪɟɦɟɧɧɚɹ ɞɢɚɝɪɚɦɦɚ ɩɚɪɵ ɡɚɩɪɨɫ-ɨɬɜɟɬ ɩɪɢ ɧɚɥɢɱɢɢ ɋɟɪɜɢɫɚ
6. ɎɊȿɃɆȼɈɊɄ ANGULARJS
Ɋɟɚɥɢɡɚɰɢɹ ɜɟɛ-ɩɪɢɥɨɠɟɧɢɹ ɫɢɫɬɟɦɵ ɦɨɧɢɬɨɪɢɧɝɚ ɫɩɟɰɬɪɚɧɩɨɪɬɚ ɚɷɪɨɩɨɪɬɚ ɫ ɢɫɩɨɥɶɡɨɜɚɧɢɟɦ ɩɚɬɬɟɪɧɚ MVC ɜɨɡɦɨɠɧɚ ɜ ɫɥɟɞɭɸɳɟɣ ɫɜɹɡɤɟ: ɜ ɤɚɱɟɫɬɜɟ ɪɟɚɥɢɡɚɰɢɢ ɤɨɦɩɨɧɟɧɬɚ ɉɪɟɞɫɬɚɜɥɟɧɢɟ ɜɨɡɦɨɠɧɨ ɩɪɢɦɟɧɟɧɢɟ ɹɡɵɤɚ ɪɚɡɦɟɬɤɢ HTML, ɤɨɦɩɨɧɟɧɬɵ Ɇɨɞɟɥɶ ɢ Ʉɨɧɬɪɨɥɥɟɪ ɪɟɚɥɢɡɭɸɬɫɹ ɧɚ ɹɡɵɤɟ JavaScript, ɨɛɳɢɣ ɮɭɧɤɰɢɨɧɚɥ ɩɚɬɬɟɪɧɚ ɨɛɟɫɩɟɱɢɜɚɟɬ ɤɚɪɤɚɫ ɢɥɢ ɬɚɤ ɧɚɡɵɜɚɟɦɵɣ ɮɪɟɣɦɜɨɪɤ AngularJS.
AngularJS - ɷɬɨ ɤɥɢɟɧɬɫɤɢɣ ɮɪɟɣɦɜɨɪɤ, ɧɚɩɢɫɚɧɧɵɣ ɧɚ JavaScript ɢ ɜɵɩɨɥɧɹɟɦɵɣ ɜ ɛɪɚɭɡɟɪɟ. Ɉɫɧɨɜɧɚɹ ɰɟɥɶ ɮɪɟɣɦɜɨɪɤɚ - ɪɚɫɲɢɪɟɧɢɟ ɛɪɚɭɡɟɪɧɵɯ ɩɪɢɥɨɠɟɧɢɣ ɧɚ ɨɫɧɨɜɟ MVC ɲɚɛɥɨɧɚ, ɚ ɬɚɤɠɟ ɭɩɪɨɳɟɧɢɟ ɬɟɫɬɢɪɨɜɚɧɢɹ ɢ ɪɚɡɪɚɛɨɬɤɢ. AngularJS ɚɞɚɩɬɢɪɭɟɬ ɢ ɪɚɫɲɢɪɹɟɬ ɬɪɚɞɢɰɢɨɧɧɵɣ HTML, ɱɬɨɛɵ ɨɛɟɫɩɟɱɢɬɶ ɞɜɭɫɬɨɪɨɧɧɸɸ ɩɪɢɜɹɡɤɭ ɞɚɧɧɵɯ ɞɥɹ ɞɢɧɚɦɢɱɟɫɤɨɝɨ ɤɨɧɬɟɧɬɚ,
ɱɬɨ ɩɨɡɜɨɥɹɟɬ ɚɜɬɨɦɚɬɢɱɟɫɤɢ ɫɢɧɯɪɨɧɢɡɢɪɨɜɚɬɶ Ɇɨɞɟɥɶ ɢ ɉɪɟɞɫɬɚɜɥɟɧɢɟ. Ɇɟɯɚɧɢɡɦ ɩɨɫɬɪɨɟɧɢɹ ɉɪɟɞɫɬɚɜɥɟɧɢɣ ɧɟ ɬɪɟɛɭɟɬ ɹɜɧɨ ɨɛɧɨɜɥɹɬɶ ɞɟɪɟɜɨ DOM, ɬɚɤ ɤɚɤ ɮɪɟɣɦɜɨɪɤ ɫɩɨɫɨɛɟɧ ɫɥɟɞɢɬɶ ɡɚ ɞɟɣɫɬɜɢɹɦɢ ɩɨɥɶɡɨɜɚɬɟɥɹ, ɫɨɛɵɬɢɹɦɢ ɛɪɚɭɡɟɪɚ ɢ ɢɡɦɟɧɟɧɢɹɦɢ ɜ Ɇɨɞɟɥɢ ɢ ɜɨɜɪɟɦɹ ɨɛɧɚɪɭɠɢɜɚɬɶ, ɤɨɝɞɚ ɢ ɤɚɤɨɟ ɉɪɟɞɫɬɚɜɥɟɧɢɟ ɬɪɟɛɭɟɬɫɹ ɨɛɧɨɜɢɬɶ [4].
AngularJS ɢɦɟɟɬ ɜ ɡɚɩɚɫɟ ɦɟɯɚɧɢɡɦ ɜɧɟɞɪɟɧɢɹ ɡɚɜɢɫɢɦɨɫɬɟɣ (Dependency Injection), ɤɨɬɨɪɵɣ
ɫɭɳɟɫɬɜɟɧɧɨ ɭɩɪɨɳɚɟɬ ɫɛɨɪɤɭ ɜɟɛ-ɩɪɢɥɨɠɟɧɢɣ ɢɡ ɧɟɛɨɥɶɲɢɯ, ɧɚɞɟɠɧɨ ɩɪɨɬɟɫɬɢɪɨɜɚɧɧɵɯ ɫɥɭɠɛ.
Ɉɛɳɚɹ ɫɬɪɭɤɬɭɪɚ ɜɡɚɢɦɨɞɟɣɫɬɜɢɹ ɤɨɦɩɨɧɟɧɬɨɜ MVC ɜ ɪɚɦɤɚɯ ɦɨɞɭɥɹ ɩɪɢɥɨɠɟɧɢɹ ɞɥɹ
ɮɨɪɦɢɪɨɜɚɧɢɹ ɨɬɱɟɬɨɜ ɫ ɢɫɩɨɥɶɡɨɜɚɧɢɟɦ ɞɚɧɧɨɝɨ ɮɪɟɣɦɜɨɪɤɚ ɩɨɤɚɡɚɧɚ ɧɚ ɪɢɫ. 3.
Ɋɢɫ. 3. Ɉɛɳɚɹ ɫɬɪɭɤɬɭɪɚ ɜɡɚɢɦɨɞɟɣɫɬɜɢɹ ɤɨɦɩɨɧɟɧɬɨɜ MVC ɜ AngularJS
142
Ȼ.ɉ. ȿɥɢɫɟɟɜ, Ⱥ.ȼ. Ɍɚɪɚɫɟɧɤɨ, Ɉ.Ⱥ. Ƚɨɪɛɚɱɟɜ, Ʌɸ Ⱦɠɨɧɞɚ
ɇɟɦɚɥɨɜɚɠɧɵɦ ɮɚɤɬɨɪɨɦ ɹɜɥɹɟɬɫɹ ɞɟɤɥɚɪɚɬɢɜɧɵɣ ɩɨɞɯɨɞ AngularJS ɤ ɤɨɧɫɬɪɭɢɪɨɜɚɧɢɸ
ɩɨɥɶɡɨɜɚɬɟɥɶɫɤɨɝɨ ɢɧɬɟɪɮɟɣɫɚ. ɋ ɩɪɚɤɬɢɱɟɫɤɨɣ ɬɨɱɤɢ ɡɪɟɧɢɹ ɷɬɨ ɨɡɧɚɱɚɟɬ, ɱɬɨ ɉɪɟɞɫɬɚɜɥɟɧɢɹ
ɨɩɢɫɵɜɚɸɬ ɠɟɥɚɟɦɵɣ ɷɮɮɟɤɬ, ɚ ɧɟ ɫɩɨɫɨɛɵ ɟɝɨ ɞɨɫɬɢɠɟɧɢɹ. ȼɨɡɦɨɠɧɨɫɬɶ ɞɟɤɥɚɪɚɬɢɜɧɨɝɨ ɨɩɢɫɚɧɢɹ ɉɪɟɞɫɬɚɜɥɟɧɢɣ ɩɨɡɜɨɥɹɟɬ ɛɵɫɬɪɨ ɫɨɡɞɚɜɚɬɶ ɫɥɨɠɧɨɟ ɢ ɢɧɬɟɪɚɤɬɢɜɧɵɟ ɢɧɬɟɪɮɟɣɫɵ.
Ⱥ ɩɪɢɧɹɬɢɟ ɪɟɲɟɧɢɣ ɨ ɬɨɦ, ɤɨɝɞɚ ɢ ɤɚɤ ɢɡɦɟɧɹɬɶ ɷɥɟɦɟɧɬɵ DOM ɛɟɪɟɬ ɧɚ ɫɟɛɹ ɮɪɟɣɦɜɨɪɤ.
ɁȺɄɅɘɑȿɇɂȿ
ȼ ɪɚɛɨɬɟ ɪɚɡɜɢɜɚɟɬɫɹ ɩɨɞɯɨɞ ɤ ɪɟɚɥɢɡɚɰɢɢ ɩɪɨɝɪɚɦɦɧɨɝɨ ɩɚɬɬɟɪɧɚ ɩɪɨɟɤɬɢɪɨɜɚɧɢɹ MVC
ɨɬɧɨɫɢɬɟɥɶɧɨ ɜɟɛ-ɩɪɢɥɨɠɟɧɢɣ. ɇɚ ɨɫɧɨɜɟ ɢɡɥɨɠɟɧɧɨɝɨ ɚɧɚɥɢɡɚ ɦɨɠɧɨ ɫɞɟɥɚɬɶ ɜɵɜɨɞ, ɨ ɰɟɥɟɫɨɨɛɪɚɡɧɨɫɬɢ ɩɪɢɦɟɧɟɧɢɹ ɩɚɬɬɟɪɧɚ MVC ɩɪɢ ɪɚɡɪɚɛɨɬɤɟ ɜɟɛ-ɩɪɢɥɨɠɟɧɢɣ ɫɢɫɬɟɦ ɦɨɧɢɬɨɪɢɧɝɚ
ɫɩɟɰɬɪɚɧɫɩɨɪɬɚ ɚɷɪɨɩɨɪɬɚ. Ⱦɚɧɧɵɣ ɩɨɞɯɨɞ ɩɨɡɜɨɥɢɬ ɡɧɚɱɢɬɟɥɶɧɨ ɭɩɪɨɫɬɢɬɶ ɦɨɞɭɥɶɧɭɸ ɪɚɡɪɚɛɨɬɤɭ ɢ ɞɚɥɶɧɟɣɲɟɟ ɫɨɩɪɨɜɨɠɞɟɧɢɟ ɩɪɨɝɪɚɦɦɧɨɝɨ ɩɪɨɞɭɤɬɚ.
ɅɂɌȿɊȺɌɍɊȺ
1. ɒɤɥɹɪ Ʌ., Ɋɨɡɟɧ Ɋ. Ⱥɪɯɢɬɟɤɬɭɪɚ ɜɟɛ-ɩɪɢɥɨɠɟɧɢɣ. – Ɇ.: ɗɤɫɦɨ, 2011.
2. Ƚɚɦɦɚ ɗ., ɏɟɥɦ Ɋ., Ⱦɠɨɧɫɨɧ Ɋ., ȼɥɢɫɫɢɞɟɫ Ⱦɠ. ɉɪɢɟɦɵ ɨɛɴɟɤɬɧɨ-ɨɪɢɟɧɬɢɪɨɜɚɧɧɨɝɨ ɩɪɨɟɤɬɢɪɨɜɚɧɢɹ.
ɉɚɬɬɟɪɧɵ ɩɪɨɟɤɬɢɪɨɜɚɧɢɹ. – ɋɉɛ.: ɉɢɬɟɪ, 2014.
3. Lavin J. AngularJS Services. Pack Publishung Ltd., Aug. 2014, ch. 1, pp. 8-11.
4. Ʉɨɡɥɨɜɫɤɢɣ ɉ., Ⱦɚɪɜɢɧ ɉ. Ɋɚɡɪɚɛɨɬɤɢ ɜɟɛ-ɩɪɢɥɨɠɟɧɢɣ ɫ ɢɫɩɨɥɶɡɨɜɚɧɢɟɦ AngularJS. – Ɇ.: ȾɆɄ-ɉɪɟɫɫ, 2014.
MVC SOFTWARE ARCHITECTURE PATTERN
FOR WEB-APPLICATION OF SYSTEM OF MONITORING OF AIRPORT TRANSPORT
Eliseev B.P., Tarasenko A.V., Gorbachev O.A., Lyu Dzhonda
The article describes MVC and MVP patterns, ways of interaction and the role of each component of the pattern,
the possibility of using services when developing an application. The diagrams of http-request-response pairs are presented
when using services and without them. The main features of the AngularJS framework are described.
Keywords: pattern, web-application, service, JavaScript, MVC, MVP, AngularJS.
REFERENCES
1. Shklyar L., Rozen R. Arhitektura web-prilozheni (Web-application architecture), Moscow, Eksmo, 2011, 640 p.
2. Gamma E., Helm R., Dzhonson R., Vlissides Dzh. Priemyi ob'ektno-orientirovannogo proektirovaniya. Patternyi
proektirovaniya (Design Patterns. Elements of Reusable Object-Oriented Software), Saint Petersburg, Piter, 2014. 368 p.
3. Lavin J. AngularJS Services. Pack Publishung Ltd., Aug. 2014, ch. 1, pp. 8-11.
4. Kozlovskiy P., Darvin P. Razrabotki veb-prilozheniy s ispolzovaniem AngularJS (Mastering web application development with AngularJS), Moscow, DMK-Press, 2014, 394 p.
ɋɜɟɞɟɧɢɹ ɨɛ ɚɜɬɨɪɚɯ
Елисеев Борис Петрович, 1957 г.р., профессор Технологического университета Нингбо, ректор МГТУ ГА,
окончил Дальневосточный государственный университет (1982), профессор, доктор юридических наук, доктор
технических наук, заслуженный юрист РФ, автор более 150 научных работ, область научных интересов –
государственное управление, административное, финансовое, воздушное право.
Ɍɚɪɚɫɟɧɤɨ Ⱥɥɟɤɫɟɣ ȼɹɱɟɫɥɚɜɨɜɢɱ, 1987 ɝ.ɪ. ɨɤɨɧɱɢɥ ɆȽɌɍ ȽȺ (2014), ɧɚɱɚɥɶɧɢɤ ɨɬɞɟɥɚ ɪɚɡɜɢɬɢɹ ɢɧɮɨɪɦɚɰɢɨɧɧɵɯ ɫɟɪɜɢɫɨɜ ɈɈɈ «ɂɧɬɟɥɥɟɤɬɭɚɥɶɧɵɟ ɬɟɥɟɦɚɬɢɱɟɫɤɢɟ ɫɢɫɬɟɦɵ ɞɥɹ ɬɪɚɧɫɩɨɪɬɚ», ɨɛɥɚɫɬɶ ɧɚɭɱɧɵɯ
ɢɫɫɥɟɞɨɜɚɧɢɣ - ɩɪɨɟɤɬɢɪɨɜɚɧɢɟ ɩɨɥɶɡɨɜɚɬɟɥɶɫɤɢɯ ɢɧɬɟɪɮɟɣɫɨɜ.
Ƚɨɪɛɚɱɟɜ Ɉɥɟɝ Ⱥɧɚɬɨɥɶɟɜɢɱ, 1959 ɝ.ɪ., ɨɤɨɧɱɢɥ ɂȽɍ (1982), ɞɨɤɬɨɪ ɬɟɯɧɢɱɟɫɤɢɯ ɧɚɭɤ, ɩɪɨɮɟɫɫɨɪ, ɞɢɪɟɤɬɨɪ ɂɪɤɭɬɫɤɨɝɨ ɮɢɥɢɚɥɚ ɆȽɌɍ ȽȺ, ɚɜɬɨɪ 56 ɧɚɭɱɧɵɯ ɪɚɛɨɬ, ɨɛɥɚɫɬɶ ɧɚɭɱɧɵɯ ɢɧɬɟɪɟɫɨɜ – ɪɚɞɢɨɮɢɡɢɤɚ, ɫɩɭɬɧɢɤɨɜɵɟ ɫɢɫɬɟɦɵ ɧɚɜɢɝɚɰɢɢ.
Ʌɸ Ⱦɠɨɧɞɚ, 1963 ɝ.ɪ., ɨɤɨɧɱɢɥ ɭɧɢɜɟɪɫɢɬɟɬ ɜ ɝ. ɑɚɧɴɚɧɶ, ɞɨɤɬɨɪ ɧɚɭɤ ɩɨ ɫɩɟɰɢɚɥɶɧɨɫɬɢ: Ɇɨɫɬɵ ɢ ɬɨɧɧɟɥɢ
ɢɧɠɟɧɟɪɧɵɟ, ɩɨɱɟɬɧɵɣ ɩɪɨɮɟɫɫɨɪ ɆȽɌɍ ȽȺ, ɪɟɤɬɨɪ Ɍɟɯɧɨɥɨɝɢɱɟɫɤɨɝɨ ɭɧɢɜɟɪɫɢɬɟɬɚ ɇɢɧɝɛɨ, ɚɜɬɨɪ ɛɨɥɟɟ
30 ɧɚɭɱɧɵɯ ɪɚɛɨɬ, ɨɛɥɚɫɬɶ ɧɚɭɱɧɵɯ ɢɧɬɟɪɟɫɨɜ – ɬɪɚɧɫɩɨɪɬɧɨɟ ɨɛɪɚɡɨɜɚɧɢɟ, ɬɪɚɧɫɩɨɪɬɧɚɹ ɢɧɮɪɚɫɬɪɭɤɬɭɪɚ.
Скачать