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.
220 questions
1
vote
5
answers
390
views
Anti-pattern? Double header and exposed implementation detail
Consider that I've implemented SHA-256 hashing in C as incrementally updated IUF (init-update-finalize) working context and 3 subroutines. To use it in free-standing environment, or to efficiently use ...
2
votes
2
answers
426
views
In unit testing: How to abstract a dependency of subject under test?
Disclaimer: I am learning unit testing. I am also kind of beginner in object-oriented design.
Currently, I am involved in the development of an application to manage the finance of a humble food ...
5
votes
1
answer
576
views
Confused on how abstraction and encapsulation is helpful
Using assimp I've created a function to load 3D models and it does everything I need and I don't plan to use another library or write something custom, however, I am curious how techniques such as ...
2
votes
3
answers
359
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&...
3
votes
3
answers
2k
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 ...
-2
votes
1
answer
863
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) ...
0
votes
1
answer
166
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 ...
1
vote
2
answers
246
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 ...
0
votes
0
answers
234
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. ...
2
votes
2
answers
263
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 ...
1
vote
2
answers
283
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 ...
16
votes
7
answers
5k
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 ...
0
votes
2
answers
149
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 ...
0
votes
0
answers
69
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)...
1
vote
2
answers
332
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 ...
0
votes
1
answer
217
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-...
0
votes
1
answer
3k
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 ...
5
votes
2
answers
224
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 ...
0
votes
2
answers
533
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-...
0
votes
3
answers
276
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 ...
-1
votes
1
answer
234
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 ...
0
votes
2
answers
358
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 ...
1
vote
4
answers
199
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 ...
2
votes
2
answers
307
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 ...
1
vote
2
answers
457
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 ...
3
votes
5
answers
451
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 ...
1
vote
0
answers
102
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 ...
4
votes
1
answer
219
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 ...
-4
votes
1
answer
581
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:
...
0
votes
1
answer
195
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 ...
1
vote
1
answer
138
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 ...
2
votes
4
answers
2k
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 ...
1
vote
1
answer
504
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 ...
1
vote
1
answer
1k
views
Where to handle duplicate key exceptions in multy layer application
+-------------+ +--------+ +----------+
| repository +-------->+service +------->+controller|
+-------------+ +-^------+ +------------+
+-------------+ | ...
0
votes
2
answers
156
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 ...
37
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, ...
1
vote
1
answer
167
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 ...
3
votes
3
answers
335
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 ...
6
votes
2
answers
663
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 ...
0
votes
2
answers
111
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, ...
1
vote
1
answer
140
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)...
3
votes
2
answers
686
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 ...
13
votes
5
answers
5k
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 ...
1
vote
7
answers
723
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 ...
0
votes
1
answer
276
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 ...
1
vote
2
answers
196
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 ...
2
votes
4
answers
306
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, ...
0
votes
2
answers
294
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 ...
10
votes
5
answers
4k
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; }
...
2
votes
1
answer
369
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:
...