面向对象的几个概念
■ A class is a structure that represents an object’s type. An object refers to its class to
get various information about itself, particularly what code to run to handle each
action. Simple programs might have a handful of classes; moderately complex ones
will have a couple of dozen. Objective- C style encourages developers to capitalize
class names.
■ An object is structure containing values and a hidden pointer to its class. Running
programs typically have hundreds or thousands of objects. Objective- C variables that
refer to objects are typically not capitalized.
■ Instance is another word for “object.” For example, a circle object can also be
called an instance of class Circle.
■ A message is an action that an object can perform. This is what you send to an object
to tell it to do something. In the [shape draw] code, the draw message is sent to the
shape object to tell it to draw itself. When an object receives a message, its class is
consulted to find the proper code to run.
■ A method is code that runs in response to a message. A message, such as draw, can
invoke different methods depending on the class of the object.
■ The method dispatcher is the mechanism used by Objective- C to divine which method
will be executed in response to a particular message. We’ll get out our shovels and dig
a lot more into the Objective- C method dispatch mechanism in the next chapter.
另外适用于object-c的:
The interface is the description of the features provided by a class of objects. For
example, the interface for class Circle declares that circles can accept the draw
message.
The implementation is the code that makes the interface work. In our examples,
the implementation for the circle object holds the code for drawing a circle on the
screen. When you send the draw message to a circle object, you don’t know or care
how the function works, just that it draws a circle on the screen.
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 字符编码:从基础到乱码解决
2012-10-23 item21