The Artima Developer Community
Sponsored Link

Agile Buzz Forum
Why Lazy Accessors?

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
Why Lazy Accessors? Posted: Jan 23, 2007 4:22 PM
Reply to this message Reply

This post originated from an RSS feed registered with Agile Buzz by James Robertson.
Original Post: Why Lazy Accessors?
Feed Title: Cincom Smalltalk Blog - Smalltalk with Rants
Feed URL: http://www.cincomsmalltalk.com/rssBlog/rssBlogView.xml
Feed Description: James Robertson comments on Cincom Smalltalk, the Smalltalk development community, and IT trends and issues in general.
Latest Agile Buzz Posts
Latest Agile Buzz Posts by James Robertson
Latest Posts From Cincom Smalltalk Blog - Smalltalk with Rants

Advertisement

Ramon Leon explains succinctly why I like lazy initialization for variables instead of direct variable access:

On thing to always remember when using lazy accessors, is that one can’t ever access the instance variable directly from inside the class. You need to always use the accessor method. I’ve waffled back and forth between direct variable access and lazy initialization several times, but I’ve finally chosen lazy initialization as my preferred method because it allows one to grow a program better by allowing existing objects to be upgraded on the fly without worrying about uninitialized instance variables. I also enjoy being lazy.

In the two main apps I support - this server and BottomFeeder, I use on the fly updating. On the fly updating is way, way simpler when you use lazy initialization. Over time, I've come to the conclusion that on the fly updating is a highly desirable trait in an application, so I like lazy initialization. I suppose it depends on what kind of code you write, and for for what purpose - but for what I do, I agree with Ramon.

Technorati Tags:

Read: Why Lazy Accessors?

Topic: What to link to? Previous Topic   Next Topic Topic: Turtles all the way Down

Sponsored Links



Google
  Web Artima.com   

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