# Module name == class name?

**URL:** <https://www.ruby-forum.com/t/module-name-class-name/109110>\
**Category:** Ruby\
**Created:** [July 11, 2007, 3:58pm UTC](https://www.ruby-forum.com/t/module-name-class-name/109110 "2007-07-11T15:58:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [July 11, 2007, 3:58pm UTC](https://www.ruby-forum.com/t/module-name-class-name/109110/1 "2007-07-11T15:58:55Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [July 11, 2007, 9:05pm UTC](https://www.ruby-forum.com/t/module-name-class-name/109110/2 "2007-07-11T21:05:19Z")

</div>

On 7/11/07, removed\_email\_address@domain.invalid [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ```
> 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

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [July 11, 2007, 11:56pm UTC](https://www.ruby-forum.com/t/module-name-class-name/109110/3 "2007-07-11T23:56:48Z")

</div>

On 11 Jul, 20:04, “Tim P.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> 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

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [July 12, 2007, 5:09am UTC](https://www.ruby-forum.com/t/module-name-class-name/109110/4 "2007-07-12T05:09:15Z")

</div>

On 7/11/07, removed\_email\_address@domain.invalid [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > module MyWebsite  
> > Yes, I think this is a very good idea. As I would need only one  
> > Because in the test script the login is an antecedent to the main  
> > page.
> 
> I don’t like it. I am confused.

Unfortunately, I am not a Watir user. Is there a mailing list for the  
ruby Watir project?

Have fun with the testing.

Blessings,  
TwP
