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
7answers
273 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
106 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
109 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
115 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
168 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
436 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
170 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: ...
0
votes
1answer
101 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
901 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
266 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
579 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
260 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
70 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
494 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
69 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
395 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
449 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
2k 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
207 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
67 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
554 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
296 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 ...
22
votes
8answers
5k 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
745 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
80 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
166 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
70 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
71 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
380 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
3k 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
125 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
701 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
186 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
82 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
555 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
428 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
434 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
1k 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
445 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 ...
3
votes
3answers
11k 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
117 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 ...
2
votes
2answers
1k 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
210 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
99 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.
2
votes
1answer
259 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
69 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
1answer
770 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: //...