I'm currently refactoring some code to make it more testable. Specifically, I am extracting the interface of several classes to allow easy creation of test doubles.
I'd like to keep the public interface the same to this code, naming the interface after the original class.
However this leaves me with the problem of what to call the original class.
I'm using C++.
If my interface is:
class ServiceClient;
What should I call the contrete, I've come up with a few options that I'm not convinced by:
class ConcreteServiceClient;
class ServiceClientImpl;
class StandardServiceClient;
class BasicServiceClient;
What conventions do people use?
Methods should be verbs, in mixed case with the first letter lowercase, with the first letter of each internal word capitalized. Except for variables, all instance, class, and class constants are in mixed case with a lowercase first letter. Internal words start with capital letters.
Interface Name: Should start with uppercase letter and be an adjective e.g. Runnable, Remote, ActionListener etc. Method Name: Should start with lowercase letter and be a verb e.g. actionPerformed(), main(), print(), println() etc. Package Name: Should be in lowercase letter e.g. java, lang, sql, util etc.
I would change the name of the interface class.
class ServiceClientInterface {};
Then place the concrete implementations in seprate namespaces:
namespace MyService
{
class Client: public ServiceClientInterface {};
}
namespace MyServiceTest
{
class TestClient: public ServiceClientInterface {};
}
Or something completely different.
PS. I am into full names. I don;t like the the short 'I' is interface thing. Your taste may vary.
Normally, I reserve "Impl" for the pimpl idiom. I use a full "Interface" on abstract base classes. For concrete implementations, drop the Interface and prefix with what specialization this is:
class ServiceClientInterface {
// some pure virtual methods
};
class XMLServiceClient {
// Or whatever "service" it is
};
class TestServiceClient {
// some well defined
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With