Questions about interface related design considerations, such as programming to the interface.
0
votes
0answers
70 views
Interface methods that take objects as parameters
The (probably unnecessary) Background
I am creating an interface that will define how information is passed over a named pipe between a background service and tray application that displays ...
1
vote
1answer
124 views
Code re-use in C++, via multiple inheritance or composition? Or…?
I originally asked this question on StackOverflow, but I was directed here, and I think my problem is perhaps as much conceptual as technical, so here goes.
If you’re defining a hierarchy of abstract ...
0
votes
3answers
261 views
Why do APIs generally consist of interfaces? [duplicate]
I am starting out in Java API design and in reading existing code bases, I have found that most APIs consist of interfaces only with their implementations bundled in a different package.
Having read ...
7
votes
4answers
421 views
Split up large interfaces
I'm using a large interface with about 50 methods to access a database. The interface has been written by a colleague of mine. We discussed this:
Me: 50 methods is too much. It's a code smell.
...
2
votes
0answers
53 views
The inheritance argument of zope.interface (providedby vs isinstance)
What limitations does inheritance of an interface through an abstract base class present that are addressed by zope.interface?
In the following talk given in 2010 by Jeff Rush about interfaces, at ...
1
vote
4answers
211 views
Combinatorial explosion of interfaces: How many is too many?
I'm a relative newcomer to OOP, and I'm having a bit of trouble creating good designs when it comes to interfaces.
Consider a class A with N public methods. There are a number of other classes, B, C, ...
1
vote
2answers
62 views
Creating an Interface To a Language's Standard Library?
In the process of learning test-driven development, I've been introduced to dependency injection and the use of interfaces, and have started using these concepts in my own PHP code in order to make it ...
5
votes
1answer
64 views
Designing communications for extensibility
I am working on the design stages of an application that will a) collect data from various sources (in my case that's scientific data from serial ports), keeping track of the age of the data, b) ...
0
votes
2answers
122 views
Java best practice Interface - subclasses and constants
In the case where a couple of classes implements an interface, and those classes have a couple of constants in common (but no functions), were should I put this constant ?
I've had this problem a ...
2
votes
2answers
114 views
Design for an interface implementation that provides additional functionality
There is a design problem that I came upon while implementing an interface:
Let's say there is a Device interface that promises to provide functionalities PerformA() and GetB(). This interface will ...
0
votes
0answers
102 views
How to desing a roulette like interface
What I need to do is this: In my app I create some profiles (just names) and these names are saved on a database. The names limit is 5. After this, in other activity I load these names from the ...
0
votes
1answer
91 views
Should interface only be used for behavior and not to show logical data grouped together? [duplicate]
Should an interface only be used to specify certain behavior? Would it be wrong to use interface to group logically related data?
To me it looks like we should not use interface to group logically ...
0
votes
2answers
134 views
Is using interfaces on internal code a good idea? [duplicate]
I'm working on a set of automated tests that we use internally at work. Lately, we've been designing classes that implement interfaces in addition to inheritance.
As I understand it, interfaces in ...
6
votes
1answer
211 views
How to hide AOP implementation dependency without breaking encapsulation?
I have the concept of a SlowLoading thing:
public interface SlowLoading {
boolean hasLoaded();
}
I also have a component MyComponent:
public interface myComponent{
void doSomething();
}
My ...
0
votes
2answers
128 views
c# naming - What are common conventions for a suffix to distinguish between read-only and writable interfaces [closed]
Assume an interface that allows queries on a spatial tree
public ISpatialTree
{
int FindChildIndex(Vector point);
bool IsLeaf { get; }
ICollection<ISpatialTree> Children { get; }
}
...
2
votes
1answer
84 views
Interface hierarchy design for separate domains
There are businesses and people. People could be liked and businesses could be commented on:
class Like
class Comment
class Person implements iLikeTarget
class Business implements iCommentTarget
...
5
votes
5answers
204 views
How to enforce implementation of interface to behave a certain way
Suppose you had the following interface
public interface IUserRepository
{
User GetByID(int userID);
}
How would you enforce implementers of this interface to throw an exception if a user is ...
0
votes
2answers
128 views
Interface method signature not restrictive enough
I wrote a piece of code at my job sometime ago. While writting the code I wrote few interfaces who would allow me to add more flexibility and at that time I was also trying to understand OOP concept ...
13
votes
3answers
604 views
Why are interfaces more helpful than superclasses in achieving loose coupling?
(For the purpose of this question, when I say 'interface' I mean the language construct interface, and not an 'interface' in the other sense of the word, i.e. the public methods a class offers the ...
3
votes
1answer
98 views
Different scoring algorithms for different competition elements
I am creating a scoring system for a competition that is somewhat obscure, but it resembles the Olympics in terms of its high-level structure. Therefore, I will ask my question in terms of an ...
3
votes
2answers
151 views
How to manage memory in C interface for C++ implementation considering c++11?
I have a library implemented in C++ which has a C interface. This C interface is, for all intents and purposes, the only way to use this library. C++11 seems to discourage the use of raw pointers but ...
1
vote
1answer
158 views
Should I use inheritance or an interface?
So in a nutshell I have an abstract class :
public abstract class Member
{
public string PCode { get; set; }
public string Reference { get; set; }
public DateTime? ElectedDate { get; set; }
}
And ...
1
vote
3answers
122 views
Empty superclass for Collection of derived classes
Basically, what I would like to obtain is a way to iterate through ONE list, and call methods specific to the interface the objects in the collection implement.
In my Java project, it would result in ...
0
votes
2answers
82 views
UML Class Diagram: Abstract or Interface?
I am modeling a class diagram and have spotted an opportunity to simplify it slightly. What I want to know is, would this it be better to implement an abstract class or an interface?
The scenario is ...
1
vote
2answers
248 views
Go-like interfaces + multi-methods make sense?
Thinking about the design of a potential new language, I wonder how related are the concepts of built a OO similar to GO interfaces and multi-methods (I get this from ...
0
votes
1answer
92 views
When is it suitable to use inheritance [duplicate]
I recently had a small "argument" about inheritance with a friend. I think people overuse it a lot. Intuition tells me that that the only good reason for class inheritance is polymorphism - when there ...
0
votes
1answer
89 views
Can a Java interface declaration enforce parameter properties?
As far as I know, declaring an interface is like so:
public interface Roots_Squares {
public double square_root( double value );
}
Now... how do you enforce value to have non-negative values? ...
0
votes
3answers
178 views
Necessity of Interfaces for Small Projects
Is it necessary to use interfaces for small projects? I work at a shop writing small custom applications for clients, primarily data manipulation. I'm mostly self-taught but also took some programming ...
2
votes
2answers
107 views
Segregating interfaces/concerns to a tree
When working with a single object there are a number of ways to segregate interfaces to it.
Breaking it into smaller components that can be treated independently.
Breaking it into simpler ...
1
vote
3answers
237 views
Why are inheritance and interfaces restricted to instance members?
Disclaimer: I think the rules are almost the same in most OO languages, but since I'm most familiar with C# I'll be relating to this specific language.
I think that the use of attributes and ...
0
votes
3answers
129 views
Is declaring STL variables in a class definition too revealing?
If you are trying to hide implementation, would declaring STL variables be too revealing?
// in Word_Bucket.h
class Word_Bucket {
private:
std::vector<std::string> contents;
...etc
}
...
0
votes
1answer
136 views
How to use namespaces to separate interface from implementation, in c++?
As far as I can tell, you can make your interface known to others by providing your .h file. Your .cpp is the implementation. Then they can see the function names, the parameter types, the return ...
2
votes
2answers
287 views
Implementing the Interface Segregation Principle
Does this IConvertible interface satisfy the Interface Segregation Principle (ie. the "I" in SOLID)?
Here is the definition:
public interface IConvertible
{
TypeCode GetTypeCode();
bool ...
0
votes
1answer
49 views
Inverse of Extract Interface refactoring
I'm working with a Java project that has several interfaces, many of which have only one implementation. (See related question)
For a given revision of the software, one could think this acceptable ...
0
votes
0answers
39 views
What should I do with too much interfaces needed for a dialog
Let me start by doing a small summary of the changes we did in our code in the last year. We have a software (VERY big) that is used to visualize multiples underground networks, enter data in the ...
44
votes
10answers
4k views
Is better Show() + Hide() or SetVisible(bool visible)?
What is better and why? (From interface-design point of view) :
a) To have two Show() and Hide() functions
b) To have one SetVisible(bool visible) function
EDIT: For example some object have ...
3
votes
3answers
1k views
Why were default and static methods added to interfaces in Java 8 when we already had abstract classes?
In Java 8, interfaces can contain implemented methods, static methods, and the so-called "default" methods (which the implementing classes do not need to override).
In my (probably naive) view, there ...
2
votes
4answers
295 views
Understanding “programming to an interface”
I have come across the term "programming to an interface instead of an implementation" a lot, and I think I kind of understand what it means. But I want to make sure I understand it's benefits and ...
-1
votes
3answers
205 views
Regarding interfaces of classes in OOP
When one says "a class' interface":
Does he/she refer to all of the get and set methods - or do they refer only to the methods' signatures and return types, without the inner implementation of these ...
0
votes
2answers
113 views
Using interfaces as part of encapsulation
I'm creating interfaces for a number of our existing classes for mocking reasons. Many of these classes also have package scope methods as an attempt to give some level of encapsulation by ensuring ...
0
votes
1answer
310 views
Does it make sense to break fluid interface if a bad argument is passed?
If I chain some setters together and one of them does not return $this, then I will get a fatal error. But maybe that is a good thing.
$object = new object();
...
-4
votes
1answer
134 views
what is the main utility of Interface in real world programming (OOPS) [duplicate]
what is the main utility of Interface. we know that we can implement dynamic behavior using interface but i guess it is not only the utility. so i like to know when we have to write interface and when ...
-1
votes
1answer
30 views
delivering ebook throught mobile app [closed]
I have designed the interface of a mag app which would deliver digitized magazine in the size of A3 paper to the mobile phone.
My choice of fileformat is jpg of each of the pages, but is there any ...
0
votes
0answers
48 views
Use Objective-C protocols like Java interfaces [duplicate]
I'm a Java developer moving to Objective-C.
So far in Objective-C I've seen protocols used extensively to implement the delegate pattern, but I haven't seen then to add a layer of abstraction in the ...
1
vote
3answers
102 views
Refactoring - Utility classes behavior under a common interface
I was suggested to put my question here, so I'm doing so ;)
I need a common interface which represents some specific behavior:
public interface Contract(){
public void methodA();
public void ...
1
vote
2answers
213 views
Interface Segregation Principle - type hinting multiple interfaces
The question is about typehinting of the role interfaces.
The code example has two DataMappers which typehint the interface they need in the constructor,
FooDataMapper type hints the Preparable ...
0
votes
1answer
85 views
Naming interfaces for persistent values
I have 2 distinct types of persistent values that I'm having trouble naming well.
They're defined with the following Java-esque structure, borrowing Guava's Optional for the example and using generic ...
0
votes
1answer
247 views
The real difference between web and native apps in mobile and smart devices [closed]
I still don't understand the difference between a native app and web or hybrid apps from the interface point of view. Now, apps such as Twitter, Facebook, etc. Are they native? or web? or hybrid apps? ...
2
votes
1answer
145 views
Using partially implemented interfaces
Consider the following hierarchy in C++ notation:
class A
{
public:
virtual void doStuff()=0;
virtual void doOtherStuff()=0;
};
class B:public A
{
public:
...
3
votes
4answers
710 views
Which methods should be put in an interface and which in abstract classes?
I have seen many frameworks and modules and their standard they follow is like this
UserInterface which have some predefined methods
AbstractUserClass which implements userInterface
Then ...