Question

I am trying to use parsley framework in my flex application. Messaging System is one of the best feature that I see while using parsley,

But I had a doubt,

Does using Parsley framework in your application means that,

  1. Replace every addEventListener() functionaltiy with the Messaging System of Parsley ?
  2. Cannot create any objects using new newObject();. Should use dependency Injection, instead of creating explicit objects ?

Are the above doubts true ?

Was it helpful?

Solution

No. Using Parsley does not mean you must/should replace all your event listeners with Parsley's messaging.

The whole idea of Parsley is to decouple, in other words, it's about making parts of your app not tied to other parts of your app.

You CAN decouple using Flex Messaging, because Flex events can transvers. But: 1) Flex events transvers through the display list which is not always what you want 2) Flex events depend on String, which can be a pain if you refactor, or make typos

So the answer to both your questions is: Only use Parsley events and Parsley objects if you want Parsley to manage those objects. Which will not be the case always.

Decoupling can be good, but it can be a chore. Unlike the previous answer. Decoupling is GREAT for unit testing. It actually makes it easier, because in theory, everything is a unit by itself not tied to other Units. Just because Parsley can inject them for you, it doesn't mean it HAS to do it for unit testing.

Actually, Flex is built around Injection. There is a difference between automatic injection and injection. When you assign a dataProvider to a List, you are Injecting, it's just that your are doing it manually. Parsley simply offers a way to manage Injection automatically for you.

However, yes, sometimes you might be wondering why something didn't get injected, but it is not that difficult to figure out why.

I wrote a series of posts to help people get going with Parsley, check it out http://artinflex.blogspot.com/2010/09/quick-dive-into-parsley-intro-why.html it might be useful.

OTHER TIPS

I work at the place where I cannot choose the tools to use, and Parsley is one of the tools I wouldn't choose if I was given a choice. If you think about being able to debug and test your project, encapsulation, modular design etc - avoid using "micro architecture frameworks" at all costs :)

Parsley, similarly to SWIZ, Mate, less so Cairngorm and probably others, of which I don't have an in-depth knowledge, relies on metadata. This adds a whole lot of indirection. This means you can't influence or even debug what happens not only "under the hood" but in your own code, too. You don't know when and why the function will get called, but most importantly, why would it not get called. The "dependency injection" means that you will not be able to run unit tests on "injected" components - because by "injecting" them you create a dependency to every thing you have in your project.

In the end of the day, you write more code to serve the framework, you spend orders of magnitude more time debugging and resolving quirks of the framework, the application gains a lot of weight and runs much slower then it would w/o the framework. After some time you used the framework, the code becomes one huge incomprehensible mess impossible to split into smaller parts to update / replace them.

So, if it wasn't obvious :) Do not use injection, but do use addEventListener().

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top