[Discussion] I am a little bored with object-oriented thinking. I don't know how to look at it.

Source: Internet
Author: User
[Discussion] I am a little bored with object-oriented thinking. I don't know what you think? I remember that I first came into contact with object-oriented programming language (java) and later made php. object-oriented features inherited encapsulation polymorphism. 1. Inheritance: inherits objects that you do not know where to come from. (of course, this is a problem for designers. However, it seems that most programmers do not write well in code, especially after complicated business ). & Nbsp; website data sources are very [discussed] very annoying at the beginning of object-oriented, do not know what you think?
Remember that the first contact with the object-oriented method is java

Later I made php, and the object-oriented features inherited encapsulation polymorphism.

1. Inheritance: inherits objects that you do not know where to come from. (of course, this is a problem for designers. However, it seems that most programmers do not write well in code, especially after complicated business ).
There are many website data sources, some of which are cache (memory in particular here), some files, some databases, and errors. I don't know where the data comes from. Exclude them one by one. Encapsulation directly blocks the channel.

2. encapsulation. it was originally designed to ensure that the upper layer does not need to worry about the lower layer. at the same time, data is blocked and only provides external methods without being modified. However, the division of labor in general companies is not the same as that in the logic layer of the data source layer. However, the division of labor is basically based on the business. No one dared to say that my data access layer would be okay, and no one dared to say that my class would not be faulty. Data encapsulation is of little significance in web.

3. polymorphism. Php does not support method rewriting.


In addition, the hash table needs to be checked multiple times for php object calls, and the performance is not high. In fact, php classes are implemented using hash tables. to put it bluntly, they are encapsulated in the hash table on the array instead of array. It is better to use array.

For object-oriented applications in php, I think it is very suitable for me to use operations such as generating a thumbnail database to encapsulate images.


Welcome to the discussion.

------ Solution --------------------
Object-oriented is a way of thinking
Object-oriented programming is a method

Software engineering involves top-down analysis and bottom-up programming. It describes the process-oriented programming method, which requires a deep understanding of every detail involved.
The object-oriented programming method is top-down analysis and top-down programming. He does not need to understand the details at the beginning, but gradually expands in the process. Leave an empty object in a link that you do not know for the moment.

Object-oriented programming brings a lot of convenience, but also brings more system overhead.
This is why the windows operating system has changed from 10 M to 300 M and 400 M, and the function has increased a lot, but the speed is getting more and more snails.


------ Solution --------------------
Upstairs.

Traditional programming is a data structure + function. with the object-oriented thinking, it becomes a data structure and a method for operating the data structure, that is, a more explicit division of functions.

C language has pointers or even function pointers. you can directly operate on the memory of a specified address. it is very simple to use C to implement derivation in object-oriented systems, such as Polymorphism. but for most languages, they are not so flexible, so they all provide the features of these languages to specifically support object-oriented, do not blame them.

In addition, object-oriented systems focus on cohesion, which means that communication between different objects relies heavily on explicit messages. Therefore, the interface design during development requires more consideration and design.

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.