Splitting implementation and interface in C++
Splitting implementation and interface in C++
Posted Feb 24, 2025 17:22 UTC (Mon) by farnz (subscriber, #17727)In reply to: Splitting implementation and interface in C++ by viro
Parent article: Rewriting essential Linux packages in Rust
Yes. The extra work of splitting something into an interface module and an implementation module is significant, and does not reduce the complexity of reasoning about a change, nor the amount of code that has to be reviewed for assessing validity of a change.
This is distinct from splitting the implementation up inside a single C++ module; having multiple module units, one for the exported interface and many for the internal implementation, makes a lot of sense, but having two separate C++ modules, one of which exports an unimplemented interface, and the other of which exports an implementation of that interface, is a mess, since it means I have to make sure that the two separate modules are kept in sync manually.
Why create that extra workload when I can have a single module with an internal module partition such that it's very obvious when I change the interface without changing the implementation to match, and where I have one thing to release instead of two?
