【发布时间】:2016-05-31 03:37:36
【问题描述】:
我是一些小众语言的优秀开发人员,并且正在有机地学习 C#,因此尝试了解最佳实践。
我能否获得一些关于以下示例代码块最适合我构建 Shopify 集成的反馈。
namespace WMShopify
{
// Is it common to have the namespace and class the same?
public class WMShopify
{
// Are there different practices for private/public vars?
public string APIKey { get; set; } // Capital
public string password { get; set; } // lower case
public string secretString { get; set; } // Camel
private string _combinedVar; // Camel/underscore for private
}
// Should these be in a separate *.cs file?
public class WMShopifyOrders
{
// Method capital/lower/camel?
public int getOrderCount()
{
// lower/capital/camel?
int localMemberVar = 0;
return localMemberVar;
}
}
// Should these be in a separate *.cs file?
public class WMShopifyProducts
{
public List<string> getProductList()
{
return new List<string>();
}
}
}
【问题讨论】:
-
我发现最佳实践是一致性。如果您或您的团队已经确定了特定的样式指南,则应该遵循它。
标签: c# .net variables namespaces