How to structure the front-end page?

A shopping page. 10,000 lines of js. There is no architecture. Naked, how to use design patterns to make the code beautiful, concise, easy to maintain?

Mar.03,2021

first of all, the book Design patterns has a subtitle: "the basics of reusable object-oriented software." So to use the design pattern, the first thing is to change the "procedural" code to the "object-oriented" code.

next, object-oriented, there must be "objects". In other words, you should divide the existing code into roles and establish the object system according to the responsibility, function, life cycle and other factors. This process is likely to be the largest refactoring.

next is the time for the design pattern to debut. Find the right scene and use the right mode.

finally, there are some factors inside and outside the technology:

  1. whether there are test cases, automation or labor, ensure normal work after refactoring
  2. whether the duration is allowed
  3. whether other modern front-end tools can be introduced

Modularization. This is the design idea for most frameworks. This is a design pattern that encapsulates and calls some repetitive code blocks to simplify the code as much as possible, and then try to leave leeway when writing the code. Do not cause difficulties in subsequent expansion in order to save trouble. Of course, this is only a general discussion. It is mainly a question of the extent of your experience and technology. The technology is in place, what framework or language is not a problem

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-1e463cc-44b77.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-1e463cc-44b77.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?