Questions tagged [interface]

Object interfaces allow you to create code which specifies which methods a class must implement, without having to define how these methods are handled.

Filter by
Sorted by
Tagged with
2 votes
1 answer
61 views

API design for Implementing NaN/Unknown values for custom numeric type

I'm gradually writing an arbitrary-precision arithmetic library for C++. I've decided it could be useful to have the default constructor produce an object of indeterminate value, rather than relying ...
saxbophone's user avatar
1 vote
1 answer
65 views

Take meal orders from breakfast, lunch and dinner menus

I have an exercise requires me to write a service to management menu. The requirement like this: Food menu includes: breakfast menu, lunch menu, dinner menu. The three menu haves list menu item( name, ...
David Moore's user avatar
4 votes
0 answers
96 views

Determine when a file is no longer being changed by hashing

I have a requirement to essentially scan a filesystem on any kind of filesystem and move a resource whenever it is ready. To do this I have the following code ...
Patrick Christie's user avatar
4 votes
0 answers
99 views

Injectable EventLogger for custom application events that are handled differently from normal logs

I am trying to become better at designing classes for dependency injection and IOC in general. It is often not an intuitive concept. I have the following python interface and implementation for a ...
Patrick Christie's user avatar
1 vote
0 answers
81 views

Hashing service for files or directories on a generic filesystem [closed]

my program requires a hash to be generated for files and folders for data integrity between transfers and file system events (if hash is different, file is not ready). For data integrity, I wish to ...
Patrick Christie's user avatar
6 votes
1 answer
1k views

Date range generator

An app has a feature that's much like any calendar application (like the Outlook calendar for example). Consequently, I need to do a lot of date logic. I wrote a class with date calculation methods ...
user2190492's user avatar
1 vote
1 answer
95 views

Java: Using one class or algebraic data types to model different state?

I'm creating a tool to analyze a card game which is played by three players. A Card is associated with a number of points and looks like this: ...
user253872's user avatar
1 vote
0 answers
120 views

.NET Repository Pattern

I'm currently in the process of defining some framework, one of the first things that I thought I could start with was defining some repository pattern/layer. I generally wanted some input on it, ...
JO3-W3B-D3V's user avatar
-1 votes
1 answer
61 views

implementing abstract classes vs interfaces [closed]

I am new to using interfaces and abstract classes. The team I am working with came up with an implementation of what they call a base class that will be implemented by all view model classes. This is ...
user1181226's user avatar
3 votes
1 answer
142 views

Lightweight interface implementation in Python 3 using abstract classes

Here is my take at a lightweight interface implementation, where I focus on discoverability of suitable classes from strings (for simplicity, class name is used as an id). Each interface has it's own &...
Roman Susi's user avatar
-1 votes
2 answers
181 views

A simple java game engine [closed]

I'm starting an object orientated game engine in Java. My plans for the engine is to be able to split things easily into multi-core loads. My idea is that a Unique (interface with a ...
tuskiomi's user avatar
  • 185
2 votes
2 answers
84 views

Registering listeners according to SOLID pricipals

I'm practicing oop concepts these days. To figure it out I tried the below problem. There is a sensor monitoring system. It is a simple system that prints a value, ...
Neminda Prabhashwara's user avatar
0 votes
0 answers
28 views

Filtering methods for 3 collections

I'll start by saying that I just started learning Go coming from Python (and some basic on Java), so I am trying to understand how to write Go code in more idiomatic way and not in a Python way. Any ...
Przemyslaw Wilk's user avatar
2 votes
1 answer
38 views

Typescript : Adding types to a function that takes in a string and returns a different promise based on the string

I have a function that takes in a string and based on the string hits different APIs to fetch images. I have solved it by writing an interface and then as the return type of the function, it returns a ...
rakshith's user avatar
5 votes
2 answers
448 views

Best approach for the Design Pattern for multiple schedulers using interface and abstract class

I have a requirement to fetch data for different types of Users (Customers, Publishers etc) for three different timelines (retro, current, and past), all have different URLs. There is a scheduler ...
Pankaj's user avatar
  • 151
0 votes
1 answer
366 views

Composing functionality of sealed class with interfaces

...
JPtheK9's user avatar
  • 103
4 votes
1 answer
943 views

multiple inheritance in c++ to implement different interfaces

I am working on a finite element (FE) code and want to provide multiple material models (20+). In FE applications, the computational domain is subdivided into a set of geometrically simple elements, e....
StefanKssmr's user avatar
0 votes
3 answers
213 views

Using "Generics" to implement "Unit Of Work"

I need to design a generic "Unit Of Work", basically so that I can "change the context of the Database" only changing the implementation of ...
Igor's user avatar
  • 172
7 votes
4 answers
1k views

IService<T> or defining IProductService, ICustomerService

As per tutorial here, I have the following classes: (In reference to this tutorial's section) ...
taylorswiftfan's user avatar
7 votes
2 answers
132 views

Refactoring validator system

I've validator system that validates input data before saving to DB. So let's say I want to create new user. We are at the service class: ...
makiz1234's user avatar
3 votes
3 answers
230 views

Returning interfaces in Java without significant casting

I am writing some code that takes and returns interfaces following the patterns in Effective Java Third Edition. I understand the principle - we want to take in interfaces because in many cases we don'...
CL40's user avatar
  • 133
4 votes
1 answer
1k views

Interface class for SQLite databases

I am learning the basics about managing an SQLite database by using Python and, mainly for practice purposes, I have then defined an interface class in order to let operations on database as clear as ...
rudicangiotti's user avatar
1 vote
0 answers
63 views

Code for creating a dialog for choosing a date

I have code that creates an AlertDialog to select a date by a user. I ran into a problem that this code began to take up a lot of space. Could you offer ideas on how to shorten this code / put it into ...
Destroyer's user avatar
  • 427
-2 votes
1 answer
541 views

C++ generic task interface for delayed execution

I want to rework my current game-server engine to use some global queue of tasks which will be distributed through all the working threads. I started with task interface. I want it to be able to ...
Piodo's user avatar
  • 97
1 vote
1 answer
2k views

Should Golang interface be shared among different packages of an application?

I'm developing a Go application that has lots of packages. Many of the packages use the same type from a 3rd party library. Should an interface be defined for the type in each package, and let the ...
someone's user avatar
  • 29
4 votes
1 answer
183 views

Architecture Logging

I have two database tables UsersDownload, Non-UsersDownload. There is also two model object and two service that take in the object and insert the data into the correct table. Is this the best ...
Jefferson's user avatar
  • 357
0 votes
1 answer
67 views

Schedule talks in tracks [closed]

Consider my simple business requirement as follows: There is a list of talks and they need to be scheduled in tracks. Each track has a morning session starting at 9am and an afternoon session starting ...
Rahul Chakrabarty's user avatar
3 votes
1 answer
754 views

C# REST / Http Client Abstraction

I have a REST library. These are the abstractions. Have I missed anything that a developer would need to use this in a dependency injection / IoC Container scenario? Anything that bothers you about ...
Christian Findlay's user avatar
4 votes
0 answers
315 views

C# Dictionary Wrapper for VBA

I am a technical reviewer/writer and I use VBA for Word a lot to manage issues in Word documents I receive. I have frequently come across niggles when using Collections, Scripting.Dictionaries or ...
Freeflow's user avatar
  • 645
6 votes
2 answers
243 views

Opposite access to enums

Consider I have many enums (Java) that looks somewhat like this: ...
Hallel's user avatar
  • 163
10 votes
0 answers
2k views

Geode Contents Predictor StardewValley Mod

The goal I really enjoy the game Stardew Valley. One of the things that the game has are geodes. Much like real-world geodes, these geodes can be cracked open, and you can find some fun things inside....
Dan Oberlam's user avatar
  • 7,744
5 votes
1 answer
175 views

Manage Excel Styles with VBA OOP Approach (Follow up)

This is a follow up to this question Code incorporates Mathieu's comments and it works. As some parts of the review left some code to my knowledge, I ask for another review to see if I implemented ...
Ricardo Diaz's user avatar
5 votes
1 answer
216 views

Manage Excel Styles with VBA OOP Approach

I want to manage the Excel Styles in a more flexible way with bulk actions and at the same time improve my newly acquired OOP concepts. Objectives: Load the current Styles list (name and type=...
Ricardo Diaz's user avatar
4 votes
2 answers
2k views

Drag and drop selected array items in Javascript

I've written a function that moves selected items from a list into a new position. I've found that in order to do this, I need to retain the original 'index structure' of the array. The way I've done ...
concealed curry's user avatar
2 votes
1 answer
117 views

Interface and inheritance; creating download types for a download manager

I'm creating a download manager in C# (in combination with Unity 2019.1.8, running the .NET 4.x equivalent (MONO) scripting back end). To accomplish this I decided to start using interfaces and class ...
Remy's user avatar
  • 289
1 vote
2 answers
163 views

Parcel size classifier [closed]

I submitted a technical assignment for a job interview process and I am stressing out wondering if my submission was any good. I would like to learn and be a better developer, so please give me ...
Javed's user avatar
  • 29
4 votes
1 answer
153 views

Factory pattern for creating embossing machines

I'm working on a program that creates a file for a specific embosser machine (machine that creates plastic bank card for example). I have 3 embosser machines and all of them create different files. ...
TJacken's user avatar
  • 291
5 votes
1 answer
43 views

CandidateArchive for model-assisted multi-fidelity global search algorithm

For my research I'm working on global search methods where a candidate solution can have it's fitness (=score) evaluated in multiple fidelities (=accuracy levels). The goal of the ...
Energya's user avatar
  • 190
4 votes
2 answers
725 views

Displaying IP addresses in Go using Stringer interface

I am trying out some Go code examples (while coding a private project) to get more "in-depth" knowledge about the language. I have come across an exercise from the Go Tour website about displaying ...
Guilherme Ferreira's user avatar
0 votes
1 answer
50 views

proper structure of classes using interface classes [closed]

Given the following two interfaces what would the proper way to set up the two actual classes? ...
John S's user avatar
  • 111
3 votes
2 answers
269 views

Mario Party Snake and Ladders Board

Context Was inspired from this LeetCode post to do my own System Design exercise of the common Snake and Ladders problem. As I was writing the code Mario Party kept coming to mind so I added a little ...
greg's user avatar
  • 1,017
2 votes
1 answer
78 views

Rendering elements (which can change numbers) using jQuery

Currently when the user selects some tags in my app I generate them in a function, like this: ...
Aerodynamika's user avatar
3 votes
2 answers
119 views

Infinite and countdown counters

I'm refactoring my scheduler and for one of its triggers I need an endless counter that would automatically restart. Since this is a simple and very common task I don't want to ever have to implement ...
t3chb0t's user avatar
  • 44.1k
1 vote
0 answers
487 views

Simple Serial Port Windows Interface

I implemented a very simple blocking uart interface. Most of the serial instruments I interface with are master/slave and I have to wait on data to proceed forward. I am contemplating add some ...
Eddie C.'s user avatar
20 votes
5 answers
4k views

House plan design (Head First C#)

I've been working through the book Head First C# and this is an exercise from chapter 7, which is about interfaces and abstract classes. Note that the class design was mandated by the authors, I'm ...
Phrancis's user avatar
  • 20.3k
4 votes
1 answer
8k views

Writing to a file in Golang across concurrent go routines

I've been reading around how golang writes to a file, and this stack overflow question and this reddit question highlights the fact Go doesn't gurantee atomicity when writing to a file system. ...
Rambatino's user avatar
  • 243
0 votes
1 answer
102 views

Functional List in C++ [closed]

This is rather toy example of immutable datatype in C++. I've tried to follow functional languages like Scheme, Racket - making list as a cons cell: list is list or is empty. ...
Robert Hanigan's user avatar
5 votes
1 answer
132 views

Service for generating faked objects

I'm using the Bogus library to mock up some data for testing. This is my main method demonstrating how the faking service should be used: ...
TomSelleck's user avatar
1 vote
1 answer
48 views

Proper naming for objects which have a position and bounds on a plane

I have an interface which is for an object which has bounds in a 2D plane. ...
Adam Arold's user avatar
2 votes
1 answer
383 views

Handling related generic type parameters

In answering a question on StackOverflow, it occurred to me that a more generic version of GroupBy for C# that delegated membership in each group to a class could ...
NetMage's user avatar
  • 412