Writing (almost) everything as library component!!!

I don't think that 'cpp core guidelines' recommends a single header.

So yes, the first concept would be 'divide and conquer'. Therefore namespace are invented. For instance if you want to do something with a printer you create a namespace printer and put everthing that has to do with a printer in this namespace.

Another step would be minimal dependency. Rather create an intermediate object which manages the input to the printer then pollute the printer interface with input specific stuff.

There is surely nothing wrong with library components. That makes it even more important to keep your interface clean.
Vindieselwalker wrote:
you will write many many lines of code shared among many colleagues. How would you manage the complexity of your future projects?

natural consequence is that those "many lines of code" have to form a reusable component, whether you call it "library" or "unit of release" or whatever.

And in order to be reusable, it has to be independently-testable, under assumption that the components used by the one under test are themselves tested. And from that follows a hierarchy of components/libraries/etc. A hierarchy that better be a DAG, with no cycles.

C++ Core Guidelines mentions these natural rules in
http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Ra-lib "A.2: Express potentially reusable parts as a library"
and
http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Ra-dag "A.4: There should be no cycles among libraries"

I've worked on a 175MLoC codebase where these rules were applied, enforced, and were successful.
Last edited on
Another thing I prefer is to to have many small libraries with few dependencies instead of big libraries with a lot of dependencies (especially external ones).
I think you have this backwards. The more libraries you have, the more dependencies you get.

Think about it. You compile your program. You link with 25 libraries. You get
Error: undefined symbol FurryKoalaBear

You have 87 additional libraries. In which one is FurryKoalaBear defined? You hunt for an hour, only to find that it's in one of the libraries you're already linking against! Dang. But it's defined in lib22.so and you refer to it in lib19.so and lib22 comes before lib19 in the link line. No problem. change the order.

Uh oh. Now 121 symbols are undefined. Something about that order is wrong....

In contrast, if you had just a few libraries, you could let the linker sort it all out for you.
The original OP (Vindieselwalker) is was a spammer! He's just copying recent posts by various authors from reddit.
Original post: https://www.reddit.com/r/cpp/comments/b65n0p/writing_almost_everything_as_library_component/
Last edited on
@Peter87, the OP sounded far too polished to be a noob, as he was probably trying to appear to be.
Peter87, so? Perhaps it's a bit suspicious, but that thread is only 5 days old. That is not proof of spam, perhaps he wanted to get another community's eyes on it. Web links in their profile is a big red flag for me if something looks like it's a spam account.

Edit: I see now that this is not the only instance of this happening. You are probably correct in that it was a spammer.
Last edited on
closed account (z05DSL3A)
Ganado, one of his posts had a few web links tacked on the end (not in the original post elsewhere).
I edited my previous post. You're probably correct. If it were just one instance of it, I would have given it the benefit of the doubt, but you showed that it was two threads copied from Reddit, each by different authors.

Yes, all clear now. Clearly spam.
Last edited on
That is not proof of spam, perhaps he wanted to get another community's eyes on it.

The OP had made four posts. All were exact copies of reddit posts by four different authors. His oldest post contained a spam link. That was enough evidence for me.
Whether the posts were spam or not is rather a moot point now, they've all been deleted.
Topic archived. No new replies allowed.