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~~
ringa_lee2017-05-19 10:43:26
Write it in front
Before project design, let’s ask a few questions:
What problems do we need to solve in the actual development of Double 11 activities? What are the solutions to these problems?
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?
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
Plan
Design
Implementation (phased)
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:
Function point division: module, page, PV/UV/Track, event
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.
Pages and modules are combined by ID.
Data burial points and page combination.
How to handle the event system. Operation processing on the page.
Others....
Project implementation
Consider a few questions:
How to implement the project in phases?
How to iterate on the previous versions?
How to quickly verify whether our ideas are correct?
How many people are arranged to develop and how many people continue to maintain this project?
Left issues
This project can only cover some activities, and many activities are not universal. People's needs are always changing.
More and more modules need to be maintained, and maintenance is very difficult.
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...