Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Renamed Bundle classes to be named like the bundle itself for more cl…
…arity
- Loading branch information
Showing
12 changed files
with
27 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
c486e1b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont get this commit, the bundle is already in a namespaced path called SomethingBundle why would you want to make it even more verbose ?
c486e1b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Completely agree with henrikbjorn. Namespace should be enough.
c486e1b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with henrikbjorn. Whenever the namespace is not enough, one can always do the following:
c486e1b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was probably a bit too fast on this one. I have reverted the change for now to allow more discussion.
c486e1b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are the cases where one would actually need to use a Bundle class (per margijn's example)?
I imagine two cases where renaming the custom bundle classes could be beneficial:
Assuming
use as
should be avoided, I wonder if this would be better or worse:I can't forsee a reason why one would need to access anything withing the base Bundle class (which a
use
would have allowed for easily).c486e1b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jmikola
c486e1b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't arguing one way or the other, just postulating some reasons why it might have been done :)
c486e1b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did discuss this with Bernhard earlier and his commit is what I thought would be best.
The point is that when looking into code, or using an IDE, you use the Name of a class/object.
The name does normally not include the namespace. So you will have lots of duplicates.
Second, you need meaning!
Something called Bundle is meaningless. What bundle, what for? Only relying on the namespace to explain this doesn't help much.
Also consider putting two "whatever" inside the same namespace. Like two controller. You might come to a point where you want this.
So I am fully in favour of adding some meaning to the name of a class. Its easier to read, easier to understand and easier to look up.
However this does not mean to come back to the ugly namespace hacks done in the past.
c486e1b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with CodingFabian and Bernhard on this issue. Although we have namespaces now this doesnt mean we can go back and give our classes meaningless producing clashes in naming.
Concrete Implementations should have concrete names, try to understand "Bundle extends AbstractBundle".
"Its in the namespace" is not a valid argument in my opinion, a class has meaning in the namespace it is in. Using a meaning class-name inside a package makes it harder to understand the code that uses this class.
c486e1b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then i dont really see the meaning of namespaces... Why dont we just go back to I_Want_To_Name_Stuff_Like_This ?
c486e1b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Namespaces are a way to make internal code easy to understand. If a class is only used within a component, there's no problem in giving it a short name that has enough meaning in the scope of this component.
Not for public API. If a class is designed to be used by other developers, give it a name that has enough meaning, independent of the namespace.
A good comparison might be: If it makes sense to talk about classes with the same name in a conversation, they should probably have different names.
"Add that code to the Bundle class"
"Which one?"
c486e1b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another point is usability. Imagine having two different Bundle.php files open at the same time in your editor (don't forget that applications will potentially have dozens of custom Bundles!). It's very easy to edit the wrong Bundle.php if you are not extremely careful.
c486e1b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with beberlei and others for the above stated reasons.
Symfony\Components\Templating\Renderer\Renderer
Symfony\Components\Templating\Storage\Storage
Symfony\Components\Validator\Validator
Symfony\Components\Process\Process
Symfony\Components\HttpKernel\Profiler\Profiler
etc...
are perfectly valid class names and I don't have problem with duplication in their paths.
Bundle class is WebBundle, it therefore lives under WebBundle namespace along with a lot of other WebBundle related stuff
c486e1b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"The point is that when looking into code, or using an IDE, you use the Name of a class/object."
I've been using the following, which works perfectly:
The rules I generally use are,
A class name does have meaning, but once you're outside of the context of said namespace, it should be fully qualified.
Also, is there a reason why this is used:
Rather than:
c486e1b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I totally understand the
Symfony\Framework\SomeBundle\Bundle
naming which makes a lot of sense.naming it
Symfony\Framework\SomeBundle\SomeBundle
just looks ugly and does not bring any value but makes us need to type even more characters everytime we are referencing a bundle in Doctrine ORM or Doctrine ODM. And just the bundle namespaces alone makes a line that i a thousand characters wide.I say if your editors, ide or whatever you are using cant handle it well then maybe you should start looking after a new edtior, besides the top of every file will say what bundle you are editing becuse the namespace declaration will be there.
@bschussek if this
"Add that code to the Bundle class" "Which one?"
comes up i assume the question would have been to a specific bundle and so there wont be any confussion. :)c486e1b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean when referencing entity/document classes? The Bundle's initializing class,
Symfony\Framework\SomeBundle\SomeBundle
, should only need to show up if you're enabling the Bundle in your kernel. Other places, like routing.yml includes and class references, should be unaffected.c486e1b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i mean then WebExtension should be named FoundationBundleWebExtension because there can be more than one so its clear what bundles WebExtension someone is talking about.