I guess it's a little bit of IOC.  It's really based on environment as well, so 
we get the data from different places based upon where the code is deployed 
(dev, stg, prod, qa, etc).  In some of our other apps, we have the application 
set up to "get postal codes", but that then starts assuming the app "knows" a 
lot about what to get and where to get it, rather than the components doing 
that for themselves.  I'll probably end up having some service calls within the 
library to get that information, but didn't know if someone had figured this 
out already.

I guess the 3 ways are:

1. Service calls within the library that point to the same spot each time (not 
optimal should the server change as it has in the past)
2. Have the app get the data and pass that on to the components (forces tight 
coupling with app, and having knowledge about the components)
3. Use a build script to compile the mxml/as files and thus have the 
environment built in that way.  (need to get antennae up and running...soon :)  
This way no matter where the file is deployed, it would get the data from the 
correct spot.)

4. Any other suggestions? :D

--- In flexcoders@yahoogroups.com, Angelo Anolin <angelo_ano...@...> wrote:
>
> Looks more like you are trying to achieve inversion of control principle.
> 
> Instead of the component calling invoking a method of an object, the object 
> is *smart* enough to know when to invoke the call and provide data to the 
> calling component.
> 
> i think your application should do just fine regardless whether you apply 
> IOC. There are certain trade offs as well - from a cleaner code and 
> maintainability point of view.  As much as I do in development, I only make 
> the call to the database when necessary - regardless whether the call is from 
> the component or the object. JIT - Just in time is more like it.
> 
> 
> 
> ________________________________
> From: gareth_arch <gareth_a...@...>
> To: flexcoders@yahoogroups.com
> Sent: Thu, 3 June, 2010 14:18:18
> Subject: [flexcoders] Best practice - remote calls from a flex library
> 
>   
> I'm trying to figure out best practice for making remote calls to my server 
> from components that are in a flex library.
> 
> e.g.  I have a postal code lookup component.  This component will make 
> require a user to enter a state, which will get all cities for that state (or 
> counties, or metro areas, etc.).  This requires a database call.  Now rather 
> than forcing the application that uses this component to make this call to 
> the server then inject the resulting data results into the dataprovider for 
> my postal code lookup component, I want the component to load this data.
> 
> Is it best practice to have something like com.mywebsite.business that 
> contains the remote calls for the library, then the component, when needed, 
> will load that data?
> 
> Just trying to get a few opinions on how everyone handles this.  I have 
> another library that contains most of my business logic (services, VOs, 
> events) and one that contains my components (modified arraycollections, 
> customized comboboxes), but wasn't sure about adding these items in.
> 
> Any thoughts would be appreciated,
> 
> Thanks,
>


Reply via email to