Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Re^4: Moose role with requirement consuming another role

by Boldra (Deacon)
on Jul 21, 2011 at 08:38 UTC ( #915813=note: print w/replies, xml ) Need Help??

in reply to Re^3: Moose role with requirement consuming another role
in thread Moose role with requirement consuming another role

No, none of my roles are abstract base classes, they all provide additional functionality. Role::App reads the config file, creates objects based on its contents, and provides methods for fetching these objects.

Anyway, I can't see how a class which inherits from another class (or a role) could be called an abstract base class - it's not at the base. But perhaps you are using a different definition.

- Boldra
  • Comment on Re^4: Moose role with requirement consuming another role

Replies are listed 'Best First'.
Re^5: Moose role with requirement consuming another role
by Arunbear (Parson) on Jul 21, 2011 at 10:53 UTC
    In a Java-like language, an abstract base class is often used to provide functionality (often mandated by some interface) to classes that inherit from it, but it cannot be used/instantiated on its own. "abstract" means that it can't be instantiated, it doesn't mean that it provides no functionality.

    This is how you are using Role::App. It is like an an abstract base class in the sense that it can't be instantiated and it provides functionality to App::FixIt. Some of that functionality is mandated by Role::Logger. What the docs are saying is that mandated methods have to be supplied in classes not in roles.

      Ok, then it's clear we are using a different definitions of "abstract base class". You include classes which provide functionality in your definition, I do not. I don't think the Moose documentation you referenced supports your usage.

      - Boldra
        The documentation I referenced does not define an abstract base class, it only says
        "If you are familiar with the concept of abstract base classes in other languages, you may be tempted to use roles in the same way."
        Since Java is one of those languages that has an abstract base class concept (as well as a mechanism for mandating that certain methods are implemented), I have been referring to the Java style of abstract base classes.

        If the documentation doesn't support this usage, then which usage do you think it supports?

Re^5: Moose role with requirement consuming another role
by Anonymous Monk on Jul 21, 2011 at 11:08 UTC
      Thanks for those definitions.

      This statement:

      In CeePlusPlus, a class that has any PureVirtual member functions is an abstract base class.
      seems to suggest that, at least for C++, an abstract base class is the same as an abstract class.

      However, I still think it's clear that while all Moose roles are abstract classes (they cannot be instantiated), only those Moose roles which do nothing more than list 'requires' are abstract base classes. None of the Moose roles I am using are abstract base classes.

      Update: Having read more about the "interface role", I've changed my mind. What I called an abstract base class above is really an interface-only role. Arunbear recognized this in the beginning. I don't have any of these in my real code.

      - Boldra

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://915813]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2017-02-23 01:02 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (338 votes). Check out past polls.