I used to listen to others before said: The best way to learn programming is to learn the source code of the master. It seems that this is really true. However, if you want to read someone else's source code is not a very easy thing, you want to have fun from this, it's more difficult.
I have also tried to read the code of others in the past, but I haven't read it, so I can't talk about any gains and fun. Today, I saw a simple message board program. When I started debugging, I spent the power of nine bulls, and finally it was able to run. The kind of happy and excited is really indifferent. Although I can't completely explain how I debugged, but at least I can make the program run, I will never have a similar problem in the future. Take a look now, it is also very simple. May be the source code in the operation phase when the author is open, thus offering the program debugging, and all OK is turned on in the project properties.
When I started to look at it, when I used XML to implement the message board, I didn't care too much. After all, I used to have a message board, and I also use the XML process. Think, isn't it to use XMLTextReader and XMLTextWriter two classes to read and write an XML document? What is rare. When I saw the source code, I found me wrong, he didn't use the two classes used to implement the read and write of the XML document. About writing documents, he uses the XMLDocument class directly, which may be because the document he needs to write is not very complicated. This is nothing surprised, I still don't think about it here. When I saw it, he read the document and displayed these content on the webpage, I am indeed a shock. As soon as the three lines of code are realized, maybe? I don't believe it. Look down, it is true, his idea should be more open, he doesn't directly read the content, and then an addition to the Datalist, but read the XML document a Dataset, will DataSet The default view of the table item is bound to DataList as a data source, which saves a lot of workload. It should be said that the idea of using the data source is not a fresh thing, but he can be flexible to use it here, it is really difficult. After binding the data source to DataList, DataList should have the corresponding item to receive data, which is true, but to do this, hardly use any code, set the DataList template. Add Item name and label for receiving values, can be linked to the data source for Label editing its DATABING attribute. At this point, the entire display process is completed. I really realized the wonderful place, this satisfaction is not as heavy as my favorite team won the ball.
After reading this source code, I think about those source code you read before, I finally understood the reason for the previous failure. The source code used to read is either too complicated, or you can't compile. So, when we learn other people's source code, we can't ask for a lot. You should start from a small source code, slowly look large. For small source, you can debug first, understand those content in the source code, is it used to do something, so that there is a roughly understanding of the functionality to be implemented, then see the source code will be targeted. . When you look at the big source, you can follow this step, but because there are many contents of the large source code, you must try to figure out its architecture.