Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > module name == class name?

Reply
Thread Tools

module name == class name?

 
 
aidy.lewis@googlemail.com
Guest
Posts: n/a
 
      07-10-2007
Hi,

I use the open-source automated functional test tool: Watir. In each
class I hold methods relating to a specific HTML page. To avoid any
name conflict, I think I should be wrapping each class within a
module. Is it good form to have a module name that equals the class
name.

e.g. module Login
class Login

end
end ?

Thanks

Aidy

 
Reply With Quote
 
 
 
 
Tim Pease
Guest
Posts: n/a
 
      07-11-2007
On 7/11/07, http://www.velocityreviews.com/forums/(E-Mail Removed) <(E-Mail Removed)> wrote:
> Hi,
>
> I use the open-source automated functional test tool: Watir. In each
> class I hold methods relating to a specific HTML page. To avoid any
> name conflict, I think I should be wrapping each class within a
> module. Is it good form to have a module name that equals the class
> name.
>
> e.g. module Login
> class Login
>
> end
> end ?
>


If your Login module only contains one class and nothing else, then
you should remove the module and use only the class. You will still
have the naming conflict if you should want another Login class.

A different approach would be to encapsulate all the classes related
to a particular website in a module.


module MyWebsite
class Login
end

class UserInfo
end

# etc.
end


Blessings,
TwP

 
Reply With Quote
 
 
 
 
aidy.lewis@googlemail.com
Guest
Posts: n/a
 
      07-11-2007
On 11 Jul, 20:04, "Tim Pease" <(E-Mail Removed)> wrote:
> On 7/11/07,(E-Mail Removed) <(E-Mail Removed)> wrote:
>
> If your Login module only contains one class and nothing else, then
> you should remove the module and use only the class. You will still
> have the naming conflict if you should want another Login class.
>
> A different approach would be to encapsulate all the classes related
> to a particular website in a module.
>
> module MyWebsite
> class Login
> end
>
> class UserInfo
> end
>
> # etc.
> end
>


Yes, I think this is a very good idea. As I would need only one
require and include.

The one thing I am concerned about is hierarchy. One HTML page does
not inherit another by nature. Should I inherit through a sequence of
actions (i.e. a use-case)? A use-case is not OO - Meyer tells us this.

Should I say:

class Main_Page < Login

Because in the test script the login is an antecedent to the main
page.

I don't like it. I am confused.

Aidy

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating class instance from module and class name gentlestone Python 6 10-06-2009 08:13 AM
Re: module docstring, documentation,anything? please note is the module type/object NOT some module Maric Michaud Python 0 06-24-2006 12:42 PM
Nested Class, Member Class, Inner Class, Local Class, Anonymous Class E11 Java 1 10-12-2005 03:34 PM
Find out the file name of a module from inside the module? Andreas Neudecker Python 4 08-09-2004 03:49 PM
Getting module object by name in C extension module Ilariu Raducan Python 2 07-14-2004 10:56 AM



Advertisments