当前位置:网站首页>Welfare, let me introduce you to someone
Welfare, let me introduce you to someone
2022-07-02 21:11:00 【A gentle breeze】
Personal profile
️ Personal home page : A gentle breeze *️
The blogosphere : Programming based , Back end , big data , Information security
Writing style : dried food , dried food , still tmd Dry goods of
Series column :【JavaScript】
Support Yangge : give the thumbs-up 、 Collection 、 Leaving a message.
Long time no see , I miss you so much !
Hello everyone ! I'm brother Yang
It's Valentine's day , But some brothers told me he had no object , How can this work ? therefore , I took out what I pressed at the bottom of the box , I must introduce him well , Teach him an object-oriented outline , If he is not satisfied with the object , Don't worry , Then let him customize the object , One step at a time , Big brother read my article , I was moved to tears . Although I have no object , But he introduced someone to others , This is giving roses to others and leaving fragrance in your hands , Life is complete .
If your good brother doesn't have a date on Valentine's Day , please give the thumbs-up , Collection This article , Then put this article forward Give it to him , I believe he will thank you Act of kindness !
List of articles
One 、 Object-oriented overview
Process and object oriented
To accomplish one thing to illustrate what is process oriented and object-oriented .
- Process oriented solutions : Focus on specific steps , Only follow step by step , To be able to complete this thing .
- Object oriented solutions : Focus on one object , These objects perform their respective duties , We just give orders , Can command these objects to help us complete the task .

summary :
- For process oriented thinking , We play the executor , Everything must be done by yourself .
- For object-oriented ideas , We play the commander , Just find the corresponding object , Let them help us do specific things .
Disadvantages of process oriented thinking
The code written is some variables and functions , With the continuous increase of program functions , There will be more and more variables and functions , At this time, it is easy to encounter the problem of naming conflict , Because the codes of various functions are intertwined , It leads to code structure confusion , Become difficult to understand 、 Maintenance and reuse .Advantages of object-oriented thinking
You can encapsulate the operation code of the same kind of things into objects , Take the variables and functions used as the properties and methods of the object , Then call... Through an object , This makes the code structure clear 、 distinct .
Object oriented features

encapsulation
encapsulation : It refers to hiding the internal implementation details , Only open the operation interface .
Interface : It's the method of the object , No matter how complex the interior of the object is , Users only need to know how to use these interfaces .
give an example : Computers are very sophisticated electronic devices , The implementation principle is also very complex , Users do not need to know these details when using , As long as you operate the keyboard and mouse, you can use .
advantage : No matter how many times the code inside an object has been modified , As long as you don't change the interface , It will not affect the code written when using this object .

inheritance
Inherit : It refers to that one object inherits the members of another object , So as to expand without changing another object .
give an example 1: The relationship between animals and cats and dogs , Human reproduction, etc .


give an example 2:String An object is an abstraction of all strings , All strings have toUpperCase() Method , Used to convert a string to uppercase , This method is actually inherited from String object .
advantage :
- The function can be extended on the premise of maintaining interface compatibility .
- Enhanced code reusability , Facilitate the modification and supplement of procedures .
polymorphism
polymorphic : It means that the same operation acts on different objects , There will be different execution results .
understand : actually JavaScript Designed as a weakly typed language ( That is, a variable can store any type of data ), It's the expression of polymorphism .


for example , Numbers 、 Array 、 Functions have toString() Method , When the method is called with different objects , The results are different .

Tips : In object orientation , The implementation of polymorphism is often inseparable from inheritance , This is because when multiple objects inherit the same object , You get the same method , Then change the execution result of the method with the same name according to the difference of each object .
Tips : Although object-oriented has encapsulation 、 Inherit 、 These design ideas , However, it does not mean that as long as these characteristics are met, excellent programs can be designed , Developers also need to consider how to make rational use of these features .
example 1: When packaging , How to provide a complete and minimal interface for external callers , So that the external caller can get the desired function smoothly , There is no need to study the internal details .
example 2: When designing for inheritance and polymorphism , For multiple different sub objects that inherit the same object , How to design a set of the same method to operate .
Two 、 Custom object
Object definition
grammar : Objects are defined by “{ }” Grammar realizes .
form : Object as object member ( Properties and methods ) constitute , Multiple members are separated by commas .
member : The members of the object are stored in the form of key value pairs {} in .

