-
Notifications
You must be signed in to change notification settings - Fork 6
Naming conventions discussion #22
Comments
Well, we should establish a naming convention for the other classes as well, e.g. I would like to use the short way everywhere: We're using a charting library, so it should be clear that the configuration is for charts, actually 😄 --> But that's something you need to decide. |
And when we're talking about conventions already: Should we use /// <summary>
/// Creates a new instance of <see cref="LineChartData"/>
/// </summary> or /// <summary>
/// Creates a new instance of <see cref="LineChartData"/>.
/// </summary> |
Should usings be declared outside or inside the namespace? I'm asking because I normally use Resharper and the StyleCop extension and the default setting puts the namespaces inside (Second example). E.g. using System.Collections.Generic;
namespace ChartJs.Blazor.ChartJS.DoughnutChart
{
//...
} or namespace ChartJs.Blazor.ChartJS.DoughnutChart
{
using System.Collections.Generic;
//...
} |
Another thing: Resharper suggests to use /// <summary>
/// Gets or sets the percentage of the chart that is cut out of the middle.
/// </summary>
public int CutoutPercentage { get; set; } = 50; Should we use this in the same way? |
For boolean values, I would recommend: /// <summary>
/// Gets or sets a value indicating whether the title is displayed or not.
/// </summary>
public bool Display { get; set; } |
If you give me some advice / opinion here, I would like to help you out and adjust all classes. In the best case, this should take one day or so. |
I think using shorter names for the chart dataset classes is ok, as you said this is a chart library so the I feel like adding a Personally, I like having my And lastly, I feel like starting the summary for properties off with "Gets or sets..." is a very succinct way of telling a developer what's going on. And is (again) also done by the .NET team (e.g Console.OutputEncoding) |
Okay let's do this one by one. By the way, I think it would be a good idea to expand the guidelines with the results of this discussion. Either rename and use the XML_Conventions or create a new file for this. LineChartDataset vs LineChartDatasetI'm very open to the idea that we use Keep in mind that currently the default is the long version ( Do you have a different suggestion or should we try to do it like this? Period / Full stop for summariesThat's one I'm still not sure myself. Would you agree on this convention? Usings inside or outside namespacesHave you read this SO question about this? We use usings outside of the namespace. Summaries on propertiesThe Gets or sets part is in general a good idea. However I have a few points to mention about this.
EDIT:
to
That is actually a quite nice solution as it doesn't loose the description by chart.js. Summaries for boolean propertiesI like the "Value indicating wether .. or not". However, as mention in the previous point, only fall back to that if there isn't a chart.js description. MindSwipeBy the time I'm done with this @MindSwipe already mentioned some points which I totally agree on as you can see above. However the last point is, again, in general very good, but in this case not the right thing if there already is a description for basically the same option in the chart.js-docs. Coding style of corefxTake a look at the coding style of corefx. In general, I will follow these but I have a few things to say before. Braces (1)The points about braces (always on newline) is very good.
Indentation with spaces (2)This really doesn't matter to me. You can use spaces or tabs, just always keep the amount of whitespace the same. var (10)I'm not a fan of Consts PascalCasing (12)Yes. However I'm in the habit of using "SOMETHING_LIKE_THIS". For the future, use PascalCasing. Non-ASCII chars (15)I've never done it like this but this would be a good idea since we're working with web-stuff where this kind of thing is even more sensitive. Indent labels (16)To be honest with you, I don't even know what this means. |
Sure. It should be extended I guess.
If you don't mind, I can do that. I understand that it's a major change because it affects literally everything... For the get and set stuff: I think, it's a good idea to keep the documentation from Chart.Js and add this
That's okay for me as well.
Same here. I always add braces :D
This means a change for me (I always use var), but it's okay.
Okay, I used camel case with an upper case start (Or something like that, I don't really remember).
I have never used non ASCII chars before. Who does even do this?? :D Ok, I know a lot of guys programming in their mother language... :D |
@Joelius300 Would you mind to summarize the discussion in the XML_Conventions (and rename the file probably) or should I do it? I will also adjust my pull reuqest to meet the new conventions already, later. |
I will update the conventions when I get time (so not now lol). I have also reviewed your PR and requested some changes but overall it seems good. Ps. camelCase with Upper case start is the literal definition of PascalCase :) |
I can maybe try to add a pull request there, too. (I will see how much time there is).
Oh, then I was mistaking something, haha 👍
Well, I'm from germany, so I have this 'problem' as well. I've never been using German terms in variable names though :D But sure, strings are a problem. |
Just a quick note: Using statements and using declarations actually differ in when they call Dispose on the object (but I assume you already know this) Here's an Example: public async Task UsingStatement()
{
HttpResponseMessage response;
using (var client = new HttpClient())
{
response = await client.GetAsync("https://hacker-news.firebaseio.com/v0/item/8863.json?print=pretty");
} // client gets disposed here
// Do stuff with the response
if (response.IsSuccessStatusCode)
{
Console.WriteLine(await response.Content.ReadAsStringAsync());
}
}
public async Task UsingDeclaration()
{
using var client = new HttpClient();
HttpResponseMessage response = await client.GetAsync("https://hacker-news.firebaseio.com/v0/item/8863.json?print=pretty");
// Do stuff with the response
if (response.IsSuccessStatusCode)
{
Console.WriteLine(await response.Content.ReadAsStringAsync());
}
} // client gets disposed down here Just keep this in mind when writing a piece of code that uses Also, aren't we already (by default) using C# 8.0 or am I misunderstanding this Microsoft docs page? |
@MindSwipe We're not targeting .net core 3 at the moment. We're targeting .net standard 2.0, that's why it doesn't default to c# 8 but to c# 7.3. Do we want to change this? It probably wouldn't have any disadvantages.. EXCEPT the nonnullable-reference stuff.. It probably wouldn't be too hard to add a few question marks to a few properties but it would have to be done. We could also just stay away from this feature for now. Or we stay on c# 7.3. |
If you ask me, I would already go with C#8. I mean, we will need to adjust this if we want to move to .NetCore 3.0 sometimes either way... |
I feel like making the move to C# 8.0 wouldn't bring any harm, as nullable reference types are optional and we would manually need to opt in to by adding Also, even if we do opt in to nullable reference types, worst that happens is Visual Studio throws a warning our way but it would still compile and work |
From #50:
@Joelius300: Note to you :) |
We should really update this file now. Otherwise, we will forget something... https://github.com/Joelius300/ChartJSBlazor/blob/master/XML_Conventions.md (And rename it probably.) |
Yes this is the most important thing after we're done with 0.10.3. We need do complete this file before any other charts are reworked. I can work on it from time to time and will open a PR so any missing stuff can be thrown at me :) |
public A(B b)
{
this._b = b;
} or public A(B b)
{
_b = b;
}
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="Class.cs" company="Joel L., ChartJsBlazor contributors">
// MIT License
// Copyright (c) 2019 Joel L.
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
// The underlying library from https://github.com/mariusmuntean/ChartJs.Blazor
// is also available under the MIT license. The LICENSE.md file is missing but it's written in
// https://github.com/mariusmuntean/ChartJs.Blazor/blob/master/src/ChartJs.Blazor/ChartJs.Blazor.csproj.
// If https://github.com/mariusmuntean (the author of the underlying library) sees this and has a problem
// with how I use the library or with how I mention the MIT license of his library, please contact me.
// </copyright>
// <summary>
// Class summary.
// </summary>
// -------------------------------------------------------------------------------------------------------------------- |
Only use Yes, private variables are prefixed with _. In our library we don't have many of those (because it's almost all just models) but when there are we should prefix them with _. Coplies with point 3 of the corefx coding-style. Are you sure you want those license headers? I always found them to be a bit obnoxious with little to no advantage.. Can you present me some good arguments to add those? |
Okay. I guess, I will need another Resharper settings file for that (I'm using the style from my company and therefore I see a lot of issues all the time 😄). I will check the private fields as well and see what I can do :)
Well, I didn't use them before as well because they bloat up the files. It was just a suggestion from the code style my company uses. If you don't want to add it, I'm ok as well. We have the option to only include a reference to the license file instead of copying the whole license, as well. But again, just a suggestion. |
Another thing here: Do we want this code style for empty braces: (I saw that you (@Joelius300) did it like this in the line chart rework). |
I did this because I didn't want to add two basically empty lines. As far as I'm concerned, the other common way to do it would be using two lines like so:
I don't really know which one I'd choose but since this library has been using |
Hi @Joelius300. What do you think: Should the chart dataset classes be named
LineChartDataset
orLineDataset
like inDoughnutDataset
? Can we discuss a convention here, maybe?The text was updated successfully, but these errors were encountered: