


javascript - Does object-oriented need to be process-oriented first? What are the similarities and differences with componentization and modularization?
Dear seniors, do we need to be process-oriented before being object-oriented?
In object-oriented programming, how to quickly sort out and locate the logical relationships between objects?
Where is object-oriented flexibility reflected?
Object-oriented is suitable for heavier development. Does writing small effects such as carousels in ordinary js still require object-oriented?
What are the similarities and differences between object-oriented and componentization in JavaScript, and what are the similarities and differences between JavaScript and modularization?
Reply content:
Dear seniors, do you need to be process-oriented before being object-oriented?
In object-oriented programming, how to quickly sort out and locate the logical relationships between objects?
Where is object-oriented flexibility reflected?
Object-oriented is suitable for heavier development, right? Does writing small effects such as carousels in ordinary js still require object-oriented?
What are the similarities and differences between object-oriented and componentization in JavaScript, and what are the similarities and differences between JavaScript and modularization?
The problem involves too much, so let’s talk about it in a provocative way.
Process orientation in software development is absolute, program = orderly execution of process. In fact, there was no concept of process-oriented before, but after the emergence of object-oriented, in order to distinguish this method from the previous method of using functions to organize code, then the code organized using functions was called process-oriented. (Just my personal opinion)
Object-oriented is a way of organizing code. It has various benefits. Just search it yourself.
As can be seen from the above, process-oriented or object-oriented refers to the organization of code, while componentization and modularization refer to the organization of functions in the project, so the two have nothing to do with each other.
During microelectronics maintenance, if a module is damaged, you only need to replace the module. Therefore, extending to software development, modularization means that the code is clearly encapsulated and has a definite scope rather than affecting the entire project.
The various tools used daily are actually based on the idea of components. Components will be frequently and widely reused without being restricted by the scope of the module.
As for your various questions, the final answer remains the same: it depends on the needs, just meet the requirements. Note that code readability, flexibility, and maintainability are part of the requirements, which are very, very, very important.
Very simple comparison:
<code>//最简短的代码是1行 alert('Yeah'); //最简短的函数要4行 function f() { alert('Yeah'); } f(); //最简单的对象要7行 function o() { this.f = function() { alert('Yeah'); } } var obj = new o(); obj.f();</code>
There is a lot of design content. Object-oriented and process-oriented are two different ideas, but there must be a process in it to elicit objects. Process-oriented is analysis, and object-oriented is construction. Componentization and modularization are the products of object-oriented and process-oriented (personal opinion)
Process-oriented and modular, these are necessary for writing programs.
Procedure orientation is easy to understand, all programs are processes
Modularization is also easy to understand, that is, to isolate the parts that can be independent in the program process, ensuring the readability of the program, and regardless of control It is more concise to fix errors or troubleshoot bugs. I believe that people who have learned C and then want to learn C will think about one question, that is, what is the difference between structures and objects? They can both play a role in modularizing the code. If you say that structures have no methods, I would say that structures have no methods. You can also define function pointers. You said that structures do not have this pointers. In many cases, I think there is no difference between this pointers and syntactic sugar. As for constructors and other things, it is simpler and structures can do it.
What I want to say is that the most important thing about object-oriented is inheritance
When I was in school, the teacher would give an example, such as human as the parent class, and then the teacher class and student class can be derived, and the student class can in turn derive boys. Class, girl class.
However, this example is very nonsensical and poor. Students will not derive such a lot of useless classes when doing coursework.
And in fact, most developers will not randomly derive weird classes, which will lead to poor readability of the program.
So where is class inheritance usually used?
Give an actual example
I recently wrote React, and the beginning of each component with state is written like this, class XXX extends React.Component{}
Here, as long as I inherit React.Component, my component will have render method, which can display class content on the web page; my component also has a componentWillReceiveProps method, which can execute the process I want when the component receives new data. I don't have to worry about how these things are triggered, but I know that they will definitely be triggered. This is the ability obtained by inheriting a class.
Similarly, if you use VS to develop a WPF window program or something, your form will also inherit a class from the Microsoft basic library, so that your form will have basic click responses, drag and drop, etc. Function, you don’t have to write it yourself.
There are various frameworks, everything is the same. If you inherit the basic class of the framework, you can get the functions provided by the framework.
When object-oriented is mentioned in textbooks, software engineering is usually mentioned, as well as the book "The Myth of the Man-Month". Software engineering and object-oriented are all things that programmers summed up when developing software on a large scale. , similar to building a house, lay the foundation first, and after the foundation is laid, I will build more functions on top of it. Therefore, if you just follow the textbook and do some exercises when you are a student, you will not be able to understand the many meanings of object-oriented
Haha. What a great question. I’ll mark it first and I’ll take the time to answer it later

ThesecrettokeepingaPHP-poweredwebsiterunningsmoothlyunderheavyloadinvolvesseveralkeystrategies:1)ImplementopcodecachingwithOPcachetoreducescriptexecutiontime,2)UsedatabasequerycachingwithRedistolessendatabaseload,3)LeverageCDNslikeCloudflareforservin

You should care about DependencyInjection(DI) because it makes your code clearer and easier to maintain. 1) DI makes it more modular by decoupling classes, 2) improves the convenience of testing and code flexibility, 3) Use DI containers to manage complex dependencies, but pay attention to performance impact and circular dependencies, 4) The best practice is to rely on abstract interfaces to achieve loose coupling.

Yes,optimizingaPHPapplicationispossibleandessential.1)ImplementcachingusingAPCutoreducedatabaseload.2)Optimizedatabaseswithindexing,efficientqueries,andconnectionpooling.3)Enhancecodewithbuilt-infunctions,avoidingglobalvariables,andusingopcodecaching

ThekeystrategiestosignificantlyboostPHPapplicationperformanceare:1)UseopcodecachinglikeOPcachetoreduceexecutiontime,2)Optimizedatabaseinteractionswithpreparedstatementsandproperindexing,3)ConfigurewebserverslikeNginxwithPHP-FPMforbetterperformance,4)

APHPDependencyInjectionContainerisatoolthatmanagesclassdependencies,enhancingcodemodularity,testability,andmaintainability.Itactsasacentralhubforcreatingandinjectingdependencies,thusreducingtightcouplingandeasingunittesting.

Select DependencyInjection (DI) for large applications, ServiceLocator is suitable for small projects or prototypes. 1) DI improves the testability and modularity of the code through constructor injection. 2) ServiceLocator obtains services through center registration, which is convenient but may lead to an increase in code coupling.

PHPapplicationscanbeoptimizedforspeedandefficiencyby:1)enablingopcacheinphp.ini,2)usingpreparedstatementswithPDOfordatabasequeries,3)replacingloopswitharray_filterandarray_mapfordataprocessing,4)configuringNginxasareverseproxy,5)implementingcachingwi

PHPemailvalidationinvolvesthreesteps:1)Formatvalidationusingregularexpressionstochecktheemailformat;2)DNSvalidationtoensurethedomainhasavalidMXrecord;3)SMTPvalidation,themostthoroughmethod,whichchecksifthemailboxexistsbyconnectingtotheSMTPserver.Impl


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 Chinese version
Chinese version, very easy to use

WebStorm Mac version
Useful JavaScript development tools

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver Mac version
Visual web development tools
