Lowercase or CamelCase namespaces?

(Viktor) #34

I see the main argument is unreadability of lowercase namespaces.

(Alexander Makarov) #35

There’s no such issue. We prefer single word namespaces but current rule is to write them suchAs\this\.

There is only a single argument for using uppercase first letter SuchAs\This\ — adoption by majority of nowdays packages.

(Knight Yoshi) #36

PascalCase looks nice and all, but I’m not a fan of it for namespaces. Using camelCase for the namespace seems more fitting.

If major packages died, should Yii die? LOL!
Ultimately it’s whatever. As long as we can import and clearly read what’s being imported then I don’t care as much.

(Alexander Makarov) #37

Likely. That would mean PHP funeral :slight_smile:

(Knight Yoshi) #38

Well, yes, but my point is that if your friends jump off a bridge you don’t have to jump too. LOL

(Schanz15) #39

I also prefer lowercase namespaces. I remember when I used Guzzle for the first time. They provide a number of helper functions in the ǹamespace GuzzleHttp\Promise. A typical usage in PHP looks like this:


use GuzzleHttp\Promise;

// [...] Some code


// [...] more code

When I first worked with Guzzle, I remember having a hard time to understand how the above code works since I always assumed that Promise is a class as opposed to a namespace. In Yii we wrap helper functions as static methods of a class — so that problem wont arise. But I think thats definitely a reason against PascalCase for namespaces (like @schmunk already wrote)

(Lubosdz) #40

This is probably best approach - camelCase not CamelCase.

(Serban Cristian) #41

this looks weird.

Again, just do what most big package providers do, use CamelCase
You don’t have to love it, you just have to accept it, most people are used to it, so you’ll make life easier for lots of people and an even easier transition between frameworks at work, where people might work with 2 or 3 frameworks.

Pick your battles, this isn’t really one of them.

(Lubosdz) #42

Be nice, constructive & not offensive.
The way you express yourself contributes also to framework’s culture.
There are enough arguments for all 3 variants.
I provided mine. So did you.

(Serban Cristian) #43

ah, sorry if that came as offensive, that wasn’t my intention, i’ll edit my comment to sound better.

(muitosefala) #44

If there is an adoption by majority of nowadays packages, why not go to the majority to simplify?
What is better for anyone who read and write code: to have a ‘standard’ expectation or have to adapt to many styles? I personally prefer PascalCase not because it is beautiful or what, but because it is more understandable when you have to use similar names in code for classes, methods or any other things that have to be distinguished.
‘Such As’ may be named SuchAS, if not may be confused to ‘Su Chas’ or ‘Suc Has’ or even ‘Suchas’.
naming can be anything but must be clarified, and PascalCase does it very well. I think camelCase does it also but not so well as PascalCase.

(AndreasP) #45

Personally I prefer “camelCase” or “lowercase” for namespaces, but almost all packages use PascalCase for namespaces now. Having parts lowercase and PascalCase together in a project leads to confusion because people need to remember the case additionally to the name.

So, despite I like camelCase more I would vote - with a for PascalCase as it’s much more widespread and it may feel more familar for people coming from other frameworks. And integrated 3rd party components also do not that alian.

But there is also a good reason to stick with camelCase: Changing everything would make migration difficult.

(Andrzej Bernat) #46

@twisted1919 is right. We should follow trends. Otherwise we will get out of the main stream. I vote for CamelCase.

(Jacob Moen) #47

PascalCase it is, then :wink:

(AndreasP) #48

That’s a bit confusing. Camel Case usually means “starting with lower character and use upper in the middle”: “camelCase”.
Starting with upper is usually called PascalCase as this has been the standard in Pascal language for quite a long time. An alternative name is “Upper Camel Case”.
But when just Camel Case is used as term, most people think about starting with lower.

Anyway: Despite I personally like camelCase more and changing everything to PascalCase might cause quite some migration trouble I vote for PascalCase for namespaces as it’s wide spread and most people are used to it.

(Andrzej Bernat) #49

Yeah, thanks :slight_smile:

(Jacob Moen) #50

I remember it by thinking that the camel really is a dromedary in disguise, and that the real camel goes by the name ‘Pascal’ :slight_smile:

(Dromedary = one hump, camel = two humps)

(Stefano Mtangoo) #51

I would vote for Pascal case if this problem received a reasonable solution

Yii\Db\QueryBuilder as class vs Yii\Db\QueryBuilder as namespace as in Yii\Db\QueryBuilder\SimpleBuilder

(Razon Yang) #52

I vote for PascalCase or camelCase, just because it makes namespace more readable.

And in my personal view, I prefer to PascalCase instead of camelCase since most of packages use PascalCase, makes code more pretty.

(Jacob Moen) #53

I am probably the odd one out, because I actually prefer to use snake_case in my own coding :stuck_out_tongue:
I guess too much C programming. But also because it’s just too convenient to type.
Mostly for local and member variables, though. :wink:
I am totally fine with PascalCase, however.