Skip to main content

Timeline for Are header files actually good?

Current License: CC BY-SA 3.0

6 events
when toggle format what by license comment
Sep 20, 2015 at 22:16 comment added underscore_d If headers were actually useful for separating interface and implementation, things like PImpl wouldn't be needed to hide private components and decouple end-users from having to recompile against them. Instead, we get the worst of both worlds. Headers feign a quickly dismissed facade of separation, while opening a myriad of pitfalls, which require verbose boilerplate code if you need to work around them.
Mar 24, 2014 at 15:55 comment added gbjbaanb @Petter I think you misunderstand, conceptually they are no different - a header exists to provide an interface in the C language, and though you are right - you can combine the 2 (as many do with header-only C code) its not a best practice that I've seen followed in many places. All C# devs I've seen split the interface away from the class, for example. Its a good practice to do this as then you can include the interface file in multiple other files without pollution. Now, if you think that this split is a best practice (it is) then the way to achieve it in C is by using header files.
Jan 1, 2013 at 12:54 comment added Petter Nordlander well, that does not require header files and that does not make header files any better. Yes, they are needed in languages with a legacy, but as a concept they are not needed to split interface/implementation in different files (actually, they make it worse).
Dec 31, 2012 at 0:30 comment added gbjbaanb eh? isn't that what I said - you define the interface and the class implementation in 2 files.
Dec 30, 2012 at 14:49 comment added Petter Nordlander Interface and Implementation in different files? If you need this by design this is still very common to define the interface (or abstract class) in languages such as Java/C# in one file and hide the implementation(s) in other files. This does not require old and tricky header files.
Dec 29, 2012 at 18:27 history answered gbjbaanb CC BY-SA 3.0