Organizing C++ Components [closed]

In my current company we’ve brought the discussion about how to organize most of our different C++ components considering the following requirements:

  • There might be interdependencies between components
  • Components with very specific/obscure third party dependencies are not included in this exercise
  • Not every project needs every component, just a small subset of them

There are basically two schools of thought (at least within the company) as to how to organize all of the components:

  • The first one believes we should group all of the components together in a massive library (which can be composed of more than one shared object and allows linking to what a project needs, but in terms of installation and compilation it’s everything together).
  • The second one believes we should create a library per component and maintain them totally separately (each of them installed separately and including as many shared objects as they need).

I can see many cons and pros to both approaches and personally I don’t believe any of them is right or wrong, but I’d like to get a bit more insight from those who have experienced with both approaches and can support with facts the use of one approach over the other.

Edit: being more specific about the concerns.

  • How would you manage the version dependencies between a “many small libraries” approach?
  • How do you avoid having a mess of interdependencies between objects when having a massive library approach?
  • What kinds of performance issues would each approach cause in both windows and linux systems, when statically or dynamically linking? What kinds of benefits?
  • Any other comment that could be helpful in deciding what approach to follow?

1

At our company, the dividing line between approach one and approach two comes down to the external dependencies of the component(s). For instance, we have hundreds of “core” components with no dependencies whatsoever, and those are grouped into only a single library. On the other hand, the one component that we use to talk to a specific type of database gets its own library. Similarly, we have a library for our internal service framework, a library for our internal logging framework, and so on, since those libraries depend on the frameworks being installed on the target machines.

1

You should keep an eye on two aspects here:

  1. The first one is how components you cannot change are already arranged. Third party components or some legacy components you don’t want to change anymore
  2. Components you or your company wrote, which can be merged or split

One of my Best Practices when deciding how to divide any code in packages is to let the progress itself decide how it would be better for me. That means for example you start a game which will need boost, opengl, openal and opencl. Maybe you’re thinking of a cool engine component loading resources and so on.

You will surely not start with opencl and GPGPU algorithms or audio, so don’t even include opencl/openal in your project at first. You will go that way using boost and opengl to start your project. Then you will might notice that you’re using many filesystem operations at different locations in your code and writing too many strings which are appended for filepaths to load. That would be a nice start of your engine, but still don’t even try to create bunch of files and folders for components you’re not going to implement immediately.

As a conclusion ask every new piece of code if it has a right to exist. Then you’ll see that the question of how to organize your components is no question which should be answered at the beginning of any project, but anytime a further component is used in the project.

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