Having just picked up Programming Flex 2 I was dismayed that components seem (almost) to be an afterthought. Yes they're documented, with 2 chapters dedicated to them - but the importance of them is from an architecture perspective seems to be glossed over.
After keyboard sized imprints in my forehead for the past day coding. I'm going to say this, definitely develop your Flex applications with a component first approach (well I will anyway!) don't bother with a cruddy component-less prototype. You will save far more time in the long run designing your app from the ground up with components in mind and skipping the ugly component-less prototype step. Why do you want to do this ?
Components are a VeryGoodThingâ„¢.
Components are so easy to use, that it's almost criminal to start building your first rough cut without them. One of the biggest benefits is how well you can capture your business interface needs within the components. Almost turning your mxml and actionscript into a domain specific language. For example in an eCommerce application, the heirachy might look like this
AppStack (< View Stack )
- Dashboard ( < Canvas )
- OrdersStack ( < View Stack )
--- OrdersList ( < Panel )
--- OrderView ( < Panel )
- CustomersStack ( < View Stack )
- InventoryStack ( < View Stack )
- ReportsStack ( < View Stack )
With examples of public methods:
OrdersList.refreshOrders()
OrdersList.switchToCustomersOrders(customerID:Number)
OrderView.changeToEditMode()
OrderView.showBackOfficeInformation()
This takes no imagination to understand the application. With a little bit of foresight, it reduces your prototyping and development time as you can translate your wireframes into components pretty much from the get go.
Keep your reader's subscribed - next up we'll look at an actual component implementation. From pencil sketch through to working code.