Do beginners always need to follow the object-oriented design?
Source: Internet
Author: User
Sometimes it is not appropriate to abstract the desired function into a class, so it can only be implemented in a process-oriented manner (or even cannot be integrated into a function). how should we do this? Will the habit of "first let the code run as expected and then refactor later" adversely affect the future? Sometimes it is not appropriate to abstract the desired function into a class, so it can only be implemented in a process-oriented manner (or even cannot be integrated into a function). how should we do this? Will the habit of "first let the code run as expected and then refactor later" adversely affect the future? Reply content: No, because it is impossible to learn it so early. First, learn to write code, and then get object-oriented. Of course, this doesn't mean you don't need to use the class. it's easy for beginners to use it and use it more easily. in the future, we will understand best practice more deeply. OO is the correct way of thinking to solve the problem. it is a disease to OO, and it is not necessary to cure the problem. First of all, not all problems are suitable for object-oriented solutions. then, for beginners, it is important to consolidate the foundation. if you want to learn object-oriented, you may wish to explain the exercises you have done before in the object-oriented way to find out what you feel.
Follow my Node pop-up column to get started with a Node/front-end skill in 15 minutes and provide all source code. Not all things need to be converted into classes. object-oriented is just a way. If you really want to oo for oo, a small program can write a lot, and there is nothing to use, because the class is too redundant, it is still not easy to maintain.
In addition, many times you have to go to the step of "writing code to make code run", and refactoring is far from enough. many projects may not be able to even rebuild. The way of Jianfa should look at the various Jianfa, from traditional to simplified, and draw out the most general legal principles from them to form their own understanding of Jianfa.
Then, we need to combine general legal principles to form our own Jianfa.
For programming, we need to first have an object before we can write more code for her. when you use the framework later (qt, wpf ......), You can read the magic, and then learn the encapsulation ideas of these good frameworks. at least you can learn the factory model.
When I learned c, every algorithm in every data structure was written by myself. then I learned c ++, java, and c # and later I found that these things could be ready-made and easy to use, then we will naturally learn the object-oriented approach. Process-oriented writing.
After all, you are a beginner and do not know how to target objects.
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