Questions tagged [interfaces]

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

Filter by
Sorted by
Tagged with
1
vote
1answer
89 views

An interface for designing Arduino code

Often I want Arduino board to control several peripherals. Writing program for all of them in one document using #define SOME_PIN 4 constructions seems pretty inconvenient to me. Especially in such a ...
2
votes
3answers
515 views

What is the name of this pattern (if any)?

There's a sort of pattern that I've sort of stumbled myself into "discovering" that seems extremely useful, but I've never seen it described before. It's sort of a way of achieving inheritance through ...
0
votes
2answers
188 views

Complex interfaces in multilayer project

In my C# project I need to swap data providers in the future so I have created interfaces to build future providers off of. But this is the first time I have worked with interfaces that are "complex" ...
1
vote
1answer
227 views

How to represent a specific type of interface dependency in component diagram?

I'm currently having a hard time with creating a component diagram that should represent a certain type of component/interface dependency and hope that you can give me some hints. As background, I ...
4
votes
3answers
424 views

Decoupled design using static interfaces

Now first I want to mention that I am not quite sure what is the term describing the issue at hand but I hope that I can illustrate it with some code. Problem: A shared class library defines an ...
0
votes
1answer
59 views

What to specify as interfaces in component diagrams

I am following the textbook Object oriented software specification using UML, patterns and Java (3rd edition) and I am defining interfaces between system components (subsystems). But I encountered a ...
2
votes
1answer
161 views

Abstraction for Account transactions and balance

We have 10 applications which updates account balance table, without logging credit/debit line transactions (not sure why). They all have the pretty much same SQL Statement. In order to get out of ...
0
votes
1answer
75 views

Would you implement an interface to connect to a database?

I found in a book (Learning PHP Design Patterns, Chapter 2, page 25) a text explaining the importance of interfaces in OOP design. The author ended up by giving this example: <?php interface ...
4
votes
5answers
776 views

Newbie question: Should all class public methods come from an interface?

I'm currently learning about TDD techniques, one of the suggestion is to test only public methods and skip the private ones. I have also been reading about Mocking. If I want to mock a certain method, ...
4
votes
4answers
241 views

Should custom exceptions live with the interface or the implementation?

I have an interface IMyService in a class library. I have an implementation of this interface MyService in a separate class library. MyService may raise a custom exception CustomException. Should ...
0
votes
4answers
1k views

Avoiding vtable pointers in objects in C++

In my previous question, it was highlight that implementations of C++ such as GCC must store a vtable pointer in every copy of a class for each parent class which has a virtual function. So a class ...
0
votes
3answers
179 views

Implementing interface using class members

