tag:blogger.com,1999:blog-7515306875906042828.post4543042752583936259..comments2024-02-05T11:56:11.174-08:00Comments on Objology: Burned By Bein' Lazy AgainTravis Griggshttp://www.blogger.com/profile/01599271142862167244noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-7515306875906042828.post-60778001108279941512011-05-12T10:42:37.529-07:002011-05-12T10:42:37.529-07:00I like Bobby Woolf's old classification of ins...I like Bobby Woolf's old classification of instvars into key, state and cache. I use lazy initialisation for cache variables. I use explicit initialisation for state instvars. I use creation methods to initialise key instvars.<br /><br />- When time permits, I get rid of lazy initialisation in areas I rewrite whenever I judge the instvars to be key or state, since that is when I expect the pattern to hide or cause bugs.<br /><br />- When using the pattern with cache instVars, I like to pair with flush methods that indicate any interdependencies.<br /><br />I find shoving all the instVars I can into this categorisation helps. It makes my initialisation decisions for me in most cases, and a debatable case at least reveals itself as a debatable case.Niall Rosshttp://customrefactor.sourceforge.netnoreply@blogger.comtag:blogger.com,1999:blog-7515306875906042828.post-61088542695058183602011-05-01T06:27:53.630-07:002011-05-01T06:27:53.630-07:00Dont get carried away... :-)
This has nothing to ...Dont get carried away... :-)<br /><br />This has nothing to do with lazy initialization; this is just a plain programming error.<br />Consider the would-be initialization expressions (cruft removed) in the alternative #initialize method:<br /><br />foo := bar * 10.<br />bar := foo / 10.<br /><br />this is a simple bug calling for a reassessment of the algorithm.<br /><br />This kind of bug is even benign since it gets triggered very deterministacally (on access) and it hits you the very first time when you try what you have worked on.<br /><br />To tonyg: since this is a bug, I want the exception. Having a system detecting this situation during definition would be interesting in an academic sense, but not really necessary.Christian Haiderhttps://www.blogger.com/profile/02317472949691360308noreply@blogger.comtag:blogger.com,1999:blog-7515306875906042828.post-27004611237210425642011-04-28T06:51:46.925-07:002011-04-28T06:51:46.925-07:00It's an interesting problem, Travis. I've ...It's an interesting problem, Travis. I've suffered similarly on occasion over the years :-) I've just written up a few thoughts on the topic here: <a href="http://www.eighty-twenty.org/index.cgi/tech/smalltalk/declarative-laziness-20110428.html" rel="nofollow">http://www.eighty-twenty.org/index.cgi/tech/smalltalk/declarative-laziness-20110428.html</a>tonyghttps://www.blogger.com/profile/00433430495816900315noreply@blogger.com