The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Module no-no's

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
Daniel Berger

Posts: 1383
Nickname: djberg96
Registered: Sep, 2004

Daniel Berger is a Ruby Programmer who also dabbles in C and Perl
Module no-no's Posted: Jun 30, 2005 1:58 PM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Daniel Berger.
Original Post: Module no-no's
Feed Title: Testing 1,2,3...
Feed URL: http://djberg96.livejournal.com/data/rss
Feed Description: A blog on Ruby and other stuff.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Daniel Berger
Latest Posts From Testing 1,2,3...

Advertisement
Never do this:
module Foo
   VERSION = "1.0.0"
end

Why? Because if someone mixes your module into their class, and they don't have a VERSION defined for that class, they're going to end up with your version number for the class. This is probably not what anyone wants.

If you want to assign a version to your module, but don't want to step on anyone's toes, use the module name as part of the version so that folks can distinguish between a class VERSION and a module VERSION if they want to, e.g.
module Foo
   FOO_VERSION = "1.0.0"
end

class Bar
   include Foo
   VERSION = "1.3.2"
end

p Bar::VERSION # "1.3.2"
p Bar::FOO_VERSION # "1.0.0"

Read: Module no-no's

Topic: The Fully Upturned Bin Previous Topic   Next Topic Topic: Aimido rips off 43things with a smile

Sponsored Links



Google
  Web Artima.com   

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