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.

1026 questions
24
votes
12 answers

When should I return the Interface and when the concrete class?

when programming in Java I practically always, just out of habit, write something like this: public List foo() { return new ArrayList(); } Most of the time without even thinking about it. Now, the question is: should I always…
n3rd
  • 5,669
  • 4
  • 35
  • 55
24
votes
3 answers

How to get the name of the calling class (in PHP)

define('anActionType', 1); $actionTypes = array(anActionType => 'anActionType'); class core { public $callbacks = array(); public $plugins = array(); public function __construct() { $this->plugins[] = new admin(); …
Mark Tomlin
  • 7,684
  • 8
  • 51
  • 68
23
votes
7 answers

Using generics in abstract classes

I'm working on an abstract class where the implementing class needs to implement a list of T. The problem is that this doesn't work: public class AbstractClass { public int Id { get; set; } public int Name { get; set; } public abstract…
thaBadDawg
  • 4,968
  • 6
  • 31
  • 43
19
votes
3 answers

Does the Bridge Pattern decouples an abstraction from implementation?

I learned Bridge pattern from different articles and I have implemented that as per my understanding . One thing that is confusing me is bridge pattern says BridgePattern decouples an abstraction from its implementation so that the two can vary…
Ali
  • 527
  • 6
  • 25
19
votes
2 answers

Storing formatted text in a DB while maintaining abstraction

How would you store formatted blocks of text (line breaks, tabs, lists - etc.) in a database (nothing specific) to be displayed on the web (XHTML) while maintaining a level of abstraction so that the data can be used in other applications or if the…
Tom
  • 5,815
  • 3
  • 24
  • 30
18
votes
2 answers

How can you pass a List to a method?

I have a servlet with several methods that get a list of objects from the DAO, turn the list into JSON, and send it back in the response. Every list is made of objects that have a method: public String getAsJson(){...} And the servlet has a bunch…
Windle
  • 1,248
  • 1
  • 12
  • 29
17
votes
1 answer

Wrapping DbSet with a custom DbSet/IDbSet?

First off, I think this is somewhat ridiculous to do but the other members of my team insist upon it and I can't come up with a good argument against it other than "I think it's dumb"... What we're trying to do is create a completely abstract data…
16
votes
4 answers

Command Pattern seems needlessly complex (what am I failing to understand?)

I've read up on the Command Pattern, and I think I'm missing something. The Command object exists to abstract away the details of the Receiver object. It seems to me that we could simply stop here, and hold references to Command objects to execute…
15
votes
1 answer

Abstracting away from data structure implementation details in Clojure

I am developing a complex data structure in Clojure with multiple sub-structures. I know that I will want to extend this structure over time, and may at times want to change the internal structure without breaking different users of the data…
mikera
  • 101,777
  • 23
  • 241
  • 402
15
votes
2 answers

Is this a typical use case for IOC?

My current application allows users to define custom web forms through a set of admin screens. it's essentially an EAV type application. As such, I can't hard code HTML or ASP.NET markup to render a given page. Instead, the UI requests an instance…
15
votes
2 answers

Modularizing SQL even if only syntactic sugar

Is there a way to modularize SQL code so that is more readable and testable? My SQL code often becomes a long complicated series of nested joins, inner joins, etc. that are hard to write and hard to debug. By contrast, in a procedural language…
prototype
  • 6,440
  • 12
  • 48
  • 86
14
votes
6 answers

more advantages or disadvantages to delegate members over classic functions?

class my_class { public int add_1(int a, int b) {return a + b;} public func add_2 = (a, b) => {return a + b;} } add_1 is a function whereas add_2 is a delegate. However in this context delegates can forfill a similar…
alan2here
  • 2,865
  • 4
  • 32
  • 55
14
votes
5 answers

How to identify that code is over abstracted?

What should be the measures that should be used to identify that code is over abstracted and very hard to understand and what should be done to reduce over abstraction?
TalentTuner
  • 16,603
  • 5
  • 35
  • 59
14
votes
5 answers

Best way to use Javascript's "good parts"

On Stackers' recommendation, I have been reading Crockford's excellent Javascript: The Good Parts. It's a great book, but since so much of it is devoted to describing the best way to use Javascript's basic functionality, I'm not sure how I can put…
Tom Lehman
  • 75,197
  • 69
  • 188
  • 262
14
votes
18 answers

Abstraction away from CSS

Many frameworks seek to abstract away from HTML (custom tags, JSFs component system) in an effort to make dealing with that particular kettle of fish easier. Is there anything you folks have used that has a similar concept applied to CSS? Something…
SCdF
  • 51,261
  • 23
  • 74
  • 108
1 2
3
68 69