Questions tagged [interfaces]
Questions about `interface` related design considerations, and also "programming to the interface instead of the implementation"
727
questions
2
votes
2
answers
317
views
In unit testing: How to abstract a dependency of subject under test?
Disclaimer: I am learning unit testing. I am also kind of beginner in object-oriented design.
Currently, I am involved in the development of an application to manage the finance of a humble food ...
6
votes
10
answers
6k
views
In "I don’t want my users knowing that I’m handing them an interface.", why is the severity "I don’t want" instead of "Users don't need to know"?
According to some answers to this question, I should not add prefix "i" to interface.
I'm not raising new reasons to support or oppose the prefix "i" on interface. Instead what I ...
0
votes
3
answers
244
views
Is "my method supposes to work with specific subtype only" a reason to avoid "declare the most abstract type"?
According to Why define a Java object using interface (e.g. Map) rather than implementation (HashMap), I know I should declare the most abstract type as possible. However, I found that a situation ...
7
votes
9
answers
8k
views
Why just "interface segregation principle" but not "method segregation principle"?
According to one definition of "interface segregation principle" that states currently in Two contradicting definitions of Interface Segregation Principle – which one is correct?, a client ...
2
votes
3
answers
238
views
How to retain the concrete type when writing base-class-oriented code?
A scenario often arises when attempting to make some existing code reusable. I introduce an interface to represent the commonality between some new feature I'm implementing and some existing ...
5
votes
5
answers
2k
views
How to think when grouping functionality into modules
What are some commonly used strategies when it comes to divide software into modules, other than there should not be any cyclic dependency between any modules? Some ways I think of
Group everything ...
2
votes
2
answers
246
views
How to "explicitly" declare an implicit interface?
Abstract (virtual) interfaces allow you to explicitly declare a set of methods which a child class must implement in order to compile and be used with other parts of the code. This works great for ...
2
votes
3
answers
675
views
Should my methods return concrete classes or interfaces?
I'm building a ASP.NET Core Web API and the application consists of 3 main modules.
Data module: Contains the entities and DbContext
Web API: Contains the controllers
Service module: Contains all the ...
3
votes
4
answers
491
views
Does "declare the most abstract type" increase coupling actually?
According to Why define a Java object using interface (e.g. Map) rather than implementation (HashMap), I know I should declare the most abstract type possible, so for example:
public interface Fruit{
}...
1
vote
1
answer
108
views
Virtual Method vs. Abstract Class Member
Suppose we are writing an interface class which has some "properties" and "operations." Assume also that every concrete implemented of the interface must contain the same set of ...
0
votes
4
answers
341
views
Are "easier to search for the interface" and "avoid yo-yo to interface to find implementations to fix bugs" reasons to add prefix "I" on interfaces?
According to Should interface names begin with an "I" prefix?, I should not add prefix "I" to interfaces. However, I think prefix "I" in interface may be useful sometimes....
1
vote
3
answers
211
views
How robust should an interface/implementation be?
In a spare-time project of mine, I implemented RSA public-key cryptosystem.
Because the official PKCS#1 standard specify key formats in terms of ASN.1 syntax and DER/BER coding, which is a coding with ...
0
votes
2
answers
198
views
For non-container classes, are "better naming" and "ready for commented codes" good reasons not to declare the most abstract type?
According to Why define a Java object using interface (e.g. Map) rather than implementation (HashMap), I know I should declare the most abstract type possible, but the question is about template class ...
0
votes
1
answer
78
views
Where to store a props type declaration on a DDD project?
I am trying to apply DDD to a Vue project (so it's DDD on the frontend) and I have a doubt as to where store a props type. A Vue component can have props, which is basically named data passed to the ...
1
vote
1
answer
112
views
Correct way to represent acquaintance enforced by interface in UML class diagram
Suppose I have the following client code:
using System;
namespace InterfaceCompositionUml
{
internal class Program
{
static void Main(string[] args)
{
...