What’s the best way to manage reusable classes/libraries separately?

When coding, I naturally often come up with classes or a set of classes with a high reusability. I’m looking for an easy, straight-forward way to work on them separately.
I’d like to be able to easily integrate them into any project; it also should be possible to switch to a different version with as few commands as possible.

Am I right with the assumption that git (or another VCS) is best suited for this? I thought of setting up local repositories for each class/project/library/plugin and then just cloning/pulling them. It would be great if I could reference those projects by name, not by the full path. Like git clone someproject.

edit: To clarify, I know what VCS are about and I do use them. I’m just looking for a comfortable way to store and edit some reusable pieces of code (including unit tests) separately and to be able to include them (without the unit tests) in other projects, without having to manually copy files. Apache Maven is a good example, but I’m looking for a language-independent solution, optimally command-line-based.

3

As @jgauffin points out package management really is the way to fly here. But not everything has a package manager. Or other times you just need the sources riding with things.

Specifics are really a function of what platform, thing you want to look at here would be the sorts of features exposed by git submodules or hg subrepos. Both are designed to pull some part of your source repository from an external source. In the case of hg subrepos they don’t even need to be HG — git or svn can be accessed as well.

The real challenge comes in when you want a subrepository but you need to edit some certain files within it.

I would keep them in a repos somewhere and then use a package tool to include them in my projects.

  • .NET has nuget.
  • Javascript has npm
  • Ruby uses gem

etc.

A VCS is the way to go. What you need here is to decide how you are going to store you code/configuration items in your VCS repository. The first question that I would ask is how stable are these reusable components?

If they are not going to change very much, then put then into a repository/database/project/folder/(what ever terminology your VCS uses) of their own and label them according to the product they correspond to. Then when it is time to do some coding, the developer gets the system they are working on from its repository and then the shared stuff, using the appropriate label to get the appropriate versions.

If the shared libraries will only change a little bit over time, then add some branching for the development lines that need it and use labels. Now you can get the required files/versions as per the above using the appropriate labels. You then need a management process to periodically update the trunk with these branches and test it with all the affected applications.

If there is going to be a lot of customization, then you probably need to maintain separate repositories per project as that will be easier/cheaper to manage that over a bunch of repositories with lots of branches/labels/promotion groups and the integration testing that that entails.

To extract them, use some tool if you can be bothered to work out how to configure it. Or, write a quick script to get the files needed per project and create the file structure for the project when you need to start off some development, Something like this psudo code:


required_label = "version 1.1.1"
project = "funStuff"
destination = "server/share/folder/"

get from vcs project $project $required_label into $destination
get from vcs "library project" $required_label into $destination/lib/

echo “get to work”

This may not work if you used a IDE inbuilt version management integration. The developers may need to use the VCS’s interface to check in/out configuration items that are going to be changed.

The key to making this work is to make sure that the appropriate labeling system is enforced by the VCS – the ones I have used allow you to set up a rule forcing the adding or a label on check-in or have the facility for floating labels. Use as appropriate.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật