0% found this document useful (0 votes)
13 views13 pages

Topic 3

Software construction Software construction Software construction

Uploaded by

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

Topic 3

Software construction Software construction Software construction

Uploaded by

afiqah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

SOFTWARE CONSTRUCTION

CBSC4103
TOPIC 3 : PROGRAMMING CONCEPTS
DR. MARIAYEE DORAISAMY
Abstraction
Process abstraction is
implemented by using
subprograms.

Data abstraction occurs in the I


mplementation details and Core
Functionality only. So, these two
layers are hidden from end users
. End users just use the interface
without knowing how it works .
Example
ADVANTAGES
#include <iostream>
#include <string>
using namespace std;
class Test The programmer need not write low-level code
{ 1
int nilai1,nilai2;
void BacaNom(){ Abstraction protects the internal implementation from
cout<<“Masukkan Nilai 1: "; cin>>nilai1;
cout<<"\n Masukkan Nilai 2 : "; cin>>nilai2;
2 malicious use and errors.
}
Abstraction can prevent code duplication and thus the
public: 3 programmer needs to perform the same tasks over a
void PaparJum() nd over again.
{
BacaNom();
cout<<"\n Jumlah adalah "<<nilai1+ nilai2<<endl; Abstraction promotes code reuse and properly
} 4 classifies the class data members.
};
int main() Output:
{ Masukkan Nilai 1 : 100 The Programmer can change the internal details of
Test s; Masukkan Nilai 2: 50 5 the class implementation without the knowledge of
s.PaparJum (); end-user thereby without affecting the outer layer
Jumlah adalah 150 operations.
}
Types of Data Abstraction

BUILT IN USER DEFINED


ABSTRACT
DATA TYPES
A B ABSTRACT DATA
TYPES

Example Example
• Int, Char, String, • Declare variable by own
Float and etc. • Manipulating objects in
our coding
DECOMPOSING
A bigger problem decompose into smaller problems
• The process of decomposing a larger problem
into smaller problems or sub problems is
called as Modularization.

Separately Grouping all Hide internal Clean and


compiled the relevant details to well defined
data and prevent interfaces
operations interferences
MODULARIZATION IN JAVA

It makes the program


development more manageable.

It employs the divide and


Example
conquer approach
Java API provides a rich collections
of classes and methods for
It allows reusability – new performing common mathematical
programs can be developed by calculation, string manipulations
using the exiting methods. and other useful application as well.

It avoids repeating codes


Example :
WHAT IS PROCEDURE ? proc concatenate_two_strings()
var string first_name = “Amirul “
A procedure is a set of coded instructions that tell a var string last_name = “Mohamad"
var string full_name = first_name + " "
computer how to run a program or calculation. Depending + last_name
on the programming language, a procedure may also end
be called a subroutine, subprogram or function.
The difference between function and procedure is :
• Function return a value
• Procedure does not return value

Procedure allows task more manageable, Procedures are resources


it will also allow us to test specific parts of
our code and make sure it is working Procedure save time – allow only one
properly, before moving on to the next time codes - used many times
task
Procedure allow our program to look
like our top design
WHAT IS FUNCTIONS ?

It is a subprogram – perform
task Example
func string concatenate_two_strings()
{
var string first_name = “Amirul “
It is invoked by expression var string last_name = “Mohamad"
var string full_name = first_name + " " + last_name
return full_name
}
It has two purpose which are :
• It name the action
• It functions according to the action
that needed by the variable
identifier
It contains header (type of result, identifier of the function and list of
parameters), and declarative part and body { }
MODULARIZATION IN JAVA

It makes the program


development more manageable.

It employs the divide and


Example
conquer approach
Java API provides a rich collections
of classes and methods for
It allows reusability – new performing common mathematical
programs can be developed by calculation, string manipulations
using the exiting methods. and other useful application as well.

It avoids repeating codes


PARAMETER PASSING METHOD
Pass By Value : in-mode
biodata ( “Ali Ahmad” , 30)

Pass By Result : out-mode


biodata ( a1, a2)

3 types semantics Pass By Reference: in-out mode


The way parameters modes
are transmitted to Biodata( &a1, &a2)
subprograms • In mode
• Out mode
• In-out mode
Pass By Name
It can be pass by result (scalar
variable ) or pass by reference
(constant variable) , or any other
method
Nested IF
Pilihan Bersarang (Semua pilihan perlu dilepasi unt
uk melaksanakan arahan) --
Cara baca : First In Last Out( FILO) / Last In First O
ut (LIFO)
Tidak
A
Jika ( ) ---if
-Jika ( ) – if Ya
-Jika ( ) --- if Tidak
-Jika Tidak ( ) ---else B
-Jika Tidak ( ) ---else
Ya
-Jika Tidak ( ) – else
C
Revision Questions
TOPIC 3
❑ Define Data Abstraction.
❑ Explain two types of Data Abstraction.
❑ List the advantages of Data Abstraction.
❑ Define Modularization.
❑ Describe Procedure.
❑ Give an example of Procedure.
❑ What are the benefits of having Procedure?
❑ Describe Function.
❑ Give an example of Function.
❑ Write the difference between Procedure and Function.
❑ Function header contains ?
❑ Explain four types of parameter passing method?
❑ State 3 types of semantic model in parameter passing method?
Thank you
This text can be replaced with your own text

You might also like