One of the nifty new features in RB 2008 release 3 is Attributes. Aaron does a good job of explaining it in his blog. I think it’s every bit as important and useful as introspection. I’ll give you an example of where I think I’ll be using Attributes and why I think the IDE is missing something.
I’m working on an application that will have a properties list. It might be something like the properties list in the REALbasic IDE itself by the time it gets done. I really don’t know because I’m ‘playing around’ with the interface.

I started doing some coding and when I started
hard coding the property listbox. I took a step back and thought that this might be an excellent place to use introspection. I mean, why not use the ability to get the properties and values of class members for display? I did a quick and dirty prototype and liked what I saw.

However, my prototype quickly showed the flaw in my logic. Using introspection shows
every property of the passed in class and in a name and order not conducive to users. I started thinking about ways to get around this limitation like adding an array with the property name in the order that I wanted. I then had to work around what I wanted the user to see, not what my internal class names were. Hhhmm....not a good solution afterall.

Then an RB friend mentioned Attributes which is new in REALbasic 2008 Release 3. What are attributes? Boiled down they can be properties of properties (but not limited to just properties). So, for example I could add an ‘Order’ attribute to all the properties in my class that I want to the user to see and at runtime read them into an array, sort them by number and then display them in the order I want. I can also add a ‘Display’ attribute that allows me to change what the user sees.

This solves my problem fairly well. I can keep it generic enough to reuse the properties list for many, many things. I haven’t implemented it yet, but I think it’ll work. Plus, I’m sure I’m only scratching the surface of what attributes can do for me since not only are they valid for properties, but they’re good for nearly any object in REALbasic itself including classes, methods and more!

Like introspection, I think most RB developers won’t use attributes. But if you have a need for it, it is indeed very powerful.

To add attributes to your object (this includes properties) you can right click and select attributes from the contectual menu. This brings up a generic attributes dialog. Unfortunately, in Mac OS X this brings up a sheet dialog with aboslutely no reference to what object you’re adding attributes to.

Pasted Graphic Well, I guess technically the parent window title tells me the object I’m in, but it’s not resolved beyond that. It needs to give a bit more feedback to the developer. FogBugz ID 3347

The other issue I have is that the only way to find attributes is to right click on every object or search for the word ‘attributes’ which then shows you the object in the search results.

Pasted Graphic 1

The search results aren’t very helpful though they are better than nothing. I plan on having many classes that have a ‘name’ property. The screenshot of my search just shows one class with one attributes set. I can’t imagine what it will be like when I have dozens of classes that have two or three attributes for a dozen or so properties in each one.

Why isn’t there some sort of visual feedback in the IDE? FogBugs ID 3348 I suppose it’s because it’ll confuse people that don’t ever use attributes but I maintain that if they don’t use them they won’t be shown. Would something like the way Apple’s Mail application showing the number of unread emails (badges I believe they’re called) work with Attributes? In the extreme case I’d be happy with a secret key combination (documented of course) so I can quickly and easily see where I have attributes in the lists.

Anyway, I’m ranting a little when I don’t mean to. It’s a very cool feature that I think I’ll get some good use out of. I think with a little work the IDE can work with us developers a bit better without “becoming like xCode” as another developer remarked to me today. Thoughts?