chore(Conventions): naming standards #196

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
2 participants
Contributor

NathanWalker commented Jan 4, 2016

closes AngularClass#185

I'm not saying merge this actually, however this is how the naming conventions would play out here.

I've had mixed feelings about them for awhile but in general, like them.
I've just never been a big fan of long filenames which is why I'm not in love with whatever.component.ts vs. whatever.ts, however it does make things clear.
This becomes more idiomatic when you consider most conventions suggest placing files inside a folder called components such as shown here in this PR.
So when opening files and you see:
app/components/home/home.component.ts
vs.
app/home/home.ts

First, for large projects with more than 2-3 nested hierarchies, you would need a screen or IDE at least wide enough to show the long path and filename when you have multiple tabs open to discern the difference between 2 of the same named files in different folders, ie.:
app/component/home/home.component.ts
vs.
app/component/users/profile/home.component.ts
^ just an example but it can definitely happen ;)

But in the end, I digress. Whatever the community believes is universally great.

If this is the way to go, then by all means, merge 👍

@NathanWalker NathanWalker commented on the diff Jan 4, 2016

src/app/components/home/home.component.ts
@@ -27,7 +27,7 @@ import {XLarge} from './directives/x-large';
// Every Angular template is first compiled by the browser before Angular runs it's compiler
template: require('./home.html')
})
-export class Home {
+export class HomeCmp implements OnInit {
@NathanWalker

NathanWalker Jan 4, 2016

Contributor

Even though using ngOnInit will work without implementing OnInit, it appears to be recommended to still implement for TypeScript sake:
angular/angular#5814

@gdi2290

gdi2290 Jan 4, 2016

Owner

I didn't include this on purpose

@gdi2290 gdi2290 commented on the diff Jan 4, 2016

src/app/components/app.component.ts
])
-export class App {
+export class AppCmp {
@gdi2290

gdi2290 Jan 4, 2016

Owner

if it's .component then the name should also be AppComponent

@NathanWalker

NathanWalker Jan 4, 2016

Contributor

Certainly is the going standard out there.
I guess this PR is almost more for discussion :)

I just shutter at the thought of naming all components with full suffix Component.... just for simplicity sake. When shorthand is ample, why not I guess.

@gdi2290

gdi2290 Jan 4, 2016

Owner

if Cmp then .cmp.ts

@NathanWalker

NathanWalker Jan 4, 2016

Contributor

^ I like that. At end of day, I like to use what is universally found in the community. It just makes bringing new people into a project easier because they see what they are used to and have seen everywhere else.

So I like that personally, but don't want to use it if my project would be the only one using it ;)

Owner

gdi2290 commented Jan 4, 2016

I have my own reasons for the current structure that I will be covering in a blog post in the future that may conflict with the current naming conventions

@gdi2290 gdi2290 commented on the diff Jan 4, 2016

package.json
@@ -70,7 +70,7 @@
"tslint-loader": "^2.1.0",
"typedoc": "^0.3.12",
"typescript": "^1.7.3",
- "typings": "^0.3.1",
+ "typings": "^0.4.1",
@gdi2290

gdi2290 Jan 4, 2016

Owner

can you make a separate pull-request for this?

@NathanWalker

NathanWalker Jan 4, 2016

Contributor

Will do!

Contributor

NathanWalker commented Jan 4, 2016

@gdi2290 Absolutely! Don't merge (as mentioned)! However, maybe we can keep the PR open just to see if others have thoughts that may help form the standards or reach consensus?

Idk, I wish I didn't have mixed feelings about the going conventions/standards, but it seems they are amiss on conveniences and simple shorthand.

Owner

gdi2290 commented Jan 8, 2016

I wish there was a convert to issue button. I'll include this in the FAQ

gdi2290 closed this Jan 8, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment