module name == class name?

Discussion in 'Ruby' started by aidy.lewis@googlemail.com, Jul 10, 2007.

  1. Guest

    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
    , Jul 10, 2007
    #1
    1. Advertising

  2. Tim Pease Guest

    On 7/11/07, <> 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
    Tim Pease, Jul 11, 2007
    #2
    1. Advertising

  3. Guest

    On 11 Jul, 20:04, "Tim Pease" <> wrote:
    > On 7/11/07, <> 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
    , Jul 11, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. E11
    Replies:
    1
    Views:
    4,736
    Thomas Weidenfeller
    Oct 12, 2005
  2. Ilariu Raducan
    Replies:
    2
    Views:
    344
    Ilariu Raducan
    Jul 14, 2004
  3. Andreas Neudecker
    Replies:
    4
    Views:
    302
    Andreas Neudecker
    Aug 9, 2004
  4. Maric Michaud
    Replies:
    0
    Views:
    7,185
    Maric Michaud
    Jun 24, 2006
  5. gentlestone
    Replies:
    6
    Views:
    939
    Bruno Desthuilliers
    Oct 6, 2009
Loading...

Share This Page