开发者

Finding how a large Java code works

I have done 开发者_JAVA技巧some Java programs on my own but now I found an interesting Java project to work. I chose one item from todo list and now I would like to implement it and find a suitable place in the original code for it. What are some good strategies to find the correct place? I'm using Eclipse Helios and its debugger.


This is where coding convention and technical documentation would help you. If the java programs you are talking about is written correctly with the correct conventions and everything, you should be able to figure out where your code should reside.

Best way would be to run through the part where the TODO is needed. If the todo is specific to current class, it would be ideal to just put it in the same file. Of course, TODO usually (but not all the time) means that it might be an enhancement to the current code. If that's the case, then creating a new method for it would be good.

if on the other hand, you think your code would be useful for the entire project, a utility method would be the perfect place to store your code.


If it's something you can make a local copy of, try getting it all to work IE do a couple of test runs, and then try deleting some files that look unimportant. It may sound silly but it'll show you straight away whether or not something is a core part of the code.

Once you get down to class level, read the whole thing. Eventually you'll get to know a few core classes really well and gain a basic understanding of what all the others do.


If you are completely new to a project, but that project has other developers I suggest you ask someone more familiar with the code base. If you are on your own you would have to see if there are any functions that are similar to what you want to do. You could then try and put your own code in the same place (package/class/whatever is appropriate) and job done!

Good luck!


Start working on a private branch (you do use some version control software, right?) and make sure you understand how to validate the project (you do use automated tests, right?). After that, just start experimenting!


If this is an open source project then it most likely have some means of contacting the developers for the project. A mailing list is usually available, where you can ask these questions to those who know the code well.

Remember to choose an active project...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