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

70%: Introduce namespaces #56

Merged
merged 19 commits into from
May 29, 2015

Conversation

rsinger
Copy link
Member

@rsinger rsinger commented May 19, 2015

This branch introduces namespaces to Tripod.

Feel free to argue about which classes should go in which namespaces and how they should be named.

The way I've divided them up currently (although this is totally open for discussion) is:

Tripod

  • ITripod IDriver
  • ITripodStat
  • ChangeSet
  • ExtendedGraph
  • Labeller
  • Timer
  • ITripodSearchProvider (perhaps could just be iSearchProvider, thoughts?) ISearchProvider (formerly iTripodSearchProvider)

Tripod\Mongo (btw, it will take forever to get used to this inversion)

  • Tripod Driver (formerly MongoTripod)
  • TripodBase DriverBase (formerly MongoTripodBase)
  • MongoGraph
  • Labeller (formerly MongoTripodLabeller)
  • ImpactedSubject (in current master, this is ModifiedSubject, but that concept has been changed in this feature)
  • Config (formerly MongoTripodConfig)
  • TriplesUtil
  • IndexUtils
  • NQuadSerializer (formerly MongoTripodNQuadSerializer)
  • MongoSearchProvider (this wasn't renamed because this is defining a Mongo-based search provider)
  • Updates (formerly MongoTripodUpdates)
  • TransactionLog (formerly MongoTransactionLog - this might have been a mistake, as it's probably more like MongoSearchProvider)
  • SearchDocuments (formerly MongoTripodSearchDocuments)

Tripod\Mongo\Composites

  • IComposite (views, tables, and search are now defined as composites, this is an interface common among all)
  • CompositeBase
  • Views (formerly MongoTripodViews. Do the composites need their own part of the namespace? I feel that might be overkill)
  • Tables (formerly MongoTripodTables)
  • SearchIndexer (formerly MongoTripodSearchIndexer)

Tripod\Mongo\Jobs

  • ApplyOperation (this is the background job to generate the composites - the jobs could arguably have their own Tripod\Mongo\Jobs namespace. Discuss moved into their own package)
  • DiscoverImpactedSubjects (same as above)
  • JobBase (same)

Tripod\Exceptions

  • Exception (formerly TripodException)
  • CardinalityException (formerly TripodCardinalityException)
  • ConfigException (now it's own file, previously was bundled with MongoTripodConfig as MongoTripodConfigException)
  • LabellerException (formerly TripodLabellerException)
  • SearchException (formerly TripodSearchException)
  • ViewException (formerly TripodViewException - is this MongoTripod-specific?)
  • TimerException

Where class names changed, if they had any associated getter methods, these would have changed, as well. This was kind of a big undertaking, so there may be some that were missed, so feel free to point any out that you might run across.

Also, as I was going through the classes that were imported from legacy libraries (e.g. ExtendedGraph), I cleaned things up a bit, adding docblocks, removing unused (or broken) methods, etc.

@scaleupcto
Copy link
Contributor

Should MongoGraph and Extended graph simply be Tripod\Graph and Tripod\Mongo\Graph respectively?

@scaleupcto
Copy link
Contributor

It bugs be that ITripod and Tripod\Mongo\Tripod are not nouns. Everything else is (apart from Jobs which are verbs but I think we can let that slide as classname = jobname in resque).

Apart from the obvious Manager I can't think of a better name right now but I do think we need to and now is the time ;-)

@rsinger
Copy link
Member Author

rsinger commented May 22, 2015

I do like that. Part of me kind of thinks that ExtendedGraph could useful as its own library, but lets not go insane.

@scaleupcto
Copy link
Contributor

ITripodSearchProvider -> ISearchProvider +1. We are using capital I right?

@scaleupcto
Copy link
Contributor

jobs should have their own package.

@rsinger
Copy link
Member Author

rsinger commented May 22, 2015

Yes, i was a typo.

@scaleupcto
Copy link
Contributor

Composites should have their own package, i.e. Tripod\Mongo\Composites\Views

@rsinger
Copy link
Member Author

rsinger commented May 22, 2015

@RobotRobot I can easily buy Tripod\Mongo\Jobs, but I think I'm on the fence on Composites - what's your conviction to it?

@rsinger
Copy link
Member Author

rsinger commented May 22, 2015

Tripod -> Client ?

@rsinger
Copy link
Member Author

rsinger commented May 22, 2015

i.e. new \Tripod\Mongo\Client()

@rsinger
Copy link
Member Author

rsinger commented May 22, 2015

(also, in what dialect is 'Tripod' a verb? Is this a Staffordshire thing?)

@scaleupcto
Copy link
Contributor

It's not a verb. But it's not a common noun in the sense that it describes the purpose of the class, if you see what I mean.

I like Client.

@rsinger
Copy link
Member Author

rsinger commented May 22, 2015

Oh, I see, right. I agree that the 'library' is Tripod, not the class.

@scaleupcto
Copy link
Contributor

Another idea (not necessarily better than client, and keep them coming) we could keep ITripod, but Tripod itself could become Driver. That way you have a mongo Driver for ITripod. Let's keep going on this...

@rsinger
Copy link
Member Author

rsinger commented May 22, 2015

I'm not sure I like IClient very much, though. Could the interface name be ITripodClient (or Driver, I like that, too -- can't say I prefer one over the other)

@scaleupcto
Copy link
Contributor

re. Composites, just general tidyness. That package looks crowded. I would drop the Base from the base classnames and move them to a sub package too.

@rsinger
Copy link
Member Author

rsinger commented May 22, 2015

Actually, the more I think of it, the more I like the argument behind 'mongo Driver for iTripod.

@scaleupcto
Copy link
Contributor

Right that's it in terms of feedback from me today, will be offline rest of day so if you need to get this merged you have my opinions... ;-)

@rsinger
Copy link
Member Author

rsinger commented May 22, 2015

Ok, that's reasonable. When spiking this out, I was concerned that it was just pushing the clutter to the namespaces (and that that might be harder for the uninitiated to navigate), but I don't have a strong opinion on that (especially now that I'm on the other end of the process)

@@ -82,10 +82,10 @@ function showUsage()
*/
function generateTables($id, $tableId, $storeName, $stat = null)
{
$tableSpec = MongoTripodConfig::getInstance()->getTableSpecification($storeName, $tableId);
$tableSpec = TripodConfig::getInstance()->getTableSpecification($storeName, $tableId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We seem to have \Tripod\Mongo\Config in other places, but TripodConfig here. Is this correctly named?

@@ -1,4 +1,11 @@
<?php

namespace Tripod;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've prefixed the namespace in another lib with Talis - do we want to do something similar here?
https://github.com/talis/persona-php-client/blob/master/src/Talis/Persona/Client/Login.php#L2

If we do it'll need an update to the composer.json file in order to work

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not terribly keen on this, but I'll defer to @RobotRobot

@@ -251,7 +253,7 @@ public function testGenerateViewWithCountAggregate()
)
);

$actualView = MongoTripodConfig::getInstance()->getCollectionForView('tripod_php_testing', 'v_counts')->findOne(array('_id'=>array("r"=>'http://talisaspire.com/works/4d101f63c10a6',"c"=>"http://talisaspire.com/","type"=>'v_counts')));
$actualView = \Tripod\Mongo\Config::getInstance()->getCollectionForView('tripod_php_testing', 'v_counts')->findOne(array('_id'=>array("r"=>'http://talisaspire.com/works/4d101f63c10a6',"c"=>"http://talisaspire.com/","type"=>'v_counts')));
// var_dump($actualView); die;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the var_dumps

Conflicts:
	scripts/mongo/createTables.php
	src/mongo/Config.class.php
	src/mongo/delegates/TransactionLog.class.php
	src/mongo/delegates/Views.class.php
	test/unit/mongo/MongoTripodTablesTest.php
@rsinger rsinger changed the title 10%: Introduce namespaces 70%: Introduce namespaces May 29, 2015
@rsinger
Copy link
Member Author

rsinger commented May 29, 2015

From the feedback, I have:

  • Renamed Tripod to Driver, TripodBase to DriverBase, and ITripod to IDriver
  • Added \Tripod\Mongo\Jobs and \Tripod\Mongo\Composites and moved the related classes into them
  • Added TimerException to \Tripod\Exceptions

Any other comments before I merge into the feature branch?

@scaleupcto
Copy link
Contributor

We're renaming the interface to IDriver too?

@rsinger
Copy link
Member Author

rsinger commented May 29, 2015

Should we not? It's the interface for a Tripod Driver, right?

@scaleupcto
Copy link
Contributor

I guess. I'm not going to argue about this too much given the chainable API #23 should be the right way to use tripod in the future.

@rsinger
Copy link
Member Author

rsinger commented May 29, 2015

Agreed. I am certainly not married to the change: I just thought it seemed more consistent. I could be just as happy (well, ambivalent, really) with either name.

rsinger added a commit that referenced this pull request May 29, 2015
@rsinger rsinger merged commit 856286f into decouple-invalidation-from-save May 29, 2015
@rsinger rsinger deleted the introduce-namespaces branch May 29, 2015 12:45
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.

4 participants