2
votes

I am actually in the process of Architectural of our project. We have choosen Mate framework. The project is not so quite complex, but what advantages i would get over MXML when i choose Modules.

Main App - > Views - > Events - > Maps - > Services [PHP or Java]

When i come up with Modules based Architecture, it seems to be good but i doubt it should not end up with tight coupling and unwanted issues which may break the head later to solve.

Main APP - > Modules - > Module Interface -> Events - > Maps - > Services 
[PHP or Java]
  1. What advantages i do get if i choose Modules over MXML Component?
  2. What is the prefered and the best way to Architect an Flex Application?
  3. Since the Application is going to communicate with Backend, do we need to make the frontend more complex?
  4. Is there any Modules based Archiecture for a sample preview or any example where they have defined a good Architecture.
3

3 Answers

4
votes

I've built several Flex applications using the Mate framework but my environment is probably a bit different then yours. In any case, to answer your questions:

What advantages i do get if i choose Modules over MXML Component?

Modules should be used for pieces of functionality that you want to reuse across multiple applications. The benefit of using modules as KensoDev mentioned is that they can be used in other applications without having to rewrite or duplicate code. If the application you're architecting is going to be standalone and none of the functionality is going to be reused I would go with straight MXML.

What is the prefered and the best way to Architect an Flex Application?

It really does depend on the app. Most of the apps I've built using Mate were MXML based and we didn't use any modules, but it may make sense to use modules in your case. It all depends on what the project requirements are.

Since the Application is going to communicate with Backend, do we need to make the frontend more complex?

I'm a firm believer in making the UI as simple as possible and doing all of the heavy work on the middle tier or back end. The goal of any project is to make life easier or more convenient for the user. In other words, the front end that's presented to the user shouldn't be complex but the underlying business logic and back end work could be.

Is there any Modules based Archiecture for a sample preview or any example where they have defined a good Architecture.

Mate has some sample projects available for you to look at in terms of how they structure their projects. If it helps, we usually structure our projects similar to this:

src
|
|_assets (Images or other assets go here.)
|
|_ApplicationName
  |
  |_events (Your custom Mate events go here.)
  |
  |_maps (Your Mate Maps go here.)
  |
  |_model
  | |
  | |_managers (Your Data Managers go here. Most of the data processing from the back end happens here.)
  | |
  | |_vo (Your Value Object classes go here.)
  |
  |_ui
    |
    |_components (MXML components go here. Typically these are your "Front End" components.)
    |
    |_presenters (Your Presentation Models go here. Think of them as the "code behind" classes for your front end components.)
    |
    |_renderers (Any custom item renderers for lists of data grids go here.)
    |
    |_skins (Any custom skins for your components go here.)
    |
    |_views (Your application Views go here.)

I hope this helps!

4
votes

modules: the advantages of working with modules is application weight, having modules will get you a leaner thiner application and when you open a page/tab you load a module into the application

nother advantage of modules is DRY, you can have modules in several applications without any need to write code twice or anything like that.

Bet Way: it's really a matter of your application, there's no absolute truth about that. I have huge apps without any modules and other much lighter and simpler with modules it's really specific per app

Complex client side: if you have a back end, the back end will be the service layer of the application, you will have to create a model, view, controller/command (probably).

this is the best way (IMHO) to create a flex application nowdays.

Modules Sample: Google for potomac, I think you will find what your'e looking for there http://www.potomacframework.org/

2
votes

What advantages i do get if i choose Modules over MXML Component?

Modules and components are two very different things. A module is like a DLL in Windows or a Jar file in Java. In that it carries a section of code that can be loaded and unloaded at runtime. So modules can contain one or more MXML components. They don't replace the use of MXML components. You will still build your application using MXML whether you use modules or not. Unfortunately, modules are packed with a lot other "features" that don't make working with them as simple as say a Jar file in Java.

They have an upside and downside to them. You can reduce your memory footprint by loading and unloading code, but these days byte code size is NOT the main culprit of memory bloat. It's actually how the statements use the heap that causes memory to go up. You can easily share code between projects without Modules using a SWC or just simple sharing code through shared SVN projects.

Other downsides with modules is it creates more boundaries in your program. Referring to objects from within a Module can be a problem. Objects that uses a Module can refer to objects defined within the module, but not vice a versa so if you're not careful in how you organize your modules you can end up dumping code into the module that doesn't belong there.

I would start out not using modules then refactor if I have a clear need for them. Modules will only make the overhead of developing your overhead go up once you start using them.

What is the prefered and the best way to Architect an Flex Application?

MVC or MVCS. Model View Controller or Model View Controller Service. Some people get hung up on Commands are better than Controller, but really a Command is a Controller with only a single controller method. It's a degenerative controller. I like Controllers because it's very easy to add a new command to the Controller by just adding a method rather than a whole new class as Commands dictate. Plus a Controller allows you to group common functionality together for a screen, subsystem, etc. You can pick how fine grain you want your controllers. Also Controllers can easily be split when they get too big.

MVCS is easy to do without a framework, but using a framework is a good idea since it helps your team understand how the application is put together. Also open source software does a pretty good job of documenting the framework for you so you don't have to answer a lot of low level questions about your framework. Good choices are Swiz, Parsley, or Mate. However, most are moving to Swiz or Parsley now away from Mate and Caringorm. Caringorm will be Parsley in the future FYI.

Presentation Model pattern will help you when you want to do more unit testing so looking at how that works would be beneficial to your research. Although I'm more of a unit test the Controller and Model and do either traditional QA for the View or integration testing. QA is much easier.

Since the Application is going to communicate with Backend, do we need to make the frontend more complex?

You'll have to make a decision about how much complexity you want the front end to handle. Background processing is a weakness in Flex so sometimes that makes sense to pass to the backend. I think you'll be surprised at how much work goes into the front end. Flex is a RIA which means more work will be taking place in the Front end that's normal, but you'll have to decide what makes sense to do where.

My suggestion is front end calls simple services on the backend using JSON or AMF (Blaze DS). If you need something like a server push you can use ActiveMQ as it has connectors to Flex.

Is there any Modules based Architecture for a sample preview or any example where they have defined a good Architecture.

Modules and architecture are influenced by each other, but using modules doesn't mean you have a well defined architecture. You just have buckets you dump code in. Modules will not designate responsibilities or organization in your code which is what architecture does. As I said Modules are like DLLs and you don't see a DLL based architecture you can pick up off the shelf. Frameworks like Swiz will help define your Architecture more than Modules. I would say stop focusing on Modules and look at architecture then see if you need them.