in large project i tend to differ between model-, control- and view-files ([mvc-pattern][1]).
the model-file contains everything concerning data especially my class (OOP). an example for a model-file could be:
function myClass(){
//private variable
var variable=5;
//public variable
this.newVariable = 10;
function myFunction() {
//do some stuff
alert("my function");
}
//public stuff
return {
myPublicFunction: myFunction
}
}
the view-file contains everything concerning to the layout and view and the control-file is filled with the stuff concerning to data-handling. control-file uses the class declared in the model-file and works with it. so the view only needs to include the control-file and call the functions it needs for the layout.
but in general it's quite different to generalize. i like the oo-pattern and trie to use is, if it makes sense. but i have only experience with iPhone-development, so i am not able to say something concerning web dev.
发布评论
评论(1)
在大型项目中,我倾向于在模型文件、控制文件和视图文件之间有所不同([mvc-pattern][1])。
模型文件包含有关数据的所有内容,尤其是我的类(OOP)。模型文件的一个示例可以是:
视图文件包含与布局和视图有关的所有内容,而控制文件则填充与数据处理有关的内容。控制文件使用模型文件中声明的类并与其一起工作。因此视图只需要包含控制文件并调用布局所需的函数。
但总的来说,一概而论是完全不同的。我喜欢 oo 模式,并且尝试使用 is,如果它有意义的话。但我只有 iPhone 开发的经验,所以我无法谈论有关 Web 开发的内容。
in large project i tend to differ between model-, control- and view-files ([mvc-pattern][1]).
the model-file contains everything concerning data especially my class (OOP). an example for a model-file could be:
the view-file contains everything concerning to the layout and view and the control-file is filled with the stuff concerning to data-handling. control-file uses the class declared in the model-file and works with it. so the view only needs to include the control-file and call the functions it needs for the layout.
but in general it's quite different to generalize. i like the oo-pattern and trie to use is, if it makes sense. but i have only experience with iPhone-development, so i am not able to say something concerning web dev.