Be careful
“{ }” Syntax is also called literal syntax of objects , The so-called literal quantity refers to a quantity representing data and types written directly in the source code , Such as 123( Numerical type )、‘123’( Character )、[123]( Array ) It's all literal .
JSON data format
JSON: JavaScript Object Notation,JavaScript Object symbols .
purpose : Applied to data storage and interaction .
grammar : JSON Is a string , Wrap the member name and string value of the object in double quotation marks .
JSON The difference from the object :
- JSON Is a string .
- JSON Not only can it be used to save objects , You can also save numbers 、 character string 、 Arrays and other types of data .

Access object members
grammar : object . member .

Variable member name syntax : object [ Variable name ] = value .

Object member traversal
grammar :for…in.

- Variable k Saved the name of each object member .
- obj[k] Access the value of the member property .
- objk Calling a member method .
Determine whether the object member exists
- When you need to judge whether a member in an object exists , have access to in Operator .
- Returns... When the member of the object exists true, Return... When not present false.

If you think this article has some inspiration for you , Might as well give the thumbs-up 、 Collection 、 Leaving a message. support , Your support will be the biggest driving force for me to continue my creation ️️️
Because the author level is limited , Mistakes and inaccuracies are inevitable , I also want to know these mistakes , I sincerely hope that readers will criticize and correct !
Last , I wish all lovers a happy ending , With all of you xdm You will find the right person this year !( This is not a concern )
边栏推荐
- 在券商账户上买基金安全吗?哪里可以买基金
- Check the confession items of 6 yyds
- 想问问,现在开户有优惠吗?在线开户是安全么?
- Lantern Festival, come and guess lantern riddles to win the "year of the tiger Doll"!
- Record the problems encountered by nodejs asynchronism
- Research Report on the overall scale, major manufacturers, major regions, products and application segmentation of precoated metallic coatings in the global market in 2022
- An analysis of the past and present life of the meta universe
- How can testers do without missing tests? Seven o'clock is enough
- Sword finger offer (I) -- handwriting singleton mode
- 5 environment construction spark on yarn
猜你喜欢

7. Build native development environment

Spark source code compilation, cluster deployment and SBT development environment integration in idea

Exemple complet d'enregistrement du modèle pytoch + enregistrement du modèle pytoch seuls les paramètres d'entraînement sont - ils enregistrés? Oui (+ Solution)

In depth research and investment feasibility report of global and Chinese isolator industry, 2022-2028

Redis sentinel cluster working principle and architecture deployment # yyds dry goods inventory #
![[cloud native topic -50]:kubesphere cloud Governance - operation - step by step deployment of microservice based business applications - database middleware MySQL microservice deployment process](/img/e6/1dc747de045166f09ecdce1c5a34b1.jpg)
[cloud native topic -50]:kubesphere cloud Governance - operation - step by step deployment of microservice based business applications - database middleware MySQL microservice deployment process

Outsourcing for three years, abandoned
![[internship] solve the problem of too long request parameters](/img/42/413cf867f0cb34eeaf999f654bf02f.png)
[internship] solve the problem of too long request parameters

Talk about macromolecule coding theory and Lao Wang's fallacy from the perspective of evolution theory

ROS learning (10): ROS records multiple topic scripts
随机推荐
Use graalvm native image to quickly expose jar code as a native shared library
Sometimes only one line of statements are queried, and the execution is slow
Roommate, a king of time, I took care of the C language structure memory alignment
Volvo's first MPV is exposed! Comfortable and safe, equipped with 2.0T plug-in mixing system, it is worth first-class
Import a large amount of data to redis in shell mode
Sword finger offer (II) -- search in two-dimensional array
[shutter] the shutter plug-in is used in the shutter project (shutter plug-in management platform | search shutter plug-in | install shutter plug-in | use shutter plug-in)
MySQL learning notes (Advanced)
How can testers do without missing tests? Seven o'clock is enough
Driverless learning (4): Bayesian filtering
[fluent] dart function (function composition | private function | anonymous function | function summary)
26 FPS video super-resolution model DAP! Output 720p Video Online
pytorch 模型保存的完整例子+pytorch 模型保存只保存可訓練參數嗎?是(+解决方案)
ROS learning (10): ROS records multiple topic scripts
JDBC | Chapter 4: transaction commit and rollback
Talk about macromolecule coding theory and Lao Wang's fallacy from the perspective of evolution theory
Research and Analysis on the current situation of China's clamping device market and forecast report on its development prospect
Redis sentinel cluster working principle and architecture deployment # yyds dry goods inventory #
Second hand housing data analysis and prediction system
2021 software security report: open source code, happiness and disaster depend on each other?