bin^2

bin^2

discord server
twitter

UI架构模式——MVC/MVVM/MV对比

MVC/MVVM/MV 对比#

scale 2
!theme vibrant
namespace mvc {
	namespace ui {
		class Controller
		class View
	}
	namespace data {
		class Model
	}
	Controller --> View :update & listen
	Controller --> Model : get & set
	View --> Model
}
namespace mvvm {
	namespace ui {
		class View
		class ViewModel
		View --> ViewModel : data binding
	}
	namespace data {
		class Model
		ViewModel --> Model : get & set
	}
}
namespace mv {
	namespace data {
		class StatefulModel
		class Model
		StatefulModel --> Model
	}
	namespace ui {
		class View
		View --> StatefulModel : observe & action
	}
}

image

MVX#

  • StatefulModel 优先
  • 如果不能修改 StatefulModel 或者仅修改 ui 层,则使用 ViewModel
  • 如果没有数据绑定框架使用 Controller
scale 2
!theme vibrant
namespace data {
	class StatefulModel
	class Model
	StatefulModel --> Model
}
namespace ui {
	class ViewModel
	class View
	class Controller
	Controller --> View : update & listen
    Controller --> ViewModel : get & set
	View --> ViewModel : data binding
	ViewModel --> StatefulModel : observe & action
	View --> StatefulModel : observe & action
}

image

加载中...
此文章数据所有权由区块链加密技术和智能合约保障仅归创作者所有。