The Artima Developer Community
Sponsored Link

Agile Buzz Forum
From near to far, from here to there, lots of vars are everywhere

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
From near to far, from here to there, lots of vars are everywhere Posted: Feb 2, 2006 11:20 AM
Reply to this message Reply

This post originated from an RSS feed registered with Agile Buzz by James Robertson.
Original Post: From near to far, from here to there, lots of vars are everywhere
Feed Title: Travis Griggs - Blog
Feed URL: http://www.cincomsmalltalk.com/rssBlog/travis-rss.xml
Feed Description: This TAG Line is Extra
Latest Agile Buzz Posts
Latest Agile Buzz Posts by James Robertson
Latest Posts From Travis Griggs - Blog

Advertisement

My colleagues probably think of me as the "ivar nazi." If I can find a way to reduce instance variable count, I won't hesitate. I chuckled when I saw a class in a 3rd party package with a lot of instance variables yesterday. I was curious. How many did it really have? And what other treasures lay hidden in the image?

So I threw together this workspace snippent:

((Class rootsOfTheWorld collect: #withAllSubclasses) fold: [:a :b | a, b]) groupedBy: [:each | each instVarNames size]

Just one line. Pretty cool I think. This snippet groups classes by their own inst var account. It does not take inheritance into account. To get that, you just replace instVarNames with allInstVarNames. In truth, it didn't make much difference for what I was looking for. Here's the top 10 I found:

instVarNames size Class(es)
21 Glorp.StoreReplicator, DataSetColumnSpec
22 RasterOp, GraphicsContext, PostScriptFile
23 MemoryPolicy, Store.PublishPundleDialog
25 DataSetView
26 ScarcityTrackingModel
29 JPEGImageWriter
38 CodeWriter
58 Code Reader
62 ObjectMemory
72 InverseColorMapInitializer

Some I expected. For example, I knew ObjectMemory was big, but not THAT big. InverseColorMapInitializer blew me away. 72 instance variables. Whoah. We even managed to get one of our own classes (ScarcityTrackingModel is not something you'll find in your image) in there.

So... how's your code do? Can anyone else get anything in this range (21 ivars+)? Were you surprised?

Read: From near to far, from here to there, lots of vars are everywhere

Topic: Smalltalk Solutions: My Presentation Previous Topic   Next Topic Topic: Writing Good User Stories

Sponsored Links



Google
  Web Artima.com   

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