南京大学计算机软件研究所.pptVIP

  • 27
  • 0
  • 约1.65万字
  • 约 86页
  • 2018-04-14 发布于浙江
  • 举报
南京大学计算机软件研究所

Class and Object 马晓星 南京大学计算机软件研究所 南京大学计算机科学与技术系 关于对象式语言 本课程并不系统讲授Eiffel语言 但应学会“欣赏” Eiffel 语言 (比较“纯”) 它首先是一个对象式程序设计语言 但强调从分析到设计到实现的平滑过渡 本课程主要讨论基于“类”的面向对象语言,但另有一些语言并不基于“类”概念。 Outline Three worlds: Object-Oriented Modeling Class: the static structure Object: the run-time structure Object creation: from classes to objects Object reference: linking up objects Outline Three worlds: Object-Oriented Modeling Class: the static structure Object: the run-time structure Object creation: from classes to objects Object reference: linking up objects Three worlds 客观世界 DVD播放机 What is reality? 复杂性 认识的主观性 问题世界 抽象!Tell me not what you are but what you have A model of a subset of the reality DVD播放机 计算机(软件)世界 A model of a model of a subset of the reality Outline Three worlds: Object-Oriented Modeling Class: the static structure Object: the run-time structure Object creation: from classes to objects Object reference: linking up objects Class: the static structure 类是对象式软件系统的基本组成单元 类的构成 类的使用 信息隐蔽设施 模块与类型 类如何构成系统? 其它 Class “A class is an abstract data type equipped with a possibly partial implementation.” Deferred and effective class But why? A very deferred class deferred class COUNTER feature item: INTEGER is deferred end -- Counter value up is -- Increase item by 1. deferred ensure item = old item + 1 end down is -- Decrease item by 1. deferred ensure item = old item – 1 end invariant item = 0 end Class Mold and instance 类自身也能被当作对象么 类的构成 类名 继承关系 成员 术语 分类 Abstract data type POINT x: POINT ? REAL y: POINT ? REAL ?: POINT ? REAL ?: POINT ? REAL Class POINT: Choose a representation (polar, cartesian) In polar representation, ? and ? are attributes, x and y are routines. A simple class class POINT feature x, y: REAL -- Point cartesian coordinates move (a, b: REAL) is -- Move by a horizontally and by b vertically. do x := x + a y := y + b end scale (factor: REAL) is -- Scale by factor. do x := factor

文档评论(0)

1亿VIP精品文档

相关文档