Chapter 18. Creating reusable components

 

This chapter covers

  • Reusable components
  • Leveraging Spark
  • Code separation
  • Skinnable components
  • Runtime shared libraries
  • Shared reusability

In the last chapter, you got an in-depth look at the Spark component architecture. Now you’ll put this newfound knowledge to work by building your own reusable component.

What is reusability? The concept of reusability isn’t unique to Flex; each language provides mechanisms to achieve it. Words like encapsulation, abstraction, and polymorphism are OOP words that describe methods for creating code that can be easily reused. The more code you’re able to reuse, the faster you can develop new applications by leveraging existing code. From a maintenance perspective, you can achieve faster turnaround time when implementing changes too, because you only have to implement the fix in one spot, and anything that accesses that code will be updated because it’s all accessing the same source.

The first thing you’ll do in this chapter is look at a scenario where you must create a component that reveals content, but in many different ways, yet without having to write a separate component for each implementation. This example dives deeper into the realm of custom component development in Flex 4 than what you were exposed to in the last chapter, with our focus here narrowed specifically to code reuse.

18.1. Putting reusability into action

18.2. Reveal gets a new look

18.3. Runtime shared libraries

18.4. Summary