So I have been working as a software engineer for about 3 months. During this period, I got involved in 2 projects (and of course several unnamed tasks): 1 uses Enterprise Java Bean, the other uses .NET with C# and ASP. I would say ASP, C# combination is easier to work with than Java+JSP. One of the reasons is that the .NET framework separates the presentation and logic very well. To put it simple: ASP for presentation (or view) and C# for business logic (or control). The other nice things I like about .NET are:
- The validation controls which can nicely replaces the lengthy validation script.
- The user control can be written and reused anywhere.
- The label control and Visibility property of controls make the interactive display of content much easier to be achieved if you compare to coding with JavaScript.
Well, let’s extend the discussion to good programming practice in general, especially in big projects which involve many developers. What I have learnt from working in medium and big development projects is that setting and following standard is important to project scaling, transferring, maintenance and development. It worth our efforts to set the standard at early stages of the project development. Some of the standards that we need to take care of include:
- Set the naming convention for every member of project group. Be consistent in naming.
- Never mix up the presentation with business logic. In the best case, a single line of business logic in presentation page should not be allowed. A good practice is to put them in separate files and make use of include, register or import.
- Minimize using of string literals. All literals should be declared as constants.
- Common tasks for all modules should be coded separately and put in a shared folder. For example, upload file, insert into database, select from database,…
- Always logging the actions performed on database or system. It is also considered a common task and is good for diagnosis.
- Be consistent in coding style. This is pretty hard to achieve because each developer has his own style.
- Never have a long methods/functions. Divide it into smaller methods if possible.
- Reuse the code as much as possible. The code can even be reused across multiple projects.
