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
-4
votes
1answer
123 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
1answer
82 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
1answer
70 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
2answers
112 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 ...
0
votes
1answer
35 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
1answer
44 views

Where to handle duplicate key exceptions in multy layer application

+-------------+ +--------+ +----------+ | repository +-------->+service +------->+controller| +-------------+ +-^------+ +------------+ +-------------+ | ...
0
votes
2answers
88 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
10answers
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
1answer
50 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
3answers
135 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 ...
5
votes
2answers
252 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
2answers
77 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
1answer
79 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
2answers
262 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 ...
9
votes
5answers
2k 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
7answers
322 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
1answer
113 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
2answers
121 views

Reading problem of object-oriented concept about the 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. Because with no brief explaining beforehand, no one could understand my ...
1
vote
4answers
126 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
2answers
177 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 ...
6
votes
5answers
560 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
1answer
187 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: ...
-1
votes
1answer
154 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\...
9
votes
4answers
2k 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 ...
0
votes
2answers
996 views

Usage of the word “override” in C++ and it's virtual functions

I know that the following function is a virtual function and needs to be overridden when extended by another class: virtual int getAge()=0; What i don't understand is the following syntax I have ...
-3
votes
3answers
914 views

Object Oriented Programming what is abstraction? [duplicate]

I was hoping that someone could explain to me in the simplest way possible and with an example, what abstraction is with regards to Oop. I've read articles online and I just don't get it. I'm hoping ...
15
votes
2answers
1k views

How do you deal with comprehending abstraction in code?

When looking at a new codebase I like to start from a bottom-up approach. Where I comprehend one file and then move up to the next abstraction. But often times I find myself forgetting what the ...
1
vote
1answer
2k views

Unit testing protected methods which have no reason to be public

I need to make a sponsorship system with complex business requirements. Basically, after a user makes a payment, the system should get triggered. There are many different types of sponsoring, so I ...
-2
votes
1answer
77 views

looking to solidify understanding of OOP principles

I just wanted some feedback on my definitions of these terms. Abstraction - only showing relevant information and hiding implementation details. Interfaces and abstract classes are an examples of ...
2
votes
1answer
825 views

Is it a good idea to wrap Material-UI Typography components in <H1>, <H2> components etc?

I love the Material-UI library, but some things that I've found annoying: I find Typography too long to write out, especially when I'm having to specify things like gutterBottom, align, etc. Whereas ...
1
vote
2answers
103 views

Thin Controller: Make a Controller Service wrap other Services?

Say you have a HomepageController that' suppose to show all the blogs, users, gallery, and some members-only info (for logged-in users) Normally, it looks like this: <?php class ...
2
votes
2answers
412 views

Is it bad practice when an Object has to be aware of another Object

I was reading this page and came across this sentence in the accepted answer: I don't like A directly knowing about B. But that's a DIP thing not a POJO thing. What if you can't abstract out B ...
3
votes
4answers
539 views

Is Abstracting your code too much a bad use of SOLID Principles?

After an unresolved argument with a friend I decided to ask the stack overflow community. Is there something like abstracting your code too much? Which of the following is the better option. We come ...
3
votes
2answers
4k views

How to deal with exceptions in DLLs?

I recently started working on an existing project written in C++ Builder. The application consists of a MainModule that loads lots of modules (DLLs). The MainModule itself is a DLL (there is a small ...
0
votes
1answer
254 views

Swapping Entities or ORM in repository pattern

Lets say i am following Repository pattern in my application and i have class UserEntity { private $model; public function __construct() { $this->model = new UserModel(); } }...
0
votes
1answer
69 views

What abstraction to use for hiearchical sum from ordered list

I am looking for an abstraction from which to solve a class of problems similar to the following: I have this ordered ResultSet (in this case sorted for NATION,REGION,DISTRICT,COUNTRY): CITY' Table ...
6
votes
2answers
949 views

Abstraction of VAOs, VBOs and Models

I have gone down the rabbit hole that is abstracting away a working game engine in OpenGL and C++. Before reaching the other side I'd like to ask about my current design, which is - the more I look at ...
1
vote
1answer
343 views

Data layer Abstraction from Business layer for search

This is regarding designing a search api. We have 3 tier architecture now using Spring MVC. All communications are via REST api. UI <-> Business <-> Data(sql). Now to implement faster ...
24
votes
9answers
7k views

When is primitive obsession not a code smell?

I have read plenty of articles recently that describe primitive obsession as a code smell. There are two benefits of avoiding primitive obsession: It makes the domain model more explicit. For ...
4
votes
4answers
1k views

What is the benefit of encapsulating a collection inside a class?

Please see the code below: public class Customer { private readonly IList<Order> _orders = new List<Order>(); public string FirstName { get; set; } ...
-1
votes
2answers
86 views

Firmware development philosophy in function wrapping

I wrote some code in the past for 8bit MCUs, realizing that every time I gained experience, the next iteration will be with a wrapper API or something more distant from the "bare metal" register ...
-1
votes
1answer
295 views

variables as abstractions for the memory cells

How are variables abstractions for the memory cells of the machine? Is it because you can change the value stored in the memory cell by assigning a different value to the variable associated with the ...
-2
votes
1answer
73 views

What to call a API and DB code layer [closed]

In a recent MVVM mobile app project I wrote a set of API classes and Database classes where there was a clear flow of logic between both api and db code. To enforce the way api and db interacted I ...
1
vote
1answer
74 views

Service with abstract model initiation

I want to implement an abstract module to store credits and I have the following structure: Model: Credit (abstract) Dao: CreditDao (interface) Service: CreditService The Credit model should be ...
2
votes
2answers
598 views

Limiting your call stack can guide you to use less abstraction?

I've been watching an presentation from Jonathan Blow on Software Quality. He as a point that adding more and more layers of abstraction gives you not only more difficulty to manage your code, but ...
0
votes
2answers
5k views

Design Pattern for a “manager” type of class

I have a class that I usually end up calling XManager. This class usually acts a dispatcher. Where it will read a config and do what the config says. Assuming that I have the following class ...
29
votes
11answers
6k views

How many design patterns and levels of abstraction are necessary? [closed]

How can I tell my software has too much abstraction and too many design patterns, or the other way round, how do I know if it should have more of them? Developers I work with are programming ...
0
votes
2answers
77 views

How to use functions based on configuration?

let's say that I am working with an IoT device. The device can have many sensors, each of them has an address, i/o direction and a reading method. temperature=d2,input,digital humidity=d3,input,...
1
vote
2answers
140 views

Are there any rules how the number of indirection layers should be limited?

Just like the two opposing mirrors are enough for infinity, most of design patterns can be applied repeatedly producing any amount of LOC desired. We can always create a factory for any factory or ...
4
votes
3answers
849 views

Clarification on the Dependency Inversion Principle

I'm reading the book "Agile Software Development, Principles, Patterns, and Practices" by Robert C. Martin. When he talks about the Dependency Inversion Principle he gives the following example of a ...