View Full Version : MVC and runtime

27 Apr 2012, 9:35 AM
First of all, I must admit I still did not get my hands deeply on the 4.x MVC.

Anyway, being a long time sencha user (2.x and 3.x) I must say that I don't really like it for as much as I've seen. I believe it's a nice try to impose a standard coding in JS, while, imho, JavaScript is cool because everyone has it's own style.

That said, I think I am missing a nice way to achieve something I've always used with sencha 3.x.

Usually my applications rely on user logins.
So actually, the first thing I was doing (in almost every app) was to show a login panel, which handled the authentication, and only that.

Because not every user is equal, I used to create my GUI with respect of the user roles (think of admins, users, guests...) and showing different parts of the application - AFTER THE USER DID AUTHENTICATE.

Furthermore, I used to completely hide from the browser unused code and loading (and overloading) the mainApplication with the code I really needed.

I know this might look a bit like security by obscurity, and in fact it is, but it also allowed my app to have some default functions names that behaved differently from user to user.
Imagine again:
- a user creates an item -> the app checks if the price is valid
- an admin creates an item -> the app allows any type of price

this could be done via the same "saveItem()" function, because there were 2 different versions of the function being served. One for users, one for admins.

Anyway, with the "forced" MVC I now need to define my models, views and controllers at the beginning of the app (when the user is still not authenticated, and, maybe, it's not even a valid user!) so I am no longer able to distinguish between roles.

That is VERY bad.

So I am asking: is there a way to add/remove models, views and controllers at runtime?

I see no "addModel()" function ... and so on.

Do you think there's a good way to achieve that?

I really would like to use the proposed MVC... as long as it complies with my needs.


27 Apr 2012, 10:22 AM
Anyway, with the "forced" MVC I now need to define my models

You are not forced to use MVC. It is an option that you can choose to adopt, or not.


27 Apr 2012, 12:32 PM
That is an option.

Thou, as a former sencha-designer paying customer who is now evaluating sencha architect, I am trying to get deeply into the new proposed development model.

Sorry Scott, but I don't think your answer is really acceptable.

A much more interesting approach and answer would involve Deft JS which, somehow, provides a reasonable way for problems like mine.

An even better approach would be pointing at a way to add models, views and controllers at runtime, which actually does not look that impossible.

Again, Scott, your answer is absolutely pointless, especially as I am long time programmer who is well trained in resolving problems, instead of circumventing them.

27 Apr 2012, 1:27 PM
Does this post help?


27 Apr 2012, 4:09 PM
Absolutely yes, that's why I mentioned DEFT JS.

Still I think Deft is a great project that provides much more than I need.

I'll keep investigating a possible patch to add models/views/controllers at runtime.

I doubt it's going to be too hard.