November 22, 2009

How Not to Code Flex Applications (RIA Unleashed: Boston 2009)

Jeff Tapper

What is bad code
* Doesn't meet needs of the project: efficiency, maintainability, time to develop
* Code which doesn't make sense

Why do we write bad code
* Lack of time
* Lack of knowledge
* Lack of caring

What bad code leads to
* Delays
* Project failure
* Job loss
* Death

Bad code samples

If you are doing something wrong note it, add comments about why so you know you need to fix it later

Bad Code Sample 1

<mx:VBox styleName="doubleLine"/>
.doubleLine {
    background-image: Embed("/assets/images/doubleLine.png");
}

* Bad use of container (don't use if it won't have children)
* Better to replace with mx:Image

Bad Code Sample 2

<mx:List itemRenderer="see below" selectable="false">
<!-- item renderer -->
<mx:VBox>
<mx:Image/>
<mx:Label/>
</mx:VBox>

* Use of list when you don't need it's features: virtualization, selectability
* Better to replace with mx:Repeater

Bad Code Sample 3

public function setDate(u:String, p:String):void {
    username.text = u;
    password.text = p;
}
<mx:TextInput id="username"/>
<mx:TextInput id="password"/>

* Properties set on controls instead of a model (race conditions, control names, additional fields)
* Modify the model let the view follow using Bindings

Bad Code Sample 4

<mx:Form currentState="{ModelLocator.getInstance().loginState}"/>
new CarignromEvent("changeState");

* View events handled in top level component
* Local property changing local state is best unless other people need to know about it

Bad Code Sample 5

<mx:VBox borderStyle="solid" backgroundColor="" otherCSSStyles>
<mx:Text/>
</mx:VBox>

* Inappropriate container nesting (mostly for styling, not child layout, i.e. container with only one child)
* Exception is mx:ViewStack and mx:TabNavigator require children be containers
* Better to use mx:TextArea as that supports background and border styles

Bad Code Sample 6

<comp:Comp1 id="menuChooser"/>
<comp:Comp2 menuForDisplay="{menuChoose.menuGroup.selection.label}"/>

* Bad coupling (two dots and you are out)
* Better to dispatch event that others can listen for

Bad Code Sample 7

<mx:Button enabled="foo &amp;&amp; (bar != ''  || bar == '') // etc."/>

* Being too clever (hard to maintain and debug)
* Move the logic into a function

Tags: design flex riaunleashedboston2009

September 26, 2007

Flashforward Boston: The Aesthetics of Computation

Rough Draft Notes

John Maeda

MIT Media Lab
Did a lot of old school work on a Mac

Focus on local goods. Focus on local crafts. How to marry creative folks with business outlets.

Wasn't allowed to do art. Paul Rand. ABC, Limited, Next, logos.

Media Lab. Technology lab with good branding. Muriel Cooper. Pioneer of digital graphical design space. Art director of MIT press for 30 years. Lead visual language workshop.

If you just make stuff good things will happen. Phantom relax with physical material.

Classics are waiting. Do something young. Computer is a different kind of system, it doesn't get tired.

Gone from visual range but still there on the computer. Go into infinity.

Do these things, what is it for?

program inks of page but leave it open for interaction

Inverse paint. Fixed brush, program moves.
Radial paint.
Time paint. Draw in time. Sculptural view

Reactive tools. All available on the web. Color type writer.

Tap Type Write

2001 Media Lab didn't want to run media library. Retired in 2002.

4 grad students

openstudio.media.mit.edu
interactive art studio, networked world, and how to be profitable. Creativity, collaboration, and commercialism.

opencode.media.mit.edu
Jello based processing language. All development on the web site.

E15
Take all content on the web and display it in a non browser environment. Change, modify, and organize how a user wants instead of viewing data as presented.

python code to generate 2d code onto 2d canvas. leverage ability to change things on the fly.

richer perception of time

3d browser history to view where you've been
load up a bunch of pages at once

e15.media.mit.edu (new project)

relation databases
social networking relationships
making the system easy to use

aggregating data to generate complete picture of someone online.

Tags: design flashforward2007boston visualization

September 26, 2007

Flashforward Boston: What's this button do?

Rough Draft Notes
robert hoekman, jr.

Need to get user up to speed, help to get through your application.

What's this button do?
I'm feeling lucky?

suffer from a lack of explanation, or lack of context, don't install confidence

Talking about instructive text:
Using senduit as an example. (upload file and get temporary URL for that file)
Need to communicate: purpose, benefit, usage
need to keep it short

using default value in field to prompt user
show default zip code value (5, 9, 5+4)

Squidoo (create pages to market things)
inline help balloons for instructive text

command line (something that triggers action) "call to action" verb-noun pair
people don't like object based actions "page organization"

people have gotten used to dragging, almost expect it on the web. People that have been on the web a long time might not expect drag and drop may not work. Be explicit.

once over drag, cursor changes. when dragging move other modules around to show them the change.

"I'm done editing" sense of closure

Old Version of WordPress.com page doesn't have clear way to sign-up. Links hidden in text. Redesigned to big green button (contrasting color, different background) "sign up now". Jumped up 10-12%. Instructive piece more obvious.

RSS. Most web users still don't know what RSS is. Why would a user click a button that says RSS if I have no idea what this means. "Subscribe to this blog" is a better way to approach it.

Feedburner has a good approach. Creates a stylized version of your feed. "Syndication" and "content" are stuffy words. XML is a scary word.

Addthis.com has a different approach. Easy one click subscription, but doesn't help inform a user if they don't know what RSS is.

commoncraft.com/ Screencasts are a great way to explain a concept or a new idea.

BaseCamp.com: Disposable constructive element. New page has text that goes away when user performs the action.

GoogleReader for a new user has a screencast that talks about what it does with screen shots. Put a personal face on the experience.

Software for making screencasts.
Windows: Jing, TechSmith Camtasia Studio.
Mac: Jing, SnapzProX.

Flickr and most popular tag page. Size reflects popularity. No one gets tag clouds. No real life methaphor. Big doesn't mean more popular.

LibraryThing.com "What are tags" link. Very scary tag cloud page. Information overload.

NYTimes.com has explanation of tag cloud above cloud. Still a horrible interface...

miva.org
miskeeto.com (new design firm)
updownrepeat.com (The art and science of web forms)

Q: How to capture the content scrolled off the web.
Snagit (handle captures all scrolling of the web page)

Tags: design flashforward2007boston flex

June 28, 2007

Inversion of Control in Flex

At the recent BFPUG Design Patterns Meeting I gave an overview of Inversion of Control. Unfortunately due to time constraints I wasn't able to also put together a compelling example and as such I won't be posting the lame example I did put together. Instead I'll point you to an example that demonstrates the concepts and gives you something more to play with.

The ReviewTube source contains an example of IoC. The main file to look at is "com/joeberkovitz/reviewtube/services/ReviewTubeComponents.mxml" which is pulled in from "ReviewTube.mxml".

The key concept is that by using MXML style bindings, you declare a component once and give it a name through the id property. Now everywhere else that you need to reference that component, standard MXML binding syntax can reference that component. The use of setter dependency injection makes it all work. A couple of points not captured in the slides that should be pointed out.

  1. Make sure the MXML file that defines your components is the first child of your main application. That way the creation of everything gets kicked off as soon as possible.
  2. You will probably want to put a creationComplete handler on the MXML file to indicate that component configuration is done and your main application can start.
  3. Components should not rely on the order that their dependent components are set.

Tags: design flex ioc