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

learn more… | top users | synonyms (1)

3
votes
2answers
94 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 ...
0
votes
1answer
138 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 ...
0
votes
1answer
71 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 ...
-2
votes
0answers
33 views

Application of Composition Inheritance and Interfaces A Model [closed]

For learing oop I opend a little project by myself. I like rollplaying so I choose to build a character generator. I guess it is quite similar to a online game character generator. I cannot explain ...
1
vote
3answers
96 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 ...
29
votes
6answers
3k views

Should interface names begin with an “I” prefix?

I have been reading "Clean Code" by Robert Martin to hopefully, become a better programmer. While none of it so far has been really ground breaking it has made me think differently about the way I ...
0
votes
1answer
97 views

Do C++ library developers only write C compatible interfaces as an afterthought? [closed]

I have developed the distinct impression that although C++ libraries are often developed for other slower languages to link with when performance is needed, some feature known as name mangling and ...
0
votes
1answer
44 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 ...
0
votes
2answers
93 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
87 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
74 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
164 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 ...
1
vote
2answers
59 views

Segregating interfaces/concerns to a tree [duplicate]

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
212 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
123 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
157 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(); ...
0
votes
1answer
77 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
235 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 ...
41
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 ...
0
votes
1answer
42 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
1answer
64 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
0answers
36 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 ...
1
vote
3answers
359 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
274 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
197 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 ...
-4
votes
1answer
98 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 ...
11
votes
9answers
4k views

Default vs Impl when implementing interfaces in Java

After reading Should package names be singular or plural? it occurred to me that I've never seen a proper debate covering one of my pet peeves: naming implementations of interfaces. Let's assume ...
-1
votes
1answer
28 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
2answers
146 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 ...
1
vote
3answers
87 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 ...
4
votes
4answers
3k views

Instantiating Interfaces in C#?

I am reading/learning about interfaces in C# at the moment, and thus far I managed to understand how it differs from an abstract class. In the book I am reading the author explains that interfaces are ...
1
vote
1answer
260 views

Interfaces, Adapters, exposing business objects via WCF design

I know there have been countless discussions about this but I think this question is slightly different and may perhaps prompt a heated discussion (lets keep it friendly). The scene: I am developing ...
0
votes
2answers
153 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
139 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
622 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 ...
4
votes
5answers
194 views

Loose coupling and shuffling dependencies

I have a bunch of classes that look something like this: public class MyGame() { private Graphics graphics; private Player player; public MyGame() { graphics = new ...
5
votes
3answers
273 views

Interface at the class or function level?

I have been falling into a pattern lately where I have been defining routines that rely on an interface defined by a function that is specified as a parameter to the routine. (The language is C#, but ...
-1
votes
2answers
152 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 ...
2
votes
1answer
262 views

How does dependency inversion principle work in languages without interfaces?

In C#/Java, the dependency inversion principle is often demonstrated by high-level classes that depends on an interface/abstraction (that it owns). Low-level classes will implement the interface, thus ...
25
votes
2answers
2k views

What is the name of the following (anti) pattern? What are its advantages and disadvantages?

Over the last few months, I stumbled a few times over the following technique / pattern. However, I can't seem to find a specific name, nor am I a 100% sure about all its advantages and disadvantages. ...
11
votes
12answers
2k views

Is “If a method is re-used without changes, put the method in a base class, else create an interface” a good rule-of-thumb?

A colleague of mine came up with a rule-of-thumb for choosing between creating a base class or an interface. He says: Imagine every new method that you are about to implement. For each of them, ...
8
votes
5answers
543 views

Should I write an interface API before an implementation?

I've been delving into more "organized" programming recently and I've been learning that I should be programming to an interface, not an implementation. With that in mind, would it be better to ...
0
votes
0answers
56 views

Study on designing user prompts (choice of wording, response format, etc.)

Sometimes there are different ways to ask a user the same question. For example, if the user tries to exit a program without saving their file, you can ask either of these questions: Are you sure ...
1
vote
1answer
253 views

Interface Dependencies or Abstract Classes

I have a decision to make and I am wondering what would be the better solution. I am refactoring an older application and intend to really get into the nuts and bolts of it. There are 8 report types ...
2
votes
6answers
1k views

Design Patterns - Why the need for interfaces?

OK. I am learning design patterns. Every time I see someone code an example of a design pattern they use interfaces. Here is an example: ...
0
votes
0answers
64 views

Software Architecture and MEF composition location

Introduction My software (a bunch of webapi's) consist of 4 projects: Core, FrontWebApi, Library and Administration. Library is a code library project that consists of only interfaces and ...
1
vote
4answers
462 views

Explanation of the definition of interface inheritance as described in GoF book

I am reading the first chapter of the Gof book. Section 1.6 discusses about class vs interface inheritance: Class versus Interface Inheritance It's important to understand the difference between ...
2
votes
2answers
256 views

Class design for calling “the same method” on different classes from one place

Let me introduce my situation: I have Java EE application and in one package, I want to have classes which will act primarily as cache for some data from database, for example: class that will hold ...
4
votes
1answer
106 views

C programming multiple storage backends

I am starting a side project in C which requires multiple storage backends to be driven by a particular piece of logic. These storage backends would each be linked with the decision of which one to ...