Chapter 1 What is an object?

What is an Object?

“We do not realize what tremendous(惊人的) power the structure of an habitual(习惯性的) language has.” It is not an exaggeration to say that it enslaves us through the mechanism of semantic(语义的;语义学的) reactions and that the structure which a language exhibits, and impresses upon us unconsciously, is automatically projected upon the world around us." – Alfred

The genesis(发生;起源) of the computer revolution was in a machine. Our programming languages thus(因此;从而;这样;如此) tend to look like that machine. But computers are not so much machines as they are mind amplification tools(思想放大器)(“bicycles for the mind,” as Steve Jobs was fond of saying) and a different kind of expressive medium(表达媒介). As a result, tools are beginning to look less like machines and more like parts of our mind.

Programming languages are the fabric of thought for creating applications. Languages take inspiration(灵感) from other forms of expression such as writing, painting, sculpture(雕塑), animation(动画), and filmmaking(电影).

Object-oriented programming (OOP) is one experiment in using the computer as an expressive medium.

Many people feel uncomfortable wading into object-oriented programming without understanding the big picture, so the concepts inroduced here give you an overview of OOP. Other might not understand such an overview until they are exposed to the mechanism, becoming lost without seeing code. If you’re part of this latter group and are eager to get to the specifics of the language, feel free to jump past this chapter – skipping it now will not prevent you from writing programs or learning the language. However, come back here eventually to fill in your konwledge so you understand why objects are important and how to design with them.

This chapter assumes you have some programming experimence, although not necessarily in C. If you need more preparartion in programming before tackling this book, work through the Thinking in C multimedia seminar, freely downloadable from www.OnJava8.com

The Progress of Abstraction

All programming languages are abstractions. It can be argued that the comlexity of the problems you’re able to solve is directly related to the kind and quality of abstraction. By “kind” I mean, “What is it you are abstracing?” Assembly language is a minimal abstraction of the underlying machine. Many so-called “imperative(必要的)” languages ( such as FORTRAN, BASIC and C) were themselves abstractions of assembly language. Although they were big improvements, their primary abstraction still requires you to think in term of the structure of the computer rather than the structure of the problem you are trying to solve. The programmer must establish the association between the machine model(the “solution space”, the place where you’re implementing that solution, such as a computer). The effort required to perform this mapping, and the fact it is extrinsic(adj. 外在的;外来的;非固有的) to the programming language, produces programs that are difficult to write and expensive to maintin.

猜你喜欢

转载自blog.csdn.net/qq_41729287/article/details/112296247