5

I'm reading a technical book about programming and I came across on this sentence,

"A dependency abstracts functionality away from calling code. You don't need to worry too much about what a dependency is doing, much less how it is doing it, but you should ensure that all dependencies are correctly managed."

I did not quite get the sentence. Can anyone explain me this?

  • It is not a complete sentence. Could you add some more before and after your quote? – user3169 May 11 '16 at 16:34
  • You've posted this incorrectly. It should read abstracts, meaning approximately "withdraws" or "removes". A dependency sets some "functionality" at a distance from the code which calls it. – StoneyB on hiatus May 11 '16 at 16:54
  • Which book did you find this quote in? – Jasper Dec 20 '17 at 19:10
10

To abstract (away), specifically in computer science, refers to intentionally obscuring the details of how something works in order to simplify things conceptually. Something is abstracted when it acts as a "black box": We put some input into the box, and get some output from the box, but we can't see the inner workings inside the box. Abstraction typically happens in layers, i.e. some system of black boxes become the inner workings of a black box at a higher level of abstraction.

For example, consider what happens when I press a key and a letter appears on the screen. The details of how this happens are quite complex: pressing the key connects a circuit that causes a specific electronic signal to be sent to the computer, that signal is interpreted by hardware drivers and directed by the operating system into Google Chrome, which receives it as a sequence of bits which are handled by various functions in Chrome's code. Then there's a separate driver for the monitor, and so on. An abstract way of describing this is as follows: I press a key on my keyboard, and the corresponding letter appears on the screen.

The reason why this is conceptually useful in computer science is because computer systems and software can be incredibly complex. Nested black boxes are the conceptual building blocks of computer science because they allow you to choose your own level of detail. Need more detail? Open up the box and look inside. Too much detail? Abstract it away by putting everything in an even larger box.


How does this work with dependencies in particular?

One of the main ways of actually abstracting something is by encapsulating a piece of functionality in a class, method, routine, module, etc. that can be referenced by other areas of code. When a reference is established, the referencer becomes dependent on the referenced code. All the referencer can do is interact with the referenced code as a black box: giving it an input and receiving an output, but never having access to the inner workings. (See encapsulation.)

  • So this means, assume Object A is the referencer and Object B use reference code from Object A. By this Object B will not care how Object A process the code that is being reference in Object B, but only the product output from Object A? – rpmansion May 11 '16 at 16:59
  • Yes, except that if A references B, that means A is calling into B (A is using the code in B). A sends some input to B and receives some output. The reference itself just tells A where to find B. A can only use that code in B which is exposed to A, e.g. using access modifiers. – Era May 11 '16 at 17:11
-3

You are talking about the functionality itself. But the purpose of a black box is reusability. A .dll is a good example of an encapsulated file. It can contain re-usable functions. This relieves the programmer of having to repeat a function in code over and over again. Thus, an encapsulated file reduces the size of the code in a software program. The .dll can be called many times and is an independent file of programs which call it. Any number of different programs can be written which can call upon the function (s) inside the same .dll file. Thus, a .dll is an incapsulated module which performs a specific set of actions...it is abstracting away the details of how it receives input, crunches the answers amd produces output.

  • 3
    I can't tell whether this is intended to be a comment on the other answer (which should either be a comment, or simply not posted at all) or an answer in its own right (which should directly answer the question). – Nathan Tuggy Aug 3 '16 at 7:48
  • 2
    This might be an answer if this site were about programming, but ELL is a language site. The answer needs to be explained in terms of what the words mean and not the programming concept that the paragraph is explaining. – ColleenV parted ways Aug 3 '16 at 14:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.