The Artima Developer Community
Sponsored Link

Agile Buzz Forum
Classes without Names

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
James Robertson

Posts: 29924
Nickname: jarober61
Registered: Jun, 2003

David Buck, Smalltalker at large
Classes without Names Posted: Sep 2, 2005 5:36 PM
Reply to this message Reply

This post originated from an RSS feed registered with Agile Buzz by James Robertson.
Original Post: Classes without Names
Feed Title: Michael Lucas-Smith
Feed URL: http://www.michaellucassmith.com/site.atom
Feed Description: Smalltalk and my misinterpretations of life
Latest Agile Buzz Posts
Latest Agile Buzz Posts by James Robertson
Latest Posts From Michael Lucas-Smith

Advertisement

Last time I talked about a new mythical language I dropped classes and replaced then with prototypes. Now it's time to take a new radical step. My colleague David Price and myself spent an entire day renaming classes and refactoring code yesterday and it gave us a moment to reflect on what it was we were actually doing.

Renaming classes is a nonsense exercise. How can you misname a class in the first place? Why is renaming it useful? One class that we renamed was called AcoRssSearchEventListPart. This is now called AcoSearchRssEventWF. But what we really wanted to do was allow developers to identify and find this behaviour by 'grouping' it with others via its prefix.

Now if any one wants to find anything to do with Searching in the ACO product, they can look for AcoSearch*. If they want to narrow that down to RSS results, then can look for AcoSearchRss*. Due to the way classes are presented in just about any OO system, they will be listed alphabetically, so this allows you to quickly scan the list of classes to find what you're looking for.

Aha!, we said, we're doing this to -find- things. So what if we took the radical step of removing class names altogether. Instead, we give classes metadata. In this case, our class would have had the following metadata:

  • It's in the application All Communities Online, or ACO for short
  • It's a search module
  • It produces RSS
  • It's focused on Event data
  • It contains some workflow

Now if we were coding from scratch, there is no way we could 'misname' a class like this. The metadata is much harder to get wrong than a class name. And here's the real benefit. When you compile against metadata, you end up with a real reference to the class in memory. That means you can change its metadata without rewriting a single line of code.

Huh? I hear you say. We have this wacky idea of dumping source code from our system. Instead, we'll keep parse trees around. So the parse node that points off to a class will actually hold on to a class. If we want to serialise our parse trees to disk, we'll probably have some sort of GUID system for identifying classes.

But what about the source code? Well, you can print out source code from the parse tree, then parse it again when a developer has changed things. The name of a class can now be generated from the metadata in any format the developer desires without affecting other developers or the semantic meaning of the code. In our case, we'd set it to print out as AcoSearchRssEventWF.

Now we get to some really cool stuff - the GUI environment. We've all heard of Intellisense. Well, let's take it a step further. Instead of sensing a prefixed search based on the type you're sending a message - we want to find said type, a class. So let's do it google style. We search the metadata for partial matches of the string you're typing and present an Intellisense popup list of results as you type. If I wanted to find something to do with event's that did RSS, I'd probably type 'rss event' and it'd likely give me back AcoSearchRssEventWF.

More interestingly, this allows you to discover code you didn't know you had. It also breaks down the semantic structure of your application in to metadata groups instead of a developer-guessed package/application/namespace structure.

Read: Classes without Names

Topic: The big uneasy Previous Topic   Next Topic Topic: Model Without a Cause

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use