Suppose that I host a project in some open source project hosting services like Google Code, Git hub or Sourceforge, is it a good practice to place the examples / practice code in the repository which I used to learn the technology? For eg., while developing an application I might develop some samples to learn JUnit
or Regex
and so on. Can I place them in the repository as well? Will it confuse the visitors of my repository?
Practice / Example codes in the repository
93 views Asked by bdhar AtThere are 3 answers
You should not put sample spikes into the main repository of a project. You could negatively impact the build process for the project (or even the code itself). My last project has ~50 sub projects/teams and took close to 24 hours to build the whole thing from scratch; it was a monster. Adding everyone's sample code would have made this build even worse. It should be considered a bad practice.
The previous answer about creating a submodule would be a better way to handle this.
I wouldn't put testing samples in the same repository as your actual project.
But IMO there's nothing wrong with publishing them in an own repository.
I like testing samples made by other people. If it's a new topic for me, I find that I can understand a test sample by someone else who is learning as well better than a full-fledged project by someone who is already familar with the topic.
You should only version what you need to develop/run the project.
Any other set of files could be in its own repository (as a submodule for instance for git), and referenced from the main project if you want.
That way, you still see those file on your main project checkout (if you include submodules), but you can also get your main project without any of those extra files.