2012年2月17日星期五

Blog #2: The challenge of merging different-style codes

  Generally, our team has accomplished all the task successfully from the beginning of the semester till now. However, we do not get all the achievements smoothly but with overcoming many challenges here and there.Among these challenges, the different coding styles of each member left the deepest impression on me. The coding style should not be a problem when there is only one person writing the code. However, the problem comes when merging codes which are written by different people with different styles.


  Two weeks ago, I was assigned the work to merge my code with Sathish’s code together to submit for the CE2 (coding exercise two) for CS2103T. Initially, I thought it was a simple and easy task since we all had finished our part of codes and I did not need to do any additional work except putting them together. Unfortunately, it turned out that merging the code become a very heavy and time-consuming work for me. Sathish has the experiences to do software engineering before. Consequently, his code was well-commented and every variable had a proper name. However, due to the over-detailed information in his codes, I had to read every line like reading a story. It took me about an hour to understand all the methods and classes in his codes. When I began to put my code in, I found that I had no choice but to use his print method to display the results; otherwise I would have to write a new print method which would disobey the principle of software engineering. What was worse, I discovered that my code had already made out the best choices under the budget. Conversely, Sathish’s code made the selecting and separating solutions in the print method. I need to redo my selection so that I could make my code fit to his print method. Finally, the merging of code was finished. I had spent a whole afternoon doing the merging. Sadly, it turned out that it had not stopped yet. Sathish told me there was something wrong in printing the results. After communication with Sathish, I knew that I had misunderstood the meanings of his variables. Concurrently, Yukai pointed out a bug that the program could not take in the zero budget. After a hard time fixing these bugs, the work was eventually done.


  It is very common and natural that different people will have different style in coding. However, when it comes to merging the code written by different people, there will be confusions which will lead to lots of problems. I have come out three solutions. Firstly, coordination is needed in pre-coding period. For example, we should standardize all the names of the variables and distribute the work properly. Secondly, communication is necessary. If we come across any confusion of the other’s code, we should communicate with him or her directly and immediately. Thirdly, the tolerance and patience are needed. We should keep in mind that with the tolerance and patience, we can conquer any difficulty.


  The coding of the first version of this project will start in this recess week. Learning from the pain of merging code in CE2, we will do sufficient pre-coding coordination work to make the individual coding work more systematic. During the coding, we will conduct online meetings at least twice a week. Besides, we will also try our best to figure out the bugs and not give up. All in all, I have gained more confidence and look forward to accomplish the first version of this project successfully.

3 条评论:

  1. To judge the compatibility of algorithms that we would use for the submission of CE2, I have gone through both Sathish’s and your codes as well. The format of Sathish’s variables names (the use of underscore in front) and your habit of leaving an additional line before the closing brace left an impression on me. Although the above mentioned does not affect readability of code, it would be great if we could have some form of standardisation. Therefore, I would like to propose the use of Eclipse auto formatting (Keyboard shortvut: Ctrl+Shift+f) after we have completed our coding since it is a simple process and we do not have to adhere to anyone’s coding style.

    For future merging problems to be minimised, I feel that we should use the recess week to reinforce the concepts taught in CS2103 even though it does not have a Mid-Semester Test. We would then be able to apply these concepts correctly to what we code, thus ensuring conformance with the Object Oriented (OO) Approach. For example, each of us would try to restrict the number of lines in our methods/functions so that it is highly cohesive (performs specific function without overlapping with others).

    回复删除
  2. Hi ZhenYang,

    This is infact a lesson for me too! I made a mistake in not explaining the codes to you in person. Rather I told you to follow the comments that I have left in the program as I felt that was sufficient enough. Apologise for that!

    This is my first time having someone to alter my code and getting them used to my coding style. I'm glad its finally done. Now we have to deal with the task of merging all 4 of our individual codes for the final project.

    I do agree with Yu Kai's post above. We definitely have to adapt to a standard that is understood by us. We definitely have to not only split workload but also have to agree on common understanding on how we are going to label variables, style of coding etc. If everyone has their own style, the merger of codes will have an extremely hard to doing it.

    回复删除
  3. Thanks Yukai and Sathish,

    I have mentioned the coordination before the coding in my blog. However, I did not grow the idea in details. Otherwise, I will exceed the words limit. In my opinion, changing one's coding style in just one project is not possible. What we can do is having a compromise. Each our team member just uses the same class diagram as a guide to code the classes and methods in Java. We treat everyone's code as an entity. We only care the input and output for an entity.This is pre-coding coordination.

    The coding concepts in CS2103 are very useful. However, many of them are higher level of designing the software engineering. Learning from these concepts, we only know the flow of creating software. We need to apply them in the reality. It will also be a challenge for us.

    回复删除