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

Is there a way to declare an object with a generic type parameter, without defining the type?

I have an abstract class that takes a generic type parameter, so that the user can define correct functionality in child classes: public abstract class Fruit{ public abstract TFruit CutFruit(); public abstract float…
user430481
  • 315
  • 1
  • 4
  • 14
-1
votes
2 answers

A C++ abstraction for sorted containers that differ only in sort function?

In C++, I have a class that contains two members which are sorted containers. The containers store the same object type, but one is sorted in ascending order and the other in descending order. Note: the object type in each container is the same,…
Matt
  • 952
  • 2
  • 8
  • 17
-1
votes
1 answer

Vending Machine C++ - Error in while loop

I am writing a "vending machine/grocery shopping" code in C++ where I have a menu of 5 items and the user can choose to add as my items as they want. The price is calculated at the end. Since the user can add as many items they want, I used a while…
yeliah
  • 41
  • 6
-1
votes
2 answers

How java abstraction works in a real time project

I went through many articles to understand the abstraction concept. Most of them have defined abstraction as hiding implementations from the code that uses the methods. Example public interface test1 { String doSomething(); } public class test2…
Vinee-the-Pooh
  • 835
  • 3
  • 10
  • 27
-1
votes
2 answers

Abstraction for bitset element iteration

I have a custom bitset class implementation in C++. I often iterate over the indexes of bits that are set in the bitset (i.e. for bitset '10011' I want to iterate over numbers 0, 3, 4.) This iteration can be implemented as follows: struct Bitset { …
Laakeri
  • 99
  • 2
-1
votes
1 answer

Isnt using a method of a seperate class considered abstraction

When calling a method from another class is it considered abstraction? Because when the main method creates the Dog object and uses the method animalSound, the user cannot see what is being done. Is this considered abstraction? Dog.java public class…
-1
votes
1 answer

A design pattern to handle similar groupings of objects with different multiplicities?

I am designing a program that allows you to create an object with traits and then add it to a database. For example, a renting property like so: public class Property { PropertyType type; int bedrooms; int bathrooms; double…
-1
votes
1 answer

a bunch of lists of numbers

I would like to write the Racket function find-subsets. The function produces the list of subsets of a list of numbers w/o helper functions and that only uses lambda, cond, cons, rest, first, and other primitive functions. For instance, the…
user12300000
-1
votes
3 answers

How to get a property value from a nested class?

Hello i have problem with get nested class property value. I want class Car { string name; string model; class Engine { public string engineNumber; public Engine(string engineNumber) { this.engineNumber = engineNumber; …
Adam
  • 125
  • 11
-1
votes
1 answer

Is it possible to use abstraction in a YAML file?

Is it possible to use arguments or abstraction to minimize repeating code in a YAML file? I'm writing a YAML file that triggers a deployment and before and after the deployment I would like to make calls to a slack channel indicating the deployment…
zero_cool
  • 3,960
  • 5
  • 39
  • 54
-1
votes
1 answer

How to improve design of the program considering interfaces and abstract classes?

Taking into account the accepted answer here, the idea for general recommendations is that, where possible, favor defining classes over interfaces. Consider the following design: A base class ChessPiece, which multiple child classes are also…
-1
votes
2 answers

Best pratices for Func and Func

Let us suppose that I have two functions like: public T Foo(Func func){ return func(); } public TResult Foo(Func func, T param){ return func(param); } And I have the following code to…
Andre
  • 652
  • 2
  • 7
  • 23
-1
votes
1 answer

A little bit confusion with C# Generics, T, Abstraction ?

I am a C# game maker with Unity. I have collectable management system. CollectableManager public List> collactableParentsList; CollectableParent public class CollectableParent : CollectableRelatedMonoBehaviour…
LazyX
  • 177
  • 2
  • 10
-1
votes
1 answer

How does python inherit/override functions in multiple inheritence?

I have the following piece of code :- class A(object): def __init__(self): print "I'm in A" def awesome_function(self): raise NotImplementedError class B(A): def awesome_function(self): print "Implemented in…
-1
votes
2 answers

How do I move try-catch into a class that handles all try-catch logic but also return errors?

I am writing a basic player wallet management class where Integers are added (credited) or subtracted (debited) to a player's wallet where errors are caught by a simple try-catch logic. Note: It only is meant to handle Integers. I am attempting to…
zardon
  • 1,601
  • 4
  • 23
  • 46