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

fluent interface for DocumentManager #234

Closed
wants to merge 2 commits into from
Closed

fluent interface for DocumentManager #234

wants to merge 2 commits into from

Conversation

henrikbjorn
Copy link
Contributor

No description provided.

$this->assertInstanceOf('Doctrine\ODM\MongoDB\DocumentManager', $this->dm->detach($document));

$this->assertInstanceOf('Doctrine\ODM\MongoDB\DocumentManager', $this->dm->remove($document));
$this->assertInstanceOf('Doctrine\ODM\MongoDB\DocumentManager', $this->dm->clear());
Copy link
Member

Choose a reason for hiding this comment

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

I think you should even use assertSame here to check that the value returned is the same DocumentManager instance, not another one

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed :)

@jwage
Copy link
Member

jwage commented Jan 20, 2012

👎 I don't think a fluent interface makes sense on the DocumentManager.

@henrikbjorn
Copy link
Contributor Author

<?php
$dm
    ->persist($document)
    ->flush()
;

feels more natural than $dm->persist($document);$dm->flush();

@jwage
Copy link
Member

jwage commented Jan 20, 2012

The DocumentManager methods are not the type of class you apply a fluent interface to. It violates the principle that methods should just do one thing when using a fluent interface. The methods you are chaining are not setters, they are operations so they should return null.

@jwage jwage closed this Jan 20, 2012
@jwage
Copy link
Member

jwage commented Jan 20, 2012

another note from @beberlei:

"fowler states it this way: the essence of Fluent Interfaces is that they approach thinking about using components differently … we think linguistically of composing sentences using clauses that weave objects together. a fluent interface is about a DSL or a linguistic sentence, in case of the entity manager this does not make sense semantically"

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.

None yet

3 participants