Code bases for desktop and mobile versions of the same app

I have written a small Java Swing desktop application. It seems like a natural step to port it to Android since I am interested in learning how to program for that platform. I believe that I can reuse some of my existing code base. (Of course, exactly how much reuse I can get out of it will only be determined as I start coding the Android app.)

Currently I am hosting my Java Swing app on Sourceforge.net and use Git for version control. As I start creating the Android app, I am considering two options:

  1. Add the Android code to my existing repository, creating separate directories and Java packages for the Android-specific code and resources.

  2. Create a new Sourceforge project (or even host a new one) and creating a new Git repository.

    a. With a new repository, I can simply add the files from my original project that I will reuse. (I don’t particularly like this option as it will be difficult to modify both copies of the same file in both repositories.)

    b. Or I can branch the original repository. This adds the difficulty of merging changes of shared source files.

Mostly I am trying to decide between choices 1. and 2b. If I’m going to branch the existing repository, what advantages are there to hosting it as a separate SF project (or even using another OSS hosting service) as opposed to keeping all my source code in the current SF project?

1

I’m actually working on the exact same thing at the moment. Personally, I find it easiest to keep everything in one repo, one branch. I use separate java packages for common, swing, and android code. I have interfaces for all the calls from the common package into the GUI packages, so the common code has no idea which GUI it’s running against.

The advantage to this approach is it forces you to keep your code bases synced up, sort of like a personal continuous integration. If your versions aren’t isolated from each other in source control it’s a lot easier to keep them from diverging.

Don’t think about what you might need later. Think about what works best for you right now. The most important thing is to make your code modular. If you do that, putting it into a separate library, separate branch, or separate repo if and when you need it later is trivial.

1

The correct way to go is to divide your code in three parts: common, Swing-desktop, Android. Whether you use one repo or three is up to you; three repos might make sense if their nature is going to be different: different committers, different branching/versioning policies, etc. or perhaps the repos are going to be huge and you don’t want to burden Swing-desktop developers from downloading the Android code and the other way round.

3

The best way to accomplish your code reuse would be to take the common functions of the apps and extract them to an external library that is linked in both projects which are each in their own repository. This eliminates duplicating code through branching or having a single complex repository. It would likely be a lot of work to accomplish this depending on how your desktop app is designed, the amount of effort involved to get everything set up this way may be to large of an investment because the returns are mostly in long term maintainability.

The next best option would be to put both projects in the same repository, this could get a bit tricky to manage if your project grows in scope. This option would also be a bit difficult to manage if you ever had more people involved, though this could be a non issue for you.

I would avoid branching to create the android app you will run into problems maintaining a single correct version of your shared code, and you will have sizable portions of each branch that are separate distinct code that should never be merged together. That isn’t how branches are designed to work and it will cause headaches for you.

1

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