my approach for a front-end design task
requirements
- UI design
- User experience
- what's the user scenario?
- different states?
- loading, error, normal, alert error
- where it is used by a web page?
- User behavior & interaction
- what are we expected for user to use the widget?
- accessibility
- use
aria-label
, role
, alt
, for
- Data
- get data from server
- what
- ajax
- streaming, websocket
- when
- where
- send data to server
- what
- validate & serialize formData
- when
- where
- platform
- desktop
- mobile
- responsive
- priority on the page
- server-side rendering
- client-side rendering
approach
- decide a design pattern
- MVC
- Controller:
- 监听 Model 层的事件,将 Model 层的数据传递到 View 层。
- 监听 View 层的事件,并且将 View 层的事件转发到 Model 层。
- View: HTML & CSS
- Model: stores business logic
- Emitter
- link
View
and Model
View
'render method can subscribe to Model
's update or change event
- design methods
- think about code reuse & maintainability
附录
- Model-View-Controller MVC in JavaScript
- 被误解的MVC和被神化的MVVM