Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Namespace specification #31

Open
dionys opened this Issue Feb 4, 2015 · 6 comments

Comments

Projects
None yet
3 participants
@dionys
Copy link

dionys commented Feb 4, 2015

The drivers and their parts (like buyer, card, etc) uses different methods to create the namespaces. For example, if we have the driver MyDriver, then its module will be named Business::CPI::Gateway::MyDriver (like Business::CPI::Gateway::PayPal). But the buyer module for this driver will be named Business::CPI::MyDriver::Buyer, because Business::CPI::Util::load_class() function uses template Business::CPI::${driver_name}::${class_name}. So we have two different ways to create the namespaces ${class_name}::${driver_name} and ${driver_name}::${class_name}.

I think that need to use only one of these ways:

Business::CPI::Gateway::MyDriver
Business::CPI::Buyer::MyDriver

or

Business::CPI::MyDriver::Gateway
Business::CPI::MyDriver::Buyer

or may be third

Business::CPI::Gateway::MyDriver
Business::CPI::Gateway::MyDriver::Buyer

And I propose the first (${class_name}::${driver_name}) way.

@andrewalker

This comment has been minimized.

Copy link
Owner

andrewalker commented Feb 4, 2015

Thank you for your input, @dionys.

This issue annoys me too, and maybe I didn't think it through when I was first creating the classes :) But still, I'm not quite sure of what would be the best way to go.

The third way seemed too long for me. The second way would seem messy with internal namespaces, so that Business::CPI::PayPal::* is in the same namespace as Business::CPI::Role::*, etc. Seems weird to me, but maybe I should just get over it. Another issue would be that it wouldn't be clear that Business::CPI::MyDriver::Gateway is the main class of MyDriver. Maybe it should be called just Business::CPI::MyDriver? But then again, there are things like Business::CPI::Util. Seems incoherent to me.

Finally, the first case.. my issue with it is that a typical, complex, driver would have a directory more or less like this:

- lib/
     - Business/
         - CPI/
             - Gateway/
                - MyDriver.pm
             - Buyer/
                - MyDriver.pm
             - Cart/
                - MyDriver.pm
             - Item/
                - MyDriver.pm
             - Receiver/
                - MyDriver.pm
             - Account/
                - MyDriver.pm

That is also weird for me. When it gets installed, the driver won't have a directory of it's own, it will be scattered around the same folders as the other drivers.

Well, anyway, these are my thoughts on the issue. Do you still think ${class_name}::${driver_name} is the way to go? Why do you prefer that way?

@dionys

This comment has been minimized.

Copy link
Author

dionys commented Feb 4, 2015

Hmm. You’re right.

Taking in response to your comments I see 2 ways:

  1. Too long namespace:
    • Business::CPI::Gateway::MyDriver
    • Business::CPI::Gateway::MyDriver::*
  2. Another namespace (like DBI & DBD)
    • Business::CPG::MyDriver (or CPIG, or CPD, etc)
    • Business::CPG::MyDriver::*
@andrewalker

This comment has been minimized.

Copy link
Owner

andrewalker commented Feb 4, 2015

I hadn't thought of the other namespace! Sounds very reasonable!

@renatocron

This comment has been minimized.

Copy link
Collaborator

renatocron commented Feb 4, 2015

I think another name-space looks more intelligent decision!

Renato,

Eokoe.com

On Wed, Feb 4, 2015 at 6:58 PM, André Walker notifications@github.com
wrote:

I hadn't thought of the other namespace! Sounds very reasonable!


Reply to this email directly or view it on GitHub
#31 (comment)
.

@dionys

This comment has been minimized.

Copy link
Author

dionys commented Feb 4, 2015

So. If you will use another namespace, then no more needed Business::CPI::Base namespace: Business::CPI::Base::Buyer will be Business::CPI::Buyer, etc.

@andrewalker

This comment has been minimized.

Copy link
Owner

andrewalker commented Feb 5, 2015

Sure. Much better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.