Angular 2 - Leading underscore for private members

533 views
Skip to first unread message

nucl3ar

unread,
Jan 14, 2016, 9:49:27 AM1/14/16
to AngularJS
Hi,

I'm looking for a naming convention for Angular 2 but couldn't find any.

I've seen some samples where leading underscore for private members were commonly used.

But I don't see the point since there is the keyword "this".

Can somebody enlightens me on this matter ?

Thanks

michael corbridge

unread,
Jan 14, 2016, 3:02:49 PM1/14/16
to AngularJS
I think what you are seeing is some c# conventions sneaking into angular2 from the .net developers?  Maybe ... I come from a java / AS3 background where that convention is not used.   I have noticed that if you look at the source code behind the frameworks, developers can tend to use the leading underscore.  I always thought they did this to avoid collisions with variables on the outside.  Or to scare people away.  it works on me!

Florian BECLIN

unread,
Jan 14, 2016, 5:28:37 PM1/14/16
to ang...@googlegroups.com
This is funny.
I come from the .NET background, and I don't like this convention (never used it too).
At this moment, our team is developing a new web application with a java back-end, and my colleague (which is coming from the java world ; this is cynical) is 100% that is the convention for Angular2.
But I couldn't find any, and I would like to keep (if possible) the same convention for this purpose between front-end and back-end.

--
You received this message because you are subscribed to a topic in the Google Groups "AngularJS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/angular/dUpiZJ1M7mM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Günter Zöchbauer

unread,
Jan 15, 2016, 4:14:05 AM1/15/16
to AngularJS
In Dart the leading underscore has private semantics (like lower-case in Go). 
I guess it's easier to translate TS to Dart and some like it anyway as convention.

Florian BECLIN

unread,
Jan 15, 2016, 4:17:43 AM1/15/16
to ang...@googlegroups.com
Thanks,

We're are using Typescript instead.

--

Günter Zöchbauer

unread,
Jan 15, 2016, 5:39:15 AM1/15/16
to AngularJS
I mean they used it in TS because it's easier to generate the Dart version of Angular.
Maybe the Angular team just likes to use similar conventions for TS and Dart code.
Reply all
Reply to author
Forward
0 new messages