How NOT to Code - Challenge 9

Jan 26, 2010

Today's challenge is a Flex code issue. What's wrong with this code?


<mx:VBox borderStyle="solid"
     borderColor="#000000"
     backgroundColor="#FFFFFF"
     width="200" height="100">

     <mx:Text text="{bodyText}" width="100%" height="100%"/>

</mx:VBox>

Example from Jeff Tapper's 'How NOT to code Flex' presentation at MAX 2009.

http://slidesix.com/view/262JeffTapperHownottocodeFlexApplications-nP23P

Comments

Rodion Bykov

Rodion Bykov wrote on 01/26/102:43 PM

It's wrong 'cause container is used around only one Text control. VBox can be just skipped and it should be.
simon gladman

simon gladman wrote on 01/27/107:22 AM

"It's wrong 'cause container is used around only one Text control" - how about if there's some additional code that adds other components to the vbox later on? In that case, it's correct :)

simon
Rob McKeown

Rob McKeown wrote on 01/27/101:03 PM

My guess is that the container is there because you can't put a border around a Text control directly
John Mason

John Mason wrote on 02/09/108:49 AM

Rodion got it. You're not VBoxing anything here really. As Tapper says this is inappropriate container nesting and should be avoided.

Write your comment



(it will not be displayed)