Home  >  Q&A  >  body text

javascript - Discussion on the design plan of a project

Recently I am working on a configurable project for the company's event page, let's call it cms
The function is to configure the corresponding module in the management background every time a promotional event such as Double 11 is held, and finally generate the page

The interface is a structure similar to this

{
    list:[
        {
            type: 1,  //这个模块的type,比如1对应商品组合模块
            cmsId: 1, //这个模块的唯一id
            data: {
                //具体的这个模块的数据
            }
        }
    ],
    code: 200,
    msg: ''
}    

My current thinking is this:
Define a common interface through a simple factory pattern

var factoryInterface = function(type,data){
    switch(type){
        case 1:
            return new BannerWithBroadcastTpl(data)
            break;
        case 2:
            return new PicDisplayTpl(data)
            break;
    }
}   

BannerWithBroadcastTpl and PicDisplayTpl are both defined components. Each component has a create method to create the component

Use the following code to finally complete the initialization of the project

for(var i=0,length=data.length;i<length;i++){
    !(function(i){
        factoryInterface(data[i].type,data[i]).create(_this.root)
    })(i)
}

Now I want to discuss with you masters whether there are any other code design solutions for this plan. Everyone is welcome to comment~~

迷茫迷茫2732 days ago557

reply all(1)I'll reply

  • ringa_lee

    ringa_lee2017-05-19 10:43:26

    Write it in front
    Before project design, let’s ask a few questions:

    1. What problems do we need to solve in the actual development of Double 11 activities? What are the solutions to these problems?

    2. Can we use this system to solve the problems we encountered in the actual development of Double 11 activities? Can it solve dozens of percent of the problems?

    3. How much does it cost to do this project? Is it worthwhile to use this Cost to solve a certain proportion of problems?

    Project Core

    1. Plan

    2. Design

    3. Implementation (phased)

    4. Left issues

    Project Plan
    Ask a question:
    How many identical design points are there in each Double 11 event, and how many points can be abstracted? --> Do you want to be a simple template system, or a system with complete functions? Fully automatic or semi-automatic? --> What functions need to be implemented? --> What resources are there and are they sufficient? (Manpower, time, etc.)
    Think clearly about the above issues and give a complete plan.

    Project Design
    Based on thinking through all the above issues, here is an example:

    1. Function point division: module, page, PV/UV/Track, event

    2. What are the modules that can be shared? How many display types are there for a type of wood block? Therefore, at least two typeIds are needed to distinguish them.

    3. Pages and modules are combined by ID.

    4. Data burial points and page combination.

    5. How to handle the event system. Operation processing on the page.

    6. Others....

    Project implementation
    Consider a few questions:

    1. How to implement the project in phases?

    2. How to iterate on the previous versions?

    3. How to quickly verify whether our ideas are correct?

    4. How many people are arranged to develop and how many people continue to maintain this project?

    Left issues

    1. This project can only cover some activities, and many activities are not universal. People's needs are always changing.

    2. More and more modules need to be maintained, and maintenance is very difficult.

    3. Others...

    Summary
    I am just giving a simple example here on how to solve this project problem. I hope there are more solutions. Everyone is welcome to complain...

    reply
    0
  • Cancelreply