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

refactor connection usage #7

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

makasim
Copy link

@makasim makasim commented Mar 24, 2011

I've made some changes in ChargifyConnector useage.

Now all object should receive connector as a fitst constructor parameter.

This change makes the library more flexibal.

You can have as many connectors as you want (two connectors: test and prod for example).
Also it makes the library easy to test.

I would very happy ifyou add this changes to your branch.

makasim added 2 commits March 24, 2011 16:27
make it posible to change connection for the model.
@jforrest
Copy link
Owner

Thank you!

I will have some time this weekend to integrate your changes. I will shoot
you an email once I finish.

On Thu, Mar 24, 2011 at 10:22 AM, makasim <
[email protected]>wrote:

I've made some changes in ChargifyConnector useage.

Now all object should receive connector as a fitst constructor parameter.

This change makes the library more flexibal.

You can have as many connectors as you want (two connectors: test and prod
for example).
Also it makes the library easy to test.

I would very happy ifyou add this changes to your branch.

Reply to this email directly or view it on GitHub:
#7

@makasim
Copy link
Author

makasim commented Apr 1, 2011

Sometime past and there is not any news from you.
I would like to hear your feedback to my changes.
Are you going to merge?

Thanks!

@makasim makasim closed this Apr 1, 2011
@makasim makasim reopened this Apr 1, 2011
@ziemkowski
Copy link

I was just going to create an issue saying there was no way to set connection information without editing the source files, which makes updating more prone to issues. Your changes fix that issue since I can just have a custom class that returns a connector that any other file can then use without knowing the connection information and without editing any of the source files.

Read the diffs and they look good. +1 for pulling in these changes.

One question though, since this change isn't backwards compatible, why not take the opportunity to make the factory methods actually static? For example, you still have to create a subscription with a connection, and then replace the instance with one returned by getByID(), getByCustomerID(), or getAll(). Would definitely be cleaner to have ChargifySubscription::getByID($connector, $id); for instance.

Going even further, I could see swapping the parameter order so $connector is last and optional with a static ChargifyConnector::$default_connector used if null (which could be populated by say the last created connector or via a method that makes the connector default).

@makasim
Copy link
Author

makasim commented Apr 1, 2011

I don't like the idea of factory method. Because:

  1. It makes dependency between connector and api classes less clear.
  2. It is library and if it so it should be as much flexible as it possible,
  3. The default connector can be handled by an application api layer which stands above the lib.

But I see the way to archive what you want. I think it can be a ChargifyConnectorManger (like it in Doctrine) which can be used by api classes.

Thanks for support.

@makasim makasim closed this Apr 1, 2011
@makasim makasim reopened this Apr 1, 2011
@ziemkowski
Copy link

I shouldn't have used the term factory, I was using it loosely to mean they're creation methods. It just seems odd that they're instance methods creating new instances, instead of say a static method.

So I have to create an instance, then replace it with the method's new instance, and then when I call some other method, the connector creates yet another instance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants