Class could have static, private, protected, public methods. Each method is made for modifying, adding, removing etc.
How do you group functions in class's code to make it clean to read? What is the best practices?
Thank you.
Class could have static, private, protected, public methods. Each method is made for modifying, adding, removing etc.
How do you group functions in class's code to make it clean to read? What is the best practices?
Thank you.
This is how I do it for Java classes:
一种约定不需要适合所有场景——通常,在我们的团队中,我们使用 C#,并且我们使用“区域”来对私有字段、静态成员、私有方法、构造函数、受保护方法和公共方法进行分组。顺序并不重要,因为 VS 可以很好地折叠所有区域,给出一个摘要视图。有时,我们也使用“覆盖”和/或“虚拟”区域。它还取决于所讨论的类的复杂性。对于少数复杂的类,您甚至会根据功能找到区域。例如,所有“解析”内容(变量、私有方法、解析中涉及的公共方法)都将集中在一个区域下。最后,目标是拥有可读(可维护)的代码,而“一致性”将是实现这一目标的工具之一——只要团队理解这一点,就应该有