Blog 4 - Testing

| 4 Comments | No TrackBacks

Today, I'm going to talk about CxxTest. But before we start to explore this cool unit, I think I need to introduce testing first. Testing is a really important part in programming, because in a thousand lines code, you might do something wrong in somewhere, or just missing some statuses. Without testing, though codes still run, but no one sure that this code won't go something wrong in the future. So, the best way to make sure our code is good, we can use some tools to help us. CxxTest is one of the useful testing units for C/C++, and it use just similar to C, so it is easy to use. But there comes another problem, where should test? In my experience, each function in your code needs "tests". Why I use "tests", not "a test"? Because of a small function, may need to deal with many cases. For example, one day, I just finished a function that can read something through user's input, and I need to identify the kinds of input. So maybe user enters a path of file, a web site, or something else, it make sense that I already writing some format to figure out the types. When we start testing, we can type some weird format to destroy our program. Use "destroy" I think is a great word to describe what testing system work, because only we find something wrong that we can know where need to fix. After writing as much as you can think the types to input, CxxTest will automatically help you to find error and the reason. And it will also show the percentage you pass the test, programming is really painful, but now you have a clear goal right there, so fight with the number and let it become 100%!

There are some useful macros to use in your test.h. Such as TS_ASSERT() will check the statement is true or not, it makes sense that you can put your function into this macro. Then it will return a "." if success, and show error in which test and which line. And there are so many macros you can check on http://cxxtest.sourceforge.net/guide.html to see detailed. Makefile is a good way to help you manage your source.

Some people think testing is boring, but I really enjoy it! Because I dislike the buggy codes, I will use many way try to test my code before I knew CxxTest. It give me a new way and rule way to testing code, I guess I will feel more confidence on my code now.

Blog 3 - Subversion and Source Control

| 4 Comments | No TrackBacks

        This time, we talk about Subversion and Source Control.  Before start to talk these two tools, I guess I can introduce what is version control system and source control system first.  First of all, version control system, as the name suggests, it can help programmer to control the version of program.  Imaging that one day you finish some coding, it work very well.  However, next day, when you want to add something new functions into your code, the code become buggy and buggy, finally, you just can't go back to begin.  You also forget to make some backup or tags, so you starting coding the first part again, and feel painful.  Though it can be avoid by some good habits, such as diligent backup your code, or make tag when you finish a part of work.  But once you forget, something bad will happened.  Using version control system, you can easy go back to previous version, and you can also compare two version are different in which part.  Though coding still painful, but using version control can let you feel much better.  Secondly, sometimes we need to cooperate with people, and one case we can imaging is, if two or more people try to work on same code at the same time, what will happen?  First, we need to upload the code when we finish, but different content with same file name, so we may over write other people's code.  So we can image that finally only the last upload people's code will stay.  How to avoid this problem?  Source control system can solve this problem.  This system will tell user that someone already committed the newer version, and asking user want to overwrite or compare with two versions.  And after compare two different versions, user can edit each part that code is different.  Then commit again and overwrite.  It sound like source control system is really powerful, but it has some annoying part.  For example, last time I just committed a code and then I still working on the same code, but as the same time, my partner saw that code and found that the format he doesn't like, so he move all the curly parens, and mix some if-else into switch case.  Through the code still work the same, but when I want to commit, I will see almost the whole code change.  It sound really fun, but if it happen on you, it is not fun.  So using the source control system, if you want to make some big change, try to let your partner know.

 

        Subversion, I think this tool just have both version control and source control, because once you committed, it will be a new version.  And it also can let user compare where the different between two versions is.  Though I use this system only half semester, I still have some experience on using subversion.  To call Subversion, we need to use "#svn"and uses some function follow it.  <%svn checkout [URL]> or <%svn ct [URL]> is the first time you need to use, it can make your computer linked with the group space.  That makes sense after doing this, your computer become one of the working space.  You will see a .svn folder in your space, that's why Subversion can automatic update or commit to correct site.  <%svn update> or <%svn up>is a most frequently used command, if something updated, it will show "U ppp.cpp" this kind of message, because you never know when you partner will committed their code, so do this command every time.  <%svn add [file/dir]>this can add files or directories to workspace, but they will be uploaded only after you committed.  <%svn status> or <%svn st>can show you what file is not in your workspace, such as "? asd.cpp".  And show what files you edited this time, such as "M zxc.cpp".  <%svn commit -m "message for this version"> this is also one of the most important commands in the Subversion.  It can upload all your change to workspace.  And there are some useful commands like use <%svn mv oldname newname> to rename, <%svn revert [file/directory]> to undo all change in this time to last version, but this command only can work before you committed.  <%svn copy>can let you make your tags or branches, <%svn merge> can mix two version's codes.  <%svn info>will show up information about these versions, <%svn log>will let you know the history of version. Finally, there are some status will show up during you using some commands.  "?" is for file which not in workspace, "A" is for files that this time you add, "C" means that file has been change, so cannot be merge, you may need to edit first, "D" means this file will delete from your workspace, "M" is for files you modified this time, and "U" means this file is been updated to new version.

 

        Subversion let me feeling good during Iteration1 and Iteration2 working with my partner.  But I'm still not very good at creating tag or when should make branch.  Practice makes perfect, I will keep trying these command and one day I'll good at using Subversion.

Blog 2 - Working in Groups

| 4 Comments | No TrackBacks

Iteration 1 is the first program that I co-work with other people. It makes me feel very excited when program start working, though still buggy. At the beginning of the part, we are discuss about what part should we division of work, cause I think I have a strong sense in logic, I pick up to finish the rule of token part. But it have a problem, how to let my partner to use my code? And also thinking about the variable names, I need to use some names that easy to understand. I think this is a good chance to practice and habit that using the good variable names. I also use lots of line comment, because I need to make my partner understand what I'm doing. I don't like to write comment in the past, I thought writing comment is waste time and no one will notice, but through this project, I notice that comment is really important, not only let my partner know what I'm doing, but also can use comment to leave some hint or idea for myself, make next time work more easy to start.

As time going, I finished some rule of token, that can match token and return value back to main program, but there's another problem pop out. Though I finish my part of work, and it can successfully compiler, but I don't know my code is good or not. Output part is not my business, so I can only wait my partner writing code then I can test. This problem isn't show up in single-programming, and I think that if we are co-working, we need to design a schedule, to define that when should we finish which part, so we can make sure that we can do a little, then test a little, go more safe way in writing program. Though I have this good idea, we still have no schedule until finished iteration 1. Because we are not used in follow the schedule, so when we start coding, we want to finish all at once. Though I think this is a very high efficient way to program, we finally got a very buggy code, and we have no idea what's wrong in which part of our code. We finally find all bugs and fixed, but I still feel so painful. So I guess next time, in iteration 2, try to follow the schedule, it might let group work become much better.

Though we meet lots of problem in iteration 1, I still feel good in some part, such as I have some problem that I have no idea to solve, I can just leave the problem, using some block comments let my partner know the problem, and partner can help me to fix that part. I used to programming by myself, so if I meet some problem I can only solve by myself. In iteration 1, I was meet some problem that matching some token, I can just leave the problem and commit, and my partner will fixed it, same thing happened on my partner. And we also can check each code have bug or not, it make us code from a buggy code to a good code. I also learn how to program with other people, and I think co-work is a way train myself learn how to plan my time. If I don't finish my part, my partner has no source to use. I think through iteration 2, 3, and 4, and so on, not only my programming skill can be stronger, but also I will good at programming with other people.

Iteration 1 is already gone, and iteration 2 is coming, this time I'll try to schedule and follow it, guess we will have good performance in iteration 2.

B1 - What do you hope to learn?

| No Comments | No TrackBacks

Hi, I am Cheng, Chung-Yuan, or you can call me Arthur. I am an exchange student from Taiwan, and I think I can learn something different with Taiwan. Though I am major in Computer Science in Taiwan too, but my university doesn't have this course. I think to writing loops, and code in general, and make them easy to understand is most interesting part for me. Because in Taiwan, I learn how to program in C++, HTML, and a little MATLAB, in data structure course, I write some C++ code to build some binary tree, and use some loop to show Pre-order, In-order, and Post-order traversal. Also make this tree and do some simple calculate, such as +, -, *, / and combinatory in this program too. I think I have a strong sense in making loops, or maybe I don't have a difficult problem yet. I finish this program and get a not bad grade. I really don't think I write a good code, in the past, when I programming, I always trial and error, and my code usually just like an alien's code. So I hope I can improve my skill in to write an easy understand code, and more skilled.

I also have a graduation project in my Taiwan university, that project need to co-work with my friend, but I have no experience that co-work a program with people, I used finish by myself. So this course give me a good chance that coding with partner, and after reading some part from "UML Distilled: A Brief Guide to the Standard Object Modeling Language by Martin Fowler", and "Code Complete by Steve McConnell", it make sense that how to allocate my time in a code. I think this a kind of a SOP. To practice and follow these processes, I think it might be able to aim me to be a good programmer.

Recent Comments

  • kimx1031: Yes it definitely gives you confidence. I really enjoyed your read more
  • egel0049: I agree with you. It is really nice to be read more
  • zdonx015: I agree with the efficiency of CxxTest. Using printf statements read more
  • lowxx060: Yes, I think we both share the same opinion as read more
  • usgaa002: Because most of the labs use work from previous steps read more
  • sherm190: The most common issue I've had with subversion is people read more
  • joh07062: Manual backups are definitely more of a pain than subversion. read more
  • tric0035: I like the way you explained subversion because a new read more
  • zhan1162: Scheduling is a good idea while working in groups. But read more
  • tongx114: Yeah, I definitely agree with you that having a schedule read more

Find recent content on the main index or look in the archives to find all content.