| «« VS.NET Background Compilation Issues Explained | The Freedom to Blog »» |
|
About
I'm Ryan Lowe, a Software Engineering graduate living in Ottawa, Canada. I like agile software development and Ruby on Rails.
I write this blog in Canadian English and don't use a spell checker. Typos happen.
Projects
» Full-time Ruby on Rails freelancer
» Full-time with Rails since May 2005 » Former committer for RadRails (now Aptana) » I also have a few Rails side-projects in development: 1. wheretogoinTO.com Toronto nightlife 2. Hey Heads Up! TODO list and sharing 3. Layered Genealogy family history research 4. foos for foosball scoring 5. fanconcert for music fans (on hold) Hiring Rails developers? I can telecommute by the hour from Ottawa, Canada »» Email: rails AT ryanlowe DOT ca
BulletBlog
Now hosted on Hey! Heads Up -- check it out!
Syndication
Pings
Recent
Derek Lowe's (Ryan's older brother) words at Ryan's funeral
blog@ryanlowe.ca no more Forging Email Headers: Good, Bad or Ugly? Sarcastic Dictionary (Part 1 of Many) Tags Hierarchies Twisting Rails is Risky Business Risky Business? My Take on Early Alphas Whoa, it's August 2007 Closing Comments A Postscript to "Growth at the grassroots" »» All Blog Posts
Linkage
del.icio.us/ryanlowe
technorati/ryanlowe.ca/blog Aurora Roy Jim Andrew Trasker Travis Kibbee Karen Dr. Unk Ayana Van Bloggers Joel Spolsky Robert Scoble Tim Bray Dave Winer Raymond Chen James Robertson Ruby/Rails Bloggers rubyonrails.org weblog David Heinemeier Hansson Dave Thomas James Duncan Davidson Mike Clark Jamis Buck Signal vs. Noise Tobias Luetke Amy Hoy: (24)slash7 Jeremy Voorhis Eclipse Bloggers Planet Eclipse EclipseZone Luis de la Rosa Eclipse Foundation Kim Horne Billy Biggs Ian Skerrett Mike Milinkovich Bjorn Freeman-Benson Denis Roy
Archives
|
AudioMan's Models
I usually talk about AudioMan's models like they are all one component, but in this post I'll get into what they are all about. The models are one part of the model-view-controller triple that I talked about before and then updated more recently. They contain the data that is displayed in the view that the user can see. The controller takes direction from the GUI and manipulates the contents of the models, like when a user is browsing a collection. There are four models, one each for the playlists, artists, albums and tracks. The contents of each subsequent model in that order depends on what is selected in the previous model. In that way, they sort of cascade. The playlists model is just a Vector of name/value pairs. The name is the label you see in the view and the value is the playlist's ID number. The artist list contains a list of all of the artists in the selected playlist. The album list contains a list of all of the albums in the selected playlist and by the selected artist. Finally, the track list contains all of the tracks that fit the playlist, artist and album that are selected. Like the playlists, it is also just a Vector but of AudioData objects representing tracks. The artist and album models are the most interesting. They receive add/remove notifications from the tracks mutator just like the tracks model does, in order to add and remove artist and album names on the fly. To do this accurately, these models needed to keep a count of the number of tracks that apply to a specific artist or album name. So I made the artist and album models Hashtables. The key in the Hashtable is the artist or album name and the value is the number of tracks that use that name. When these models receive an add notification from the tracks mutator, if the name isn't in the list it's added to the Hashtable with a value of 1. It it is in the list, the value is incremented. When these models receive an remove notification from the tracks mutator, if the name is in the list but the value is only 1 then the name is removed. Otherwise if the entry exists the count is decremented. How does a model know if it should listen to a notification from a mutator? It can't listen to them all because some additions and removals don't apply to what it's showing. That's where the TrackFilter object comes in and I'll explain that one in another post. Posted at March 10, 2004 at 07:08 PM ESTLast updated March 10, 2004 at 07:08 PM EST Comments
For the first time ever, I actually understood one of your technical Audioman posts entirely on the first try! I just finished reading "The Pragmatic Programmer" word for word, page for page. (Thanks to Andrew for recommending it) Wow. What a good book. The MVC technique is excellent. How you're using it so far seems correct. And you're right, not all models need listen to the chatter of the objects. They only need listen to their required need and context. No more, no less. Off the top of my head, that's the Law of Demeter, correct? ;-) Damn, I can see!! I can see!!! » Posted by: roy at March 10, 2004 11:13 PMHaha, you goof. Go back and read the other ones and ask questions! ;) » Posted by: Ryan at March 10, 2004 11:32 PMDude, You in Ottawa next weekend? I'll be there and the Frew. Let me know, T. » Posted by: Travis at March 11, 2004 11:00 AMYeah, man. I already told you on your blog -- I'm in! :) » Posted by: Ryan at March 11, 2004 12:03 PMah, wasn't sure if you were talking about Ottawa or Easter... nevermind. T. » Posted by: Travis at March 11, 2004 08:56 PMOh, right. I'm in for both. See you there. R. » Posted by: Ryan at March 11, 2004 09:04 PM |