2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

自分用 MVCアーキテクチャ

Last updated at Posted at 2021-09-07

MVCの概略

設計思想の話で、要はコードを整理していく指針。
目的は保守性を上げたり、コードの再利用性を上げたりすること。
これにならってコーディングしていくと拡張もしやすい。

登場人物(に置き換える)

Model氏

データの管理を担当

View氏

画面の入出力を担当
画面に表示するものや、画面からクライアントの入力を受け取るもの

Controller氏

アプリの主な制御(ビジネスロジック)を担当

補足:ビジネスロジックとは

*画面を出し分ける際の判定するか
*ユーザーがログインしたときにこのログイン情報でログインさせるか

登場人物の相関関係

最低限、以下View起点の3つを抑えとく。

1.Viewで入力
⇒Controllerに伝え
⇒その値をModelとして保持

2.Viewで入力
⇒Controllerに伝え、その値によって
⇒Viewを呼ぶ

3.Viewで使用する変数は
⇒Modelから取得する

補足

そのほかにModelの値を変更すればその変更がそのままDBに反映される高度な実装、や
MVVM(Model・View・ViewModel)アーキテクチャなどがある。

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?