Sunday, July 16, 2017

Canvas context2d

ctx.fillRect

ctx.font

ctx.textAlign

ctx.fillText

ctx.arc

WebGL 2D, very difficult to write

Saturday, July 8, 2017

Client side MVC

MVC (Model-View-Controller) is a popular software design pattern for user services. It divides the code into three independent parts:

  • Model - dynamic data structure and methods for its management,
  • View - a visual representation of the model,
  • Controller - accepts input from the user and converts it to commands for the model or view.

Model contains data, data structure and the internal application logic around it, like methods to add a new record or edit an existing one. For server-side apps the model is entirely on the server, but with advent of web application frameworks and increasing capabilities of web browsers this “thin client” approach is slowly fading away.

View is how the model is presented to the user, in web apps it's HTML and CSS.

Controller is binding between events and functions that handles them. The rule is that model and view never talk to each other directly, but always use controller.

MVC allows to better handle your code, but if you try to implement it in small projects, most of the code will be for MVC itself, rather than the actual app. So it's more suitable for bigger tasks.

There are several variations of MVC, most notable is MVP (Model-View-Presenter).