This was just a question I was wondering about in terms of best practice. I am writing a small C++ program that uses an interface to implement a function. In the class that uses the interface (i.e. ...
12
votes
5answers
4k views

Does it make sense to define an interface if I already have an abstract class?

I have a class with some default/shared functionality. I use abstract class for it: public interface ITypeNameMapper { string Map(TypeDefinition typeDefinition); } public abstract class ...
0
votes
2answers
155 views

Use case for interface

While going through some lecture video on interface. I noticed If we don't know about implementation, just requirement specification then go for interface. What can be the scenario? Though I've ...
2
votes
1answer
117 views

Whether to replace mutually exclusive but poorly related properties with an interface

A few years ago I designed a class which had two properties. The two classes ChildA and ChildB had a rich protocol with many properties and methods, but were only distantly related in my model. They ...
1
vote
3answers
2k views

C# How to avoid duplicate code with interfaces where objects have the same behaviour

So a simple example i have: public interface IFollow{ Transform Target {get;} void LateUpdate(); } public A : Monobehaviour , IFollow { public Transform Target {get; set;} public void ...
26
votes
2answers
4k views

Implementation of pure abstract classes and interfaces

Although this isn't mandatory in the C++ standard, it seems the way GCC for example, implements parent classes, including pure abstract ones, is by including a pointer to the v-table for that abstract ...
-1
votes
1answer
182 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
vote
6answers
717 views

How can I unit-test the presence of specific file contents, through an interface?

I am currently trying to test a file manager class. This class is responsible for keeping track of how long the file is good for. The file will have a date written into it that denotes when it was ...
2
votes
5answers
541 views

Interfaces Everywhere? - Best Practices [duplicate]

There is a discussion at work about the correct use of interfaces in OOP. I have been taught, and always worked from the premise, that interfaces precede concretions and all methods should be dealing ...
1
vote
2answers
153 views

Interfaces for CRUD Classes

In an in-house solution I've been working on, I've been unable to understand the benefit of how interfaces are frequently implemented throughout the project. Which is as follows: Want to do CRUD ...
1
vote
2answers
341 views

Implementing interfaces vs using a base class

I am writing an application in python. The part I am little confused about is providing a little structure to my code. This is the basic requirement of my web application. I have these different ...
-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 ...
1
vote
1answer
78 views

Interfaces for waypoints

I have a waypoint class which i use to connect a bunch of other waypoints up. But i also have a special type called a consumer, this is not technically a waypoint but it needs to act like one in that ...
0
votes
2answers
280 views

Use getter interfaces as a way to reuse DTO fields

Assume I have a lot of DTO for a same domain model like this: class User{} //DTO @Value.Immutable interface SimpleUserDTO { getName getAge } @Value.Immutable interface RegisterUserDTO ...
2
votes
1answer
74 views

Should I create seperate interfaces as a way to centralize annotation?

Assume I have these classes: @Entity @Data class Student{ @Size(min = 8) public String name; public int age; ... } @Data class StudentDTO{ @Size(min = 8) public String name; ...
0
votes
1answer
76 views

Avoiding concrete references, should expressing relationships be an exception to the rule?

I have a critical business object GroupMembership that represents the relationship between an user and a group. I have set an architectural policy that critical business objects should avoid ...
1
vote
1answer
2k views

Difference between header files and interfaces

I wanted to know whether the header files in c and c++ have same function as that of interfaces used in Java? If not what is the difference between header file and interface?
1
vote
3answers
267 views

Implementing an ILogger => how to make public some fields that are needed in specific implementation of Logger but not in others

I am implementing a custom ILogger (interface for logging) I have succesfully developed implementations of it with some famous loggers like Serilog or Log4Net. Now i want to create a memory logger, ...
7
votes
1answer
261 views

Should every method in a class be defined in an implemented interface?

I can see how interfaces are very useful to force different classes to have the same functionality. But there are also actions that are bound to a specific class (like updating an unique variable ...
3
votes
4answers
188 views

Circular Interface references

I've heard circular references are generally an issue, however I was wondering if this was true for interfaces that reference other interfaces, for example: IQuestion{ IAnswer getCorrectAnswer(); ...
0
votes
2answers
180 views

Hiding implementation framework usage in an API

I am currenctly trying to create an API for a UI framework, for a new application. This UI framework is internally implemented using an existing framework, let us say JavaFX. I want to hide the ...
1
vote
1answer
104 views

Struggling trying to create interface for Janrain-like services

We are using Janrain in our app, but I have to create an interface to make this service easily replaced (because Janrain is so custom!, it does have common things in Oauth however) However, I'm ...
6
votes
2answers
244 views

Common name for an interface that has Created and Modified fields

I'm trying to figure out is there a common name for object's interface if our intent is to show that this group of objects has date of creation and tracked dated of last modification. It is an entity ...
0
votes
2answers
278 views

Classes as parameters

I would like to write a data structure implementation in Java that uses caches as a core part of its functionality, and I would like the user to be able to provide their own cache implementations that ...
0
votes
2answers
4k views

Not implemented Methods of Interfaces [closed]

I found an interesting quote in my book with which I learn Java: Manche Methoden der in diesem Kapitel beschriebenen Schnittstellen sind in der Dokumentation als optional gekennzeichnet. Bei ...
2
votes
1answer
108 views

When should concrete public methods be used if implementing an interface?

Recently I have been trying to avoid down-casting object types from an interface type to their concrete types, and 'if' statements that check for an objects concrete type at run-time. This has made me ...
4
votes
1answer
98 views

Converting Interfaces to Sub types. Is this bad SE?

In the company I work for, I keep seeing IManager interfaces being converted into their real types and lots of "instanceof / TypeOf" if statement checks. For example: IManager manager // passed to ...
1
vote
0answers
25 views

How would I go about developing an interface that would allow integration of 6 other models?

I am new to programming, I have been trying to get my head around this. Context My project is about defining investment packages for various construction projects within a country based around an ...
6
votes
3answers
7k views

Writing 'interfaces' for static classes

I'm writing a postcode validation library, so that I can call a helper method var result = Postcode.IsValid(postcode, country) To that end I need to have 'classes' that represent supported countries ...
0
votes
3answers
192 views

Documenting my code using generic Design Patterns interfaces

Background I've been thinking about documenting design patterns in our code by setting up interfaces for the common design patterns so that when people read my code it would be clear that I am using ...
0
votes
3answers
349 views

Send records using async or sync way

I have bunch of keys and values that I want to send to our messaging queue by packing them in one byte array. I will make one byte array of all the keys and values which should always be less than 50K ...
3
votes
3answers
625 views

How to decouple code behind with business logic?

I'm having a hard time to decouple two classes. I have my code behind (will call it "class A") that I use to tweak the interface (defined in xaml). Next I have a class B that is only logic. But ...
1
vote
2answers
2k views

Can the Decorator pattern be used without an interface?

Most of the resources I've seen about the Decorator pattern look like the following: interface Tea { public double cost(); } class BasicTea implements Tea { public double cost() { return 1.99;...
1
vote
0answers
103 views

Can we break CQS to get some DRY?

In our codebase we have a lot of controllers with a very similar structure: @my_model.update_owner(something) if @my_model.update_attributes(params) return render_object(@my_model) else ...
5
votes
1answer
235 views

Properly integrate an IDL into multiple git repositories

IDLs like Protobuf, flatbuffers, Cap'n Proto or Thrift allow communication over standardised interfaces between otherwise independent projects. Most often, these projects will be developed in ...
1
vote
2answers
2k views

Why we use interface since we need to implement the method in our derived class [closed]

I have read the replies from those post(Why are interfaces useful?) and (Why use an interface when the class can directly implement the functions?), which is the similar question as my this post. But ...
0
votes
3answers
3k views

C# Implementing multiple, disparate interfaces in a single base class

(This is probably a dupe, but if so I haven't seen it yet, although it may be Best practice for encapsulating a parameter that requires multiple interfaces to be implemented, but that question doesn't ...
0
votes
1answer
57 views

How to name a function(non-default image orientation)?

I have a C++ interface for video provider. Frames can be rotated (Portrait/Landscape) as a result of platform-specific functions. enum class EFrameOrientation { KUp, // default orientation ...
11
votes
1answer
2k views

Why doesn't CharSequence define contains(CharSequence)?

This applies to to both Java SE & Android, as the contracts are identical. CharSequence documentation for Java SE CharSequence documentation for Android CharSequence does not define a contains(...