Contenu connexe Similaire à Object-Oriented Programming Concepts (20) Object-Oriented Programming Concepts13. 13Object-Oriented Concepts
©2000KwangShinOh
Http://raytrust.pe.kr
What is an
Object?
often, for implementation or efficiency
reasons
an object may wish to expose some of its
variables or hide some of its methods
so, in many languages, including Java
an object can choose to expose its
variables to other objects allowing those
other objects to inspect and even modify
the variables
15. 15Object-Oriented Concepts
©2000KwangShinOh
Http://raytrust.pe.kr
What is an
Object?
Information hiding
an object has a public interface that other
objects can use to communicate with it
the object can maintain private information
and methods that can be changed at any
time without affecting the other objects that
depend on it
you don’t need to understand the gear
mechanism on your bike in order to use it
18. 18Object-Oriented Concepts
©2000KwangShinOh
Http://raytrust.pe.kr
What is a
Message?
sometimes the receiving object needs
more information so that it knows
exactly what to do
this information is passed along with the
message as parameters
Three components comprise a
message
1. The object to whom the message is addressed
2. The name of the method to perform
3. Any parameters needed by the method
20. 20Object-Oriented Concepts
©2000KwangShinOh
Http://raytrust.pe.kr
What is a
Message?
The Benefits of Messages
an object’s behavior is expressed through
its methods
so message passing supports all possible
interactions between objects
objects don’t need to be int the same
process or even on the same machine
to send and receive messages back and forth
to each other
22. 22Object-Oriented Concepts
©2000KwangShinOh
Http://raytrust.pe.kr
What is a Class?
bicycles have some state(speed, current
cadence, current gear) and
behavior(change gears, brake, change
cadence) in common
however, each bicycle’s state is
independent of and can be different
fromother bicycles
produce a new blueprint for every individual
bicycle they manufactured
it would be very inefficient!!!!
23. 23Object-Oriented Concepts
©2000KwangShinOh
Http://raytrust.pe.kr
What is a Class?
in object-oriented software
it’s also possible to have many objects of
the same kind that share characteristics
rectangles, employee records, video clips and
so on
you can take advantage of the fact
objects of the same kind are similar and you
can create a blueprint for those objects
27. 27Object-Oriented Concepts
©2000KwangShinOh
Http://raytrust.pe.kr
What is a Class?
in addition to instance variables and
methods, classes can also define
class variables and class
methods
you can access class variables and
methods from
an instance of the class
directly from a class
you don’t have to instantiate a class
to use its class variables and methods
28. 28Object-Oriented Concepts
©2000KwangShinOh
Http://raytrust.pe.kr
What is a Class?
class methods can only operate on
class variables
they do not have access to instance
variables or instance methods
the first time it encounters the class
the system creates a single copy of all
class variables for a class
all instances of that class share its
class variables
29. 29Object-Oriented Concepts
©2000KwangShinOh
Http://raytrust.pe.kr
What is a Class?
the illustrations of objects and classes
look very similar to one another
the difference between classes and
objects is often the source of some
confusion
in the real-world it’s obvious
that classes are not themselves the
objects that they describe
a blueprint of a bicycle is not a bicycle
30. 30Object-Oriented Concepts
©2000KwangShinOh
Http://raytrust.pe.kr
What is a Class?
however, in software
it’s a little more difficult to differentiate
classes and objects
because
software objects are merely electronic
models of real-world objects or abstract
concepts in the first place
many people use the term “object”
inconsistently and use it to refer to both
classes and instances
45. 45Object-Oriented Concepts
©2000KwangShinOh
Http://raytrust.pe.kr
What is an
Interface?
the bicycle class and its class
hierarchy defines
what bicycles can and cannot do in terms
of its “bicycle-ness”
but bicycles interact with the world on
other terms
for example
a bicycle in a store is an inventory item with a
retail price, a part number, a parts list, and so
on
46. 46Object-Oriented Concepts
©2000KwangShinOh
Http://raytrust.pe.kr
What is an
Interface?
to set or get this sort of information from
a bicycle object
an inventory program and the bicycle class
must agree on a protocol of communication
this protocol comes in the form of an
interface
let’s call it InventoryItem, that contains
method definitions
the InventoryItem interface would
define methods such as setRetailPrice,
getRetailPrice, and so on
47. 47Object-Oriented Concepts
©2000KwangShinOh
Http://raytrust.pe.kr
What is an
Interface?
to work within the inventory program
the bicycle class must agree to this
protocol
by implementing the InventoryItem
interface
when a class implements an interface
the class agrees to implement all of the
methods defined in the interface
thus, the bicycle class would have to
implement setRetailPrice, getRetailPrice
48. 48Object-Oriented Concepts
©2000KwangShinOh
Http://raytrust.pe.kr
What is an
Interface?
The Benefit of Interfaces
you use an interface to define a protocol of
behavior that can be implemented by any class
anywhere in the class hierarchy
Capturing similarities
capturing similarities between unrelated
classes without artificially forcing a class
relationship
Declaring methods
declaring methods that one or more classes
are expected to implement
Notes de l'éditeur 종종 발표자는 주제나 어휘에 익숙하지 않은 청중에게 기술적 성격의 자료를 전달해야 합니다. 자료는 복잡하거나 많은 양의 상세 정보를 나타낼 수 있습니다. 기술적인 자료를 효과적으로 발표하려면 Dale Carnegie Training®의 지침 따라 하기를 이용하십시오.
사용 가능한 시간의 양을 고려하여 자료를 구성하도록 준비하십시오. 주제의 범위를 좁히십시오. 프레젠테이션을 명확하게 부분으로 나누십시오. 논리적으로 진행하십시오. 처음부터 끝까지 요점을 유지하십시오. 요약, 주요 단계의 반복, 논리적 결론으로 프레젠테이션을 끝맺음 하십시오.
청중이 시종일관 집중할 수 있도록 하십시오. 예를 들어, 반드시 데이터는 명확하고 정보는 관련이 있도록 하십시오. 상세 정보와 어휘의 수준이 청중에 적합하도록 유지하십시오. 주요 요점과 단계를 뒷받침 하기 위해 시각적 요소를 사용하십시오. 청중의 욕구에 주의를 기울이십시오. 그러면 청중이 이해하는 데 도움이 될 것입니다.
<number>
소개에서 청중과 주제의 관련성을 전달하십시오. 프레젠테이션의 간략한 시연을 제공하고 이 프레젠테이션이 청중에게 얼마나 중요한지를 입증하십시오. 어휘, 예제, 설명을 선택할 때는 청중의 관심사와 전문가적 지식 수준을 고려하십시오. 주제가 청중에게 중요하다는 점을 강조하면 청중의 주의를 끄는 데 도움을 줍니다.