What exactly does "familiarity with object-oriented programming ideas and design patterns" examine in the front-end interview?

Update

Thank you for your answer. For those who have no impression of object-oriented, I suggest you take a look at the example in Lion"s answer. After reading this example, I suddenly realized that the original object-oriented scenario is to write this kind of plug-in, that is, when common components are used at work. As an advanced step, you can refer to Meathill"s answer

. < hr >

problem description

I always see such a sentence in front-end recruitment: I start to learn front-end from elevation. The business I usually do is not complex, and object-oriented complex operations are rarely used. So much so that I don"t know to what extent this aspect should be mastered in mainstream front-end development?

interview questions encountered

once interviewed Didi, encountered a topic is scene design, probably is "Didi has several kinds of cars, hitchhiking or chauffeured cars, each kind of car unit km fuel consumption, the price is different, please calculate the mileage and the total price at the end, what kind of category should be designed to describe?" I can"t do such a problem all the time. I"ve never encountered it before. If you ask me about the design pattern, I can only answer the content of the book.

confused

so please give us your advice on how to learn this object-oriented programming idea and design pattern.

Jul.08,2021

as for the idea of object-oriented programming, I recently wrote a plug-in that uses a series of ideas to create parent class inheritance, link describes

.

there are many design patterns, in fact, if you are interested, you can take a look at the source code of JQ, which has a lot of proxy patterns, observer patterns and so on. These are very helpful to the improvement of your thinking and the writing of your code style. I hope this answer will be helpful to you


the subtitle of Design patterns is: the Foundation of Reusable object-oriented Software. His core is "object-oriented", if your code is process-oriented, it is really difficult to realize the value of design patterns.

in addition, it is recommended to take it with a copy of "refactoring". The effect is very good.

object-oriented is a way of abstraction, that is, by simulating real-world objects, abstracting what the program uses. The advantage is that it is easy for us to understand. For example, if the purchase process of an e-commerce website is written in a process-oriented way, it might look like this:


//<br>TS,

interface CarInterface {
   getName():string;
   get():number;
   //...
}

class  implements CardInterface {
    getName() {
        return '';
    }
    get() {
        return 10;
    }
}
// ... 
function getMoney(,) {
    let car:CardInterface;
    if(==) {
        car = new ();
    }else if(==) {
        car = new ();
    }else {
        throw new Error('');
    }
    return card.get()*;
}

if the car type is added later, realize CardInterface and then change the judgment of if

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b38bf2-2c150.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b38bf2-2c150.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?