Questions tagged [interfaces]

Questions about interface related design considerations, such as programming to the interface.

Filter by
Sorted by
Tagged with
0
votes
0answers
163 views

Can I keep my code loosely coupled with public-facing enums?

I have some enums in a concrete API/library that will be publicly used by application projects. My problem here, is that I cannot write an interface to these enums (that I know of). I should have ...
0
votes
1answer
461 views

Coding to an interface vs more generic interfaces

I have a number of classes (and interfaces) which 'code to an interface' interface File { ... } interface FileConverter { public function convert(File $file); //coding to an interface ...
0
votes
0answers
53 views

Restructuring similar interfaces to one unified design

In my project, I have several types of Web API controllers (and their corresponding services and repositories). When I started out, I made an interface of a generic type that would describe the basic ...
0
votes
1answer
137 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
0answers
71 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 ...
0
votes
1answer
569 views

Android, using a Fragment to hold/edit complex object, accesible from any Activity

I'll do my best to describe the problem, but I'm still very new to several concepts that I think this problem requires to be solved (namely interfaces and threads). I should preface this by saying ...
0
votes
2answers
1k 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
3answers
395 views

How do I support interfaces for different devices in the same input scenario?

I asked this question on SO but someone pointed out that I would be better off here. He's most likely right. So here I go! So I just wanted an opinion. I have 2 different ways to approach the problem....
-1
votes
3answers
240 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 ...
-1
votes
2answers
293 views

Programming beginner: Options for small program interfaces? [closed]

I have been a Rails developer for a year now, and I really want to start diving in to Ruby and pure programming without using a framework. However I am having trouble conceptualizing little programs I ...
-1
votes
1answer
88 views

add new class that implement base interface but need one more parameter

I have few strategy class that calculate ranking. Those class implements interface with method scoreUpdates. Method scoreUpdates take two parameters( winners and lossers). Now i need add new ...
-1
votes
1answer
183 views

Does Interface Segregation Principle apply to parameters/request objects?

I have recently seen an example of what I think is a clear violation of ISP, but my colleague argued it is easier to use. This is what happened: We had Options class that had 2 fields sent as a ...
-1
votes
2answers
143 views

How should i pass a generic filter for database queries?

I have a interface DataStore, which provides access to a generic data store, e.g. a local database, webserver, etc. I want to provide a way to filter results directly in the query. How should i pass ...
-1
votes
1answer
302 views

The pythonic way: replacing interfaces with ducktyping vs inheritence

tldr: I have consumer-like classes that require a number of pieces of information to do their job. It's an "all or nothing" kind of thing: the "producers" providing them with data need to provide all ...
-1
votes
1answer
41 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 ...
-1
votes
1answer
73 views

serving up future-proof kinfolk - extensible contract interfaces [closed]

Ok, I have this human here, but what can it do, how would you discover its special abilities? And when you find out what kind of expert you've got then how would you actually make use of its unique ...
-1
votes
1answer
176 views

Enable access to objects via Introduce Parameter Object or interface

I am working with multiple commands that are executed in order (and possibly have sub commands as well) which can be desribed like this: interface ICommand { void Execute(); } abstract class ...
-2
votes
1answer
137 views

UML class diagrams - how do I draw a class diagram that shows a self-reference? [closed]

So I have the following case. I have an interface A and an implementation AImpl. Now I have another implementation of A, called A2Impl, which references any instance of A besides implementing A ...
-2
votes
2answers
56 views

Interface name for time-based classes

I'd like to document that code encapsulated in a class is "time-based" in a Java-like language – the code behaves differently based on what time it is currently. To make it testable, it would read ...
-2
votes
2answers
3k views

Separate interface from implementation

What is the meaning of separating interface from implementation in C++? And also what is implied by interface and implementation?
-2
votes
1answer
198 views

How do you distinguish your public API interfaces from the interfaces you use for testing/mocking?

Mocking frameworks are useful for creating mock objects that isolate the code under test from its surrounding software environment. Some mocking frameworks cannot mock non-virtual methods, so they ...
-2
votes
3answers
564 views

Can I say Interface is a set of general behavior? [duplicate]

I'm new to OOP. Can I say Interface is a set of general behavior that may be have and act uniquely by a set of objects that have in common? And Abstract class has similarity with Interface but it have ...
-2
votes
1answer
137 views

Programming to an Interface and Keep Testability in Unique Classes [duplicate]

I try to program to an interface whenever possible, but when I have a class that fulfills a very specific and unique purpose, one that can't be abstracted. Is it correct for me to say that I've ...
-3
votes
3answers
1k views

Programming to interface in Java [duplicate]

What is the real use of interfaces in Java? What is meant by programming to interfaces? I heard these things several times but I don't know what it is and why it is used.
-3
votes
1answer
1k views

How to decouple a dependency

I am trying to decouple a dependency from Book Class to BookStorage, but got confused how to do this right. Can someone tell me how to decouple this correctly? Here is my code: public interface ...
-3
votes
1answer
120 views

How can interface work, if there is no code inside its abstract methods?

Interface is used to implement more than one class but it doesn't have any code inside its methods... however the method that is called works with its respective function. Also, it gets very confusing ...
-3
votes
3answers
71 views

Naming: How do you call an interface that allows to retrieve items?

Let's say a client need to get a list of products from somewhere. He does not care if that list comes from a cache, from a remote database, from a local database, from the resources or from the remote ...
-3
votes
1answer
1k views

Why can't I return an implementation of an interface for a method that requests the interface? [closed]

I am implementing an interface I on a class A. Class A implements I. I have an Iterator T that is supposed to return an object which implements I everytime I call next. My iterator goes as follows (...
-4
votes
2answers
184 views

Advantages of these recommendations in ooprogramming using Java

Below are the recommendation from section 5.1 of this essay. While Java is not a pure object-oriented language, it is possible to program in a pure object-oriented style by obeying the following ...
-7
votes
2answers
305 views

Why are interfaces in Java called that way?

I have been a developer for past 3 years and I have been seeing interface in most of the places as a contract for the developers to write their own implementation or a marker (eg. Serializable). But ...