I decided to start a series of posts about coding standards and best practices, the point is, why do we need to keep our eyes open on coding standards and best practices approaches, because simply coding is about maintainability, so following up this standers and practices will really add a real value to our code.
Year ago i was working DashSoft and our CEO Remon Zakaria and he told me one of the most major thing that makes you judge someone’s code is have strings inside the code, I’m talking about something like this
1 /// <summary>
2 /// Registers the controls tool tips.
3 /// </summary>
4 private void RegisterControlsToolTips()
5 {
6 this.uxControlsContainer.ToolTip = "All Page Controls container";
7 this.uxSaveCommand.ToolTip = "Save a new control to page";
8 this.uxCancelCommand.ToolTip = "Cancel all changes";
9 }
So that is totally wrong because simply if the customer asked to change some tooltips, controls names or whatever textual data, we will need to go change it in the code and then recompile the project, which means our software will need one more cycle of Regression testing rather than have acceptance testing, so that will consume more time of the project resources,
One more issue if the customer asked to have multiple languages application, no way we can save the strings statically in the code, that will make developers job harder to deliver this project.
So What we can do …… ?
Actually there are two approaches depend on application architecture
- Store those strings in Database
- Using resources
and for multi-language applications you will need to define the culture for each string so you easily switch from language to another.