jeudi 29 janvier 2015

Use regions to logically group code


Over the years I have developed a large amount of WPF and server side C# code. One coding practice I have adopted was to group code using regions by access type and to further group code such as the backing field of a property with the property itself.


I don't really have very large methods or classes and I don't use regions in methods so that is not a concern. I like this style and feel that it makes for clean code. I always know what I am looking for and like related code together.


Some people are highly opposed to regions as noted here and here. I just want to know is this a stylistic preference or are there genuine reasons not to use this?


My code as far as regions look is like this:



Private Members

Public Properties

Property 1

Property 2

Constructors

Public Methods

Private Methods




Aucun commentaire:

Enregistrer un commentaire