0% found this document useful (0 votes)
3 views5 pages

Module 8

This learning module from Binalatongan Community College focuses on Object Oriented Programming, specifically on the concept of Abstraction in Java. It outlines learning objectives, resources, tasks, and content related to abstraction, including control and data abstraction, and methods as an abstraction mechanism. The module also includes assessment questions to evaluate understanding of these concepts.

Uploaded by

deveraweng1
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views5 pages

Module 8

This learning module from Binalatongan Community College focuses on Object Oriented Programming, specifically on the concept of Abstraction in Java. It outlines learning objectives, resources, tasks, and content related to abstraction, including control and data abstraction, and methods as an abstraction mechanism. The module also includes assessment questions to evaluate understanding of these concepts.

Uploaded by

deveraweng1
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Binalatongan Community College

Brgy. Ilang San Carlos City, Pangasinan

Bachelor of Science in Information Technology (BSIT)


LEARNING MODULE

Module No. 8
Subject Code : IT 211
Subject Description : Object Oriented Programming
Term : 1st Semester 2022-2023

I. Learning Objectives:
To have a complete overview of the subject
II. Learning Outcome:
- Learn and understand the role of Abstraction in Java
programming language.
III. Learning Resources/Reference:
- Concise Guide to Object Oriented Programming, Kingsley Sage,
2019
- The Object-Oriented Thought Process Fifth Edition, Matt Weisfeld,
2019
IV. Tasks to Complete:
- Read the Abstraction in object-oriented programming
- Learn the different kinds of Abstraction and learn the methods in
object-oriented programming.
- Answer the questions in self-assessment.
V. Content:

Abstraction
ABSTRACTION IS A CENTRAL IDEA in computer science and an
understanding of this important term is crucial to successful programming.
Abstraction is the purposeful suppression, or hiding, of some details of a
process or artifact, in order to bring out more clearly other aspects, details,
or structures.
Timothy Budd
In general, philosophical terminology, abstraction is the thought
process wherein ideas are separated from objects. Our minds work mostly
with abstractions. For example, when thinking about a chair, we do not have
in mind a particular chair but an abstract idea of a chair—the concept of a
chair. This why we are able to recognize an object as a chair even if it is
different from any other chair we’ve seen previously. We form concepts of
everyday objects and events by a process of abstraction where we remove
unimportant details and concentrate on the essential attributes of the thing.
Abstraction in mathematics is the process of extracting the underlying
essence of a mathematical concept, removing any dependence on real world
objects with which it might originally have been connected, and generalizing
it so that it has wider applications. Many areas of mathematics began with
the study of real-world problems, before the underlying rules and concepts
were identified and defined as abstract structures. For example, geometry
has its origins in the calculation of distances and areas in the real world;
statistics has its origins in the calculation of probabilities in gambling.

Control Abstraction
Control abstraction is one of the main purposes of using programming
languages. Computer machines understand operations at the very low level
such as moving some bits from one location of the memory to another
location and producing the sum of two sequences of bits. Programming

high-level expression/program statement: a := (1 + 2) ∗ 5.


languages allow this to be done at a higher level. For example, consider the

To a human, this is a fairly simple and obvious calculation (“one plus


two is three, times five is fifteen”). However, the low-level steps necessary to
carry out this evaluation, and return the value ”15”, and then assign that
value to the variable ”a”, are actually quite subtle and complex. The values
need to be converted to binary representation (often a much more
complicated task than one would think) and the calculations decomposed (by
the compiler or interpreter) into assembly instructions (again, which are
much less intuitive to the programmer: operations such as shifting a binary
register left, or adding the binary complement of the contents of one register
to another, are simply not how humans think about the abstract arithmetical
operations of addition or multiplication). Finally, assigning the resulting value
of ”15” to the variable labeled ”a”, so that ”a” can be used later, involves
additional ’behind-thescenes’ steps of looking up a variable’s label and the
resultant location in physical or virtual memory, storing the binary
representation of ”15” to that memory location, etc. etc

