SlideShare uma empresa Scribd logo
1 de 25
How not to code Flex
                     Applications
                 Tips and Tricks to keep you from
                  being fired, or fed to the lions.

          Jeff Tapper
jtapper@digitalprimates.net
Digital Primates IT Consulting
Who Am I
   Jeff Tapper (jtapper@digitalprimates.net)
   Senior Consultant – Digital Primates IT Consulting
    Group
   Building Internet Applications since 1995
   Authored 10 books on internet technologies
   Adobe Certified Instructor for all Flex, AIR, Flash, and
    ColdFusion courses
   http://blogs.digitalprimates.net/jefftapper
   Twitter: jefftapper
Who Are You?
• Developers who…
  – are open to learning
  – Have some experience with Flex
  – Have a sense of humor
• If this isn’t you, you should probably leave
Agenda
•   What is bad code
•   Why do developers code badly
•   Bad Code Samples
•   Rules to Live By
•   Questions
What is Bad Code
• Bad code is…
  – Code which doesn’t meet the needs of a project
     • Efficiency
     • maintainability
     • Time to develop
  – Code which doesn’t make sense
Why do developers code badly?
• Lack of Time
• Lack of Knowledge
• Lack of Caring
Some of my bad code…
public class XMLListener extends
  EventDispatcher
{

// FIXME! - JT - yes, i know this is
// not the right solution
// but im making the socket public so I
// can attach a listener to it
// this can clearly be done better, but im
// tired, and this is what i have at the
// moment
public var socket:XMLSocket;
What are the consequences
• Bad code can lead to
  – Delays
  – Project failure
  – Job loss
  – Death
Sample 1
<mx:VBox xmlns:mx=quot;http://www.adobe.com/2006/mxmlquot;>
  <mx:TextInput id=quot;usernamequot; width=quot;150quot;/>
  <mx:TextInput id=quot;passwordquot; width=quot;150quot;/>
  <mx:VBox width=“150quot; height=quot;10quot;
  styleName=quot;doubleLinequot;/>
  <mx:Button label=quot;submitquot;/>
</mx:VBox>

Main.css
.doubleLine{
background-image: Embed(quot;/assets/images/doubleLine.pngquot;);
}
Rule1.mxml
What is wrong with #1
• Summary: Inappropriate use of container.
• Description: <mx:Image> should be used to
  display an image, not a container with an
  backgroundImage style
• Type: Maintainability, Performance
• Rule: Its never appropriate to use a container
  which will never have children.
#2
Main App
<mx:List dataProvider=quot;{ac}quot;
  itemRenderer=quot;component.ItemRendererquot;
  selectable=quot;falsequot; />

ItemRenderer
<mx:VBox xmlns:mx=quot;http://www.adobe.com/2006/mxmlquot; >
   <mx:Image source=quot;{data.image}quot;/>
   <mx:Label text=quot;{data.colorname}quot;
       height=quot;30quot;/>
</mx:VBox>

Rule2.mxml
What is wrong with #2
• Summary: List used when VBox more
  appropriate
• Description: A List control has lots of code
  dealing with selecting items, clearly, this is not
  about item selection
• Type: Performance, Maintainability
• Rule: Never use a List based component when
  list functionality is not needed.
#3
<mx:Script>
<![CDATA[
private function
  setData(un:String, pw:String):void{
  username.text=un;
  password.text=pw;
}
]]>
</mx:Script>
<mx:TextInput id=quot;username“ />
<mx:TextInput id=quot;passwordquot; />
What is wrong with #3
• Summary: Properties are set on
  controls, when data binding would be better
• Description: Setting properties on controls
• Type: Maintenance, Development Time
• Rule: Modify the Model, Let the View Follow
#4




Rule4.mxml
What is wrong with #4
• Summary: Views events handled in top level
  component
• Description: View is dispatching an event
  which is handled by a controller by passing
  event data back to view
• Type: Maintenance, Separation of Concerns
• Rule: Always handle events as locally as
  possible
#5
<mx:VBox borderStyle=quot;solidquot;
  borderColor=quot;#00000quot;
  backgroundColor=quot;#FFFFFFquot;
  width=quot;200quot; height=quot;100quot;>
  <mx:Text text=quot;{bodyText}quot; width=quot;100%quot;
     height=quot;100%quot; />
</mx:VBox>

Rule5.mxml
What is wrong with #5
• Summary: Inappropriate container nesting
• Description: Additional containers added for
  styling, not for child layout
• Type: Performance
• Rule: If you have a container with only one
  child, you are usually doing something wrong.
#6
<mx:Application
  xmlns:mx=quot;http://www.adobe.com/2006/mxmlquot;
  xmlns:comp=quot;*quot;>

  <comp:ChooseMenu id= quot;chooserquot; />

  <comp:DisplayMenu
menuForDisplay=quot;{chooser.menuGroup.selection.label}quot;
  />

</mx:Application>

Rule6.mxml
What is wrong with #6
• Summary: reaching into a child of a child
• Description: Components should interact with
  their children, not their children’s children
• Type: Separation of Concerns, Encapsulation
• Rule: Two dots and your out
#7
<mx:LinkButton label=quot;{labels.ProcessStatus}quot;
  enabled =quot;{(gridTests.selectedItems.length==1
  &amp;&amp; (hasRight ||
  (gridTests.selectedItem.StatusCode!='XX'
  &amp;&amp;gridTests.selectedItem.StatusCode!='XY')))?
  ((gridTests.selectedItem.IsDerived=='n')?
  (gridTests.selectedItem.StatusCode!='YY'&amp;&amp;
  gridTests.selectedItem.StatusCode!='YX' &amp;&amp;
  gridTests.selectedItem.StatusCode!='XYX'):false)
  :false}quot;
  click =quot;setTestStatus(event);quot;/>

Rule7.mxml
What is wrong with #7
• Summary: unreadable code
• Description: Use functions, not complex
  binding expressions
• Type: Maintainability
• Rule: Being too clever makes you a dumb-ass
Everyone Writes Bad Code -
               sometimes
• If you spend some time in the SDK source
  code, you can find gems like this:
var changeCount:int;
changeCount=Math.max(1,getStyle(quot;horizontalChangeCountquot;));
if (changeCount * 0 != 0){
   changeCount = 1;
}
Rules To Live By
• Its never appropriate to use a container when
  they will never have children.
• Never use a List based component when list
  functionality is not needed.
• Modify the Model, Let the View Follow
• Always handle events as locally as possible
• If you find you have a container with only one
  child, you are probably doing something wrong.
• Don’t be a dumb-ass
• Flex isnt broken, you are.
Questions

Mais conteúdo relacionado

Mais procurados

Extreme optimization good
Extreme optimization goodExtreme optimization good
Extreme optimization goodmatt433
 
GTM Clowns, fun and hacks - Search Elite - May 2017 Gerry White
GTM Clowns, fun and hacks - Search Elite - May 2017 Gerry WhiteGTM Clowns, fun and hacks - Search Elite - May 2017 Gerry White
GTM Clowns, fun and hacks - Search Elite - May 2017 Gerry WhiteGerry White
 
Business Aspects of High Performance Websites
Business Aspects of High Performance WebsitesBusiness Aspects of High Performance Websites
Business Aspects of High Performance Websitesmalteubl
 
How To Add A Voki to your Wordpress MU blog
How To Add A Voki to your Wordpress MU blogHow To Add A Voki to your Wordpress MU blog
How To Add A Voki to your Wordpress MU blogJohn Sutton
 
Multimedia on the web - HTML5 video and audio
Multimedia on the web - HTML5 video and audioMultimedia on the web - HTML5 video and audio
Multimedia on the web - HTML5 video and audioChristian Heilmann
 
Hardening WordPress - SAScon Manchester 2013 (WordPress Security)
Hardening WordPress - SAScon Manchester 2013 (WordPress Security)Hardening WordPress - SAScon Manchester 2013 (WordPress Security)
Hardening WordPress - SAScon Manchester 2013 (WordPress Security)Bastian Grimm
 
WWW:::Mechanize YAPC::BR 2008
WWW:::Mechanize YAPC::BR 2008WWW:::Mechanize YAPC::BR 2008
WWW:::Mechanize YAPC::BR 2008mvitor
 
Not Just a Pretty Face: How to design and build a cross-CMS CSS framework
Not Just a Pretty Face: How to design and build a cross-CMS CSS frameworkNot Just a Pretty Face: How to design and build a cross-CMS CSS framework
Not Just a Pretty Face: How to design and build a cross-CMS CSS frameworkcrystalenka
 
TechSEO Boost 2021 - The Future Is The Past: Tagging And Tracking Through The...
TechSEO Boost 2021 - The Future Is The Past: Tagging And Tracking Through The...TechSEO Boost 2021 - The Future Is The Past: Tagging And Tracking Through The...
TechSEO Boost 2021 - The Future Is The Past: Tagging And Tracking Through The...Catalyst
 
Powermanagement
PowermanagementPowermanagement
Powermanagementabebob
 
Website maintenance: keeping your WordPress site updated and safe
Website maintenance: keeping your WordPress site updated and safeWebsite maintenance: keeping your WordPress site updated and safe
Website maintenance: keeping your WordPress site updated and safeClare Parkinson
 
Site Down: How to Triage Those First Minutes
Site Down: How to Triage Those First MinutesSite Down: How to Triage Those First Minutes
Site Down: How to Triage Those First MinutesJohn Gamboa
 
Knockout js with mvc
Knockout js with mvcKnockout js with mvc
Knockout js with mvcJoel Cochran
 
Hoe uw website te laten renderen: 10 Killer tips voor succes.
Hoe uw website te laten renderen: 10 Killer tips voor succes.Hoe uw website te laten renderen: 10 Killer tips voor succes.
Hoe uw website te laten renderen: 10 Killer tips voor succes.Thomas Vande Casteele
 
Building the Fastest WooCommerce Store Ever
Building the Fastest WooCommerce Store EverBuilding the Fastest WooCommerce Store Ever
Building the Fastest WooCommerce Store EverChris Lema
 

Mais procurados (18)

Cdddd
CddddCdddd
Cdddd
 
Extreme optimization good
Extreme optimization goodExtreme optimization good
Extreme optimization good
 
A look into A-Frame
A look into A-FrameA look into A-Frame
A look into A-Frame
 
GTM Clowns, fun and hacks - Search Elite - May 2017 Gerry White
GTM Clowns, fun and hacks - Search Elite - May 2017 Gerry WhiteGTM Clowns, fun and hacks - Search Elite - May 2017 Gerry White
GTM Clowns, fun and hacks - Search Elite - May 2017 Gerry White
 
Using HTML5 sensibly
Using HTML5 sensiblyUsing HTML5 sensibly
Using HTML5 sensibly
 
Business Aspects of High Performance Websites
Business Aspects of High Performance WebsitesBusiness Aspects of High Performance Websites
Business Aspects of High Performance Websites
 
How To Add A Voki to your Wordpress MU blog
How To Add A Voki to your Wordpress MU blogHow To Add A Voki to your Wordpress MU blog
How To Add A Voki to your Wordpress MU blog
 
Multimedia on the web - HTML5 video and audio
Multimedia on the web - HTML5 video and audioMultimedia on the web - HTML5 video and audio
Multimedia on the web - HTML5 video and audio
 
Hardening WordPress - SAScon Manchester 2013 (WordPress Security)
Hardening WordPress - SAScon Manchester 2013 (WordPress Security)Hardening WordPress - SAScon Manchester 2013 (WordPress Security)
Hardening WordPress - SAScon Manchester 2013 (WordPress Security)
 
WWW:::Mechanize YAPC::BR 2008
WWW:::Mechanize YAPC::BR 2008WWW:::Mechanize YAPC::BR 2008
WWW:::Mechanize YAPC::BR 2008
 
Not Just a Pretty Face: How to design and build a cross-CMS CSS framework
Not Just a Pretty Face: How to design and build a cross-CMS CSS frameworkNot Just a Pretty Face: How to design and build a cross-CMS CSS framework
Not Just a Pretty Face: How to design and build a cross-CMS CSS framework
 
TechSEO Boost 2021 - The Future Is The Past: Tagging And Tracking Through The...
TechSEO Boost 2021 - The Future Is The Past: Tagging And Tracking Through The...TechSEO Boost 2021 - The Future Is The Past: Tagging And Tracking Through The...
TechSEO Boost 2021 - The Future Is The Past: Tagging And Tracking Through The...
 
Powermanagement
PowermanagementPowermanagement
Powermanagement
 
Website maintenance: keeping your WordPress site updated and safe
Website maintenance: keeping your WordPress site updated and safeWebsite maintenance: keeping your WordPress site updated and safe
Website maintenance: keeping your WordPress site updated and safe
 
Site Down: How to Triage Those First Minutes
Site Down: How to Triage Those First MinutesSite Down: How to Triage Those First Minutes
Site Down: How to Triage Those First Minutes
 
Knockout js with mvc
Knockout js with mvcKnockout js with mvc
Knockout js with mvc
 
Hoe uw website te laten renderen: 10 Killer tips voor succes.
Hoe uw website te laten renderen: 10 Killer tips voor succes.Hoe uw website te laten renderen: 10 Killer tips voor succes.
Hoe uw website te laten renderen: 10 Killer tips voor succes.
 
Building the Fastest WooCommerce Store Ever
Building the Fastest WooCommerce Store EverBuilding the Fastest WooCommerce Store Ever
Building the Fastest WooCommerce Store Ever
 

Semelhante a How Not To Code Flex Applications

Plone Interactivity
Plone InteractivityPlone Interactivity
Plone InteractivityEric Steele
 
Mozilla Firefox Extension Development, Course 1: Basic
Mozilla Firefox Extension Development, Course 1: BasicMozilla Firefox Extension Development, Course 1: Basic
Mozilla Firefox Extension Development, Course 1: Basiclittlebtc
 
Basics of Rich Internet Applications
Basics of Rich Internet ApplicationsBasics of Rich Internet Applications
Basics of Rich Internet ApplicationsSubramanyan Murali
 
[Muir] Seam 2 in practice
[Muir] Seam 2 in practice[Muir] Seam 2 in practice
[Muir] Seam 2 in practicejavablend
 
Wai Aria - An Intro
Wai Aria - An IntroWai Aria - An Intro
Wai Aria - An IntroMatt Machell
 
More Secrets of JavaScript Libraries
More Secrets of JavaScript LibrariesMore Secrets of JavaScript Libraries
More Secrets of JavaScript Librariesjeresig
 
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best PracticesWindows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best PracticesSriram Krishnan
 
Webcast 09/2008 - Silverlight 2 Beta 2
Webcast 09/2008 - Silverlight 2 Beta 2Webcast 09/2008 - Silverlight 2 Beta 2
Webcast 09/2008 - Silverlight 2 Beta 2sleguiza
 
Semantics & the Mobile Web
Semantics & the Mobile WebSemantics & the Mobile Web
Semantics & the Mobile Websurferroop
 
IBM Lotus Notes Domino XPages and XPages for Mobile
IBM Lotus Notes Domino XPages and XPages for MobileIBM Lotus Notes Domino XPages and XPages for Mobile
IBM Lotus Notes Domino XPages and XPages for MobileChris Toohey
 
Hacking Movable Type Training - Day 2
Hacking Movable Type Training - Day 2Hacking Movable Type Training - Day 2
Hacking Movable Type Training - Day 2Byrne Reese
 
What I brought back from Austin
What I brought back from AustinWhat I brought back from Austin
What I brought back from AustinLisa Adkins
 
Deliverance: Plone theming without the learning curve from Plone Symposium Ea...
Deliverance: Plone theming without the learning curve from Plone Symposium Ea...Deliverance: Plone theming without the learning curve from Plone Symposium Ea...
Deliverance: Plone theming without the learning curve from Plone Symposium Ea...Jazkarta, Inc.
 
Flex For Flash Developers Ff 2006 Final
Flex For Flash Developers Ff 2006 FinalFlex For Flash Developers Ff 2006 Final
Flex For Flash Developers Ff 2006 Finalematrix
 
Even Faster Web Sites at jQuery Conference '09
Even Faster Web Sites at jQuery Conference '09Even Faster Web Sites at jQuery Conference '09
Even Faster Web Sites at jQuery Conference '09Steve Souders
 
Leveraging Continuous Integration For Fun And Profit!
Leveraging Continuous Integration For Fun And Profit!Leveraging Continuous Integration For Fun And Profit!
Leveraging Continuous Integration For Fun And Profit!Jess Chadwick
 
Developing and testing ajax components
Developing and testing ajax componentsDeveloping and testing ajax components
Developing and testing ajax componentsIgnacio Coloma
 

Semelhante a How Not To Code Flex Applications (20)

Plone Interactivity
Plone InteractivityPlone Interactivity
Plone Interactivity
 
Mozilla Firefox Extension Development, Course 1: Basic
Mozilla Firefox Extension Development, Course 1: BasicMozilla Firefox Extension Development, Course 1: Basic
Mozilla Firefox Extension Development, Course 1: Basic
 
Basics of Rich Internet Applications
Basics of Rich Internet ApplicationsBasics of Rich Internet Applications
Basics of Rich Internet Applications
 
[Muir] Seam 2 in practice
[Muir] Seam 2 in practice[Muir] Seam 2 in practice
[Muir] Seam 2 in practice
 
Wai Aria - An Intro
Wai Aria - An IntroWai Aria - An Intro
Wai Aria - An Intro
 
Lecture1 B Frames&Forms
Lecture1 B  Frames&FormsLecture1 B  Frames&Forms
Lecture1 B Frames&Forms
 
More Secrets of JavaScript Libraries
More Secrets of JavaScript LibrariesMore Secrets of JavaScript Libraries
More Secrets of JavaScript Libraries
 
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best PracticesWindows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
 
Looking into HTML5
Looking into HTML5Looking into HTML5
Looking into HTML5
 
Webcast 09/2008 - Silverlight 2 Beta 2
Webcast 09/2008 - Silverlight 2 Beta 2Webcast 09/2008 - Silverlight 2 Beta 2
Webcast 09/2008 - Silverlight 2 Beta 2
 
Semantics & the Mobile Web
Semantics & the Mobile WebSemantics & the Mobile Web
Semantics & the Mobile Web
 
IBM Lotus Notes Domino XPages and XPages for Mobile
IBM Lotus Notes Domino XPages and XPages for MobileIBM Lotus Notes Domino XPages and XPages for Mobile
IBM Lotus Notes Domino XPages and XPages for Mobile
 
Hacking Movable Type Training - Day 2
Hacking Movable Type Training - Day 2Hacking Movable Type Training - Day 2
Hacking Movable Type Training - Day 2
 
What I brought back from Austin
What I brought back from AustinWhat I brought back from Austin
What I brought back from Austin
 
Deliverance: Plone theming without the learning curve from Plone Symposium Ea...
Deliverance: Plone theming without the learning curve from Plone Symposium Ea...Deliverance: Plone theming without the learning curve from Plone Symposium Ea...
Deliverance: Plone theming without the learning curve from Plone Symposium Ea...
 
A More Perfect Union with CSS
A More Perfect Union with CSSA More Perfect Union with CSS
A More Perfect Union with CSS
 
Flex For Flash Developers Ff 2006 Final
Flex For Flash Developers Ff 2006 FinalFlex For Flash Developers Ff 2006 Final
Flex For Flash Developers Ff 2006 Final
 
Even Faster Web Sites at jQuery Conference '09
Even Faster Web Sites at jQuery Conference '09Even Faster Web Sites at jQuery Conference '09
Even Faster Web Sites at jQuery Conference '09
 
Leveraging Continuous Integration For Fun And Profit!
Leveraging Continuous Integration For Fun And Profit!Leveraging Continuous Integration For Fun And Profit!
Leveraging Continuous Integration For Fun And Profit!
 
Developing and testing ajax components
Developing and testing ajax componentsDeveloping and testing ajax components
Developing and testing ajax components
 

Último

2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructureitnewsafrica
 
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...BookNet Canada
 
Accelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessAccelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessWSO2
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesManik S Magar
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxfnnc6jmgwh
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Nikki Chapple
 
Infrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsInfrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsYoss Cohen
 
Kuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorialKuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorialJoão Esperancinha
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024TopCSSGallery
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...itnewsafrica
 
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...Jeffrey Haguewood
 

Último (20)

2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
 
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
 
Accelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessAccelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with Platformless
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
 
Infrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsInfrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platforms
 
Kuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorialKuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorial
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
 
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
 

How Not To Code Flex Applications

  • 1. How not to code Flex Applications Tips and Tricks to keep you from being fired, or fed to the lions. Jeff Tapper jtapper@digitalprimates.net Digital Primates IT Consulting
  • 2. Who Am I  Jeff Tapper (jtapper@digitalprimates.net)  Senior Consultant – Digital Primates IT Consulting Group  Building Internet Applications since 1995  Authored 10 books on internet technologies  Adobe Certified Instructor for all Flex, AIR, Flash, and ColdFusion courses  http://blogs.digitalprimates.net/jefftapper  Twitter: jefftapper
  • 3. Who Are You? • Developers who… – are open to learning – Have some experience with Flex – Have a sense of humor • If this isn’t you, you should probably leave
  • 4. Agenda • What is bad code • Why do developers code badly • Bad Code Samples • Rules to Live By • Questions
  • 5. What is Bad Code • Bad code is… – Code which doesn’t meet the needs of a project • Efficiency • maintainability • Time to develop – Code which doesn’t make sense
  • 6. Why do developers code badly? • Lack of Time • Lack of Knowledge • Lack of Caring
  • 7. Some of my bad code… public class XMLListener extends EventDispatcher { // FIXME! - JT - yes, i know this is // not the right solution // but im making the socket public so I // can attach a listener to it // this can clearly be done better, but im // tired, and this is what i have at the // moment public var socket:XMLSocket;
  • 8. What are the consequences • Bad code can lead to – Delays – Project failure – Job loss – Death
  • 9. Sample 1 <mx:VBox xmlns:mx=quot;http://www.adobe.com/2006/mxmlquot;> <mx:TextInput id=quot;usernamequot; width=quot;150quot;/> <mx:TextInput id=quot;passwordquot; width=quot;150quot;/> <mx:VBox width=“150quot; height=quot;10quot; styleName=quot;doubleLinequot;/> <mx:Button label=quot;submitquot;/> </mx:VBox> Main.css .doubleLine{ background-image: Embed(quot;/assets/images/doubleLine.pngquot;); } Rule1.mxml
  • 10. What is wrong with #1 • Summary: Inappropriate use of container. • Description: <mx:Image> should be used to display an image, not a container with an backgroundImage style • Type: Maintainability, Performance • Rule: Its never appropriate to use a container which will never have children.
  • 11. #2 Main App <mx:List dataProvider=quot;{ac}quot; itemRenderer=quot;component.ItemRendererquot; selectable=quot;falsequot; /> ItemRenderer <mx:VBox xmlns:mx=quot;http://www.adobe.com/2006/mxmlquot; > <mx:Image source=quot;{data.image}quot;/> <mx:Label text=quot;{data.colorname}quot; height=quot;30quot;/> </mx:VBox> Rule2.mxml
  • 12. What is wrong with #2 • Summary: List used when VBox more appropriate • Description: A List control has lots of code dealing with selecting items, clearly, this is not about item selection • Type: Performance, Maintainability • Rule: Never use a List based component when list functionality is not needed.
  • 13. #3 <mx:Script> <![CDATA[ private function setData(un:String, pw:String):void{ username.text=un; password.text=pw; } ]]> </mx:Script> <mx:TextInput id=quot;username“ /> <mx:TextInput id=quot;passwordquot; />
  • 14. What is wrong with #3 • Summary: Properties are set on controls, when data binding would be better • Description: Setting properties on controls • Type: Maintenance, Development Time • Rule: Modify the Model, Let the View Follow
  • 16. What is wrong with #4 • Summary: Views events handled in top level component • Description: View is dispatching an event which is handled by a controller by passing event data back to view • Type: Maintenance, Separation of Concerns • Rule: Always handle events as locally as possible
  • 17. #5 <mx:VBox borderStyle=quot;solidquot; borderColor=quot;#00000quot; backgroundColor=quot;#FFFFFFquot; width=quot;200quot; height=quot;100quot;> <mx:Text text=quot;{bodyText}quot; width=quot;100%quot; height=quot;100%quot; /> </mx:VBox> Rule5.mxml
  • 18. What is wrong with #5 • Summary: Inappropriate container nesting • Description: Additional containers added for styling, not for child layout • Type: Performance • Rule: If you have a container with only one child, you are usually doing something wrong.
  • 19. #6 <mx:Application xmlns:mx=quot;http://www.adobe.com/2006/mxmlquot; xmlns:comp=quot;*quot;> <comp:ChooseMenu id= quot;chooserquot; /> <comp:DisplayMenu menuForDisplay=quot;{chooser.menuGroup.selection.label}quot; /> </mx:Application> Rule6.mxml
  • 20. What is wrong with #6 • Summary: reaching into a child of a child • Description: Components should interact with their children, not their children’s children • Type: Separation of Concerns, Encapsulation • Rule: Two dots and your out
  • 21. #7 <mx:LinkButton label=quot;{labels.ProcessStatus}quot; enabled =quot;{(gridTests.selectedItems.length==1 &amp;&amp; (hasRight || (gridTests.selectedItem.StatusCode!='XX' &amp;&amp;gridTests.selectedItem.StatusCode!='XY')))? ((gridTests.selectedItem.IsDerived=='n')? (gridTests.selectedItem.StatusCode!='YY'&amp;&amp; gridTests.selectedItem.StatusCode!='YX' &amp;&amp; gridTests.selectedItem.StatusCode!='XYX'):false) :false}quot; click =quot;setTestStatus(event);quot;/> Rule7.mxml
  • 22. What is wrong with #7 • Summary: unreadable code • Description: Use functions, not complex binding expressions • Type: Maintainability • Rule: Being too clever makes you a dumb-ass
  • 23. Everyone Writes Bad Code - sometimes • If you spend some time in the SDK source code, you can find gems like this: var changeCount:int; changeCount=Math.max(1,getStyle(quot;horizontalChangeCountquot;)); if (changeCount * 0 != 0){ changeCount = 1; }
  • 24. Rules To Live By • Its never appropriate to use a container when they will never have children. • Never use a List based component when list functionality is not needed. • Modify the Model, Let the View Follow • Always handle events as locally as possible • If you find you have a container with only one child, you are probably doing something wrong. • Don’t be a dumb-ass • Flex isnt broken, you are.