Here's the question you clicked on:
araj
What do you meant by Data abstraction in scheme? How it become useful?
Hi @araj! First of all you need to understand that Data Abstraction is a tool of Computer Science and not of Scheme. The book has used Scheme, so that will the reference for answering your question. Just like the book (SICP) states, before coming to Data Abstraction the book talks about Procedural Abstraction: We assume that we have smaller procedures which do smaller tasks for us. With that assumption we define our main procedure and look into the details of implementing those smaller programs later. Same is the case for Data Abstraction. We need not use it for simple data. Not that we can't, but we don't. However, when dealing with complex forms of data, their manipulation could be tricky. The book explains this with an example of rational numbers. Now, we surely know that addition of rationals is trickier than that of integers. So, if you look at the section on Data Abstraction in the book, you will note that without worrying about the details, the strategy assumes that we already have procedures which 0. create a rational 1. retrieve the numerator/denominator of the rational Making use of these assumptions, they have simply defined procedures for adding/subtracting etc of rationals. And then looked into defining the procedures make-rat, numer and denom later on. NOTE THAT they didn't worry about how will they make/store a rational number or access its numerator/denominator before defining the add-rat, sub-rat, mul-rat etc... The BIG thing really in all this is 'Abstraction' itself: whether procedural or data. The underlying idea is to assume that you have someone to do the small tasks for you, and using all those small result to get your net result. Hope that answers your questions! Any further questions are welcomed.
To answer your second question, the tool of Abstraction is very useful. And you will appreciate the power of abstraction if you practice it. But if I were to state it's use, that'd be: When you encounter a problem, and are supposed to solve it, while you try to solve the problem all in one, you are most likely to meet other smaller hurdles in the way. It isn't that all the problems cannot be solved in one go. It's just that taking care of every big or small problem at the same time becomes tedious. So, for our own convenience we assume that the small-task-solvers exist (while actually they don't). That is the power of abstraction. Once you have modeled you mechanism for the solution, it is after that when you look into the details of implementing those small-task-solvers i mentioned about before. 0. It reduces the amount of stress on the brain 1. the code is elegant/simple/readable/understandable 2. It majorly reduces the time you might take to solve the problem (if you were to do everything in one go) 3. It has further technical uses depending on what language you are using. I have looked at abstraction in Java. And despite that the basic idea is the same, abstraction has been used in a completely different way as compared to Scheme. 4. Abstraction is very very powerful tool not only in Computer Science, but also in other Engineering and Management systems.
1) Abstraction is one of the technique of the computer science to manage complexity of the software.It gives the power to name the common task that your software require, while ignoring the implementation details of the task. take for example square function scheme (define (square x) (* x x)) and hypotenuse function (define (hypotenuse x y ) (+ (square x) (square y))) i can see the implementation of hypotenuse function see that it uses square to calculate the final result and without going into the implementation detail of square see that the value calculated by hypotenuse must be correct as the its mathematical definition . And I can now use hypotenuse to build some other function. 2) Abstraction also enhance the read ability of the program (define PI 3.145678) If our program uses pi value at multiple places, instead of using the complete value of pi (3.145678) in the program, we can use the variable pi without loss of information.