Skip to Content
面向对象的思考过程(原书第5版)
book

面向对象的思考过程(原书第5版)

by 马特 魏斯费尔德
August 2021
Intermediate to advanced
450 pages
4h 46m
Chinese
Pearson
Content preview from 面向对象的思考过程(原书第5版)

10.2 Smalltalk的模型/视图/控制器

纵观历史,不得不提Smalltalk中引入的模型/视图/控制器(MVC)。其他面向对象的语言也使用了这种模式。MVC经常用来演示设计模式的起源。在SmallTalk中模型/视图/控制器范式用于创建用户接口。SmallTalk大概是第一个广受欢迎的面向对象的语言。

Smalltalk

Smalltalk是Xerox PARC提出的几个伟大的想法的最终结果。这些想法包括鼠标以及使用视窗环境等。Smalltalk是一门精彩的语言,它提供了所有面向对象的语言需要遵循的根本特性。对于C++的抱怨之一是它不是真正的面向对象语言,而Smalltalk则是真正的面向对象的语言。尽管在应用面向对象的早期C++有更多的追随者,而Smalltalk始终有一个非常专注的核心支持团队。Java是一个最受C++开发人员喜爱的面向对象的语言。

设计模式以以下方式定义了MVC组件:模型是应用程序对象,视图是屏幕展示,控制器则定义了用户接口如何响应用户输入。

之前的范式的问题在于模型、视图和控制器都被集中到了单个实体中。例如,单个对象会包括这三个部分。使用MVC范式,这三个部件被分离开来并且拥有截然不同的接口。所以如果你想修改应用程序的用户接口,你只需修改视图即可。图10.1演示了MVC设计。

图10.1 模型/视图/控制器范式

学习面向对象的开发过程其实就是关于接口与实现的设计问题。我们想尽可能地隔离接口和实现,也想尽可能隔离不同的接口。例如,如果多个接口之间没有任何关联(或者解决方案与问题无关),那么就不需要组合这些接口。MVC是实践接口分离的先锋之一。MVC明确地定义了特定的组件之间的接口,这些不同的组件一起解决了一个非常通用的且基本的编程问题。这个编程问题就是创建用户接口,并且建立业务逻辑和业务背后的数据之间的联系。 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Node与Express开发(第2版)

Node与Express开发(第2版)

Ethan Brown
手把手教会你linux

手把手教会你linux

桑德.范.乌格特
Java并发编程实战

Java并发编程实战

Brian Goetz, Tim Peierls

Publisher Resources

ISBN: 9787111684527