The Artima Developer Community
Sponsored Link

Agile Buzz Forum
How I Mean to Fix It

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
How I Mean to Fix It Posted: Apr 27, 2007 11:02 AM
Reply to this message Reply

This post originated from an RSS feed registered with Agile Buzz by James Robertson.
Original Post: How I Mean to Fix It
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

So, fixing the problem described in last nights post is not that hard. As pointed out in the comments, I did so and only found one screwy dependency on the behavior, something which had bitten me before and needed to be fixed anyway.

The simple/straightforward solution is to implement the center APIs along the pattern:

topCenter
	^origin x + corner x / 2 @ origin y

This will definitely need a comment to say what it does. It'll be something like "return a point along the segment between topCenter and topRight that is equidistant from both". There is a mathematical term for this kind of expression. What if we express that as a method?

ArithmeticValue>>mean: anArithmeticValue
	^self + anArithmeticValue / 2
Now we can rewrite our topCenter method as
topCenter
	^self topLeft mean: self topRight
We can still put the comment in there, but the code tells the story pretty well on it's own as well. More to follow...

Read: How I Mean to Fix It

Topic: The End of Exclsuive Access Previous Topic   Next Topic Topic: Phaux

Sponsored Links



Google
  Web Artima.com   

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