mindreframer
20 May 2007, 12:27 PM
Hello everybody, I have several issues, that maybe interesting for everybody....
1. The best way to structure your files
I've spent some time evaluating different approaches (all js in one file, several files responsible only for one area, etc....), but didn't like all of them.
When I write code, I like to hide the low-level work (and I mean there are a few levels you can go down) behind the real intention of the action/function. Ext is doing great work hiding all the crossbrowser issues from me and enabling to work with objects instead of fiddling with the DOM directly (for the most part). But I have no best practices for separation the different purposes of code...
So I thought, why not use MVC, but this time on the client. And I mean a complete, lightweight MVC structure without dependency of server.
What is the best way to develop a web app? You have to develop client + server architecture simultaneously, so you keep switching between js and server code. But if we agree on a contract defined by URL, and handle all the ajax communication through our model, we can develop the app with dummy data (arrays, objects, whatever you like, let's call them fixtures) that is loaded into the model and test the behaviour right there, tweak and tune, till we like it, and then just exchange the proxy for models to load the data from server. So, if you're in team (and who is not?), you can develop the frontend and leave the backend to your partner (or do it later yourself). What I like about this approach, is that you can test much better, since there are no timeouts and a running server to consider. You could even decide at runtime, what models to load, so unit-tests --> dummy model, production --> live model.
Automating and Unit-testing is also more feasible/less painful. Later you only have to test your "live" models, and feel good, because if something breaks, it must be in the model - layer.
These are only thoughts, it may look too simplistic, but it clears up your mind when you separate "movable" parts as much as you can. For now I've just copied the rails-style directory structure, which seems best of the breed.
Here is a prototype, it's very experimental and has sooo many memory leaks.
http://www.easy-comparison-kulist.com/staticjs/
(heavy load of js...)
2. In IE6 the model isn't loaded with data, dont know why... The proxy has the data set, and reader seems ok, but the store is still empty.
For now only profile does something, if FF it works, in Safari too, but not in IE :s I tried to the firebug lite(it's hidden behind the BorderLayout), then Ext.debug, the console is not very helpful (for objects it shows only [Object object], so after some research I found a variable dump utility, but it had infinite recursion problem (since child objects reference their parents and the loop is closed. I've just added a depth param to the function, so it would not dig too deep. When you click "Overview", the store for model "user" is displayed, the map and keys properties show the loaded data, but not in IE.
Could Jack please investigate this one, MemoryReader not working in a major browser kinda sucks....
I'd love to hear your comments about this idea!
Greets,
Roman
1. The best way to structure your files
I've spent some time evaluating different approaches (all js in one file, several files responsible only for one area, etc....), but didn't like all of them.
When I write code, I like to hide the low-level work (and I mean there are a few levels you can go down) behind the real intention of the action/function. Ext is doing great work hiding all the crossbrowser issues from me and enabling to work with objects instead of fiddling with the DOM directly (for the most part). But I have no best practices for separation the different purposes of code...
So I thought, why not use MVC, but this time on the client. And I mean a complete, lightweight MVC structure without dependency of server.
What is the best way to develop a web app? You have to develop client + server architecture simultaneously, so you keep switching between js and server code. But if we agree on a contract defined by URL, and handle all the ajax communication through our model, we can develop the app with dummy data (arrays, objects, whatever you like, let's call them fixtures) that is loaded into the model and test the behaviour right there, tweak and tune, till we like it, and then just exchange the proxy for models to load the data from server. So, if you're in team (and who is not?), you can develop the frontend and leave the backend to your partner (or do it later yourself). What I like about this approach, is that you can test much better, since there are no timeouts and a running server to consider. You could even decide at runtime, what models to load, so unit-tests --> dummy model, production --> live model.
Automating and Unit-testing is also more feasible/less painful. Later you only have to test your "live" models, and feel good, because if something breaks, it must be in the model - layer.
These are only thoughts, it may look too simplistic, but it clears up your mind when you separate "movable" parts as much as you can. For now I've just copied the rails-style directory structure, which seems best of the breed.
Here is a prototype, it's very experimental and has sooo many memory leaks.
http://www.easy-comparison-kulist.com/staticjs/
(heavy load of js...)
2. In IE6 the model isn't loaded with data, dont know why... The proxy has the data set, and reader seems ok, but the store is still empty.
For now only profile does something, if FF it works, in Safari too, but not in IE :s I tried to the firebug lite(it's hidden behind the BorderLayout), then Ext.debug, the console is not very helpful (for objects it shows only [Object object], so after some research I found a variable dump utility, but it had infinite recursion problem (since child objects reference their parents and the loop is closed. I've just added a depth param to the function, so it would not dig too deep. When you click "Overview", the store for model "user" is displayed, the map and keys properties show the loaded data, but not in IE.
Could Jack please investigate this one, MemoryReader not working in a major browser kinda sucks....
I'd love to hear your comments about this idea!
Greets,
Roman