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

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
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
 
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
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
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
 
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
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
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
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 

Último (20)

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
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
 
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
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
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
 
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
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
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
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 

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.