description Use Interface Instead of Concrete Type Overview
Use Interface Instead of Concrete Type is a refactoring operation available in JetBrains development environments for supported languages. It replaces eligible declarations or references to a concrete class with an interface that the class implements, while preserving behavior where the interface exposes the required members. The refactoring is useful for developers who want dependencies expressed as abstractions, although each replacement must remain compatible with the surrounding code.
help Use Interface Instead of Concrete Type FAQ
What does the JetBrains 'Use Interface Instead of Concrete Type' refactoring do?
It changes eligible declarations or references from a concrete class to an interface that the class implements. The goal is to reduce coupling while preserving the program's behavior.
Why would a developer replace a concrete type with an interface?
Depending on an interface makes code easier to test and allows another implementation to be substituted later. For example, code can accept a `PaymentGateway` interface instead of being tied directly to one concrete gateway class.
Does the JetBrains refactoring change program behavior?
The operation is intended to preserve behavior while changing the declared type where the interface provides the needed members. The result still needs compilation and tests because not every concrete-only method or property may be available through the interface.
Which languages support this JetBrains refactoring?
Support depends on the JetBrains IDE and language plugin because the refactoring requires language-aware type analysis. It is available only when the selected concrete class has a suitable interface and the affected declarations are eligible.
explore Explore More
Similar to Use Interface Instead of Concrete Type
compare_arrows Compare: Extract Interface from Type... See all arrow_forwardReviews & Comments
Write a Review
Be the first to review
Share your thoughts with the community and help others make better decisions.