SOLID Principles
SOLID Principles
To follow this principle, one class isn’t allowed to have more than one responsibility. This avoid
unnecessary coupling between responsibilities which leads to avoid changes in your class frequently.
As classes are independent of each other, if there is change required in one class then it can be easily
implemented without disturbing other classes/functionality.
2. Open/Closed Principle
Software entities (classes, modules, functions etc.) should be open for extensions but closed for
modifications.
It promotes the use of interfaces to enable to adapt new functionalities without changing existing
code.
They create a consistent look to the code, so that readers can focus on content,
not layout.
They enable readers to understand the code more quickly by making
assumptions based on previous experience.
They facilitate copying, changing, and maintaining the code.
1. Use PascalCasing for class names and method names. For eq. ClientActivity.
2. Use camelCasing for method arguments and local variables. For eq. itemCount.
3. Use implicit type var for local variable declarations when the type of the variable is
obvious from the right side of the assignment, or when the precise type is not important.
4. Do not use var when the type is not apparent from the right side of the assignment.
5. Declare all member variables at the top of a class, with static variables at the very top.
6. Don’t use Hungarian notation or any other type identification in identifiers like strName,
iCounter.
7. Don’t use Underscores in identifiers like client_Appointment.
8. Try to make small methods instead of creating single long method. Ideally, a method
shouldn’t contain more than 7-8 lines.
9.
10. Memory Leak
11.
12. Memory leak occurs when we allocate memory in heap & forget to delete it. So, in
order to avoid memory leak, we should always free memory from heap.
13. https://michaelscodingspot.com/find-fix-and-avoid-memory-leaks-in-c-net-8-best-
practices/
14. String vs String Builder
15. Why C# strings are immutable?
16. “using” in C#