A preliminary understanding of the class with old Ziko python _python

Source: Internet
Author: User
Tags abstract inheritance

In the beginning, please reader very very patiently read the following several boring terms to explain, originally this does not conform to the style of this tutorial, but please reader understanding, because you will be sure to read the boring things in the future. These boring explanations are all from Wikipedia.

1, problem space

The problem space is the full state of the problem solution to a problem, which is made up of the information and stored information that the problem-solving person uses.

A problem is generally defined in the following three ways:
• Initial state-incomplete information or unsatisfactory condition at the outset;
• Target status-the information or status you wish to receive;
• Operation-The steps you may take to move from the initial state to the target State.

These three parts are added together to define the problem space (problem spaces).

2. Object

Object, a Taiwanese translation object, is a term in object-oriented (object oriented) that represents a specific thing in the objective World problem Space (Namespace), and represents the basic element in the solution space of the software system.

In software systems, objects have unique identifiers, objects include attributes (properties) and Methods (Methods), attributes are information that requires memory, and methods are the services that objects can provide. In object-oriented (object oriented) software, objects (object) are instances (Instance) of one Class (class).

3. Object-oriented

Object-oriented Programming (English: object-oriented programming, abbreviation: OOP) is a programming paradigm, but also a method of program development. Object refers to an instance of a class. It encapsulates the program and data as the basic unit of the program to improve the reusability, flexibility and scalability of the software.

Object-oriented programming can be regarded as a kind of thought that contains various objects which are independent and call each other in the program, which is contrary to the traditional idea: the traditional program design advocates to regard the procedure as a set of functions, or a series of instructions to the computer directly. Each object in object-oriented programming should be able to accept data, process data, and communicate data to other objects, so they can all be considered as a small "machine", or object.

It has been proved that object-oriented programming has extended the flexibility and maintainability of programs and is widely used in large project design. In addition, supporters claim that object-oriented programming is easier to learn than previous practices because it allows people to design and maintain programs more easily, making them easier to analyze, design, and understand. Opponents have denied this in some areas.

When we refer to object-oriented, it means not just a programming method. It is more in the sense of a program development approach. In this context, we must learn more about object-oriented system analysis and object-oriented design (object oriented, Ood).

Here's a reference to the history of oop from Wikipedia.

Copy Code code as follows:

The prototype of object-oriented programming, as early as in the 1960 Simula language can be found, then the field of program design is facing a crisis: in the software and hardware environment gradually complex situation, the software how to get good maintenance? Object-oriented programming solves this problem to some extent by emphasizing repeatability. The Smalltalk language of the the 1970s was classic in object-oriented terms-so that 30 years later today it is still regarded as the foundation of object-oriented language.
The earliest budding of the concepts of objects and examples in computer science can be traced back to the MIT PDP-1 system. This system is probably the earliest real system based on capacity architecture (capability based architecture). In addition, 1963 Ivan Sutherland's Sketchpad application also contains the same idea. The object as a programming entity was first introduced into thinking in the 1960 's by Simula 67 language. The language of Simula is designed by Orly-John Dar and Cliston Naigat in the Oslo Computer center in Norway to simulate the environment. (they are said to be the language designed to simulate ships and are interested in the interplay of properties between different ships.) They generalize different ships into different classes, and each object, based on its class, can define its own properties and behavior. This approach is the earliest conceptual embodiment of analytical procedures. In analytic programs, we map real-world objects to abstract objects, which is called "impersonation." Simula not only introduced the concept of "class", but also applied the idea of example--this may be the earliest application of these concepts.

The Smalltalk language, invented by Xerox PARC Institute in the 1970s, defines the concept of object-oriented programming as a broad application of objects and messages in basic operations. The creators of Smalltalk are deeply influenced by the main ideas of Simula 67, but the objects in Smalltalk are completely dynamic-they can be created, modified, and destroyed, which differs from static objects in Simula. In addition, Smalltalk also introduces the idea of inheritance, which transcends the programming model of the non-creation instance and the Simula without inheritance. In addition, the idea of Simula 67 is also applied in many different languages, such as Lisp and Pascal.

