~ January, 2007 ~

24
Jan
2007

Covariant property types round 2

In thinking about it more, I think the right answer to the question of covariant property types might to allow covariant getters and to allow the types of getters and setters to be different.

class Application {
    public function get menu() : Menu;
    public function set menu(menu : Menu);
}

class MyApplication {
    public function get menu() : MyMenu;
    public function set menu(menu : Menu);
}

This covers the read only case and the read/write case. If the author wants to make MyApplication truly robust, the setter for menu will have conversion code to create a MyMenu from the Menu. If it does not need to be robust in this way, the author can throw an exception.

Allowing getters and setters to be of different types might be advantageous in other circumstances.

class Foo {
    public get dataProvider() : ICollection;
    public set dataProvider(provider : Object);
}

One could also imagine overloading the setter.

class Foo {
    public get dataProvider() : ICollection;
    public set dataProvider(provider : Array);
    public set dataProvider(provider : ICollection);
}

Again, I leave it for the language geeks to let me know if this is a bad idea. Just some idle thoughts on how to make properties a little easier to work with.

22
Jan
2007

Covariant property types?

Quick question for the language nuts out there.

Java and C++ both have the notion of covariant return types when overriding.

Typically, the rule is that an overridden method in a subclass can have a return type that is more specific than its superclass, like so (written in AS-like pseudocode).

class Application
{
    function getMenu() : Menu
}

class MyApp extends Application
{
    override function getMenu() : MyMenu
}

This is allowed because MyApp honors the contract originally specified by the Application class. The getMenu() function is returning a Menu. However, because it is defined as returning a more specific type of Menu, further type checking can be done, and you can get better code hints when you know that you are using an object of type MyApp.

Some languages also allow changing the type of arguments to functions. In these cases, the arguments have to be contravariant, not covariant (wider, not narrower).

class Menu extends UIComponent
{
    // blah blah blah
}

class Application
{
    function setMenu(newMenu: Menu)
}

class MyApp extends Application
{
    override function setMenu(newMenu: UIComponent)
}

The MyApp subclass honors the contract specified by the Application superclass, because it allows you to call setMenu with any object of type Menu. It widens the definition of setMenu to, in this case, allow any UIComponent to be passed in. Callers who were expecting MyApp to behave like a traditional Application would be none the wiser, but callers who knew the special abilities of the MyApp class could take advantage of its super powers.

I would love to add these types of language features to ActionScript, but the problem is that I want to use them for properties, and the usual recipe doesn’t work so well.

class Application
{
    function get menu() : Menu;
    function set menu(menu: Menu);
}

class MyApp extends Application
{
    override function get menu() : MyMenu;
    override function set menu(menu: OOPS???);
}

I am not a language guy, but I would love to be able to have the freedom to redefine a read/write property with a covariant (narrower) type. What this means is that setting the property with the wrong value may lead to a runtime exception. However, there are many cases where these values are either only set once (at the creation of an object) or only within controlled situations.

In the example pseudocode above, I’d love to be able to have, for example, a generic “menu” property of Application that I could do generic things with. But within my subclass, I’d like to have the type of the menuproperty be the actual class I’m using for my menu, so I can do things like: myApp.menu.specialFadeEffect() without downcasting.

Any language geeks out there? Is allowing covariant read/write property types when overriding a bad idea?

17
Jan
2007

Keeping the Flex ecosystem humming

Most of us on the Flex team come from the world of desktop software, which has a certain rhythm. You plan, you prioritize, you build it, you test it, and you ship it. During this cycle, each turn of the crank takes 12-18 months.

The Flex project is similar and it’s not. On the one hand, the Flex product is like desktop software in that we probably do want to keep it stable for a while before releasing new functionality. When people are depending on your framework, it, you shouldn’t change it every month.

On the flip side, the Flex team has a responsibility to “keep things going” on a steady basis. In that way, it’s very different from desktop software. To keep the Photoshop community going, the best thing to do is to ask the engineering team to put their heads down and to keep working on the next killer version of Photoshop. To keep the Flex community going, you want the team to be more actively engaged throughout the process. Most of the dev team is active on lists like flexcoders. People like Ely do experiments with Flex and post about them.

One of the most important pieces of the puzzle is documentation. We are trying to find new ways to move faster on getting documentation to customers, and as part of this, the doc team is now posting new chapters to the Flex documentation as soon as they have written them.

There are other “ecosystem” plans that we haven’t put into action yet (shhhhh!). In the meantime, what do you think the Flex should be doing? What would help you? What would help the Flex community in general?

15
Jan
2007

Using Flash (and PDF) tastefully

The Flash runtime is great for certain uses. Rich content is one obvious area. Video, animations, etc., are great uses for Flash. Complicated application UIs are another. Once you get past a certain threshold, it isn’t practical to build an application UI in HTML. Virtual Ubiquity’s word processor comes to mind. It looks and feels like a desktop word processor, and it would just be insane to do this in HTML.

For sites that could be done effectively in either HTML or Flash/Flex, it can sometimes be hard to use Flash tastefully. I mean.. I’m a Flex guy, but there are times when I visit a Flash-based site and I wish it were done in HTML instead.

I don’t know if there are any hard and fast rules for when to use HTML and when to use Flash. Instead, I like to look at examples. Here are two examples of sites that have blended HTML and Flash together very effectively:

CNN

CNN is doing a special section on Dr. Martin Luther King’s papers. The navigation is done in Flash, and the physical documents are reproduced in PDF. A section at the bottom of the page provides extra links in HTML.

The Flash area makes this special section feel more like an interactive magazine than a set of HTML pages. The visual design is more magazine-like, and the animation between pages reinforces the chronological relationship between the sections. Sound recordings of famous speeches are embedded directly in the page. Video is also embedded in the page (although in this case, it kicks you out to a separate player.. I think this would have been nicer to do in place).

Etsy

The other example of a hybrid HTML/Flash site I like is Etsy, which is a site for people to sell hand-crafted items. In terms of site design, what sets this site apart from other e-Commerce sites is the creativeness of their visualizations.

Want to see the most recent items that people have posted to the site? Try the time machine. If that is too wacky for you, try time machine 2. You can also see items by color geography, etc.

Not all of these visualizations are 100% successful, and I am sure that not all of them are 100% original. For example, the first time I saw an interface that used physical cards that could be spun around and thrown was over three years ago at www.intentionallies.co.jp, designed by Yugo Nakamura.

What strikes about Etsy, though, is the balance they strike between HTML and Flash. Whereas Intentionallies comes across as an avant-garde interface built in Flash as a replacement for HTML, Etsy comes across as a comfortable blend of HTML and Flash. HTML is used where it makes sense, and Flash is used where it makes sense. It doesn’t seem forced. It seems natural.

15
Jan
2007

I’m back

Now that our dev manager, Heidi, is back from maternity leave, I should have a bit more time to keep my blog going. Sorry for the low output over the last several months. It was a bit hectic here as we all scrambled to cover for her absence.

What were we working on? Well, we were mostly busy getting the 2.0.1 release out the door. This includes support for the mac, support for Eclipse 3.2, as well as tons of bugfixes. We also worked on the Japanese release, and we have been working with the Apollo team on making Flex Builder a great dev environment for Apollo (although none of this is publicly available yet). Finally, we have been getting a jump start on some 3.0 features (which are also not publicly available yet).

While I was away from the blog world, I did some thinking about what I wanted to blog about when I come back. I’ll continue to blog about technical aspects of Flex, but I think I’ll also spend some time focusing on general aspects of user interface design. What makes a great RIA? How will RIAs of the future be different than web apps of today? What makes for a bad RIA?

It’s good to be back.