1-1面向对象初探
变量也是Object
Data: the properties or status; is the core
Operations: the functions对外能提供的服务,给灯通电或者不通电。
map
Problem space --------------Solution space
object oriented(00)
是一种组织 设计 和实现的思想(Designs&Implementations)
2-2 面向对象基本概念
对象之间通过message进行信息交换
Object send messages
Messages are
Composed by the sender
Interpreted by the receiver
Implemented by the methods
Messages
May cause receiver to change state
May return the result
Object vs.Class
Object(cat)
Represent things,events ,or concepts
Respond to message at run-time
Class(cat class)
Define properties of instances
Act like types in C++
OOP Characteristics
1.Evertything is an objetct.
2.A program is a bunch of objects telling each other what to do by sending messages.
3.Each Object has its own memory make up of other objects.
4.Every object has a type.
5.All objects of a particular type can receive the same messages.
An object has an interface
The interface is the way it receives messages.
It is defined in the class the object belong to.
Functions of the interface
如果有借口,那么可以很方便的换其他东西,做出在程序中可以拆换的东西
耦合-内聚,耦合性大是我们希望做到的。
Communication:与外界进行沟通。
Protection;如果有借口,就可以保护内部的Implementations,外边的借口了还是不变的。
The Hidden Implementation(隐藏实现)
Inner part of an object, data members to present its state, and the actions it takes
when messages is rcvd is hidden.
Class creators Vs. Client programmers
-Keep client programmer's hand off portions they should not touch.
-Allow the class creators to change the interval working of the class without worrying how it will affect the client programmers.
Encapsulation(封装)
bundle data and methods dealing with these data together in an object
Hide the details of the data and action.
Restrict only access to the publicized methods.