-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🚀 Feature: Make .NET SDK and code examples feel more authentic and remove anti-patterns. #2926
Comments
I think this is an issue worthy of discussion, would love to hear what other C# users in our community think. |
Regarding the I see two viable options here. The first one is using a (1) Using the builder pattern (nothing specific to C#), note the capitalized method names (this is C# specific): var cb = new ClientBuilder();
var client = cb
.SetEndpoint('http://[HOSTNAME_OR_IP]/v1')
.SetProject('5ff3379a01d25')
.SetKey('cd868c7af8bdc893b4...93b7535db89')
.SetSelfSigned()
.Build() // note the call to build, which 'finalizes' the builder and generates a valid instance of Client
; (2) Using C# properties: var client = new Client(); // using the Client constructor
client.Endpoint = "http:https://[HOSTNAME_OR_IP]/v1";
client.Project = "5ff3379a01d25";
// etc Properties are basically syntactic sugar and avoid us having to add all the clunky getter/setter methods you would see in e.g. Java. Also note that im creating a new instance of Client using the constructor. Static methods are only useful as 'factories' but in the example above, there is nothing special (eg arguments) about the call. The constructor can (should) be used for simple initialization and dependencies or mandatory parameters can be declared on it. |
@TorstenDittmann @adityaoberai Thoughts? |
With C#, I personally prefer using properties as well. But I don't think the example shown above will be the best way forward for us considering that aside from the Endpoint, other properties like |
May I ask where I can find the .NET SDK? It isn't mentioned in the docs under https://appwrite.io/docs/. |
The issue does refer to the sdk-for-dotnet repo, which is currently out of date. A .NET server-side SDK is under the works, however, and you can track progress on this PR here in our SDK Generator repo. |
Closing this issue since the PR : appwrite/sdk-generator#320 is now merged 🎉 |
🔖 Feature description
The .NET SDK has issues with code examples and SDK generated. Code use is not authentic to the language and contains anti-patterns. Here are some example:
string path = "/database/collections/{collectionId}".Replace("{collectionId}", collectionId);
Should be:
string path = $"/database/collections/{collectionId}";
And
Uses "Java-esque setXXX() idioms in C#." This is considered an anti-pattern.
use proper properties instead. For reference see ASP.NET's startup and Options code examples.
We could use our community's help here, to suggest similar issues with good code practice in the examples and generated SDK we provide.
🎤 Pitch
As mentioned by Reddit user f-berasategui, our .NET SDK feels like it's "written by a Java person." We should strive to have each SDK feel authentic to it's user base, and we should try to make changes to examples and SDK generator to make this happen. We need to avoid
anti-patterns
.https://www.reddit.com/r/programming/comments/t9gmn1/comment/hzugo45/?utm_source=share&utm_medium=web2x&context=3
👀 Have you spent some time to check if this issue has been raised before?
🏢 Have you read the Code of Conduct?
The text was updated successfully, but these errors were encountered: