Closed asthomas closed 8 years ago
Great question... I mentioned in the read-me that there is some expected divergence from the actual C# code style. Here's a few reasons why: 1) I started this project following strict C# code styling and attempted to make everything exactly like it is/was in .NET, but then I noticed that linq.js did the same thing, where they started out with title-case on everything, but then decided to change to standard JS code styling with lower case method names etc. I thought about it long and hard, and realized: 2) JavaScript coders will reject title-case. It's just not how 99% of JavaScript developers code. So hanging on to title-case would be a huge detriment to this project. 3) The more code I wrote, the more I realized that unless you're using JSIL, it's not beneficial to anyone to enforce title-case in JavaScript.
I still prefer title-cased namespaces, where some may prefer lower-case or camel. Classes will always be title-case, and most constants (unless and actual enum) will be upper-case.
I'm open to suggestion here. But I think the general consensus is, if you want JavaScript/TypeScript coders to be open to using your code, you have to be "JavaScript Friendly".
Also, TypeScript is simply different in a lot of ways than C#, and I found it better to be comfortable with that fact and embrace that at the end of the day, it's JavaScript.
I notice that the method names are using the Javascript convention of a lower-case first character, whereas the .NET convention is upper case. If the purpose here is to generate a compatible library for porting C# to Typescript, why put the user through the tedious process of changing the first letter of every method call? If the purpose is to provide a familiar interface for people who already know C# and the .NET libraries, why diverge from the familiar interface?
For example, look at the Dictionary implementation.