Object-oriented programming became a dominant idea in the 80 's, which owes much to the expanded version of C++--c language. With the development of graphical user interface (GUI), object-oriented programming is well adapted to the trend. The close correlation between GUI and object-oriented programming is evident in Mac OS X. Mac OS x is written in objective-c language, which is a copy of the Smalltalk version of the C language. The idea of object-oriented programming also makes event-handling programming more widely available (although this concept is not only in object-oriented programming). One argument is that the introduction of GUI has greatly facilitated the development of object-oriented programming.

Nickeraus Wilter and his colleagues at the Federal Institute of Technology in Zurich studied abstract data and modular programming. Modula-2 included these, while Oberon included a special object-oriented approach-unlike Smalltalk and C + +.

Object-oriented features were also added to the popular language at the time: Ada, BASIC, Lisp, Fortran, Pascal, and so on. Since these languages did not initially have object-oriented design, this blending often leads to compatibility and maintainability issues. In contrast, the "pure" object-oriented language lacks some of the features that programmers rely on to survive. In this context, the development of new languages has become a top priority. As a pioneer, Eiffel successfully solved these problems and became a more popular language at the time.

In the past few years, the Java language has become a widely used language, in addition to its proximity to C and C + + syntax. Java portability is an indelible step in its success, because this feature has attracted the input of a large programmer group.

In the recent development of computer language, some languages that support object-oriented programming and process programming are quietly surfacing. The best of them are Python, Ruby, and so on.

As the process-oriented programming makes the technology of structural programming improve, modern object-oriented programming method makes the use of design patterns, contract design and modeling language (such as UML) technology also improved.


You reader, when you read this sentence, I think you have a vague understanding of object-oriented. So what does class and OOP have to do with it?

Wikipedia defines a class like this:

Copy Code code as follows:

In object-oriented programming, classes (Class) is a construction of object-oriented computer language, a blueprint for creating objects, and describes the common properties and methods of objects created.

The more restrictive definition of a class is the cohesive package of a particular metadata. It describes the behavior rules for some objects, which are called instances of the class. Classes have interfaces and structs. Interfaces describe how to interoperate with classes and their instances, and structs describe how the data in one instance is divided into multiple attributes. A class is the most specific type of object with a layer. A class can also have a run-time representation (a meta object) that provides run-time support for manipulating metadata related to a class.

Support class programming languages have somewhat subtle differences in support for the various features associated with the class. Most of them support different forms of class inheritance. Many languages also support features that provide encapsulation, such as access modifiers. class provides the means to implement the three most important features of object-oriented programming (encapsulation, inheritance, polymorphism).

See here, reader may have an understanding that to OOP programming, you have to use the class. It can be said that, although not very strict. However, the converse cannot be said. It's not that using a class is definitely oop.

Writing classes

The understanding of class requires reader to have some abstract thinking. Because the class itself defines the abstract characteristics of something. For example, define a class:

Copy Code code as follows:

Class Human: #这是定义类的方法, usually the name of a class with a first-letter word or word stitching
Pass

OK, let's start here and write a class, but this time we're not using Python, it's pseudocode, and of course, this code is a far cry from Python. As follows:

Copy Code code as follows:

Class Human:
Limbs
Character
Hobby
Learning ()

Objects (object) are instances of a class. A class named human has just been defined to define all the human in the world, but this is an abstract human, not a specific person. And for a specific person, his limbs characteristics, personality, hobbies, etc. are specific, these things are called attributes.

Here is a specific person: Wang, the above class instantiation.
Wang-Human ()
Wang. Limbs = Slender
Wang. Hobby = See mm

Here, Wang is an example of this class of human. The value of a specific object property is called its "state." (The system allocates memory space to the object and does not allocate memory space to the class, which is well understood that the class is an abstract system that is not able to allocate space for the abstract object, which is specific)

Writing to this point, reader is probably the class has a vague understanding of it?

Given the class, it seems a little far away from our intuitive feeling. So take it slow. The content of this lecture is not much, hope reader can understand.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.