CakePHP developer is trying to use JavaScript MV *. Confused

I have a few years ago with server side MVC application development using CakePHP and a few more with php vanilla. Unfortunately, I cannot say the same about JS applications, although I have experience in straightening static pages using Mootools.

So now I'm trying to learn how to create client-side applications, and my success has not been so great so far. Since the only MVC I touched on is CakePHP, every JS MV * framework seems obscure at best. It doesn't help at all that I'm so used to writing the neat CakePHP and Mootools Class code that the large blocks of JS code just seem messy.

I even tried to write my own simple MVC-like lib, emulating CakePHP for most academic use. There is probably no need to say that I didn’t get anything with him.

Some things that I understood when learning and writing my MVC:

  • Js is asynchronous. CakePHP works the way it happens because PHP is synchronous. JS has an endless list of things that need to be implemented in different ways, and about the same lengthy list of things that can be done in different ways thanks to asynchronous. What are the most important differences between server side MVC (or its CakePHP implementation) and client side MV *?
  • I still do not quite understand the concept of client models. In Cake, they handle data validation and database connections. The client, on the other hand, is an unsafe environment, so client-side models can perform basic data filtering, preliminary validation, and default values. Am I completely wrong here?
  • Some applications require a server. Should the server be MVC?
  • It seems that on the client side of MV * you can have multiple controllers at the same time. Although I seem to understand that she has her own capabilities, my knowledge at this moment is so small that I can’t even think of a better question than “What is he doing?”

I also downloaded TodoMVC and tried to learn various structures with little success. The main problems with it are that it is only one-page (actions occur with different URLs, but the layout remains the same), and the implementations are so different that it is difficult for me to learn the basics, not to mention finding the best suitable structure for me. In addition, it does not contact the server in any way, which is a huge disappointment, since I wanted to see how different structures do it.

Thus, the best answer to this question is a link to a book called Client-side JavaScript MV * for dummies (who only have experience on the server side of MVC) , which would earn you somewhere around 500 Internet in addition to regular StackOverflow rewards.

I would be extremely grateful for any insights (full references) on any of my incoherent written subject topics. You will be rewarded with the standard + 1, and as an additional incentive, I promise to write your nickname on the note after saving it and save it on my monitor for the next month. The person with the most useful answer, of course, receives Accepted and can additionally provide an image that will be printed along with their nicknames, which will be attached to my monitor.

+4
source share
1 answer

I am interested to know where you ended up on this. PHP was my first love, and although I still enjoy the lightness of the language, it is difficult to take it seriously when it is so clearly terminated for faster and more scalable technologies.

You hit on the head that javascript asynchrony complicates the situation, but it definitely opens the door to better performance. There are quite a few libraries (more for node.js than client-side work) that are designed to make javascript written as if it were synchronous - again I don’t see it helping with your current demand, but well know another share of your pain.

I think MVC in javascript might be like this:

M: models just explain your data. So, if you have a person, you can say that each person has a name that contains a string, an age that has an int, etc. Now that you are creating a new person, you can receive confirmation. The models, the client side, are usually very simple, I found.

V: looks are another interesting thing. Some people like to have a large set of rendering functions that contain HTML (ew) strings. Others like to have views just to be a wrapper for templates like handlebars.js (perhaps the best solution).

C: functions are almost identical to the controller in PHP.

My advice for you would be NOT to write your own, but rather take Backbone.js (quickly become an industry standard), study it inside and out, and possibly build on top of it.

Good luck

0
source

All Articles