mirror of
https://github.com/junian/Standard.Licensing.git
synced 2026-04-25 05:45:51 +03:00
[GH-ISSUE #45] Improvement #39
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/Standard.Licensing#39
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ammarheidari on GitHub (Nov 20, 2024).
Original GitHub issue: https://github.com/junian/Standard.Licensing/issues/45
Proposal: Reevaluating Coding Style for Variable Declaration (
varvs. Explicit Types) with Focus on Syntax Improvement and Code CleanupI am raising this issue to propose a community discussion regarding the project’s coding style, specifically the use of
varversus explicit type declarations. While this project currently leans towards usingvarwherever possible, I believe adopting a more balanced approach could improve code quality and maintainability.Background
During a recent pull request, I modified some
vardeclarations to explicit types as part of a syntax improvement effort. My intention was not just to change the style but to enhance the readability, clarity, and robustness of the code. I’d like to provide more details on how this approach aligns with the principles of code cleanup and syntax improvement:Benefits of Explicit Types for Syntax Improvement
Improved Readability:
Clarity in Refactoring:
Enhanced IDE Support:
Consistency Across Styles:
varin simple cases, creating a consistent, readable codebase. For example:Code Cleanup Considerations
Code cleanup is more than just formatting—it’s about making the code easier to maintain, understand, and extend. While
varoffers brevity, overusing it can result in less maintainable code, especially in the following cases:Ambiguous or Complex Code:
Explicit types clarify code intent where the type is not obvious or when the variable is initialized with methods returning generic or abstract types.
Future-proofing:
As the project grows, explicit declarations can help onboard new contributors by reducing the cognitive load of inferring types throughout the codebase.
Proposed Approach
I suggest we adopt a balanced coding style that focuses on both brevity and clarity, inspired by .NET team guidelines:
varwhen the type is explicitly named on the right-hand side of the assignment (e.g.,var list = new List<int>();).Dictionary<string, List<int>> data = ...;).Request for Community Feedback
This is not about declaring one style superior to the other but about discussing whether a hybrid approach might suit this project better. A clear and agreed-upon style guide could enhance consistency, readability, and maintainability, benefiting both current contributors and future ones.
I welcome feedback from the community on this topic. Please share your thoughts, concerns, and suggestions. If there is consensus, we could update the style guide to reflect the community’s preferences.