教学文库网 - 权威文档分享云平台
您的当前位置:首页 > 范文大全 > 文秘资料 >

复合设计模式学习笔记-MVC Song

来源:网络收集 时间:2026-08-12
导读: 设计模式 复合模式 MVC 策略模式 观察者 组合模式 MVC song Model View, Model View, Model View Controller MVC's the paradigm for factoring your code, into functional segments so your brain does not explode. To achieve reusability you gotta kee

设计模式 复合模式 MVC 策略模式 观察者 组合模式

MVC song

Model View, Model View, Model View Controller

MVC's the paradigm for factoring your code,

into functional segments so your brain does not explode.

To achieve reusability you gotta keep those boundaries clean,

Model on the one side, View on the other, the Controller's in between.

Model View — It's got three layers like Oreos do.

Model View creamy Controller

Model objects represent your applications raison d'être.

Custom classes that contain data logic and et cetra.

You create custom classes in your app's problem domain,

then you can choose to reuse them with all the views,

but the model objects stay the same.

You can model a throttle in a manifold,

Model level two year old.

Model a bottle of fine Chardonnay.

Model all the twaddle stuff people say.

Model the coddle in a boiling eggs.

Model the waddle in Hexley's legs.

One, two, three, four.

Model View — You can model all the models that pose for GQ.

Model View Controller

View objects tend to be controls that view and edit,

Cocoa's got a lot of those, well written to its credit.

Take an NSTextView, hand it any old Unicode string,

the user interacts with it, it can hold most anything.

But the view don't knows about the Model:

That string could be a phone number or the words of Aristotle.

Keep the coupling loose and so achieve a massive level of reuse.

Model View — All rendered very nicely in Aqua blue

Model View Controller

You're probably wondering now.

You're probably wondering how,

the data flows between Model and View.

The Controller has to mediate,

between each layer's changing state,

设计模式 复合模式 MVC 策略模式 观察者 组合模式

to synchronize the data of the two.

It pulls and pushes every changed value.

Yeah.

Model View — mad props to the smalltalk crew!

for Model View Controller

Model View — it's pronouced Oh Oh not Uh Uh

Model View Controller

There's a bit more on this story,

a few more miles upon this road,

well nobody seems to get much glory

writing controller code.

Well the model is mission critical

and gorgeous is the view,

But I'm not being lazy, but sometimes it's just crazy

how much code i write is just glue.

And it wouldn't be so tragic,

but the code ain't doing magic:

it's just moving values through.

And I wish I had a dime

for every single time

I set a TextField's stringValue.

Model View — how we're gonna deep—six all that glue

Model View Controller

Controller's know the Model and View very

uahh — intimately

They often are hardcoding

which is very verboten for reusability.

But now you can connect any value you select

to any view property.

And I think you'll start binding,

then you'll be finding less code in your source tree.

Yeah I know I was astounded,

that's not even a rhyme.

But I think it bares repeating

all the code you won't be needing,

when you hook it up in IB.

Model View — it even handles multiple selections too

Model View Controller

设计模式 复合模式 MVC 策略模式 观察者 组合模式

Model View — hope I get my G5 before you

Model View Controller

Yeah, yeah, yeah. Yeah.

汉语翻译:

复合模式之王--Model - view-controller

模型-视图-控制器

MVC是一种泛型

它构造代码成为功能段,免得你脑袋淤阻

为达到复用,你必须让边界干净

这边是模型,那边是视图,控制器在中间

模型 视图 和夹心饼干一样有三层

模型 视图 控制器

模型 视图 模型视图 模型 视图 控制器

模型对象正是你的应用系统存在的理由

你设计的对象,包含了数据、逻辑和其他

在你的应用领域,你创建定制的类

你可以选择复用所有视图

但模型对象无需改变

你可以建模一部机器,随便什么机器

建模一个两岁小孩

建模一瓶白葡萄酒

建模人们的窃窃私语

建模一些水煮蛋

建模Hexley的蹒跚步履

模型 视图

你可以建模GQ时尚杂志中的模特儿

模型 视图 控制器

视图对象通常是控件,用来显示和编辑

Cocoa也是这样,设计良好,赢得好评

设计模式 复合模式 MVC 策略模式 观察者 组合模式

把任何老的Unicode字符串交给NSTextView

用户可以和它交互,它几乎可以包含任何东西

但视图不知道模型

字符串可以是一个电话号码,或者亚里士多德的文学作品

保持松耦合

达到最高的复用

模型 视图,一切都是水波荡漾的蓝色

模型 视图 控制器

你可能正在纳闷

你可能正在纳闷

模型和视图之间的数据流动

是由控制器居中协调进行

两者之间状态的改变,数据的同步

都是有控制器控制的

控制器负责将每个改变的状态送进送出

模型 视图 对于Smalltalk的人来说

这是最大的支柱

模型 视图控制器

模型 视图,读作“噢噢”,不是“呜呜”

模型 视图 控制器

旅程尚未结束

前方还有道路

编写控制器的人

似乎没有得到掌声

模型的使命很重要

视图的外观很美妙

我或许很懒,但有时却是疯了

我写了多少代码,只为了黏着两者

其实并不惨痛

说穿了代码并没有神奇之处

只是用来搬动值罢了

我无意出言恐吓

这是有声誉的

对于控制器你照做就是了

我真希望能得到一个铜板的奖赏

每次将字符串

送到TextField时

设计模式 复合模式 MVC 策略模式 观察者 组合模式

模型 视图

我们要如何丢弃黏结

模型 视图 控制器

控制器相当熟悉模型和视图

所以常常硬编码来妨碍复用

你可以将模型的键连接到任何视图属性

一旦开始 …… 此处隐藏:5236字,全部文档内容请下载后查看。喜欢就下载吧 ……

复合设计模式学习笔记-MVC Song.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.jiaowen.net/fanwen/2175951.html(转载请注明文章来源)
Copyright © 2020-2025 教文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:78024566 邮箱:78024566@qq.com
苏ICP备19068818号-2
Top
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)