Data Abstraction
Data abstraction is the enforcement of a clear separation between the
abstract properties of a data type and the concrete details of its
implementation. The abstract properties are those that are visible to client
code that makes use of the data type– the interface to the data type–while
the concrete implementation is kept entirely private, and indeed can change,
for example to incorporate efficiency improvements over time. The idea is
that such changes are not supposed to have any impact on client code, since
they involve no difference in the abstract behavior.
For example, one could define an abstract data type called lookup table,
where keys are uniquely associated with values, and values may be
retrieved by specifying their corresponding keys. Such a lookup table may be
implemented in various ways: as a hash table, a binary search tree, or even
a simple linear list. As far as client code is concerned, the abstract properties
of the type are the same in each case.

Abstraction in Object-Oriented Programs


There are many important layers of abstraction in object-oriented
programs. 2 At the highest level, we view the program as a community of
objects that interact with each other to achieve common goals. Each object
provides a service that is used by other objects in the community. At this
level we emphasize the lines of communication and cooperation and the
interactions between the objects.
Another level of abstraction allows the grouping of related objects that
work together. For example JAVA provides units called packages for grouping
related objects. These units expose certain names to the system outside the
unit while hiding certain features. For example the [Link] package provides
classes for networking applications. The JAVA Software Development Kit
contains various packages that group different functionality.
The next levels of abstraction deal with interactions between individual
objects. A useful way of thinking about objects, is to see them as providing a
service to other objects. Thus, we can look at an object-oriented application
as consisting of serviceproviders and service-consumers or clients. One level
of abstraction looks at this relationship from the server side and the other
looks at it from the client side.
Clients of the server are interested only in what the server provides (its
behavior) and not how it provides it (its implementation). The client only
needs to know the public interface of a class it wants to use—what methods
it can call, their input parameters, what they return and what they
accomplish.

Methods as an Abstraction Mechanism


IN THIS SECTION we’ll discuss an abstraction mechanism you’re
already familiar with: the method (variously called subroutines, procedures,
and even functions).
Black Boxes

A Method is an abstraction mechanism and consists of instructions for performing some task, chunked
together and given a name. ”Chunking” allows you to deal with a potentially very complicated task as a
single concept. Instead of worrying about the many, many steps that the computer might have to go
though to perform that task, you just need to remember the name of the method. Whenever you want
your program to perform the task, you just call the method. Methods are a major tool for dealing with
complexity.

A method is sometimes said to be a ”black box” because you can’t see


what’s ”inside” it (or, to be more precise, you usually don’t want to see
inside it, because then you would have to deal with all the complexity that
the method is meant to hide). Of course, a black box that has no way of
interacting with the rest of the world would be pretty useless. A black box
needs some kind of interface with the rest of the world, which allows some
interaction between what’s inside the box and what’s outside. A physical
black box might have buttons on the outside that you can push, dials that
you can set, and slots that can be used for passing information back and
forth. Since we are trying to hide complexity, not create it, we have the first
rule of black boxes:
The interface of a black box should be fairly straightforward, well-defined,
and easy to understand.
Your television, your car, your VCR, your refrigerator... are all examples
of black boxes in the real world. You can turn your television on and off,
change channels, and set the volume by using elements of the television’s
interface – dials, remote control, don’t forget to plug in the power – without
understanding anything about how the thing actually works. The same goes
for a VCR, although if stories about how hard people find it to set the time on
a VCR are true, maybe the VCR violates the simple interface rule.
Now, a black box does have an inside – the code in a method that
actually performs the task, all the electronics inside your television set. The
inside of a black box is called its implementation. The second rule of black
boxes is that:
To use a black box, you shouldn’t need to know anything about its implementation; all you need
to know is its interface.
In fact, it should be possible to change the implementation, as long as
the behavior of the box, as seen from the outside, remains unchanged. For
example, when the insides of TV sets went from using vacuum tubes to using
transistors, the users of the sets didn’t even need to know about it – or even
know what it means. Similarly, it should be possible to rewrite the inside of a
method, to use more efficient code, for example, without affecting the
programs that use that method.
VI. Assessment: Discuss the following questions.

1. What are the Methods of Abstraction, and give examples in Java


programming?
2. What is the role of abstraction in object-oriented programming?
3. Discuss briefly the difference between data abstraction and control
abstraction and site an example in coding Java programs.

You might also like