Win a copy of Fixing your Scrum this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Rob Spoor
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Himai Minh

Java code to read

 
Greenhorn
Posts: 29
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am looking to improve my ability to reach other people's code. Google.com has failed to pull any websites that can direct me to people's code that I can read over. Does anyone have a particular website that has excellent written code that I can browse over? Thank you in advanced.
 
Marshal
Posts: 73725
332
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am never convinced you learn much by simply reading code. Maybe you should submit us some code and let us see what we think of it.
 
Jesse Schlicklin
Greenhorn
Posts: 29
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How would you practice then reading other people's code? For example, If I was hired at company XYZ and they had a preexisting software then asked me to fix a bug in the program. What is the best way to practice this? I try to make my code clean to read with comments but I may not always be that lucky to receive clean code in the real world.
 
Saloon Keeper
Posts: 13171
285
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
By having written lots of peer-reviewed code, and by debugging a lot of code in practice.

You're not going to learn debugging by reading code. You need to actually get your hands dirty with finding and eliminating bugs.

You can do this in your free time by contributing to projects on GitHub. Many of them have a list of open issues, and you can decide to solve an issue for them by cloning the project, debugging and fixing it, and then submitting a pull request for the fixes you wrote.
 
Campbell Ritchie
Marshal
Posts: 73725
332
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would practise by writing my own code.
 
Rancher
Posts: 383
13
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jesse,

The key word Stephan and Campbell use is writing when it comes to code. Nothing helps one become familiar with code like writing and debugging your own code...over and over. The more you put yourself into situations with your code where something fails (e.g. an exception occurs, the output is not as expected, etc...), and you break it down to debug it and find a solution, the better it prepares for debugging other people's code. More frequent practice can expose you to the multitude of problems you can run into with code.

Allow me to use an analogy: Say you're studying to get your driver's license (pretend you've never, or very rarely, driven a vehicle before). If you were to only read the driver's manual, and not actually do any driving, such as taking driving courses, how prepared do you think you would be when it came to taking the driving part of the test? Just reading about how to operate a vehicle and knowing the rules of the road does not equate to being a good driver.

Same thing in coding. You indicated that you try to make your code clean to read with comments, which, to a point, is good (sometimes people put in too many comments, ones that are irrelevant or redundant, for example), but in reality people have their own styles/habits/methods of coding. This brings us back to my point above about exposure to different kinds of bugs through more frequent practice.

Stephan mentioned contributing to projects on GitHub. Having done this myself over the years, I agree that that is a great opportunity to get the exposure you need.

Hope this helps.
 
Marshal
Posts: 26745
81
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
On the other hand... I learned a lot about various Java features by reading the Oracle tutorials for those features. The tutorials almost always come with code examples, and I've found that I can learn a lot by downloading that code and making modifications to it. Now sure, that "learning" is learning about how to write code to work with, say, a Swing text component. But it is "other people's code" and it does involve reading it. Not only that, it involves reading it with the goal of finding the part of the code which does a particular thing.

It might be an idea to clarify what you want to get out of this reading-other-people's-code project. There's what I just described, reading the code to find out how it does something. And then there's reading code critically to find out whether it satisfies all of its requirements in the right way -- code review is a very common thing that people do. And there's reading other people's code to learn common ways of doing things, idioms let's call them. For that you need to be confident that you're reading well-written code and not just some random person's code.
 
Do Re Mi Fa So La Tiny Ad
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic