Questions tagged [abstraction]

Use this tag in reference to either hardware abstraction, such as how Windows can use the same APIs even on different hardware, or any other method where the reality is separated from the user-level programs by software. This should not be used for emulation.

Filter by
Sorted by
Tagged with
2 votes
3 answers
153 views

Is it necessary or "class obsession" (opposite to primitive obsession) to create classes for non-business fields?

I know there are some posts talk about primitive obsession : When is primitive obsession not a code smell?, Is "avoid the yo-yo problem" a valid reason to allow the "primitive obsession&...
wcminipgasker2023's user avatar
2 votes
3 answers
376 views

C++ Is it okay to use nested classes as a way to namespace derived classes?

I have many abstract classes that describe many abstract ideas and objects. These classes have many complex relationships with each other, and I realize that while writing code with some of the ...
nreh's user avatar
  • 151
-2 votes
1 answer
201 views

How to create a cross-platform class abstraction?

I have been struggling with how to create an "object-oriented" cross-platform abstraction. In C++, a class requires a certain amount of coupling between its interface (i.e., public methods) ...
Patrick Wright's user avatar
0 votes
1 answer
67 views

How to seamlessly interact with a message broker when the underlying system (SQS, RabbitMQ) can change depending on the environment?

Having a poor knowledge of the extended features of the available message brokers, I was wondering how to approach this. We have some environments where only RabbitMQ is available, others where ...
kant312's user avatar
  • 111
1 vote
2 answers
120 views

Strategies to abstract away technical details when dealing with transactions

I like programming in such a way that every component/injectable of the applications I build, has a clearly defined scope, and it's easily tested. With years working as a Developer I've come to ensure ...
caeus's user avatar
  • 129
0 votes
0 answers
140 views

Designing long running background jobs that are part of domain language

I am going to type out my problem in terms of my domain use case; When an Operator has an Ingest with a valid Dataset (Lowside, Drive and EntryPoints selected), they will opt to then Scan the Ingest. ...
Patrick Christie's user avatar
0 votes
0 answers
51 views

Auth0 Middleware Layer Abstraction

I am currently spearheading a project to rearchitect our authentication, and we've signed on with Auth0 as a vendor that will manage the authentication component (for the time being - authorization ...
DeeKayy90's user avatar
  • 101
2 votes
2 answers
201 views

Should I abstract function calls with duplicate arguments?

I have an intuition, that I'd like to read what others have talked about. To me, it seems fairly intuitive that when you have a function which is called multiple times with the same arguments, it ...
Thiago Pereira Maia's user avatar
1 vote
2 answers
236 views

Should I stop using jQuery and create custom abstractions?

I'm a junior web developer. My current work is on a form-based server side web application. It was set up using jQuery. I'm now the primary person working on it. In a previous job, which was more ...
pikachu's user avatar
  • 19
16 votes
7 answers
4k views

Where should interfaces be used?

One thing I've long struggled with being able to grasp properly is, when designing a program in an object-oriented language, where and how should explicitly named/defined interfaces be added? In ...
The_Sympathizer's user avatar
0 votes
2 answers
131 views

Externally relying on the method call of the DI class means introducing a dependency on the implementation detail?

So I've got a class that calculates a discount (Let's call it class "A"). It has a price fetcher class as a dependency (constructor injection) (Class "B"). The price that is ...
pro100tom's user avatar
  • 449
0 votes
0 answers
41 views

How to handle ISR callbacks when writing a Hardware Abstraction Layer (HAL)?

I'm writing a Hardware Abstraction Layer (HAL) to abstract a hardware peripheral on an mcu. The driver peripheral looks like this. Driver module. Includes hal.h void drv_init(void); void drv_set(int x)...
ProgrammingPort022's user avatar
0 votes
2 answers
119 views

How to design relationships with constraints on subclass type?

I'm developing a full-stack Rest application following a narrative description of a working context. There is a class Job with two subclasses Job_A and Job_B. Job_A produces Report_A while Job_B ...
Wippo's user avatar
  • 109
0 votes
1 answer
172 views

How far can one debug a low-level API in closed-source environments?

Assume a low-level API is provided without source code (e.g. DirectX). The API provides a virtualization of hardware resources (GPU, CPU, audio card, etc.), which enables the user to call hardware-...
chckx592's user avatar
0 votes
1 answer
2k views

Encapsulation of External API in Infrastructure Layer AS Persistence

My question is about DDD, the Infrastructure layer, it's relation to the Domain, and specifically how we can take advantage of the ability to "swap out" one persistence implementation for ...
apriestley's user avatar
5 votes
2 answers
169 views

Finding the right abstraction and minimising invalid states

I am writing a library to allow two people to play chess for a toy project. For what is worth, it is in C++. I have deemed useful to have a class named Move, which represents a move which needs to be ...
user2891462's user avatar
0 votes
2 answers
306 views

Data structure for graphs and vectors in C

I'd like to design an implementation for graphs in C. I'm wondering what the most efficient approach in terms of both computational power and memory consumption would be. I've looked at various open-...
j3141592653589793238's user avatar
0 votes
3 answers
228 views

Refactor SLA problem of high level code inside if/else?

I have some code where I believe the SLA (single level of abstraction) principle is broken in a way that the low-level code (if-statements) is outside and the high level code is nested inside the ...
Thomas Weller's user avatar
-1 votes
1 answer
141 views

Designing a class implementing a method which signature types depends on the instance contained

My goal is to define a Service class which process method accepts a RequestType argument that is defined by the contained ServiceType and returns an object of a type defined by ServiceType. By doing ...
Antonio Santoro's user avatar
0 votes
2 answers
271 views

Abstraction way in a bank software system

I am creating a bank software system. In this system, there are 3 account types: Savings, Checking, CD. Each account from any type has an ID, apr, and amount, and we can withdraw from it. So I can ...
X Y's user avatar
  • 301
1 vote
4 answers
172 views

How to express abstractions?

In a program there is an abstraction from an person to a shape. This abstraction is so that collision detection can be performed. Here is my original class hierarchy: namespace Graphics { class Shape ...
Richard Bamford's user avatar
2 votes
2 answers
278 views

In OOP, are all class methods valid?

Some classes have methods that don't match up with procedural data abstraction. Here is an example of a problem hierarchy, the Render() method doesn't seem to be part of an procedural data abstraction ...
Richard Bamford's user avatar
0 votes
2 answers
286 views

What's an abstraction?

I know this is a very basic topic, but I'm curious why an abstraction in programming is always defined as a simplification/hiding of some functionality. Let's say I wrote a set of functions that let ...
Wojtek Wencel's user avatar
3 votes
5 answers
282 views

Does abstraction have a relationship with the abstract key word in java?

I learnt the concept of abstraction as: Reducing complexity by hiding unnecessary details. Does this have a relationship with the abstract keyword in java? I see that the abstract keyword is being ...
Jandroid's user avatar
  • 140
1 vote
0 answers
95 views

How can I improve this API solution

Intro I'm creating an app and I'm not sure if the structure of the solution is correct. I have a BaseController that uses generics. This controller is inherited by others that do not have to ...
Emily's user avatar
  • 19
4 votes
1 answer
187 views

Do kotlin libraries with inline APIs encourage high coupling and discourage unit testing?

As an example, let's assume our application needs some way to communicate with other systems using HTTP. interface HttpClient { fun <T> get(url: String, returnType: Class<T>): T fun ...
enp4yne's user avatar
  • 149
-4 votes
1 answer
377 views

Express SQL Query As Abstract Object Model

Goal: write code to express SQL queries in C# that get converted to SQL at the data layer level and will be compatible with any common data layer / ORM such as Dapper or Entity Framework (EF). Edit: ...
Christian Findlay's user avatar
0 votes
1 answer
143 views

Are inheritance, abstraction and polymorphism regarded as association in OOP?

In the realm of OOP, inheritance, abstraction and polymorphism are basic concepts of the paradigm. On top of that, there also have the concept called "associations" which I understand is ...
Steve.NayLinAung's user avatar
1 vote
1 answer
90 views

How to decide on abstraction level and entity definitions?

I am working on a hobby project of mine where I want to make an application to doing my personal finances. Just for learning. I am trying to adhere and implement best practices and patterns to learn ...
avanwieringen's user avatar
2 votes
4 answers
842 views

Wrapping 3rd party library - avoiding leaking abstraction

I'm currently developing an application using SFML. My biggest concern at the moment is making a layer of abstraction over the library, so I can easily change it to something else if needed. What I'm ...
mdx's user avatar
  • 203
1 vote
1 answer
279 views

General question on Pairing of Abstract Factory with Bridge

I am trying to get myself familiarized with the design patterns and I am reading through this line on the relationships between different patterns. I cannot get my head around this one though, You ...
Sen's user avatar
  • 19
1 vote
1 answer
342 views

Where to handle duplicate key exceptions in multy layer application

+-------------+ +--------+ +----------+ | repository +-------->+service +------->+controller| +-------------+ +-^------+ +------------+ +-------------+ | ...
poppycockears's user avatar
0 votes
2 answers
118 views

What's the pattern to share database to other module in security perspective?

In a large iOS application, I have a database module which is dedicated to handle application databases with read/write public APIs for other module. UI module has a feature to share the database, in ...
Sazzad Hissain Khan's user avatar
36 votes
10 answers
7k views

When is it appropriate to introduce a new layer of abstraction into a class hierarchy?

Suppose I'm creating a game played on a 2D coordinate grid. The game has 3 types of enemies which all move in different ways: Drunkard: moves using type 1 movement. Mummy: moves using type 1 movement,...
Frank's user avatar
  • 471
1 vote
1 answer
107 views

Tips for module naming and criteria for grouping files in a directory

It appeared, that I have in my pet project two abstractions: asset loaders and drawing tasks. For each abstraction I have some classes representing them (currently a single class for drawing task ...
Yaroslav Kishchenko's user avatar
3 votes
3 answers
254 views

confused with abstraction definition?

I have some years of oop programming experience,I though I know what abstraction is (using abstract class and interface), but I am confused with the definition that appear in a book which says: "The ...
secondimage's user avatar
6 votes
2 answers
561 views

Is it good design to have one constructor that supplies a "default" concrete class to another that takes an abstraction?

I like to invert dependencies whenever possible by depending mostly on abstraction and allowing the concrete implementations to be passed into the object by clients, or a factory. I've found this to ...
Ryan Palmer's user avatar
0 votes
2 answers
94 views

How do you handle abstraction when you have no control over the attribute class?

Python, has the library pathlib with the concrete class Path. I have a class called Cleanup, that looks like this: from pathlib import Path Cleanup: def __init__(self, source : Path, ...
user avatar
1 vote
1 answer
93 views

Designing a generic graph

I am looking at designing a Graph class, that should work for both lists and matrix. For ex: something like, class Graph { public: virtual ~Graph() = 0; virtual bool AddEdge(int src, int dest)...
vinit's user avatar
  • 131
3 votes
2 answers
569 views

What is an example, in Javascript, of the difference between Abstraction and Indirection?

I thought I understood what abstraction meant - refactoring code so that it applies to more general use cases. However I have recently learned that some types of abstraction may actually be ...
drenl's user avatar
  • 167
12 votes
5 answers
3k views

Too much abstraction making code hard to extend

I'm facing problems with what I feel is too much abstraction in the code base (or at least dealing with it). Most methods in the code base have been abstracted to take in the highest parent A in the ...
YamizGers's user avatar
  • 137
1 vote
7 answers
613 views

Dealing with large code base quickly in agile

At my current company, the project I work on is coded in Java, at least for the systems / backend part. Whenever I get assigned a task dealing with the Java code, it take me hours or even days to ...
henhen's user avatar
  • 149
0 votes
1 answer
151 views

How can I use disparate concrete classes that share similar functionality to create an interface that abstracts those similarities?

I've run into this issue a few times. I have preexisting framework objects that do not share a common ancestor. An example of this would be a class representing a an environment variable and a class ...
Sidney's user avatar
  • 191
1 vote
2 answers
160 views

Not understanding ADT concept from book "Object-oriented software construction 2/e"

I've been learning object-oriented concept from this book, and stuck in a specified concept in the middle of chapter 6. No one could understand my question without brief prologue, so I'm starting with ...
Andy Lin's user avatar
  • 185
2 votes
4 answers
211 views

Can encapsulation/information hiding cause problems in error identifying/locating?

I understand the principles behind opaque data types, encapsulation, information hiding, etc. in theory: preventing alteration to parts of a program can prevent people from accidentally messing it up, ...
Nicholas's user avatar
  • 163
0 votes
2 answers
221 views

How to implement a combination of behaviours for my objects

I need to create a program to manage an association. Members of this association have different roles and each role has specific characteristics. My problem is that I'm not able to abstract this ...
Concy's user avatar
  • 59
9 votes
5 answers
3k views

Is there a reason to define an interface for a pure data class?

I am reviewing a colleague's code and as part of the changes, this person introduced a few new pure data classes like so (C#): public class Result : IResult { public bool Succeeded { get; set; } ...
Logan S.'s user avatar
2 votes
1 answer
323 views

Approach for implementing Device and Protocol layers in C++?

I'm writing a program that will interface with an external device. It will support numerous devices that may use different communication interfaces like USB, serial, etc. This is what I have so far: ...
John O'brien's user avatar
-1 votes
1 answer
206 views

Database abstraction layer

I'm currently developing an SaaS application in PHP, with Laravel, using its own DB class. Let's pretend we've got 2 classes under 2 namespaces, plus Laravel's own DB - so Illuminate\Support\Facades\...
XLR's user avatar
  • 11
19 votes
7 answers
5k views

What is "premature abstraction"?

I've heard the phrase being thrown arround and to me the arguments sound completely insane (sorry if I'm strawmaning here, Its not my intention), generally it goes something along the lines of: You ...
James's user avatar
  • 317

1
2 3 4 5