Today something about simplifying your life.
While programming, there are so many situations when you want to write a simplier code. Maybe not in a “short code” project, but when you develop applications of 5000 – 6000 and more, you realize that you should write as best code as it is possible.
Since July, I have been working on a big project with other developers. There are so many situations in which I can’t read the code after two weeks, both if it is my code or other developer. In this post I want you to focus on object initializers.
1. Using object initializer:
2. Using constructor to initialize:
3. Using accessors:
As you can see -> in the last example, class CSettings has a lot lines of code, and in my opinion it is the worst implementation. Of course sometimes you can’t use only the first option, but I wanted to show you how to write the best code in this situation.