Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

11
votes
2answers
428 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 ...
0
votes
1answer
127 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
62 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 ...
1
vote
1answer
135 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
50 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
384 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
412 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 ...
1
vote
2answers
781 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
112 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
64 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 ...
4
votes
2answers
230 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
213 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 ...
13
votes
6answers
2k 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 ...
3
votes
4answers
469 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
76 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
98 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 ...
-3
votes
1answer
68 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
70 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
278 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
2k 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
74 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
109 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
581 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
2answers
161 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
1answer
80 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
1answer
433 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
2answers
324 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
2answers
291 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
1answer
896 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
2answers
410 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 ...
2
votes
3answers
6k 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
1answer
111 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 ...
1
vote
2answers
807 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
1answer
170 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
1answer
94 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.
1
vote
0answers
155 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
1answer
67 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 ...
4
votes
1answer
669 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
1answer
30 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. ...
6
votes
4answers
654 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 ...
30
votes
13answers
4k 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
1answer
237 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 "...
-1
votes
1answer
196 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
0answers
119 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
1answer
150 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 ...
1
vote
3answers
222 views

Resistance to abstraction [closed]

I am on an ASP.NET MVC project where we use Razor to define pages. One thing I like to do is to use Razor's @helper to DRY up pretty much any duplication in HTML (i.e. formalize even small UI patterns)...
2
votes
1answer
520 views

How to frame the concept behind CMake?

I'm using CMake for several years now and found that - in the cases where I'm struggling with CMake - I'm still not completely sure about the concept behind CMake (not taking into account CTest, CPack ...
2
votes
1answer
215 views

Using own ArrayList in general purpose C libraries, but allowing a different implementation

I've written a couple of libraries since beginning to use C again last year. One thing that still needs addressing in both of these is the correct use of array-based lists - hereafter, ArrayLists. At ...
4
votes
2answers
370 views

Fix a leaky abstraction (type checking)

I have a method that accepts an interface and does type checking on the parameter, and depending upon the type a decision is made to either send an email or an alert public void Bar(...