January 3rd, 2005, 03:10 PM
I've been learning a bit about OOPS lately. I understood the concept of "abstraction" .. But i couldn't understand its link with programming. Are you abstracting things from the user ??.
If yes then does it make a real difference between ordinary sequential coding and OOPS as
the user never has to bother about the elements of the program. The user gives the input and inturn gets the desired output. Where does abstraction really come into play in this ?.I guess i got the whole concept wrong .Do help me out ...
January 3rd, 2005, 04:08 PM
Some nice reading: http://java.sun.com/docs/books/tutor.../abstract.html
Sometimes, a class that you define represents an abstract concept and, as such, should not be instantiated. Take, for example, food in the real world. Have you ever seen an instance of food? No. What you see instead are instances of carrot, apple, and (our favorite) chocolate. Food represents the abstract concept of things that we all can eat. It doesn't make sense for an instance of food to exist.
Similarly in object-oriented programming, you may want to model an abstract concept without being able to create an instance of it. For example, the Number class in the java.lang package represents the abstract concept of numbers. It makes sense to model numbers in a program, but it doesn't make sense to create a generic number object. Instead, the Number class makes sense only as a superclass to classes like Integer and Float, both of which implement specific kinds of numbers. A class such as Number, which represents an abstract concept and should not be instantiated, is called an abstract class. An abstract class is a class that can only be subclassed-- it cannot be instantiated.
Though i have learnt abstraction but hardly use as well. Hope some experts would give more examples of the common usage
January 3rd, 2005, 08:01 PM
Another example would be if you were wanting to create a game and had several different types of vehicles that all worked differently, you could create an abstact vehicle class that covered some things that all vehicles share, then leave the specifics to each individual class (like truck, plane, boat...) This is an example of using generalisation (or inheritance) coupled with abstraction to cut down the amount of code you are required to write, and also to enable code-reuse (which is like the holy grail of OOP)
Hope that helped somewhat.
January 11th, 2005, 04:53 PM
If you want a good view of abstraction, and other OOP things. Get yourself an unreal or Ut game and look at the Uscript. OOP at its best.
Since the beginning of time, Man has searched for the answers to the big questions: \'How did we get here?\' \'Is there life after death?\' \'Are we alone?\' But today, in this very theatre, you will be asked to answer the biggest question of them all...WHO LIVES IN A PINEAPPLE UNDER THE SEA?