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
votes
1
answer
230
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\...
22
votes
7
answers
9k
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 ...
2
votes
2
answers
6k
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
3
answers
1k
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 ...
17
votes
5
answers
2k
views
How to comprehend 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 ...
0
votes
1
answer
4k
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
1
answer
122
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
1
answer
2k
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
2
answers
221
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
2
answers
645
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 so ...
3
votes
4
answers
1k
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 ...
5
votes
2
answers
10k
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 ...
-1
votes
1
answer
360
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
1
answer
82
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
2
answers
2k
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
1
answer
438
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 ...
30
votes
9
answers
12k
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 example,...
4
votes
4
answers
2k
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
2
answers
198
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
1
answer
839
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
1
answer
102
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
1
answer
106
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 ...
3
votes
2
answers
2k
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
2
answers
10k
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 ...
31
votes
11
answers
7k
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
2
answers
99
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
2
answers
217
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 ...
3
votes
3
answers
1k
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 ...
0
votes
2
answers
576
views
The meaning of abstract method? [duplicate]
Edit: the difference between my question and What are the differences between abstract classes, interfaces, and when to use them, What are abstract classes and abstract methods? is that the chosen ...
1
vote
1
answer
125
views
Are there any cases when an abstraction should inherit ISerializable?
There is a @Mark Seemann's cite from a conversation which states that an abstraction must never implement IDisposable:
I like how @nblumhardt put it almost six years ago:
an interface [...] ...
-2
votes
1
answer
613
views
What is a software abstraction? [duplicate]
This page on JS Promises says it is a software abstraction. What is a software abstraction and why is the JS Promises called software abstration?
1
vote
2
answers
632
views
clarification about DAL and MySQLi functions in PHP
Up to now, I was considering MySQLi functions in PHP one example of DAL. And I initiated a simple project to publish in an article with the title "starting with PHP and DAL and MySQL"
But when I made ...
0
votes
2
answers
938
views
Design pattern name for thin wrapper for unit testing purpose
Assuming I'm using a class from third party library that does not implement an interface, for example:
class ThirdPartyLibClass {
void DoThis() { ... }
void DoThat() { ... }
}
I want to ...
-3
votes
1
answer
2k
views
Turn based game class design
I wrote abstract base for some turn-based games (like chess or tic-tac-toe) and wrote game based on this base. And I stuck with choosing how to design class hierarchy. Here is two variants for wich I ...
-2
votes
2
answers
534
views
Is 'List' a leaky abstraction?
Abstraction - Creates barrier between representation & usage of List ADT
Encapsulation - Ensures maintaining in-variants of List ADT.
An invariant is a fact about a data structure that is ...
8
votes
3
answers
30k
views
C++ derived class copy constructor
If I have an abstract class Drink which has a derived class Coffee, what would the copy constructor for Coffee look like? If it accepts a reference of Type Coffee as a parameter then I wouldn't be ...
4
votes
1
answer
165
views
What alternatives are there to using an object of a contravariant interface polymorphously?
The gist of what I'm trying to do is get an instance of the appropriate user service, then pass it whatever subtype of User we're working with.
Models:
public class User
{
public string ...
3
votes
2
answers
3k
views
Creating abstraction over API
I'm trying to figure out how to create abstraction over different APIs, which have common things. For example let's take the mobile platforms you have Android, Windows Phone and IOS. Let's say I want ...
-1
votes
1
answer
428
views
abstract classes or other generalization classes?
i have a question about software engineering best practice.
Let's consider a class "User", with 2 subclasses "Student" and "Teacher"
if we need to specify some data for "University special council" ...
1
vote
1
answer
133
views
Are terms "abstraction" and "abstract data types" connected with each other?
I am new to OOP. I've read definiton of both terms in many different articles and books, but still can't understand whether there is any relationship between them.
3
votes
1
answer
575
views
Maintaining consistency with loosely coupled business and data layers
Take the following sequence of events:
Business layer requests data x and y from data layer.
Data layer returns version 1 of x and y.
Business layer starts performing logic based on data x and y.
...
0
votes
1
answer
107
views
Reflexive calls of objects in the same hierarchy
I am not sure how to phrase this. I believe this should have been asked somewhere, but I am unable to find it because I don't know the keywords.
Basically, I have some types like this:
interface Foo
...
5
votes
1
answer
990
views
Creating generic actions in redux
I am wondering if there is anything wrong with creating generic actions in redux which dynamically change different properties in the store , so that i can reduce boilerplate code.
For example:
//...
0
votes
1
answer
57
views
What relationship describes two different abstractions of the same dataset
I am wondering if there is a specific term for when multiple representations are data equivalent. Meaning that you can transfer the data from one representation to the other without any loss of data.
...
8
votes
4
answers
2k
views
How to separate public and "mostly private" code in C#? (Friend classes, PIMPL pattern, etc.)
Reminder: If you have tips, please remember to put the reason objectively, such as "having two distinct SetInt() functions in the same file violates reader expectations that they'll be overloads, and ...
32
votes
13
answers
5k
views
Help in understanding computer science, programming and abstraction [duplicate]
Until now, I always believed that you should learn programming languages that make you do low-level stuff (e.g. C) to understand what's really happening under the hood and how the computer really ...
1
vote
1
answer
436
views
What is the difference between ADTs and objects? [closed]
This question was answered in "Understanding Abstract Data Types (ADTs)", and the top voted answerer (by Frank Shearar) is currently as follows:
Objects are not ADTs (*) [editor's note: Links to "On ...
-1
votes
1
answer
825
views
Terminology: abstraction vs models [closed]
I'm building a model of the SQL query language.
It doesn't attempt to abstract SQL at all - instead, it tries to model it directly, so it has model objects named Query, Table, Column, Variable, ...
1
vote
0
answers
147
views
Having a globally static cached list without breaking encapsulation?
I have a couple wrappers around third party APIs that allow me to retrieve information from certain web services. Querying these services can be rather time intensive, so in my older version of my ...
1
vote
1
answer
199
views
Setting up my inheritance model?
I'm working on refactoring a synchronization web app that our company uses. Currently it's merely a set of controllers that fire up a set of helpers that go through a long chain of if-else type ...