SlideShare ist ein Scribd-Unternehmen logo
1 von 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

Weitere ähnliche Inhalte

Was ist angesagt?

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
 

Was ist angesagt? (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
 

Ähnlich wie 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
 

Ähnlich wie 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
 

Kürzlich hochgeladen

04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 

Kürzlich hochgeladen (20)

04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 

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.