0

Abstraction means hiding 'implementation details'..... So the goal of abstraction is to achieve information hiding?? And what is hidden in Information hiding if not implementation details?? And how abstraction is a technique to information hiding?

Charles
  • 48,924
  • 13
  • 96
  • 136
Mishthi
  • 1,659
  • 4
  • 15
  • 12

2 Answers2

0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

/* Example of Abstratcion: An application for mobile manufacturing company - Every phone must have to implement caller 
 * and sms feature but it depends on company to company (or model to model) if they want to include other features or not 
 * which are readily available , you just have to use it without knowing its implementation (like facebook in this example).
 */
namespace AbstractTest
{
    public abstract class feature
    {
        public abstract void Caller();
        public abstract void SMS();
        public void facebook()
        {
            Console.WriteLine("You are using facebook");
        }
    }    
    public class Iphone : feature    
    {
        public override void Caller()
        {
            Console.WriteLine("iPhone caller feature");
        }
        public override void SMS()
        {
            Console.WriteLine("iPhone sms feature");
        }
        public void otherFeature()
        {
            facebook();
        }
    }
    public class Nokia : feature
    {
        public override void Caller()
        {
            Console.WriteLine("Nokia caller feature");
        }
        public override void SMS()
        {
            Console.WriteLine("Nokia sms feature");
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            Iphone c1 = new Iphone();
            c1.Caller();
            c1.SMS();
            c1.otherFeature();
            Nokia n1 = new Nokia();
            n1.Caller();
            n1.SMS();
            Console.ReadLine();
        }
    }
}
Achintya
  • 1
  • 3
  • Sorry, the question was not to provide an example, but to explain the concept. Please add detailed explanation as to how your code helps in clearing his doubts. If not, please remove the answer. – phoenix Feb 14 '16 at 10:33
0

The goal of abstraction is not to hide information in the sense of variable values, that would be encapsulation.

Abstraction's only goal is allow programmers to use an algorithm or concept without understanding it. Information hiding may be a by-product of this but it is not its goal.

Marcus Whybrow
  • 18,372
  • 7
  • 64
  • 88