Questions tagged [abstraction]

Abstraction is a computer science concept in which an implementation is separated from its interface.

Abstraction is a computer science concept in which an implementation is separated from its interface. Abstraction allows an implementation to be modified without changing the interface, so that other code which relies on this interface does not have to be modified.

For instance, a function prototype in C would be considered the function's interface, and its definition is considered the implementation. The function definition can change (for instance, to improve performance or fix a bug), but as long as the function signature (as specified by the prototype) is the same, any code calling the function can remain the same.

1121 questions
-1
votes
1 answer

Interface definition for encapsulating a generic data source

I am currently working on a C# Plugin based design where the Plugin API methods will have access to a Context object which will contain the relevant information required for the method to work. In the current implementation, a file path is…
-1
votes
1 answer

How can I successfully abstract the following lines of code? (Python Tkinter GUI)

I am trying to create a GUI in Python for a class assignment called 'Chocolate Vending Machine'. Students are required to use Python's Tkinter. We list a couple of chocolate brands such as Snickers, Twix and Mars and put a price tag on each of them.…
-1
votes
1 answer

Polymorphism is nothing but overwriting functions of inherited classes?

Here is a code I am taking from another post: Is what seems like polymorphism in PHP really polymorphism? class Animal { var $name; function __construct($name) { $this->name = $name; } } class Dog extends Animal { function…
-1
votes
1 answer

Discussion: CMSIS VS Hardware Abstraction Layer by method of Texas Instruments

I have used TI TMS320 MCUs for years. TI provides header and source files for accessing hardware. TI Implements a hardware abstraction layer to do that as you probably know. ARM micro-controllers come with CMSIS, an standard for hardware abstraction…
Rasool
  • 3
  • 3
-1
votes
1 answer

Inserting Values to Non Abstract Methods in Abstract Class Using a Sub Non Abstract Class

I want to access and use 3 private variables in an Abstract Class(MainAbstract.java) from another class that has extended (SubAbstract.java) from the previously mentioned Abstract Class. From the sub class I want to access the getters() and…
ChiranthakaJ
  • 47
  • 1
  • 2
  • 10
-1
votes
1 answer

How can I decrease verbosity when inheriting from C# generic types to non-generic types?

With C# generics (specifically, type parameters for classes), is it possible to refer to specified type parameter values in an specialized ("non-generic") type (class) that extends/inherits the generic one? In this case, I'm overriding virtual…
Nathan Schulte
  • 125
  • 2
  • 12
-1
votes
2 answers

Python class decorator, cannot use constructor

So I have the following decorator code class Factory: def __init__(self, cls): self.cls = cls def __instancecheck__(self, inst): return isinstance(inst, self.cls) def Produce(self): return self.cls() And…
Neo
  • 49
  • 6
-1
votes
1 answer

C++ Inheritance of abstract reference members for polymorphism

I have an abstract class with N protected members: class Something { protected: UINT someVal; std::vector g_MyVec; // some virtual abstract methods ... public: UINT getSomeVal() { return someVal; } std::vector
Fer
  • 460
  • 2
  • 4
  • 17
-1
votes
3 answers

Printing a private field from a separate class

I have been tasked with linking two classes together. The first class is a ticket machine which allows the person to buy a ticket and then print it out (via System.out.println). The second class is a clock display which displays the time. My task is…
user3455584
  • 5
  • 1
  • 10
-1
votes
1 answer

Correct use of abstract factory

When I feel the need of having a factory class in my projects, I'm tempted to use this approach: public class ProductFactory { public Product makeProduct(Type t){ switch (t) { case A: return new ProductA(); break; …
DanTheMan
  • 191
  • 4
  • 11
-1
votes
1 answer

Abstracting a script so that each of my tab objects on a single page aren't actually affecting each other

I have a set of scripts that I have inherited on a project and am having some issues as I am not a javascript developer in any way. What I need to do is to abstract this script so that each of my tab objects on a single page aren't actually…
VikingBlooded
  • 884
  • 1
  • 6
  • 17
-1
votes
2 answers

What's the most used philosophy of keeping independent concepts separate in OOP?

Or according to your own experience, what's your favorite trick ?
symfony
  • 915
  • 2
  • 13
  • 20
-1
votes
2 answers

encapsulation difficulty in nested c++ classes

We all are familiar with the concept of encapsulation and abstraction but sometimes this may lead to an obstacle I'm curious about the tricks or methods or whatever you call them to solve the problem. here we have a nested c++ class: #include…
Pooya
  • 992
  • 2
  • 10
  • 31
-1
votes
1 answer

Android Navigation Drawer abstraction

I know this question has been asked before (2 other i found similar) but they didnt address this side of the scenario! SO here's the scenario, I created a class as this: public class BaseActivity extends ActionBarActivity { // Implemeted the…
kevoroid
  • 5,052
  • 5
  • 34
  • 43
-1
votes
2 answers

Java 1.6 abstracted random access

As a java guru, what would you suggest to abstract random access so that a code can be agnostic to whether the data its accessing is in memory or in a file on the harddrive? (The files in question could be several gigabytes in size. Having random…