Putting the Model, View and Controller folders besides appConfig.as and Main.as
hi!
in most of the examples, i notice that model view and controller
folders are kept away and packaged separately, from the package
containing AppConfig.as and Main.as etc . I wanted to know, if it's
ok, to put them all togather ? Just wanted to reduce the complexity
of my application and lessen the number of folders.
I experimented with a small project, and it seems ok. But not sure,
if this affects or breaks some rule that MVC takes care of . Like
if something can go wrong if they are packaged togather.
PS: by packaging togather, i mean app.AppConfig , app.Main, app.model.StatsModel , app.controller.XYZCommand etc.
V
Comments are currently closed for this discussion. You can start a new one.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
Support Staff 1 Posted by Ondina D.F. on 28 Mar, 2013 12:27 PM
Hey!
If you had a structure like this one:
-src
-----model
----------SomeModel.as
-----view
-----controller
And then you’d inject your model like this:
[Inject] public var model:SomeModel;
and tried to access it like this:
model.getSomeProperty();
you’d probably get an error like : Call to a possibly undefined method getSomeProperty()
and a warning that would read like this:
Definition name is the same as an imported package name.
Unqualified references to that name will resolve to the package and not the definition. If a definition is named the same as a package that is in scope, then any unqualified references to that name will resolve to the package instead of the definition. This can result in unexpected errors when attempting to reference the variable. Any references to the definition need to be qualified to resolve to the definition and not the package.
This would be ok. It wouldn’t hurt though to put AppConfig under app.config :)
Following the naming packages conventions
[http://help.adobe.com/en_US/AS2LCR/Flash_10.0/00000483.html#280733 ],
this would be a better choice:
domain.project.area.model.SomeModel
Did I answer your questions, Vishwas?
Ondina
2 Posted by vishwas.gagrani on 28 Mar, 2013 07:08 PM
it's like this ( following) , after i transferred all the 3 packages into app. Previously they were in a different folder and different package outside "src" folder. That folder was included as source folder.
-src
---app <<<<<<<<<<<<<<<<<< i noticed you didnot include this
-----model
----------SomeModel.as
-----view
-----controller
I understand the need of separate folder structuring and packages... but recently got tired of number of different folders, which became very confusing to browse through. So was trying to merge things up, where ever possible.
Thnx though, I think i got the answer !
V.
Support Staff 3 Posted by Ondina D.F. on 29 Mar, 2013 09:33 AM
Yeah, I know what you mean and feel. But, in a big project, a good folder/packages structure makes a lot of sense and is very helpful. If it’s confusing to browse through, that might be a sign that you have to rethink the structuring and naming of the functional areas and classes ;)
Ondina D.F. closed this discussion on 29 Mar, 2013 09:33 AM.