I am building a web application which is meant to help display prices of products. The web-app is centered around showing prices in a custom bar chart. I am thinking it should be composed of a Model View Controller architecture. I am looking for input on my design plan, there is more than one question here.
The model will hold the state and data retrieved from the server, as well as any state that is required to constrain the view. For example Say a certain window can only open if some toggle has been activated, the state of the toggle would be held in the model. I am thinking the state pattern would be useful here since it helps me model the system using state diagrams and there are likely to be many states. Also, it allows me to use class invariants to ensure the system is never put into an invalid state.
The view should be built upon the visitor pattern because all the elements on the screen are "Graphics", where the operations which act upon the graphics are independent of the graphics themselves. For example, all graphics can be scaled, positioned, hidden or shown. A rectangle shape might have a width and a height, but a function called "show" does not have anything to do with rectangles themselves. Does it make sense to define these operations myself when these operations are already available in JQuery? i.e I can scale an html element using $(element).css(width,numberOfPixels) ?
I think the controller should handle all the events from html elements as well as interacting with the server; like making server requests and handling the responses. Then, of course, having the controller manipulate the client side model. I've seen cases where people have implemented MVC frameworks, and they have the model communicating with the server, (rather than using the controller to communicate with the server). To me it makes more sense to use the controller to communicate with the server because the Model on the client side isn't meant for communicating, it's meant for holding state and logic. Why would I use the model to communicate with the server?
I've never used an MVC framework like AngularJS before, should I just use that rather than trying to implement my own MVC? Time is an issue, but I still want to be able to create a custom chart for the price chart.