-
Notifications
You must be signed in to change notification settings - Fork 25
Description
Description
ITranslator has many different functions. Many of which don't need to be grouped together.
When writing isolated tests, or dummy translators, it becomes inflexible if a single class has to handle all the functions ITranslator defines. It also makes it impossible to maintain a separation of concerns.
Proposed change:
Simply split ITranslator into multiple smaller interfaces that each define a subset of functions. Then ITranslator becomes empty and just inherits all the new interfaces. It has to be kept around for backwards compatibility.
interface ITextTranslator { }
interface IDocumentTranslator { }
interface ILegacyGlossaryManager { }
interface IUsageManager { }
interface ILanguageManager { }
interface ITranslator : ITextTranslator, IDocumentTranslator, ILegacyGlossaryManager, IUsageManager, ILanguageManager, IDisposable { /*empty*/ }
Naming
- Most names are self explanatory, e.g:
ITextTranslatordefines theTranslateTextAsyncfunctions. ILegacyGlossaryManagerdefines all the v2 glossary functions. I called it 'legacy' because to refer to the version number would be confusing.
Considerations
Current interfaces like ITranslator and IGlossaryManager require the IDisposable interface. This isn't strictly necessary. There is nothing in their signature that suggests they are responsible for some resource. The only thing that is is Translator and it's derivatives. Therefore I also propose that these new interfaces don't inherit IDisposable.
ITranslator and IGlossaryManager will continue to require it to maintain backwards compatibility.