0% found this document useful (0 votes)
5 views537 pages

CS101 MCQs 500

Sudent Guidess
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)
5 views537 pages

CS101 MCQs 500

Sudent Guidess
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
You are on page 1/ 537

CS101 MCQs with Answers

1. 1.

115.

Progr ammi ng L ang uages: O bj ect O ri e nt ed Par ad ig m

objec t
-
or ie nte d p ar adig m,
whi c h is a ss oc ia t ed wit h t he pr ogr a mmi ng pr oc ess ca l l ed
ob ject
-
or ie nte d
progr ammi ng(O O P).
F oll owi ngt hispar a digm, a soft wa r esyst emisvi eweda sacol l ect i onofunit s, ca ll e d
objec ts,
ea ch of whic h is ca pa ble of p er for mi ng t he a ct i ons t ha t ar e i mmedia t el y r ela t ed
t o it s el f a s wel l a s
r equ est i ng a ct ions of ot her obj ect s. T oget her , t hes e ob j ect s

int er a ct t o sol ve t he pr ob l em a t ha nd.

As a n exa mp l e of t he object
-
or i ent ed a ppr oa ch a t wor k, consi der t he t a sk of devel op i ng a gr a phica l user
i nt er fa ce. I n a n obj ect
-
or i ent ed envir onment , t he ic ons t ha t a ppea r on t he scr een wou l d b e i mp l ement
ed a s
ob j ect
s. Ea ch of t hes e obj ect s wou l d enc ompa ss a col l ect i on of fu nct i ons (ca l l ed
me t ho ds
i n t he ob j ect
-
or i ent ed ver na cula r ) descr ibi ng how t ha t obj ect is t o r espond t o t he oc cur r enc e
of va r ious event s, such a s
bei ng sel ect ed by a clic k of t he mous e but t on or bei
ng dr a gged a cr oss t he scr een by t he mous e.
T hus,

t he
ent ir e s yst em woul d b e c onst r uct ed a s a col l ect i on of obj ect s, ea c h of whic h
knows how t o r esp ond t o t he
event s r ela t ed t o it .

T ocont r a st t heob j ect


-
or i ent edpa r a di gm wit ht he i mp er a t ivepa ra di gm, c onsi
der a pr ogr a mi nvol vinga list
ofna mes. I nt het r a dit i ona li mp er a t ivepa r a digm, t hisl ist wou ldmer el yb ea col l ect
i onofda t a. Anypr ogr a m
unit a ccess i ng t he list wou l d ha ve t o c ont a i n t he a l gor it hms f or per f or mi ng t he
r equ ir ed ma nipu la t i ons. In
t he obj e
ct
-
or i ent ed a ppr oa ch, however , t he l ist wou l d b e c onst r uct ed a s a n ob j ect t ha t
cons ist ed of t he list
t oget her wit h a col l ect i on of met hods for ma nipu la t ing t he l ist . (T his mi ght inclu
de fu nct ions f or ins er t in g
a new ent r y i n t he l ist , del et i ng a n ent r y fr o
m t he l ist , det ect i ng if t he l ist is empt y, a nd sor t ing t he l ist . ) In
t ur n, a not her pr ogr a m unit t ha t needed t o ma nipu la t e t he list wou l d not c ont a
in a l gor it hms for per f or mi n g
t he p er t i nent t a sks. Inst ea d, it woul d ma ke us e of t he f unct i ons pr ovi ded i n t he

obj ect . In a sens e, r a t her


t ha n sor t i ng t he l ist a s in t he i mp er a t ive pa r a di gm, t he pr ogr a m u nit wou ld a
sk t he l ist t o sor t it s el f. It s

i nt r odu ct i on
. T o t his end, r eca ll t ha t a n obj ect ca n c ons ist of da t a (such a s a list of na mes) t
oget her wit h a
col l ect i on of met hods f or per
-

for mi ng a ct i vit i es (suc h a s inser t i ng new na mes in t he l ist ). T hes e f ea t ur es


must bedes cr ib edbyst a t ement si nt he wr it t enpr

a
class .
Onc e a cla ss ha s been c onst r uct ed, it ca n be a ppli ed a nyt i me a n ob j ect wit h t hos
e c ha r a ct er ist ics is
needed. T hus, sever a l ob j ect s ca n b e ba s ed on (t ha t is, built fr om) t he sa me cla ss .
J
ust like i dent ica l t wi ns,
t hes eob j ect swou l dbedist i nct ent it i esbut wou ldha vet hesa mec ha r a ct er ist icsbeca
uset heya r econst r uct ed
fr om t he sa me t emp la t e (t he sa me c la ss ). (An ob j ect tha t is based on a par t icula r
cla ss is sa id t o b e a n
i nst ance
of t ha
t cla ss . )
Intr oduct i on t o Com put in g

CS101

VU

P ag e
201

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 116


2. 2.
116.

Progr ammi ng L ang uages: V ar i ab le and Data T ype s

Hi gh
-
l evelpr ogr a mmi ngla ngua gesa ll ow loca t i ons in ma i n memor yt ob er ef er enc edby
descr ipt i vena mes
r at her t ha n by nu mer ic a ddr ess es. S uch a na me is known a s a
vari ab le,
in
r ec ognit i on of t he fa ct t ha t by
cha ngi ng t he va lu e st or ed a t t he loca t ion, t he va lu e a ss oc ia t ed wit h t he na me
cha nges a s t he pr ogr a m
ex ecut es. Unli ke P yt hon, our exa mp l e la ngua ges i n t hi s cha pt er r equ ir e t ha t va
r ia bles b e i dent if i ed via a
decla r a t ive st a t e
ment pr i or t o bei ng us ed els ewher e i n t he pr ogr a m. T hes e dec la r a t ive s t a t
ement s a ls o
r equir e t ha t t he pr ogr a mmer descr ib e t he t yp e of da t a t ha t wi l l be st or ed a t t he
memor y l oca t i on a ss ocia t ed
wit h t he va r ia ble.

S uch a t ype is known a s a


dat a type
a nd enc o
mpa ss es bot h t he ma nner i n whic h t he da t a it em is enc oded
a nd t he op er a t ions t ha t ca n be per for med on t ha t da t a. For exa mp l e, t he t yp e
i nt eger
r ef er s t o nu mer i c da t a
ha t ca n be
per f or med on i nt eger da t a inc lu de t he t r a dit i ona l ar it hmet i c op er a t ions a nd c
ompa r isons of r ela t i ve siz e,
sucha sdet er mi ni ngwhet her oneva lu eisgr ea t er t ha na not her . T het yp e
flo at
(s omet i mesca l l ed
re al
)r ef er s
t o nu mer ic da t a t ha t mi ght c on
t a in va lu es ot her t ha n whole nu mb er s, pr oba bly st or ed i n f l oa t ing
-
p oint
not a t ion. Oper a t ions per f or med on da t a of t ype fl oa t ar e simi la r t o t hos e per f or
med on da t a of t ype i nt eger .
R eca l l, however , t ha t t he a ct i vit y r equ ir ed for a ddi ng t wo it ems of t yp e fl
oa t diff er s fr om t ha t for a ddi ng
t wo it ems of t yp e i nt eger .

S uppose, t hen, t ha t we wa nt ed t o us e t he va r ia bl e W ei ght Limit i n a pr ogr a m t o


r ef er t o a n a r ea of ma i n

++,Ja va ,
a nd C # we wou l d dec la r e our int ent i on by i ns er t i ng t he st a t ement

i nt We ig htL i mi t;

t he pr ogr a m t o r ef er t o a memor y a r ea cont a ini ng a va l ue st or e

va r ia bl es of t he sa me t yp e ca n nor ma l l y be dec la r ed in t he sa me dec la r a t ion st a


t ement . F or exa mpl e, t h e
st a t ement

i nt H e ig ht, Wid t h;

wou l d dec la r e bot h H ei ght a nd Wi dt h t o b e va r ia bl es of t yp e i nt eger . Mor


eover , mo
st la ngua ges a ll ow a
va r ia bl e t o be a ss igned a n init ia l va lu e when it is dec la red. T hus,

i nt We ig htL i mi t = 100;

wou l dnot onl ydec la r eWei ght Limi t t obeavar ia bleoft yp ei nt eger buta lsoa ss ignit t
hest ar t ingva lu e100.
In c ont r a st , dyna mica l l y t yp ed
la ngua ges l i ke P yt hon a ll ow va r ia bles t o b e a ss igned wit hout fir st decla r i ng
t heir t ype; suc h va r ia bl es ar e chec ked f or cor r ect t yp e l a t er , when op er a t ions
a r e per f or med upon t hem.

Ot her com mon da t a t ypes i nclu de cha r a ct er a nd B ool ea n. T he t yp e c ha r a ct er


r
ef er s t o da t a cons ist i ng of
symb ols, pr oba blyst or edusi ngAS C IIor Uni c ode. Oper a t ionsper f or medonsuchda t
ainc lu dec ompa r isons
sucha sdet er mi ni ng whet her ones ymb oloc cur sbefor ea not her ina lp ha bet ica lor der ,
t est i ngt osee whet her
onest r ingofsymb
olsa ppea r sins i dea not her , a ndconca t ena t i ngonest r ingofsymb olsa t t heend ofa not
her
t o for m one l ong st r ing. T he st a t ement

c har L ette r, Digit ;

cou l d b e used i n t he la ngua ges C , C ++, C #, a nd Ja va t o dec la r e t he va r ia bles


Let t er a nd Di git t o be of t yp e

c ha r a ct er .

Intr oduct i on t o Com put in g

CS101

VU

P ag e
202

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan


T he t yp e
B oole an
r ef er s t o da t a it ems t ha t ca n t a ke on only t he va lu es t r ue or fa ls e. Oper a t ions
on da t a of
t yp e Bool ea n inclu de i nqu ir i es a s t o whet her t he cur r ent va lue is t r ue or fa lse. F
or exa mp l e, if t he va r ia ble
Limit Exc eeded wa s decla r ed

t o b e of t yp e B ool ea n, t hen a sta t ement of t he for m

if (Limi t Exc eeded) t hen (. . . ) els e (. . . )

wou l d be r ea sona bl e.

T he da t a t ypes t ha t a r e inc lu ded a s pr imit i ves i n a pr ogr a mmi ng la ngua ge,


such a s int for int eger a nd c ha r
for c ha ra ct er , ar e ca ll ed
pr i mi t iv
e d at a typ es.
As we ha ve l ea r ned, t he da t a t ypes suc h a s: int eger , fl oa t ,
cha r a ct er , a nd b ool ea n a r e com mon pr i mit i ves. Ot her da t a t yp es t ha t ha ve
not yet b ec ome wi despr ea d
pr i mit i ves i nc lu de i ma ges, a udi o, vi deo, a nd hyp er t ext . However , t ypes suc h a s
GIF ,

JP EG, a nd HT ML
mi ght soon b ec ome a s com mon a s int eger a nd f l oa t .

Intr oduct i on t o Com put in g


CS101

VU

P ag e
203

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 117


3. 3.

117.

Progr ammi ng L ang uages: D at a S tr uc t ure


In a ddit i on t o da t a t ype, va r ia bl es i n a pr ogr a m a r e oft en a ss oc ia t ed wit h
d at a str uct ure,
whi c h is t h e
conc ept ua lsha peor ar ra ngement
ofda t a . F or exa mp l e, t ext isnor ma ll yvi eweda sa longst r ingofc ha r a ct er s,
wher ea s sa les r ec or ds mi ght be envisi oned a s a r ect a ngu la r t a ble of nu mer i c va
lu es, wher e ea c h r ow
r epr es ent s t he sa l es ma de b y a par t icula r emp l oyee a nd ea c h c olu mn r epr es ent
st
he sa l es ma de on a
pa rt icula r da y.

One c ommon da t a st r uct ur e is t he


arr ay,
whic h is a bloc k of el em ent s of t he sa me t yp e such a s a one
-
di mens i ona l list , a t wo
-
di mens i ona l t a ble wit h r ows a nd c olu mns, or t a bles wit h hi gher di mens i ons. T o
est a bl ish suc h a n a
rr a y in a pr ogr a m, ma ny pr ogr a mmi ng la ngua ges r equ ir e t ha t t he dec la r a t ion
st a t ement
decla r i ngt he na me oft hea r r a ya lsospeci fyt he l engt h of ea ch di mens i on oft hea r ra
y. F or exa mp l e, F i gur e
94 displa ys t he c onc ept ua l st r uct ur e decla r ed b y t he st a tement

i nt S cores[2 ][9];

a t wo
-
wou l d be wr it t en a s

INT E GE RS c
ores (2, 9)

Onc ea na r ra yha sbeendec la r ed, it ca nber ef er enc edels ewher ei nt hepr ogr a mb yit
sna me, or a nindi vi dua l
el ement ca n b e i dent if i ed b y mea ns of i nt eger va lu es c a ll ed
i ndi ces
t ha t spec if y t he r ow, c olu mn, a nd s o
on, des ir ed. However , t he r a ng
e of t hes e ind ic es va r i es fr om la ngua ge t o la ngua ge. F or exa mp l e, i n C (a nd
it s der i va t i ves C ++, Ja va, a nd C #) indic es st a rt at 0, mea ni ng t ha t t he ent r y i n t
he s ec ond r ow a nd f our t h
colu mn of t he a r ra y ca ll ed S c or es (a s dec la r ed a bove) wou l d b e r ef er enc ed

by S c or es[1][3], a nd t he ent r y
i n t he fir st r ow a nd fir st colu mn wou ld b e S cor es[0 ][ 0]. In cont r a st , indic es st a rt
a t 1 in a F ORT R AN
pr ogr a m s o t he ent r y i n t he s ec ond r ow a nd f our t h c olumn wou l d b e r ef er enc ed
b y S cor es(2, 4) (s ee a ga i n
F igur e 94).

Fi gure
94
: A t wo
-
di mensi onal arr ay wi t h t wo ro ws and ni ne col umns

Inc ont r a st t oa na rra yi nwhi c ha llda t a it emsa r et hes


a met yp e, a n
agg reg atety pe
(a ls oca ll eda
str uct ur e,
a
record,
or somet i mes a
heterog e neo us ar ray
) is a bl oc k of da t a in whic h di ff er ent el ement s ca n ha v e
diff er ent t yp es. F or i nst a nc e, a bloc kofda t a r ef er r ingt oa nemp l oyeemi ght c onsist
ofa nent r yca
l l edNa m e

Intr oduct i on t o Com put in g

CS101

VU

P ag e
204

of
3 81
C opy rig htVi rtual U ni v ersi ty ofP aki stan

oft yp ec ha r a ct er , a nent r yca l l ed Age oft yp e int eger , a nda n ent r yca l l edS ki llR a t
i ngoft yp ef l oa t . S ucha n
a ggr ega t e t yp e wou ld b e dec la r ed i n C by t he st a t ement

str uc t

{c har

Name [25];

i nt Age ;

flo at S ki l lR at i ng;

} E mploy ee;

whic h sa ys t ha t t he va r ia bl e E mp l oyee is t o r ef er t o a str uct ur e (a bbr evia t ed st


r uct ) c ons ist i ng of t hr e e
comp onent s ca ll ed Na me (a st r ing of 25 c ha r a ct er s), Age, a nd S ki llR a t i ng (F i gur
e 95). Onc e suc h a n
a ggr ega t e ha s been decla r ed, a pr ogr a mmer ca n us e t
he st r uct ur e na me (E mp l oyee) t o r ef er t o t he ent ir e
a ggr ega t e or ca n r ef er enc e i ndi vi dua l
fie lds
wit hi n t he a ggr ega t e b y mea ns of t he s t r uct ur e na me f ol l owed
by a per iod a nd t he f i el d na me (suc h a s Empl oyee. Age) .

F igur e
95
: T he c onc ept ua l la yout of t he st r uct ur e Emp l oyee

Intr oduct i on t o Com put in g

CS101

VU

P ag e
205

of
3 81
C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 118


4. 4.

118.

Progr ammi ng
L ang uages: Ass ig n me nt S tat e me nt

Onc e t he sp ec ia l t er mi nol ogy t o b e used in a pr ogr am (suc h a s t he va r ia bles a nd


const a nt s) ha s bee n
decla r ed, apr ogr a mmer ca nbegi nt odescr ib et hea lgor it hmsi nvol ved. T hisisdoneby
mea nsofi mp er a t iv e
st a t ement s. T he m
ost ba sic i mp er a t ive st a t ement is t he
ass ig n me nt state me nt,
whic h r equ est s t ha t a va lu e
be a ss igned t o a var ia ble ( or mor e pr ec is el y, st or ed i n t he memor y a r ea ident if i
ed b y t he va r ia bl e). S uch a
st a t ement nor ma l l yt a kest hesynt a ct icf or mofava r ia ble,
foll owedbya symb olr epr es ent ingt hea ss ignment
op er a t ion, a ndt henb ya nexpr ess i oni ndica t i ngt he va lu et ob ea ss igned. T hesema nt
icsofsucha sta t ement
is t ha t t he expr essi on is t o be eva lua t ed a nd t he r esu lt st or ed a s t he va lu e of t he
va r ia ble. F or e
xa mp l e, t he
st a t ement :
Z = X + Y;

i n C , C ++, C #, a nd Ja va r equ est s t ha t t he sum of X a nd Y be a ss igned t o t he va r ia


ble Z. T he semi c ol on a t
t he endoft he l i ne, whic hisusedt os epa r a t esta t ement si n ma nyi mp er a t ive la ngua
ges, ist heonl ysynt a ct i c
diff er e
nc e fr om a n equ i va l ent P yt hon a ssignment st a t ement. In some ot her la ngua ges
(suc h a s Ada ) t h e
equ i va
-

l ent st a t ement wou l d a ppea r a s:

Z := X + Y;

Intr oduct i on t o Com put in g

CS101

VU

P ag e
206

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 119


5. 5.

119.

Progr ammi ng L ang uages: Co ntro l S tr uct ures ( i f


-
st at e me nt)

A
co ntro l stat e me nt
a lt er s t he
ex ecut i on sequ enc e of t he pr ogr a m. Of a ll t he pr ogr a mmi ng c onst r uct s.

i f (co nd it io n)

S tate me nt A
else

S tate me ntB .

denot e t his usi ng t he if


-
st a t ement , we

wi ll pr oc eed a s foll ow:

if ( ma r ks> =50)

You ha ve pa ssed t he exa mi na t i on

Els e

You ha ve fa il ed t he exa mina t i on

Intr oduct i on t o Com put in g

CS101

VU
P ag e
207

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 120


6. 6.

120.

Progr ammi ng L ang uages: Co ntro l S tr uct ures ( i f


-
st at e me nt exa mp les)

Int hismodu l e, wewi l ll ea r na not her exa mp l e.

S uppos ea univer s it ywa nt st ogivea schola r ship, ifa st udent


get s mor e t ha n 3. 0 C GP A i n a gi ven s emest er . We ca n wr it e t he pr ogr a m i n t he f
ol l owi ng wa y a nd you
ha ve a ls o seen it s i mp l ement a t i on i n t he vi deos i n t he onli ne c omp il er .

flo at f=3. 5;

i f (CG
PA>=3. 0)

else

Intr oduct i on t o Com put in g

CS101

VU

P ag e
208

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 121


7. 7.

121.

Progr ammi ng L ang uages: Co ntro l S tr uct ures (L oops)

T her e is a not her t ype of cont r ol st r uct ur e known a s l oop. T he l oop c ont r ol st r uct
ur e it er a t es a set of
i nst r uct ions ba sed on t he pr ovided condit i on.

C ons i der t he fol l owi ng exa mpl e, we a r e i nt er est ed t o pr i nt t he cou nt i ng fr om 1


t o 5. One wa y of doi ng t his

is a s foll ows :
Doi ng
t his usi ng l oop

is ea si er , you just need t o gi ve one st a t ement t ha t is pr int i ng cou nt i ng a nd you


need
t o t el l t ha t how ma ny t i mes, you wa nt t o do it . One ca n wr it e t he l oop a s foll ows :

i nt i=1;

w hi le (i< =5)

co ut<< i;

i= i+1;

T his l oop wil l ex ecut e 5 t imes a s foll ows :


8. 8.

2. T hen a ga i n condit i on wou l d b e


c hec ked,

a nd t he c ondit i on woul d
be t r ue a s 2<

6<=5). T his woul d b e t he t er mi na t i on f or t he loop.

Intr oduct i on t o Com put in g

CS101

VU

P ag e
209

of
3 81
C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 122


9. 9.

122.

Progr ammi ng L ang uages: Progr ammi ng Co nc urr e nt Act ivi ti es

S uppose we wer e a sked t o des i gn a pr ogr a m t o pr oduc e a ni ma t i on for a n a ct ion


comput er ga me i nvol vi ng
mult ipl ea t t a cki ngenemyspa ces hips. Onea ppr oa chwoul dbet odes i gna singl e
pr ogr a mt ha t woul dc ont r ol
t he ent ir e a ni ma t i on scr een. S uch a pr ogr a m wou l d be c ha r ged wit h dr a wi ng ea
c h of t he spa ces hips, whic h
(if t he a ni ma t i on is t o a pp ea r r ea list ic) wou ld mea n t ha t t he pr ogr a m wou l d ha
ve t o keep up wit h t he
i ndi vi dua l c ha r a ct er ist i
cs of nu mer ous spa cecr a ft . An a lt er na t e a ppr oa ch wou l d b e t o des i gn a pr ogr a
mto
cont r ol t he a ni ma t i on of a singl e spa ces hip whos e cha r act er ist ics a r e det er mi
ned by pa ra met er s a ssigned a t

e c ons t r uct ed by cr ea t i ng mu lt ip l e
a ct iva t i ons of t his pr ogr a m, ea ch wit h it s own set of para met er s. By ex ecut i ng t
hes e a ct i va t ions
si mu lt a neous ly, we c ou l d obt a i n t he i l lusi on of ma ny i ndivi dua l spa ces hips st r
ea ki ng a cr oss t he scr een a t
t he sa me t i me.

S uch si mu lt a neous ex ecut i on of mult ipl e a ct i va t i ons is ca ll ed


par al le l proc ess i ng
or
co nc urre nt
process i ng.
Tr ue pa ra ll el pr oc ess i ng r equir es mult ip l e CP U cor es, one t o ex ecut e ea ch a ct i va
t i on. W hen
onlyoneC P Uisa va ila ble, t hei l lusi onofpa r a llelpr oc e
s singisobta inedb ya ll owingt hea ct i va t i onst osha r e
t he t i me of t he si ngl e pr oc ess or in a ma nner si mi la r t o tha t i mpl em ent ed b y mu
lt ipr ogr a mmi ng s yst ems
.

Ma ny moder nc omput er a pplica t ionsa r emor e ea si l ysol vedi nt hec ont ext ofpar a
llelpr oc ess ingt ha
ni nt h e
mor et r a dit i ona lc ont ext invol vi nga si ngl es equ enc eofi nst r uct ions. I nt ur n, newer
pr ogr a mmi ngla ngua ges
pr ovi des ynt a xfor expr ess i ngt hes ema nt icst r uct ur esi nvolvedi npa r a ll elc omput a t
i ons. T hedes i gnofsuc h
a la ngua ge r equ ir es t he i dent if i
ca t i on of t hes e s ema nt ic st r uct ur es a nd t he devel op ment of a synt a x for
r epr es ent i ng t hem.

Ea chpr ogr a mmi ngla ngua get endst oa ppr oa cht hepa ra ll elpr oc ess i ngpar a digmfr
omit sownpoi nt ofvi ew,
r esult ing in diff er ent t er mi nol ogy. F or exa mp l e, wha t we ha v
e inf or ma ll y r ef er r ed t o a s a n
act i vat i on
is
ca ll ed a
t ask
in t he Ada ver na cula r a nd a
t hread
in Ja va . T ha t is, in a n Ada pr ogr a m, si mult a neous a ct ions
a r e per for med b y cr ea t ing mu lt ipl e
t asks,
wher ea s in Ja va one cr ea t es mu lt ip l e
t hreads.
In eit her ca se,
the
r esult is t ha t mu lt ip l e a ct i vit i es a r e gener a t ed a nd ex ec ut ed i n muc h t he sa me
wa y a s pr ocess es under t h e
cont r ol of a mu lt it a ski ng op er a t ing syst em. W e wi l l a dopt t he Ja va t er mi nology
a nd r ef er t o such

P er ha ps t he most ba sic a c
t ion t ha t must be expr ess ed i n a pr ogr a m i nvol vi ng pa ra ll el pr oc ess i ng is t ha t
of
cr ea t i ng new t hr ea ds. If we wa nt mult ip l e a ct iva t i ons of t he spa ces hip pr ogr a m
t o be ex ecut ed a t t he sa m e
t i me, we need a synt a x for sa yi ng so. S uch spa wni ng of new t hr ea ds i
s si mi la r t o t ha t of r equ est i ng t h e
ex ecut i on of a tr a dit i ona l funct i on. T he diff er enc e is tha t , in t he t ra dit i ona l s et t
i ng, t he pr ogr a m unit t ha t
r equ est s t he a ct iva t i on of a funct i on does not pr ogr ess a ny fur t her unt i l t he r
equ est ed funct i on t er mi na t es
(
r eca l l F igur e 6. 8), wher ea s i n t he pa ra ll el cont ext t he r equ est i ng pr ogr a m u nit
c ont i nu es ex ecut ion whi l e
t he r equ est ed funct ion p er for ms it s ta sk (F igur e 96).
T hus,
t o cr ea t e mu lt ip l e spa ce
-

s hips s tr ea ki ng a cr os s
t he scr een, we wou l d wr it e a ma i n pr ogr a m t ha t simp l y gener a t es mu lt ip l e a ct
i va t ions of t he spa ces hip
pr ogr a m, ea c h pr ovi ded wit h t he pa ra met er s descr ibi ng t he dist i nguis hi ng cha r
a ct er ist ics of t ha t spa cesh
ip.

Intr oduct i on t o Com put in g

CS101

VU

P ag e
210

of
3 81
C opy rig htVi rtual U ni v ersi ty ofP aki stan

Fi gure
96
:
Spawni ng t hreads

A mor e c omp l ex iss u e a ss ocia t ed wit h pa ra ll el pr oc ess ing i nvol ves ha ndli ng c
ommu nica t i on b et wee n
t hr ea ds. F or inst a nc e, i n our spa ceship exa mp l e, t he t hr ea ds r epr es ent i ng t h
e diff er ent spa ceships mi ght
needt oc ommu nica t et heir loca t i onsa mongt hems el vesi nor der t ocoor di na t et heir a
ct ivit i es. Inot her
ca ses,

one t hr ea d mi ght need t o wa it unt il a not her r ea ches a cer t a in point in it s computa
t ion, or one t hr ea d mi ght
need t o s
t op a not her one unt il t he fir st ha sa ccompl is hed a pa rt icula r ta sk.

S uch c ommu nica t i on needs ha ve l ong b een a t opic of st udy a mong c omput er sci ent
ist s, a nd ma ny newer
pr ogr a mmi ng la ngua ges r ef l ect va r ious a ppr oa ches t o t hr ea d i nt er a ct i on pr obl
ems. As a n ex
a mp l e, l et us
cons i der t he c ommu nica t i on pr obl ems enc ou nt er ed when t wo t hr ea ds ma nipu la
t e t he sa me da t a . If ea ch of
t wot hr ea dst ha t a r eex ecut i ngc oncur r ent ly needt oa ddt heva lu et hr eet oa
commonit em ofda t a ,a met ho d
is needed t o ensur e t ha t one t hr e
a d is a ll owed t o c omplet e it s t r a nsa ct ion b ef or e t he ot her is a ll owed t o
per f or m it s t a sk. Ot her wis e t hey c ou l d bot h st a r t t heir i ndivi dua l c omput a t
ions wit h t he sa me i nit ia l va lu e,
whic h wou l d mea n t ha t t he fi na l r esu lt wou ld b e i ncr ement ed by onl y t hr ee
r a t her t ha n six. Dat a t ha t ca n
be a cc ess ed by onl y one t hr ea d a t a t i me is sa id t o ha ve mut ua ll y exc lusi ve a cc
ess .

One wa y t o i mp l ement mut ua l l y exc lus i ve a ccess is t o wr it e t he pr ogr a m unit s t


ha t descr ib e t he t hr ea ds
i nvol ved s o t ha t when a t hr ea d is usin
g s ha r ed da t a , it bl oc ks ot her t hr ea ds fr om a cc ess i ng t ha t da t a unt i l
such a cc ess is sa fe.

Intr oduct i on t o Com put in g

CS101

VU
P ag e
211

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 123


10. 10.

123.

Progr ammi ng L ang uages: Ar it h me ti c O per ators E xamp l es

C
-
la ngua ge ha s t he f oll owing a r it hmet ic op er a t or s:

Addit i on

-
S ubtr a ct ion

Mult ip li ca t ion

Di vis i on

Modulus

+,
-

op er a nds

is deci ma l nu mb er , t hen it r esult s in t he sa me wa y a s in ma t hema t ics, for exa mp l


e:
11. 11.

5. 0/ 2. 0 woul d r esu lt i nt o 2. 5.

However , when bot h op er a nds a r e int eger s, t hen it wou l d t r unca t e t he dec i ma l
point a nd

5/ 2 wou l d r esult i nt o 2.
5%2 wou l d gi ve 1.

Mod ule 124


12. 12.

124.

Progr ammi ng L ang uages: Re l at io nal O per ato rs E xamp l es

C
-
la ngua ge ha s t he f oll owing r ela t iona l op er a t or s:

<

Les s t ha n

<=

Les s t ha n or equa l t o

>

Gr ea t er t ha n

>=
Gr ea t er t ha n or equa l t o

==

Equa l t o

!=

Not Equa l t o

C ++R ela t i ona l Op er a t or sar e


us ed t o c ompa r e va lu es of t wo va r ia bles . H er e i n exa mp l e we us ed t he
op er a t or s in

if st a t ement .

Now i f t he r esu lt a ft er compa r ison of t wo va r ia bl es is

Tr ue, t hen

if st a t ement

r et ur ns va lu e
13. 13.

1.

And if t he r esult a ft er compa r ison of t wo va r ia bl es is

Fa lse, t h
en
i f st a t ement

r et ur ns va lu e
14. 14.

0.

#i nc l ud e<iost re am>

us i ng name sp ac e std;

void

mai n()

i nt

a=10, b=20, c=10;

if
( a>b)

Intr oduct i on t o Com put in g


CS101

VU

P ag e
212

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

cout<<" a is greater" <<e nd l;

if
( a<b)
cout<<" a is s mal l er" <<e nd l;

if
( a<=c)

cout<<" a is less t han/ e q ual to c" <<


e nd l;

if
( a>=c)

cout<<" a is less t han/ e q ual to c" <<e nd l;

O ut p ut

a is s mal ler

a is less t han/ eq ual to c

a is gre ate r t han/ eq ual to c


I
n C ++ R ela t i ona l op er a t or s, t wo op er a t or s t ha t is

==

(Is Equa l t o) a nd

!=

(is Not Equa l T o), ar e used t o


chec k whet her t he t wo va r ia bl es t o be c ompa r ed a r e equa l or not
.

Let us t a ke one exa mp l e whic h demonst r a t e


t hes e t wo op er a t or s
.

#i nc l ud e<iost re am>

us i ng name sp ac e std;

void mai n()

i nt num1 = 30;

i nt num2 = 40;
i nt num3 = 40;

if( nu m1!= nu m2)

cout<<" nu m1 Is Not E qual T o num2" <<e nd l;

if( nu m2== nu m3)

cout<<" nu m2 Is E q ual T o nu m3" <<e ndl ;

O utp ut

nu m1 Is Not E qual T o num2


nu m2 Is E qual T o num3

Intr oduct i on t o Com put in g

CS101

VU

P ag e
213

of
3 81
C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 125


15. 15.

125.

Progr ammi ng L ang uages: L ogic al O per ato rs E xa mpl es


16. 16.

1.

C
-
la ngua ge L ogi ca l Oper a t or s ar e used if we wa nt t o compa r e mor e

t ha n one c ondit i on.


17. 17.

2.

Dep endi ng upon t he r equir ement , pr op er logica l op er a tor is used.


18. 18.

3.

F ol l owi ng t a bl e shows us t he diff er ent C ++ oper a t or sava i la bl e

Oper ators

Name o f t he
Oper ator
T ype

&&

AND Op er a t or

Bi na r y

||

OR Oper a t or

Bi na r y

NOT Oper at or

Una r y

Ac c or di ng t o na mes of t he L ogi ca l Op er a t or s, t he c ondit i on sa t isfi ed i n f ol l owi


ng s it ua t ion a nd exp ect ed
output s ar e gi ven

O per ator

O ut p ut

AND
Out put is 1 onl y when c ondit i ons on bot h si des

of Op er a t or become T r ue

OR

Out put is 0 onl y when c ondit i ons on bot h si des


of Op er a t or become F a ls e

NOT

It gi ves i nver t ed Out put

Let us look a t a ll logica l op er a t or s wit h exa mpl e


-

#i nc lude<i ost r ea m>

us i ng

name sp ac e

st d;

i nt

ma i n()

{
i nt

nu m1=30;

i nt

nu m2=40;

if
( nu m1> = 40 || nu m2> = 40 )

cout <<"OR If Bloc k Get s Ex ecut ed"<< endl;

if
( nu m1> = 20 & & num2> = 20 )

cout <<"AND If B l oc k G et s Execut ed"<< endl;


if
( !( nu m1> = 40 ))

cout <<"NOT If Bloc k G et s Execut ed"<< endl;

ret ur n

0;

O ut p ut:

OR If Bloc k Get s Ex ecut ed

Intr oduct i on t o Com put in g

CS101

VU
P ag e
214

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

AND If B l oc k G et s Execut ed

NOT If Bloc k G et s Execut ed

E xp l anat io n o f t he Prog ra m

Or st at ement gives out put = 1 when a ny of t he t wo c ondit i on is sa t isfi ed.

if
( nu m1>40 || nu m2>=40)

Her e i n a bove pr ogr a m , nu m2=40.


S o,
one of t he t wo condit i ons is sa t isfi ed.
S o,

sta t ement is ex ecut ed.

F or AND op er a t or , out put is 1 onl y when b ot h condit i ons a r e sa t isfied.

if
( nu m1>=20 & & nu m2>=20)

T hus,

in a bove pr ogr a m, bot h t he c ondit i ons a r e Tr ue so if bl oc k get s ex ecut ed.

T rut h T abl e

O per ator

1st
Cond it io n

2nd
Cond it io n

O ut p ut

AND

Tr ue
Tr ue

Tr ue

Tr ue

F a lse

F a lse

F a lse

Tr ue

F a lse

F a lse

F a lse

F a lse

OR

Tr ue

Tr ue

Tr ue

Tr ue
F a lse

Tr ue

F a lse

Tr ue

Tr ue

F a lse

F a lse

F a lse

NOT

Tr ue

F a lse

F a lse

Tr ue
Intr oduct i on t o Com put in g

CS101

VU

P ag e
215

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 126


19. 19.
126.

S oftware
E ngi nee ri ng: S oft ware E ngi nee r i ng Disc i pl i ne

T o a ppr ecia t e t he pr ob l ems i nvol ved i n s oft wa r e engi neer i ng, it is helpfu l t o s el
ect a lar ge c omp l ex devic e
(a n a utomob il e, a mult ist or y of fi c e buil ding, or per ha ps a ca t hedr a l) a nd i ma
gine b ei ng a sked t o desi gn

it
a nd t hen t o super vis e it s const r uct ion. How ca n you est i ma t e t he c ost i n t i me,
money, a nd ot her r esour c es
t o compl et e t he pr oj ect ? H ow ca n you di vide t he pr oj ec t int o ma na gea b l e pi ec
es? How ca n you ensur e t ha t
t hepi ec espr oduc eda r ec ompa t ib l e?H owca
nt hos ewor ki ngont he va r ious pi ec es c ommu nica t e?Howca n
you mea sur epr ogr ess ?Howca n youcop e wit ht he wi der a nge ofdet a il(t hes el ect i on
oft hedoor knobs, t he
des i gn of t he ga r goyl es, t he a va i la bi lit y of blu e gla ss for t he st a i ned gla ss wi
ndows, t he
st r engt h of t h e
pil la r s, t hedes i gn oft he duct wor kf or t hehea t i ngs yst em)?Qu est ions oft hesa mesc
op e must bea ns wer ed
dur i ng t he devel op ment of a lar ge soft wa r e syst em.

B eca us e engi neer i ng is a well


-
est a blis hed fi el d, you mi ght t hi nk t ha t t her e is a w
ea lt h of pr evi ousl y
devel op edengi neer i ngt ec hni qu est ha tca nbeusefuli nans wer i ngsuchqu est i ons. T
hisr ea soni ngispar t ia ll y
t r ue, but it over l ooks funda ment a l diff er enc es bet ween t he pr op er t i es of soft wa r
e a nd t hos e of ot her fi el ds
of engi neer i ng. T he
s e dist i nct i onsha vec ha l l engeds oft wa r e engi neer i ngpr oj ect s, l ea di ngt oc ost
over r uns,
la t e deli ver yofpr odu ct s, a nd dissa t isfi edcust omer s. Int ur n, ident i fyingt hes e dist i
nct i onsha spr ovent ob e
t he fir st st ep i n a dva nc ing t he soft wa r e engi neer i ng di
sc ipl i ne.

One suc h dist i nct i on i nvol ves t he a bi lit y t o c onst r uct syst ems fr om gener ic pr efa
br ica t ed c omp onent s.

-
t he
-

buil di ng bloc ks when const r uct i ng co


mpl ex devic es. The desi gner of a new a ut omobi l e does not ha ve t o
des i gn a new engi ne or t ra ns miss i on but inst ea d uses pr evi ous ly des igned ver si
ons of t hes e c omponent s.
S oft wa r e engi neer i ng, however , la gs i n t his r ega r d. In t he pa st , pr evious l y des i
gned sof
t wa r e c omp onent s
wer e doma i n sp eci fi c t ha t is, t heir int er na l des i gn wa s ba sed on a spec if ic a ppl
ica t i on a nd t hus t heir use a s
gener i c comp onent s wa s li mit ed. T he r esult is t ha t compl ex soft wa r e syst ems ha
ve hist or ica l l y been bui lt
fr omscr a t ch. Aswewil l

s eei nt hisc ha pt er , signif ica nt pr ogr ess isbei ngma dei nt hisr ega r d, a lt hou ghmor e
wor k r ema i ns t o b e done.
Anot her dist inct i on b et ween soft wa r e engineer i ng a nd ot her engineer i ng dis cip l i
nes is t he la c k of
qua nt it a t ive t ec hni qu es, ca ll ed
me tr ics,
for
mea s ur i ng t he pr op er t i es of s oft wa r e. F or exa mp l e, t o pr oj ect
t hec ost ofdevel op i nga soft wa r es yst em, onewou l dl i ket oest i ma t et hec omp l ex it
yoft hepr opos edpr oduct ,

t ing t he qua l it y of a
soft wa r e pr odu ct is cha l l engi ng. In t he ca se of mec ha ni ca l devic es, a n i mpor t a nt
mea sur e of qua l it y is t he
mea n t i me b et ween fa i lur es, whic h is ess ent ia ll y a mea sur ement of how wel l a
devic e endur es wea r .
S oft wa r e, i nc ont r a st ,doesn
ot wea r out ,sot hismet hodofmea sur i ngqua l it yisnot a sa pplica bl ei ns oft wa r e
engineer i ng.

T he dif fi cult i es i nvol ved i n mea sur i ng soft wa r e pr oper t i es i n a qua nt it a t ive ma
nner is one of t he r ea sons
t ha t soft wa r e engi neer i ng ha s str uggl ed t o fi nd a
r igor ous foot i ng i n t he sa me s ens e a s mec ha nica l a nd
el ect r ica l engi neer i ng. Wher ea s t hes e la t t er subject s ar e fou nded on t he est a blis
hed sci enc e of physi cs,
soft wa r e engi neer i ng cont i nu es t o sea r ch f or it s r oot s.

T hus, r esea r chi nsoft wa r eengi neer i ngis


cur r ent l ypr ogr ess i ngont wol evel s:S omer es ea r cher s, somet i mes
ca ll ed pr a ct it ioner s, wor k t owa r d devel op i ng t ec hni qu es for immedia t e a pplica
t i on, wher ea s ot her s, ca ll ed
t heor et ic ia ns, sea r ch f or under l yi ng pr incip l es a nd t heor ies on whic h mor e st a bl
e t ec
hni qu es ca n s omeda y
be c onst r uct ed. B ei ng ba sed on a subject i ve f ou nda t i on, ma ny met hodol ogi es
devel op ed a nd pr omot ed by
pr a ct it ioner sint hepa stha vebeenr ep la c edbyot her a ppr oa chest ha t ma yt hems el
vesbecome obsol et e wit h
t i me. Mea nwhi l e, pr ogr ess by
t heor et i cia ns cont i nu es t o b e s l ow.

Intr oduct i on t o Com put in g

CS101

VU

P ag e
216

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan


T heneedf or pr ogr ess bybot hpr a ct it ioner sa ndt heor et i cia nsisenor mous. Our soci et
yha sbec omea ddict ed
t o comput er syst ems a nd t heir a ss ocia t ed soft wa r e. Our ec onomy, hea lt hca r e,
gover nment , la w
enfor c ement , t r a nspor
t at ion, a nd def ens e dep end onla r ges oft wa r esyst ems. Yet t her ec ont i nu et ob e ma j
or
pr oblemswit ht her elia bil it yoft hes es yst ems. S oft wa r eer r or sha veca us edsuchdisa
st er sa ndnea r disa st er s
a s t he r isi ng moon b ei ng i nt er pr et ed a s a nucl ea r a tt a ck, a o
ne
-
da y l oss of $5 mi l li on b y t he Ba nk of N ew
Yor k, t he l oss of spa ce pr ob es, ra dia t i on over dos es t ha t ha ve ki l l ed a nd pa ra lyz
ed, a nd t he si mult a neou s
disr upt ion of t el ep hone c ommu nica t i ons over la r ge r egi ons.

T his is not t o sa yt ha t t he sit ua t ion is a ll bl


ea k. Much progr ess is bei ng ma de i n over c omi ng suc h pr obl ems
a s t he la c k of pr efa br ica t ed c omp onent s a nd met r i cs. Mor eover , t he a ppli ca t ion
of c omput er t ec hnol ogy t o
t he s oft wa r e devel op ment pr oc ess , r esu lt i ng i n wha t is ca ll ed
co mp ut er
-
aid ed so ftw are e ng i
nee ri ng
(CAS E ),
is cont i nui ng t o st r ea ml i ne a nd ot her wis e si m pli f y t he soft wa r e devel op ment
pr oc ess . C AS E ha s
l edt ot he devel op ment ofa va r iet y ofc omput er iz eds ys t ems, knowna s
CAS Etoo ls ,
whic h i nc lu depr oj ect
pla nning syst ems (t o a ss ist in cost est i ma
t i on, pr oj ect schedul i ng, a nd per sonnel a ll oca t i on), pr oj ect
ma na gement syst ems(t oa ss ist inmonit or i ngt hepr ogr ess oft hedevel op ment pr oj
ect ), docu ment a t iont ools
(t o a ss ist in wr it i ng a nd or ga ni zi ng docu ment a t i on), prot ot yp i ng a nd si mu la t
ion syst ems (
t o a ss ist in t he
devel op ment of pr ot ot yp es), i nt er fa ce des i gn syst ems (t o a ssist in t he devel op
ment of G UIs), a nd
pr ogr a mmi ng s yst ems (t o a ss ist in wr it i ng a nd debuggi ng pr ogr a ms). S ome of t
hes e t ools a r e lit t l e mor e
t ha n t he wor d pr oc ess or s, spr ea ds heet s
oft wa r e, a nd ema il c om mu nica t i on syst ems t ha t wer e or i gi na ll y
devel op ed for gener ic us e a nd a dopt ed by s oft wa r e engineer s. Ot her s a r e quit e s
op hist ica t ed pa c ka ges
des i gned pr i ma r il y for t he soft wa r e engi neer i ng envir onment . Indeed, syst ems
known a s
integr a
ted
deve lop me nte nvi ro nme nts(IDE s)
combi net oolsf or devel op i ngsoft wa r e( edit or s, comp il er s, debu ggi ng
t ools, a nds oon)i nt oa singl e, i nt egr a t edpa cka ge. P r i meexa mp l esofsuchs yst emsa r
et hos ef or devel op in g
a pplica t i ons for sma r t phones. T hes e not on
l y pr ovi de t he pr ogr a mmi ng t ools nec essa r y t o wr it e a nd debu g
t he soft wa r e but a lso pr ovi de si mu la t or s t ha t, by mea ns of gr a phica l displa ys, a ll
ow a pr ogr a mmer t o s ee
how t he s oft wa r e bei ng devel op ed wou l d a ct ua lly p er for m on a phone.

Intr oduct i on t o Com put in g


CS101

VU

P ag e
217

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 127


20. 20.

127.

S oftware E ngi nee ri ng: S oft ware L i fe cycl e


T he most funda ment a l conc ept i n soft wa r e engi neer i ng is t he soft wa r e lif e c yc l e.
T he soft wa r e l if e cyc l e is
showni nF igur e97. T hisfi gur er epr es ent st hefa ct t ha t onc es oft wa r eisdevel op ed, it
ent er sa cycl eof
b ei n g
used a nd ma i nt a i ned

for ma ny ma nufa ct ur ed pr oduct s a s wel l. T he dif f er enc e is t ha t , in t he ca se of ot


her pr oduct s, t he
ma i nt ena nc e p ha se t ends t o be a r epa ir pr ocess
, wher ea s in t he ca se of soft wa r e, t he ma i nt ena nc e p ha se
t ends t o c ons ist of c or r ect i ng or upda t i ng. Indeed, sof t wa r e moves i nt o t he ma i
nt ena nc e p ha se b eca use

ngesi nt he
soft wa r e, or cha nges ma de dur i ng a pr evi ous modi fi ca t i on ar e fou nd t o indu c e pr
obl ems els ewher e i n t he
soft wa r e.

R ega r dl ess of why s oft wa r e ent er s t he ma i nt ena nc e p ha se, t he pr oc ess r equ ir


es t ha t a per son ( oft en not t he
or i gina l a ut hor ) st udy t
he u nder l yi ng pr ogr a m a nd it s docu ment a t i on u nt i l t he pr ogr a m, or a t l ea st t
he
per t i nent par t of t he pr ogr a m, is under st ood. Ot her wis e, a ny modif ica t i on cou l d
int r oduc e mor e pr obl ems
t ha nit sol ves. Ac quir i ngt hisunder st a ndi ngca nbeadif ficu lt t a sk,eve
n whent hesoft wa r eiswel l
-
desi gne d
a nddocu ment ed. Infa ct ,it isoft en wit hint hispha set ha t apiec eofsoft wa r eisdisca r
dedunder t hepr et ens e
(t oo oft en t r ue) t ha t it is ea si er t o devel op a new syst em fr om scr a t ch t ha n t o
modif y t he ex ist i ng pa cka g e

succ ess ful l y.

Exper i enc e ha s shown t ha t a lit t l e eff or t dur ing t he devel op ment of soft wa r e ca n
ma ke a t r emendous
diff er enc e when modif ica t i ons a r e r equ ir ed.

Fi gure
97
: T he sof t
ware l i f e cycl e

Intr oduct i on t o Com put in g

CS101

VU

P ag e
218
of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 128


21. 21.

128.

S oftware E ngi nee ri ng: Req ui re me nt A nalys is Phas e

T he ma j or st eps in t he t r a dit i ona l soft wa r e devel op ment li f e cycl e a r e r equir


ement s a na l ysis, des ign,
i mp l ementa t i on, a nd t est ing (F i gur e 98).

Req uir e me nts A nalys is:


T he soft wa r e li f e cycl e b egi ns wit h r equ ir ement s a na l ysis

t he goa l of whic h is
to
s pec if y wha t s er vi c es t he pr opos ed s ys t em wil l pr ovi de, t o ident if y a ny con dit i
ons (t i me c ons t r a int s ,
secur it y, a nd so on) on t hos e s er vic es, a nd t o defi ne how t he out si de wor l d wi ll i
nt er a ct wit h t he s yst em.
R equir ements a na lys is i nvol ves si gnif ica nt inpu
t fr om t he
st ake ho lde rs
(futur e user s a s well a s t hos e wit h
ot her t i es, such a s l ega l or fi na nc ia l i nt er est s) of t he pr op os ed s yst em. I n fa ct ,
in ca ses wher e t he ult i ma t e
user isa nent it y, sucha sa compa nyor gover nment a genc y, t ha t int endst ohir ea sof
t wa r edevel op er for t he
a ct ua l ex ecut i on of t he s oft wa r e pr oj ect , r equ ir ement s a na lys is ma y st a r t by a
fea sib il it y st udy conduct e d
sol el y b y t he us er . In ot her ca ses, t he soft wa r e devel op er ma y be i n t he busi ness
of pr odu ci ng
co mme rc i al
off
-
t he
-
s hel f (CO T S
)
soft wa r e for t he ma ss ma r ket , per ha ps t o be sol d in r et a i l st or es or downl oa ded
via
t he Int er net . In t his s et t i ng t he user is a less pr ec is el y defi ned ent it y, a nd r equir
ement s a na lys is ma y begi n
wit h a ma r ket st udy by t he soft wa r e devel op er . In a ny ca se,

t he r equ ir ements a na lys is pr oc ess consist s of

t ra de
-
offs b et ween wa nt s, needs, cost s, a nd f ea sib il it y; a nd fina ll y devel op i ng a set of r
equir ement s t h
at
i dent i f y t he f ea t ur es a nd ser vi c es t ha t t he f i nis hed soft wa r e syst em must ha ve.
T hes e r equ ir ement s a r e
r ec or dedi na docu ment ca l l eda
softw arer eq ui re me nts speci fi c at io n.
I na sens e, t hisdocu ment isa wr it t en
a gr eement bet ween a l l pa rt i es conc er ned, w

pr ovi de a mea ns of r esol vi ng disput es t ha t ma y a r ise la t er i n t he devel op ment pr


oc ess . T he s i gni fi ca nc e of
t he soft wa r e r equir ement s speci fi ca t ion is demonst r a t ed by t he fa ct t ha t pr of ess
i ona l or ga ni
za t i ons such a s
IEEE a nd la r ge s oft wa r e cl i ent s such a s t he U. S . Dep a rt ment of D ef ens e ha ve a
dopt ed st a nda r ds for it s
comp osit i on.

ob j ect i ve t owa r d whic

t o pr ovide t his st a bil it y. Indeed, most pr a ct it ioner s i n t he s oft wa r e engineer i ng f


i el d a r gue t ha t poor
com mu nica t i on a nd cha ngi ng r equir ement s a r e t he ma j or ca uses of cost ov
er r uns a nd la t e pr odu ct deli ver y

pla n onc e t he f ou nda t i on ha s been c onst r uct ed, but inst a nc es a bound of or ga niza
t i ons t ha t ha ve expa nded,
or ot her wis ea

under wa y. T his ma y ha ve b een b eca us e a compa ny deci ded t ha t t he syst em t ha t


wa s or igina ll y b ei ng
devel op edf or onl ya subs idia r yshou l di nst ea da ppl yt ot heen
t ir ec or por a t ionor t ha t a dva nc esi nt ec hnolog y
suppla nt edt heca pa bil it i esa va i la bledur i ngt hei nit ia lr equ ir ements a na lys is. Ina
nyca se, soft wa r eengineer s

nda t or y.

Fi gure
98
:
T he tradi t ional devel opment phase of t he sof t ware l i f e cycl e

Intr oduct i on t o Com put in g

CS101

VU

P ag e
219

of
3 81
C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 129


22. 22.

129.

S oftware E ngi nee ri ng: Des ig n Phase

Wher ea s r equ ir ement s a na l ysis pr ovi des a descr ipt i on of t he pr op os ed s oft wa r e


pr oduct , des i gn i nvol ves
cr ea t i ng a pla n for t he const r uct i on of t he pr op os ed syst em. In a sens e, r equ ir
ement s a na lys is is a bout
i dent i f yi ng t he pr ob l em t o b e solved, whi l e des i g
n is about devel op i ng a solut i on t o t he pr obl em. F r om a
la y
-

what
a soft wa r e syst em i s
t o do, wher ea s des i gn is equa t ed wit h dec i ding
ho w
t he s yst em wi l l do it . Alt hough t his des cr ipt i on is
enl i ght eni ng, ma ny soft wa r e engi neer s a r gue t ha t it is fla wed b eca us e, in a ct ua
lit y, t her e is a lot of
how
cons i der ed dur i ng r equir ement s a na l ys is a nd a lot of
wh at
cons i der ed dur i ng des i gn.

It is in t he
des ign st a ge t ha t t he int er na l st r uct ur e of t he soft wa r e syst em is est a blis hed. T
he r esult of t h e

If t he pr oj ect wer e t o c onst r uct a n off i c e bui l


di ng r a t her t ha n a soft wa r e s yst em, t he des i gn st a ge wou l d
cons ist of devel op i ng det a i l ed st r uct ur a l pla ns for a buil di ng t ha t meet s t he sp
ec if i ed r equir ement s. F or
exa mp l e, suc h pla ns wou l d i nclu de a c oll ect ion of b lu epr i nt s descr ib i ng t he pr
op os ed bu i ldi
ng a t va r ious
l evels of det a i l. It is fr om t hes e docu ment s t ha t t he a ct ua l buildi ng wou l d be
const r uct ed. T echni qu es for
devel op i ng t hes e p la ns ha ve evolved over ma ny yea r s a nd i nc lu de st a nda r diz ed
not a t i ona l s yst ems a nd
nu mer ous modeli ng a nd dia gr a mmi ng

met hodol ogi es.

Intr oduct i on t o Com put in g

CS101
VU

P ag e
220

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 130


23. 23.

130.

S oftware E ngi nee ri ng: I mp le me nt atio n Phas e

I mp l ement a t ion i nvol ves t he a ct ua l wr it i ng of pr ogr a ms, cr ea t ion of da t a fil es,


a nd devel op ment of
da t a bases. It is at t he i mp l ement a t i on st a ge t ha t we see t he dist i nct i on b et
ween t he t a sks of a
softw ar e
analyst
(somet i mes r ef er r ed t o a s a syst em a na l yst ) a nd a
programme r.
T he for mer is a per son i nvol ved
wit h t he ent ir e devel op ment pr oc ess , per ha ps wit h a n emp ha sis on t he r equ ir
ement s a na lysis a nd desi gn
st eps. T hela t t er isa per soni nvol vedpr i ma r i l ywit ht hei m
pl em ent a t i ons t ep. Init s na rr owes t i nt er pr et a t ion,
a pr ogr a mmer is c ha r ged wit h wr it i ngpr ogr a mst ha t i mpl ement t hedesi gnpr oduc
edbya soft wa r ea na l yst .
Ha vi ng ma de t his dist i nct i on, we shou l d not e a ga i n t ha t t her e is no c ent r a l a ut
hor it y cont r olli ng t h
e us e of
t er mi nol ogy t hr ou ghout t he comput i ng com mu nit y. Ma ny who ca r r y t he t it l e of
soft wa r e a na lyst a r e
ess ent ia l ly pr ogr a mmer s, a nd ma ny wit h t he t it l e pr ogr a mmer ( or per ha ps seni
or pr ogr a mmer ) a r e a ct ua ll y
soft wa r ea na lyst si nt heful ls ens eoft het er
m. T hisblur r ingoft er mi nol ogyisfou ndedi nt hefa ct t ha t t oda y
t he st eps i n t he s oft wa r e devel op ment pr oc ess a r e oft en int er mi ngl ed.

Intr oduct i on t o Com put in g

CS101

VU
P ag e
221

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 131


24. 24.

131.

S oftware E ngi nee ri ng: T esti ng Phas e

In t he t r a dit i ona l devel op ment pha s e of t he pa st , t est ing wa s


ess ent ia l l y equa t ed wit h t he pr oc ess of
debu ggi ng pr ogr a ms a nd c onf ir mi ng t ha t t he fi na l soft wa r e pr oduct wa s compa t
ibl e wit h t he soft wa r e
r equir ement s sp ec if ica t i on. T oda y, however , t his vis ion of t est i ng is cons i der ed
fa r t oo na r r ow. Pr ogr a ms
a r enot t he

onl ya r t ifa ct st ha t a r et est eddur i ngt hesoft wa r edevel op ment pr oc ess . Indeed, t
her esu lt of ea c h

r ec ogni z ed a s onl y one s egment i n t he over a ll st r uggl e f


or qua l it y a s s ur a nce, whic h is a n ob j ect i ve t ha t
per mea t est he ent ir es oft wa r el if e c yc l e. T hus, ma nysof t wa r e engi neer sa r gu et
ha t t est i ngshou l dno l onger
be vi ewed a s a sepa ra t e st ep in soft wa r e devel op ment , but inst ea d it , a nd it s ma
ny ma nif est a t i ons,
shou l d
be i nc or por a t ed i nt o t he ot her st eps, pr oduc i ng a t hr ee
-
s t ep devel op ment pr oc ess whos e c omp onent s mi ght

and conf i rmat i on,

and val i dat i on,

and t est i ng.

Unf or t una t el y, even wit h


moder n qua l it y a ss ur a nce t ec hniqu es, la r ge soft wa r e s yst ems c ont i nu e t o c ont
ain
er r or s, even a ft er signif ica nt t est i ng. Ma ny of t hes e er r or s ma y go undet ect ed
for t he l if e of t he syst em, but
ot her s ma y ca use ma j or ma lfu nct i ons. T he eli mi na t i on of such er r o
r s is one of t he goa ls of soft wa r e
engi neer i ng. T he fa ct t ha t t hey a r e st il l pr eva l ent i ndi ca t es t ha t a lot of r es ea
r ch r ema i ns t o b e done.

Intr oduct i on t o Com put in g

CS101

VU

P ag e
222

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan


Mod ule 132
25. 25.

132.

S oftware E ngi nee ri ng: S oft ware E ngi nee r i ng Met h odolog ies (I)

Ea r ly a ppr oa ches t o soft wa r e engi neer ing i ns ist ed on p er for mi ng r equ ir ement s
a na l ysis, des i gn,
i mp l ement a t i on, a ndt est i ngi na str ict lys equ ent ia lma nner . T hebel i ef wa st ha tt
oo muc hwa sa tr iskdur ing
t he devel op ment of a la r ge soft wa r e syst em t o a ll ow
for va r ia t ions. As a r esult , soft wa r e engi neer s i nsist e d
t ha t t he ent ir e r equir ement s speci fi ca t i on of t he syst em b e compl et ed bef or e begi
nni ng t he des i gn a nd,
li kewis e, t ha t t he desi gn b e c omp l et ed b ef or e b egi nni ng i mp l ement a t ion. T he
r esu lt wa s a devel op
ment
pr oc ess now r ef er r ed t o a s t he
wate r
-

fal l mod el,


a n a na logy t o t he fa ct t ha t t he devel op ment pr oc ess wa s
a ll owed t o f l ow i n only one dir ect i on.

In r ec ent yea r s, soft wa r e engineer i ng t echni qu es ha ve cha nged t o r efl ect t he


cont r a di ct i on bet ween t he
hi ghl y st r uct ur ed envir onment dict a t ed by t he wa t er
-
-

-
a nd
-
er r or
pr oc ess t ha t is oft en vit a l t o cr ea t i ve pr obl em
sol vi ng. T his is illust r a t ed by t he emer genc e of t he
i ncre me nt al mo de l
for soft wa r e devel op ment . F oll owi ng t his model, t he des ir ed soft wa r e syst em is
const r uct edi ni ncr ement s, t hefir st bei nga simp li fi edver sionoft hefi na lpr oduct wit hl
i mit edfu nct i on
a l it y.
Onc e t his ver s i on ha s been t est ed a nd p er ha ps eva lua t ed by t he futur e us er , mor
e f ea t ur es ar e a dded a nd
t est ed i n a n i ncr ement a l ma nner unt il t he syst em is c ompl et e. F or exa mp l e, if t
he s yst em b ei ng devel op ed
isa pa t ient r ec or dss yst emf or a hosp it
a l, t hef ir st incr ement ma yi ncor p or a t eonl yt hea bi l it yt ovi ewpa t i ent
r ec or ds fr om a sma l l sa mpl e of t he ent ir e r ec or d sys t em. O nc e t ha t ver si on is
op er a t iona l, a ddit i ona l
f ea t ur es, such a s t he a bil it y t o a dd a nd upda t e r ec or ds, wou l d be a dded i n a st
ep
wis e ma nner .

Anot her model t ha t r epr es ent s t he shift a wa y fr om st r ict a dher enc e t o t he wa t


er fa ll model is t he
ite r at ive
mo de l,
whi c h is si mi la r t o, a nd i n fa ct somet i mes equa t ed wit h, t he i ncr ementa l model,
a lt hou gh t he t wo
a r e dist i nct . Wher ea s t he i ncr em
ent a l model ca r r ies t he not i on of
ext endi ng
ea ch pr el i mi na r y ver si on of a
pr oduct i nt o a lar ger ver sion, t he it er a t ive model enc ompa ss es t he conc ept of
ref i ni ng
ea ch ver si on. In
r ea lit y, t he i ncr ement a l model i nvol ves a n under l yi ng it er a t ive pr oc ess , a nd t
he it er a t ive model ma y
i ncr ement a l l y a dd f ea t ur es.

A si gni fi ca nt exa mp l e of it er a t ive t ec hni qu es is t he


r atio nal uni fie d proc ess
(
RUP,

t ha t wa scr ea t edbyt heR a t iona lS oft wa r eC or por a t ion, whic his nowa divis i
onofIBM. R UP is ess ent ia
lly
a soft wa r e devel op ment pa ra di gm t ha t r edef i nes t he st eps i n t he devel op ment
pha s e of t he s oft wa r e l if e
cycl e a nd pr ovi des gu i del i nes f or per for mi ng t hos e st eps. T hes e gu i deli nes, a
long wit h C AS E t ools t o
suppor t t hem, a r e ma r ket ed by I BM. T oda y, R UP is

wi del y a ppli ed t hr ou ghout t he soft wa r e i ndust r y. In


fa ct , it s popula r it y ha s l ed t o t he devel op ment of a nonpr opr iet a r y ver si on, ca ll
ed t he
uni fi e d proc es s ,
t ha t
is a va ila bl e on a nonc omm er c ia l ba sis.
Intr oduct i on t o Com put in g

CS101

VU

P ag e
223

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 133


26. 26.

133.
S oftware E ngi nee ri ng: S oft ware
E ngi nee r i ng Met h odolog ies (I I )

Incr ement a l a nd it er a t ive models somet i mes ma ke u se of t he t r end i n s oft wa r e


devel op ment t owa r d
prototy pi ng
i n whic h i nc omp l et e ver si ons of t he pr opos ed syst em, ca l l ed pr ot ot yp es, a r e
built a nd
eva lua t ed. In t he ca se of t he i ncr ement a l model t hes e pr ot ot yp es evol ve i nt o t he
c omp l et e, fi na l s yst em, a
pr oc ess knowna s
evol ut io naryprototy p i ng.
Inamor eit er a t ive
sit ua t ion, t hepr ot ot yp es ma ybedisca r ded
i nfa vor ofa fr eshi mp l ement a t i onoft hef i na ldes i gn. Thisa ppr oa chisknowna s
throw aw ayprototyp i ng.
An exa mp l e t ha t nor ma l l y fa lls wit hi n t his t hr owa wa y ca t egor y is
r ap i d prototy p i ng
i n whic h a si mp l e
exa mp l e

oft hepr op os edsyst emisqu ic klyconst r uct edi nt heea r l yst a gesofdevel op ment . S ucha
pr ot ot yp e
ma y c onsist of onl y a few scr een i ma ges t ha t gi ve a n i ndi ca t ion of how t he s yst em
wi l l i nt er a ct wit h it s
user s a nd wha t ca pa bilit i es it wi ll ha ve. T he goa l
is not t o pr oduc e a wor ki ng ver si on of t he pr oduct but t o
obt a i n a demonst r a t ion t ool t ha t ca n be used t o cla r if y com mu nica t i on b et ween
t he pa r t ies i nvol ved i n t h e
soft wa r e devel op ment pr oc ess . F or exa mp l e, ra pid prot ot yp es ha ve pr oved a dva
nt a geous i n cla r
if yin g
syst em r equ ir ement s dur i ng r equ ir ement s a na lys is or a s a ids dur ing sa l es pr es
ent a t ions t o p ot ent ia l c li ent s.

A l ess f or ma l i nca r na t i on of i ncr ementa l a nd it er a t ive i dea s t ha t ha s been us ed


f or yea r s by c omput er
ent husia st s/ hobbyist sis knowna s
ope n
-
so ur ced eve lop me nt.

fr eesoft wa r e ispr oduc ed. P er ha pst he most pr omi nent exa mp l eist heL i nuxop er a t
ingsyst em whos e op en
-

sour c e devel op ment wa s or igi na ll y l ed by L i nus T or va lds. T he op en


-
s our c e devel op ment of
a soft wa r e
pa cka ge pr oc eeds a s fol l ows: A si ngl e a ut hor wr it es a n i nit ia l ver si on of t he soft
wa r e (usua ll y t o fu lf il l his
or her own needs) a nd p ost s t he sour c e c ode a nd it s docu ment a t i on on t he Int er
net . Fr om t her e it ca n b e
downloa ded a nd used b y ot her s
wit hout c ha r ge. B ec a use t hes e ot her us er s ha ve t he s our c e c ode a nd
docu ment a t ion, t hey a r e a bl e t o modi f y or enha nc e t he soft wa r e t o fit t heir own
needs or t o c or r ect er r or s
t ha t t hey f i nd. T hey r ep or t t hes e c ha nges t o t he or i gi na l a ut hor , who i nc or
por a t es

t hem i nt o t he p os t e d
ver si on of t he s oft wa r e, ma king t his ext ended ver si on a va ila bl e f or fur t her modif
ica t i ons. In pr a ct ice, it is
poss ib l e f or a soft wa r e pa cka ge t o evol ve t hr ough s ever a l ext ensi ons i n a singl e
week.

P er ha ps t he most pr onou nc ed s hift fr o


m t he wa t er fa ll model is r epr es ent ed b y t he c oll ect ion of
met hodol ogi es known a s
agile met hods,
ea c h of whi c h pr o
-

pos es ea r l y a nd qu ic k i mp l ement a t ion on a n


i ncr ement a l ba sis, r espons i veness t o cha ngi ng r equ ir ement s, a nd a r educ ed emp
ha sis on r igor ous
r eq
uir ement s a na l ys is a nd des i gn. One exa mpl e of an a gi l e met ho d is
ext re me prog r ammi ng (X P).
F ol l owi ng t he XP model, soft wa r e is devel op ed b y a tea m of l ess t ha n a doz en
indi vi dua ls wor ki ng i n a
com mu na l
wor kspa c e

wher e t hey fr eel y sha r e i dea s a nd a ss ist ea c


h ot her i n t he devel op ment pr oj ect . T he
soft wa r e is devel op ed i ncr ement a l l y by mea ns of r ep ea t ed da il y c ycl es of i nf or
ma l r equir ement s a na lys is,
des i gni ng, i mp l ement i ng, a nd t est i ng. T hus, new expa nded ver si ons of t he soft wa
r e pa cka ge a ppea r on a
r egula r b

i ncr ement s. In su mma r y, a gi l e met hods ar e cha r a ct er i z ed by fl ex ib i lit y, whi c h


is i n st ar k cont r a st t o t he
wa t er fa ll model t ha t conjur es t he i ma ge of ma na ger
s a nd pr ogr a mmer s wor ki ng i n i ndi vi dua l off ic es whi l e
r igi dl y p er for mi ng wel l
-
def i ned por t i ons of t he over a ll soft wa r e devel op ment t a sk.

T he c ont r a st s dep ict ed b y c ompa r ing t he wa t er fa ll mod el a nd XP r evea l t he br


ea dt h of met hodol ogi es t ha t
a r e bei ng a ppli
ed t o t he soft wa r e devel op ment pr oc es s in t he hop es of f indi ng b et t er wa ys t o c
onst r uct
r el ia blesoft wa r ei na neff ic i ent ma nner . R es ea r chi nt hefi el disa nongoi ngpr oc ess.
P r ogr essisbei ngma de,
but muc h wor k r ema i ns t o b e done.

Intr oduct i on t o Com put in g

CS101

VU

P ag e
224

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 134


27. 27.

134.

S oftware
E ngi nee ri ng: S oft ware E ngi nee r i ng Met h odolog ies (II )

Akeyp oi nt ist ha t t omodi f ysoft wa r eone must under st a ndt hepr ogr a mor a tlea st t
hep er t i nent par t soft he
pr ogr a m. Ga ini ng such a n under st a ndi ng is oft en dif fi c ult enou gh i n t he ca s e of s
ma l l pr ogr
a ms a nd wou l d
be c l os e t o i mp oss ibl e when dea li ng wit h la r ge s oft wa r e s yst ems if it wer e not f
or
mod ul ari ty

t ha t is, t he
di vis i on of soft wa r e i nt o ma na gea bl e u nit s, gener i ca l l y ca ll ed
mo d ules,
ea c h of whic h dea ls wit h onl y a
Modules c ome i n a va r i et y of f or ms. W e ha ve a lr ea dy s een t ha t i n t he c ont ext of
t he i mp er a t ive pa r a digm,
modu l es a ppea r a s funct ions. In c ont r a st, t he obj ect
-
or i ent ed pa ra di gm
us es ob j ect s a s t he ba sic modu la r
const it u ent s. T hes edist i nct i onsa r ei mp or t a nt beca us et hey det er mi net heu nder l
yi nggoa l dur i ngt hei nit ia l
soft wa r e des ign pr oc ess . Is t he goa l t o r epr es ent t he over a ll t a sk a s i ndivi dua l,
ma na gea bl e pr oc ess es or t o
i den
t i f y t he ob j ect s in t he s yst em a nd under st a nd how t hey i nt er a ct ?

T o il lust r a t e, let us c ons i der how t he pr oc ess of devel opi ng a si mp l e modula r pr


ogr a m t o s i mu la t e a t ennis
ga me mi ght pr ogr ess in t he i mp er a t i ve a nd t he ob j ect
-
or i ent ed pa ra di gms. In t he i mp e
r a t ive pa r a digm we
begi nbyc ons i der i ngt hea ct i onst ha t must t a kep la c e. B eca use ea c hvol l eyb egi
nswit ha pla yer ser vi ngt he

per ha psa bit ofpr oba


bilit y)wou l dc omput et hei nit ia lspeeda nddir ect i onoft heba ll.
Next ,

we wou l dnee d
t odet er mi net hepa t hoft heba l l(W i l lit hit t henet ?W her ewil lit bou nc e?). W emi ght p
la nonpla c ingt hes e
comput a t ions in a not her fu nct i on na med C omput eP a t h. T he ne
xt st ep mi ght b e t o det er mi ne if t he ot her
pla yer is a ble t o r et ur n t he ba ll, a nd if
so,

pla n on pla c i ng t hes e c omputa t i ons i n a funct i on na med R et ur n.

C ont i nui ngi nt hisfa shi on, we might a rr ive

a t t he modul a rst r uct ur edepi ct edbyt he


str uct urec har t
show n
i n F igur e 99, in whic h funct i ons ar e r epr es ent ed by r ect a ngl es a nd funct i on dep
endenc i es (i mp l ement ed by
funct i on ca lls) ar e r epr es ent ed by ar r ows. In par t icula r , t he cha r t indica t es t ha t t
he
ent ir e ga me is over s een
by a funct i on na med C ont r olGa me, a nd t o per f or m it s ta sk, C ont r olGa me ca l ls on
t he ser vi c es of t h e
funct i ons S er ve, R et ur n, C omput eP a t h, a nd Up da t eS c or e.

Not e t ha t t he st r uct ur e cha r t does not indica t e how ea ch funct i on is t o per for
m it s t a sk. Ra t her , it mer el y
i dent i fi es t he fu nct i ons a nd i ndi ca t es t he dep endenc i es a mong t he fu nct i ons. In
r ea l it y, t he fu nct i on
C ont r olGa me mi ght p er for m it s t a sk by fir st ca ll i ng t he S er ve fu nct i on, t hen r
ep ea t edl y ca ll i ng on t he
funct i ons C omput eP a t h

a nd R et ur n unt i l one r ep or t s a miss , a nd fi na l l y ca ll i ng on t he ser vi c es of


Up da t eS c or e bef or e r ep ea t i ng t he whol e pr oc ess by a ga i n ca ll i ng on S er ve.

At t his st a ge we ha ve obta i ned only a ver y si mplist ic outli ne of t he desir ed pr ogr a


m, but our poi nt ha s
a
lr ea dy b een ma de. I n a cc or da nc e wit h t he i mp er a t i ve pa ra digm, we ha ve b een
desi gni ng t he pr ogr a m b y
cons i der i ngt hea ct ivit i est ha t must beper for meda ndaret her ef or eobt a i ni nga des i
gnin whi c ht he modu l es
a r e funct i ons.

Fi gure
99
: A si mpl e st ruct ure chart

Intr oduct i on t o Com put in g

CS101

VU

P ag e
225

of
3 81
C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 135


28. 28.

135.

S oftware E ngi nee ri ng: Co upl i ng

W e ha ve i nt r oduc ed modu la r it y a s a wa y of pr oduc i ng ma na gea bl e s oft wa r e. T


he i dea is t ha t a ny fut ur e
modif i ca t ion wi ll l ikel y a ppl y t o onl y a few of t he modul es, a ll owi ng t he p er son
ma ki ng t he modi fi ca t io n
t o c onc ent r a t e on t ha t por t ion of t he s yst em r a t he
r t ha n st r uggl i ng wit h t he ent ir e pa c ka ge. T his, of c our se,
dep ends on t he a ss umpt i on t ha t cha nges i n one modu l e wil l not u nknowi ngl y a
ffect ot her modu l es i n t h e
syst em. C ons equ ent l y, a goa l when des igni ng a modula r syst em s houl d b e t o ma xi
mi z e i ndep endenc
e
a mong modul es or , in ot her wor ds, t o mi ni mi z e t he li nka ge b et ween modu l es
( known a s int er modu l e
co up l i ng
). I ndeed, one met r i ct ha t ha sbeenus edt o me a sur et he comp l ex it y ofa soft wa r es yst
em(a ndt hus
obt a i n a mea ns of est i ma t i ng t he exp ens e of
ma i nt a i ni ng t he s oft wa r e) is t o mea sur e it s i nt er modu l e
coup l ing.

Int er modu l ec oupl i ngoccur si nsever a lf or ms. Oneis


co ntro lco upl i ng,
whi c hoc cur s whena modu l epa s s es
cont r ol of ex ecut i on t o a not her , a s in a funct i on ca ll. T he st r uct ur e cha r t in F igur
e

99r epr es ent s t he c ont r ol


coup l ing t ha t ex ist s bet ween fu nct i ons. In pa r t icula r , the a r r ow fr om t he modu l
e C ont r olGa me t o S er ve
i ndi ca t es t ha t t he f or mer pa sses cont r ol t o t he la t t er . It is a lso cont r ol c oupli ng
t ha t is r epr es ent ed i n F igur e
100, wher e t h
e a rr ows t r a ce t he pa t h of c ont r ol a s it is pa ss ed fr om ob j ect t o obj ect .

Fi gure
100

Anot her for m of i nt er modul e c oupl i ng is


d at a co u
p l i ng,
whi ch r ef er s t o t he s ha r ing of da t a bet wee n
modu l es. If t wo modu l es i nt er a ct wit h t he sa me it em of da ta , t hen modif ica t i ons
ma de t o one modu l e ma y
a ffect t heot her , a ndmodif ica t i onst ot hef or ma t oft heda ta it selfc ou l dha ver ep er
cussi onsi nb ot h
modul es.

Da t a coupl i ng b et ween fu nct i ons ca n occur in t wo for ms. One is by exp l ic it l y pa ss


ing da t a fr om on e
funct i ont oa not her i nt hef or mofpa ra met er s. S uchc oupli ng isr epr es ent edi na st r
uct ur ec ha r t bya narr ow
bet ween t he funct i ons t ha t is la bel ed t
o i ndica t e t he da t a bei ng pa ss ed. T he dir ect i on of t he a rr ow i ndica t es
t he dir ect i on in whic h t he it em is t r a nsfer r ed.

S i mila r da t acoupli ngoccur sbet weenob j ect sina nobj e ct


-
or i ent eddes ign. F or exa mp l e, whenP la yer Aa s ks
t he ob j ect Judge t o eva lua t e i
t s ser ve (s ee F i gur e 100), it must pa ss t he t r a ject or y i nfor ma t i on t o Judge. O n
t he ot her ha nd, one of t he b enef it s of t he ob j ect
-
or i ent e d pa ra di gm is t ha t it inher ent l y t ends t o r educ e da t a
coup l ing b et ween ob j ect s t o a mi ni mu m. T his is beca use t he met hod
s wit hi n a n ob j ect t end t o i nc lu de a l l

In

t ur n, t her e is no need t o pa s s t ha t infor ma t i on t o ot her obj ect s a nd t hus int er


obj ect da t a coup l ing is
mi nimi z ed.

Intr oduct i on t o Com put in g

CS101

VU
P ag e
22
6

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

In cont r a st t o pa ss ing da t a expl ic it l y a s pa ra met er s, dat a ca n be shar ed a mong


modu l es i mp l ic it l y i n t he
for m of
glo b al d at a,
whic h a r e da t a
it ems t ha t ar e a utoma t i ca l ly a va i la bl e t o a ll modul es t hr oughout t he
syst em, a s oppos ed t o l oca l da t a it ems t ha t ar e a cc ess ib l e onl y wit hi n a pa r t
icula r modu l e u nl ess expl i cit l y
pa ssedt oa not her . Most hi gh
-
l evella ngua gespr ovidewa ysofi mp l ement i ngbot h

gl oba la ndl oca lda t a , but


t he use of gl oba l da t a shoul d b e emp l oyed wit h ca ut ion. T he pr obl em is t ha t a per
son t r yi ng t o modi f y a
modu l et ha t isdep endent ongl oba lda t a ma yfi ndit di ff i cult t oident if yhowt hemodu l
ei nqu est i onint er a ct s
wit h ot her mo

Intr oduct i on t o Com put in g

CS101

VU

P ag e
227

of
3 81
C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 136


29. 29.

136.

S oftware E ngi nee ri ng: Co hes io n

Jus t a s imp or t a nt a s mi ni mi zi ng t he c oup li ng b et ween modu l es is ma xi mi zi ng t


he int er na l bi ndi ng wit hi n
ea c h modu l e. T het er m
co hesio n
r ef er st ot his i nt er na lb i ndi ng or , in ot her wor ds, t he degr ee ofr ela t edness

devel op ment of a syst em a nd cons i der t he ent ir e soft wa r e l if e c yc l e. If it

bec omes nec ess a r y t o ma ke


cha nges i n a modul e, t he ex ist enc e of a va r iet y of a ct ivi t i es wit hi n it ca n confus e
wha t woul d ot her wis e b e
a simp l epr oc ess . T hus, ina ddit i ont os eeki ngl ow i nt er modu l e c oupl i ng, soft wa r e
des i gner sst r ivef or hi gh
i nt r a modu l e c
ohes i on. A wea k f or m of c ohes ion is known a s
logic al co hes io n.
T his is t he cohesi on wit hin
a modul e i nduc ed b y t he fa ct t ha t it s int er na l el ement s per for m a ct i vit i es l ogi
ca l l y si mi la r in na t ur e. F or

s commu nica t i on wit h t he out si de wor l d. T he


com mu nica t i on. However , t het opi csoft hec ommu nica t i onca nva r ygr ea t l y. S
omema ydea lwit hobt a i nin g
da t a , wher ea s

ot her s dea l wit h r epor t i ng r esult s.

Ast r onger for mofc ohes ionisknowna s


func tio nalco hesio n,
whi ch mea nst ha t a llt hepa r tsoft he modul e
a r e focus ed on t he p er for ma nc e of a singl e a ct i vit y. I n an i mp er a t ive des i gn,
funct i ona l c ohesi on ca n oft e n
be i n
cr ea sed b y isola t i ng subt a sks in ot her modul es a nd t hen usi ng t hes e modu l es a s a
bstr a ct t ools. T his is
demonst r a t ed i n our t ennis si mu la t ion exa mp l e (s ee a ga i n F igur e 99) wher e t he
modu l e C ont r olGa me us es
t he ot her modu l es a s a bstra ct t ools so t ha t it ca n
conc ent r a t e on over s eei ng t he ga me r a t her t ha n bei ng
dist r a ct ed by t he det a i ls of s er ving, r et ur ni ng, a nd ma i nt a i ni ng t he sc or e.

Inob j ect
-
or i ent eddes i gns, ent ir eobject sa r eusua ll yonl yl ogi ca l l ycohes i veb eca uset he met
hods wit hina n
ob j ect oft en p er f
or m l oos el y r ela t ed a ct i vit i es

t he only c om mon b ond bei ng t ha t t hey a r e a ct ivit i es


per f or med by t he sa me obj ect . F or exa mp l e, in our t ennis si mula t i on exa mp l e,
ea c h pla yer obj ect cont a i ns
met hodsf or ser vi nga swel la sr et ur ni ngt heba l l, whi c ha r esignif i
ca nt l ydiff er ent a ct ivit i es. S ucha nobj ect
wou l d t her ef or e b e only a logica l l y cohes i ve modu l e. However , soft wa r e des
igner s shoul d st r ive t o ma ke
ea c hi ndi vi dua lmet hodwit hi na nobj ect funct i ona ll yc ohes i ve. T ha tis, event hou ght
heobj ect i nit sent ir et
y
is onl y l ogica l l y cohes i ve, ea c h met hod wit hi n a n obj ect shou l d per f or m onl y one
fu nct i ona ll y c ohesi v e
t a sk (F igur e 101).

Fi gure
101
: L ogical and f unct i onal cohesi on wi t hin anobject

Intr oduct i on t o Com put in g

CS101

VU

P ag e
228
of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 137


30. 30.

137.

S oftware E ngi nee ri ng: I nfor matio n H id i ng

One of t he c or ner st ones of good modu la r des i gn is ca pt ur ed in t he c onc ept of


i nfor matio n hid i ng,
whi c h
r ef er st ot her est r ict i onofi nf or ma t i ont oa spec if icp or t i onofa soft wa r es yst em. H
er et het er m
i nf ormati on
shoul d b e i nt er pr et ed i n a br oa d sens e, i nc lu di ng a ny knowl edge a bout t he st r
uct ur e a nd cont ent s of a
pr ogr a m unit . As such, it inc ludes da
t a, t he t yp e of da ta str uct ur es used, enc odi ng syst ems, t he int er na l
comp osit i ona l st r uct ur e of a modu l e, t he l ogica l st r uct ur e of a pr ocedur a l unit ,
a nd a ny ot her fa ct or s
r ega r di ng t he int er na l pr oper t i es of a modu l e. T he poi nt of i nf or ma t ion hi di ng
is t o
keep t he a ct ions of
modu l es fr om ha ving unnec essa r y dep endenc i es or ef f ect s on ot her modu l es. Ot
her wis e, t he va li dit y of a
modu l e ma y be compr omis ed, p er ha ps by er r or s in t he devel op ment of ot her
modul es or by mis gu i ded
eff or t s dur ing soft wa r e ma i nt ena nc e
. If, for exa mp l e, a modu l e does not r est r ict t he use of it s int er na l da t a
fr om ot her modul es, t hen t ha t da ta ma y bec ome c or r upted by ot her modul es. Or ,
if one modu l e is des i gned

ift ha t i nt er na lst r uct ur eisa lt er ed.

It is i mp or t a nt t o not e t ha t inf or ma t ion hidi ng ha s t wo i nca r na t ions

one a s a des i gn goa l, t he ot her a s a n


i mp l ementa t i on goa l. A module shou l d be des i gned so tha t ot her modules do not
need a cc ess t o it s int er na l
i nf
or ma t ion, a nd a modu l e s houl d b e i mp l ement ed i n a ma nner t ha t r einf or c es it s
bounda r i es. Exa mpl es of
t he f or mer a r e ma xi mi z i ng c ohesi on a nd mi ni miz i ng c oupl i ng. Exa mp l es of t he
la t t er i nvol ve t he us e of
l oca l va r ia bl es, a pplyi ng enca psula t i on, a nd usi ng we
ll
-

def i ned c ont r ol st r uct ur es.

F ina l l y we shou l d not e t ha t inf or ma t ion hi di ng is cent r al t o t he t heme of a bstr a


ct ion a nd t he use of a bstra ct
by
it s us er , a llowingt heus er t oc onc ent r a t eont hela r ger a pplica t i ona t ha nd. I nt his s
ens et hen, i nf or ma t io n
hi di ng cor r esp onds t o t he c onc ept of sea li ng t he a bstra ct t ool i n muc h t he sa me
wa y a s a ta mp er pr oof
encl osur e ca n be used t o sa fegua r d compl ex a n
d pot ent ia l ly da nger ous el ect r onic equ ip ment . Bot h pr ot ect
t heir user s fr om t he da nger s i nsi de a s well a s pr ot ect t heir int er i or s fr om i nt r
usi on fr om t heir user s.

Intr oduct i on t o Com put in g

CS101

VU

P ag e
229

of
3 81
C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 138


31. 31.

138.

S oftware E ngi nee ri ng: Co mpo ne nts

W eha vea lr ea dyment i onedt ha t oneobst a cl e


i nt hefi el dofsoft wa r eengi neer i ngist hela ckofpr efa br ica t e d

-
t he
-

a ppr oa ch t o s oft wa r e devel op ment pr omis es hop e i n t his r ega r d. In pa r t icula r ,


t he obj ect
-
or i
ent e d
pr ogr a mmi ng pa ra di gm is pr ovi ng esp ec ia l l y usefu l beca use ob j ect s for m c omp l
et e, self
-
c ont a ined u nit s
t ha t ha ve c l ea r ly defi ned i nt er fa ces wit h t heir envir onment s. Onc e a n ob j ect , or
mor e c or r ect l y a cla ss , ha s
beendesi gnedt ofulf i l lacer t a inr ol e
, it ca nbeusedt ofulf il lt ha t r ol ei na nypr ogr a mr equ ir i ngt ha tser vi c e.
Mor e
-

over , i nher it a nc epr ovi desa mea nsofr efi ningpr efa br ica t edob j ect defi nit i onsi nt
hos eca sesinwhic h
t he defi nit ions must be cust omi z ed t o conf or m t o t he needs of a spec i
f ic a pp lica t i on. It is not s ur pr is i ng,
t hen, t ha t t he obj ect
-
or i ent ed pr ogr a mmi ng la ngua ges C ++, Ja va , a nd C # ar e a ccompa ni ed b y c oll ect
ions

r ol es. In p
a r t icula r , C ++ is ass ocia t ed wit h t he C ++ St a nda r d T emp la t e Libr a r y, t he Ja va
pr ogr a mmi ng
envir onment is a ccompa ni ed by t he Ja va Appl ica t i on P r ogr a mmer I nt er fa ce ( AP
I), a nd C # pr ogr a mmer s
ha ve a cc ess t o t he . NET F ra mewor k C la ss Libr ar y.

T he fa ct t ha t obj ec
t s a nd cla ss es ha ve t he p ot ent ia l of pr ovi di ng pr efa br ica t ed buil di ng bl oc ks f or
soft wa r e
des i gn does not mea n t ha t t hey a r e idea l. One pr obl em is t ha t t hey pr ovi de r ela t i
vel y s ma ll bl oc ks fr o m
whic h t o bu il d. T hus, a n obj ect is a ct ua ll y a spec ia l c a se of
t he mor e gener a l c onc ept of a
co mpo ne nt,
whic h is, by def i nit i on, a r eusa ble u nit of soft wa r e. I n pr a ct ice, most component s
a r e ba sed on t he ob j ect
-
or i ent edpa r a digma ndt a ket he f or mofa col l ect i on of one or mor e obj ect st ha t
funct i ona sasel f
-
c ont a i ned

unit .

R es ea r ch in t he devel op ment a nd us e of c omp onent s ha s led t o t he emer gi ng f i el


d known a s
co mpo ne nt
ar c hite ct ure
(a ls o known a s comp onent
-
ba sed soft wa r e engi neer i ng) i n whi c h t he t ra dit i ona l r ol e of a
pr ogr a mmer is r epla c ed by a
co mpo ne nt ass e mb l er
w
ho const r uct s soft wa r e syst ems fr om pr efa br ica t ed
comp onent s t ha t , in ma ny devel op ment envir onment s , ar e displa yed a s ic ons i n a
gr a phica l i nt er fa ce.
R a t her t ha nb ei nvol vedwit ht hei nt er na lpr ogr a mmi ngoft hec omp onent s, t hemet
hodol ogyofa comp onent
a
ss emb l er is t o s el ect p er t inent comp onent s fr om c oll e ct i ons of pr edef i ned c omp
onent s a nd t hen c onnect
t hem, wit hmi ni ma lcust omi za t i on, t oobt a int hedes ir edfunct i ona l it y. Indeed, a pr
oper t yofa wel l
-
des i gne d
comp onent is t ha t it ca n be ext ended t o enc om
pa ss f ea t ur es of a par t icula r a pplica t i on wit hout i nt er na l
modif i ca t ions.
An a r ea wher e c omp onent a r chit ect ur es ha ve f ou nd f er t il e gr ou nd is i n s ma r t
phone syst ems. Due t o t he
r esour c e c onst r a int s of t hes e devic es, a pplica t ions a r e a ct ua lly a set of colla b o
r a t ing c omponent s, ea c h of
whic h pr ovi des some dis cr et e fu nct i on for t he a pplica t ion. F or exa mpl e, ea ch
disp la y scr een wit hi n a n
a pplica t i on is usua ll y a sepa ra t e component . B ehi nd t he sc enes, t her e ma y ex ist
ot her ser vic e c omp onent s
t o st or e a nd a cc ess in
f or ma t i on on a memor y ca r d, per for m some c ont i nu ous funct i on (such a s pla ying
music ), or a cc ess i nf or ma t i on over t he I nt er net . Ea ch of t hes e c omp onent s is i
ndi vi dua l ly st a r t ed a nd
st opp ed a s needed t o ser vic e t he us er eff ic i ent ly; however , t he a pplica t i on
a ppea rs a s a sea ml ess ser i es of
displa ys a nd a ct ions.

As i defr omt he mot i va t iont o li mi t t heus e ofsyst emr es our c es, t hec omp onent a r
chit ect ur e ofs ma r t phones
pa ys di vi dends i n i nt egr a t ion bet ween a pplica t i ons. F or exa mp l e, Fa ceb ook (a
well
-
known socia l
n
et wor ki ng syst em) when ex ecut ed on a sma r t phone ma y us e t he c omp onent s of t
he c ont a ct s applica t i on
t o a dd a ll F a ceb ook fr iends a s cont a ct s. F ur t her mor e, the t el ephony a pplica t i on
(t he one t ha t ha ndl es t h e
funct i onsoft hephone), ma ya lsoa cc ess t he c ont a c

scr een (a l ong wit h his or her la st Fa ceb ook post ).


Intr oduct i on t o Com put in g

CS101

VU

P ag e
230

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 139


32. 32.

139.
S oftware E ngi nee ri ng: Des ig n

Patte r ns

Ani ncr ea si ngl ypower fu lt oolf or soft wa r e engi neer sist hegr owi ngc ol l ect i onof desi
gnpa t t er ns. A
desig n
patte r n
is a pr e
-
devel op ed model f or sol vi ng a r ecur ri ng pr obl em i n soft wa r e des i gn. F or exa mp
l e, t h e
Ada pt er pa t t er n pr ovi des a solut i on

t o a pr obl em t ha t oft en oc cur s when c onst r uct ing soft wa r e fr o m


pr efa br ica t ed modu l es. Inpa rt icula r ,apr efa br ica t ed modu l e ma yha vet hefunct i
ona l it yneededt osol vet h e
pr obl ema t ha ndbut ma y not ha vea nint er fa c et ha t iscompa t ibl e wit ht hecur r ent a p
plica t ion. Insuchca s es

pr efa br ica t ed modul e t o be


us ed i n t he a ppli ca t i on.

Anot her wel l


-
est a bl ished des i gnpa t t er nist heD ec or a t or pa t t er n. It pr ovidesa mea ns of desi gni
nga syst e m
t ha t per for ms diff er ent c omb i na t i ons of t he sa me a ct i vit i es dep endi ng on t he s
it ua t ion a t t he t i me. S uch
syst ems ca n l ea d t
o a n expl os i on of opt i ons t ha t , wit hout car eful desi gn, ca n r esult in enor mousl y c
omp l ex
soft wa r e. However , t he D ec or a t or pat t er n pr ovides a sta nda r di z ed wa y of i mp l
ement i ng such syst ems t ha t
l ea ds t o a ma na gea ble s olut i on.

T hei dent if ica t i onofr ecur r ing


pr obl ems a s wel la s t hecr ea t iona ndca t a logi ngofdes i gnpa t t er ns for s ol vi n g
t hem is a n ongoi ng c onsi der a t ions of good des i gn pr inc ipl es such a s mi ni mi z ing c
oup li ng a nd ma xi mi zi ng
cohes i on pla y a n i mp or t a nt r ol e i n t he devel op ment of des i gn pa t t er ns.

T he

soft wa r e devel op ment pa cka ges suc h a s t he Ja va pr ogr a mmi ng envir onment s pr
ovi ded b y Or a cl e a nd t h e
. NET Fr a mewor k pr ovi ded by M icr os oft . I ndeed, ma
ny of t he t emp la t es f ou nd i n t hes e t ool kit s a r e
ess ent ia l ly des i gn pa t t er n skel et ons t ha t l ea d t o r ea dy
-
ma de, hi gh
-
qua l it y solut i ons t o des ign pr ob l ems.

In cl os i ng, we shou l d ment i on t ha t t he emer genc e of design pa t t er ns in soft wa r e


engi neer i ng is a n exa m
pl e
of how di ver s e fi el ds ca n c ont r ibut e t o ea c h ot her . The or igi ns of des ign pa t t er
ns l i e i n t he r es ea r ch of
C hr ist op her Al exa nder i n t r a dit i ona l a r chit ect ur e. His goa l wa s t o i dent if y f ea
t ur es t ha t cont r ibut e t o hi gh
-
qua l it y a r chit ect ur a l des i gns f or bui
ldings or buil ding c omp l ex es a nd t hen t o devel op des i gn pa t t er ns t ha t
i nc or por a t ed t hos e f ea t ur es. T oda y, ma ny of his idea s ha ve b een i ncor p or a t ed
int o s oft wa r e des i gn a nd his
wor k c ont i nu es t o b e a n i nspir a t ion f or ma ny s oft wa r e engi neer s pr oc ess i n
soft w
a r e engi neer i ng.

Intr oduct i on t o Com put in g

CS101

VU

P ag e
231

of
3 81
C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 140


33. 33.

140.

S oftware E ngi nee ri ng: Des ig n Patte r ns E xamp les

Fac tory des ig n Patter n:

T he F a ct or y D es i gn P a t t er n (F i gur e 102) is a c ommo nl y used des i gn pa t t er n


wher e we need t o cr ea t e
Loos el y C oupl ed S yst em. Ba si ca ll y, it comes under
C rea t i ona l P a t t er n a nd it is used t o cr ea t e i nst a nc e a nd
r eus eit . F a ct or yP at t er nisba sedonr ea lt i mefa ct or yc onc ept . Asweknow, a fa ct or
yisusedt oma nufa ct ur e
somet hi nga sper t her equir ement a ndifnewit emsa r eaddedi nt hema nufa ct ur ingpr oc
ess ,

t hefa ct or yst ar t s
ma nufa ct ur ingt hos eit emsa swell. F a ct or ycla sspr ovidesa bstr a ct ionbet weenC l i ent
a ndC arwhencr ea t ing
t hei nst a nc e oft heC a r[Honda , BMWet c]incr ea si ngl ypower fult oolfor soft wa r eengi
neer sist hegr owi ng
col l ect i on of des i gn
Fi gure
102
: Fact ory
Desi gn Pat t ern

S hop p i ng Cart Des ig n Patter n:

It ha s been s hown i n t he F i gur e 103.

Us e when t he us er ca n possib l y buy mor e t ha n one pr oduct .

Us e when t he us er ca n poss ib l y buy mor e t ha n one


i nst a nc e of a pr oduct .

Us e when t he us er ma y wa nt t o r et ur n la t er t o car r y on shoppi ng

Us e when t he us er ma y wa nt t o r et ur n a t a la t er t i me t o conduct pa yment

Do not us e when you onl y ha ve one pr odu ct t o sel l.


Do not us e when your sit e is a rr a nged i n a wa y
, so t ha t it does not ma ke s ens e f or t he user t o buy
mor e t ha n one pr oduct a t a t ime (f or inst a nc e f or App li ca t ion S er vic e P r ovi der s
(AS P s) a llowi ng
a user t o upgr a de his s er vic e).

Intr oduct i on t o Com put in g

CS101

VU

P ag e
232

of
3 81
C opy rig htVi rtual U ni v ersi ty ofP aki stan

Fi gure
103
: Shoppi ng C art Desi gn Pat t ern

Intr oduct i on t o Com put in g

CS101

VU

P ag e
233

of
3 81
C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 141


34. 34.

141.

S oftware E ngi nee ri ng: S cope o f Q ual ity Ass ur ance

In t he ea r ly yea r s of comput i ng, t he pr obl em of pr oduc i ng qua l it y soft wa r e focus


ed on r emovi n g
pr ogr a mmi ng er r or st ha t occur r ed dur i ngi mp l em ent a t i on. La t er int hiss ect i on
we wi ll discuss t hepr ogr ess
t ha t ha s been ma de in t his dir ect i on. However , t oda y, t he sc op e of s oft wa r e qua
lit y c ont r ol ext ends fa r
beyond t he debu ggi ng pr oc ess , wit h bra nc hes inc l uding t he i mpr ovement of soft wa
r e engi neer i ng
pr oc edur es, t he devel op ment o
f t r a ini ng pr ogr a ms t ha t i n ma ny ca ses l ea d t o c er t if ica t i on, a nd t h e
est a bl ishment of st a nda r ds on whi c h sou nd soft wa r e engi neer i ng ca n be ba s ed. I
n t his r ega r d, we ha ve
a lr ea dy not ed t he r ol e of or ga ni za t i ons suc h a s IS O, IEEE, a nd AC M in i mpr oving
pr of e
ssi ona l is m a nd
est a bl ishi ng st a nda r ds for a ss ess i ng qua l it y c ont r ol wi t hi n s oft wa r e devel op
ment c ompa ni es. A sp ec if i c
exa mp l e is t he IS O 9000 ser i es of st a nda r ds, whi ch a ddr ess nu mer ous i ndust r ia l
a ct i vit i es suc h a s des i gn,
pr oduct i on, inst a l la t ion, a nd s e
r vic i ng. Anot her exa mpl e is IS O/ IEC 15504, whic h is a set of st a nda r ds
devel op ed joi nt ly b y t he IS O a nd t he I nt er na t i ona l Elec t r ot ec hnica l C om miss i
on (IEC ).

Ma ny ma j or soft wa r e cont r a ct or s now r equ ir e t ha t t he or ga niza t i ons t hey hir e


t o devel op soft wa r e me
et
such st a nda r ds. Asar esult , soft wa r e devel op ment compa ni es a r e est a blishi ng
softw are q uali ty ass ur ance
(S Q A)
gr oups, whic ha r ec ha r gedwit hover s eei nga ndenf or ci ngt hequa l it yc ont r ols yst
emsa dopt edb yt he
or ga niza t i on. T hus, in t he ca se of t he
t ra dit i ona l wa t er fa ll model, t he S QA gr oup wou l d be cha r ged wit h
t he t a sk of a ppr ovi ng t he s oft wa r e r equ ir ement s spec if i ca t ion b ef or e t he des i
gn st a ge bega n or a ppr ovi ng
t he desi gn a nd it s r ela t ed docu ment s befor e i mp l ement a t ion wa s init ia t ed.

S ever a l t he

st epi nt hedevel op ment pr oc essbea ccur a t el ydocu ment edf or futur er ef er enc e.
However , t hisgoa lc onfl i ct s
wit h hu ma n na t ur e. An iss u e is t he t empt a t ion t o ma ke

decis i ons or cha nge dec isi ons wit hout upda t i ng t h e
r ela t eddocu ment s. T her esult ist hec ha nc et ha t r ec or dswi llb ei nc or r ect a ndhenc
et heir usea t fut ur est a ges
wi ll b e mis l ea di ng. H er ei n li es a n i mp or t a nt benef it of C AS E t ools. T hey ma ke
suc h t a sks a s
r edr a wi ng
dia gr a msa ndupda t ing da t adict i ona r ies muc h ea si er t ha nwit h ma nua l met hods. C
ons equ ent l y, upda t esar e
mor el i kel yt obe ma dea ndt hef i na ldocu ment a t i onis mor eli kel yt obea ccur a t e.(T
hisexa mpl eisonl yone
ofma nyi nst a nc esinwhic hs oft wa r
eengi neer ingmust c op ewit ht hefa ult sofhu ma nna t ur e. Ot her si nc lu de
t he i nevit a bl e p er sona l it y c onf l ict s, jea lous i es, a nd ego cla shes t ha t a r ise when
p eopl e wor k t oget her . )

Anot her qua lit y


-
or i ent ed t heme is t he us e of r evi ews in whic h va r ious pa r t ies i
nvol ved i n a soft wa r e
devel op ment pr oj ect meet t ocons i der a spec if ict opi c. R evi ewsoc cur t hr oughout t
hesoft wa r edevel op ment
pr oc ess , t a king t he for m of r equ ir ement s r evi ews, desi gn r evi ews, a nd i mp l
ement a t i on r evi ews. T hey ma y
a ppea r a s a pr ot ot yp e demo
ns t r a t ion i n t he ea r l y s t a ges of r equir ement s a na lys is , a s a s tr uct ur ed
wa l kt hr ou gha mong memb er soft hesoft wa r edes i gnt ea m, or a scoor di na t iona
mongpr ogr a mmer swhoar e
i mp l ement i ng r ela t ed por t ions of t he desi gn. S uch r evi ews, on a r ecur r ing ba sis,
pr o
vi de c ommu ni ca t io n
cha nnels t hr ou gh whic h misu nder st a ndi ngs ca n be a voi ded a nd er r or s ca n be cor r
ect ed b ef or e t hey gr ow
i nt o disa st er s. T he si gnif ica nc e of r evi ews is ex emp l if i ed by t he fa ct t ha t t hey a r
e spec if ica l l y a ddr ess ed i n
t he IEEE S t a nda r d for S of
t wa r e R evi ews, known a s IEEE 1028.
st a kehol der s a nd t he s oft wa r e devel op ment t ea m a t whic h t he f i na l s oft wa r e r
equ ir ement s sp ec if ica t i on i s
a ppr oved.
I ndeed, t his a ppr ova l ma r ks t he end of t he f or ma l r equ ir ement s a na l ysis p ha se a
nd is t he ba sis
on whi ch t he r ema i ni ng devel op ment wi l l pr ogr ess . However , a ll r evi ews a r e si
gni fi ca nt , a nd f or t he sa ke
of qua lit y c ont r ol, t hey shou l d be docu ment ed a s par t of

t he ongoing r ec or d ma i nt ena nc e pr oc ess .

Intr oduct i on t o Com put in g

CS101

VU

P ag e
234

of
3 81
C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 142


35. 35.

142.

S oftware E ngi nee ri ng: S oft ware T esti ng

Wher ea s soft wa r e qua l it y a ss ur a nce is now r ec ogniz ed a s a subject t ha t per mea


t es t he ent ir e devel op ment
pr oc ess , t est i ng a nd ver i fi ca t ion of t he pr ogr a ms
t hems el ves c ont i nu es t o b e a t opic of r es ea r ch. In modu l e
107, we discuss ed t ec hni qu es for ver if yi ng t he c or r ect ness of a lgor it hms i n a ma t
hema t i ca ll y r igor ous

such
t est i ng is i nexa ct a t best . We ca nnot gua r a nt ee t ha t a piec e of soft wa r e is cor r
ect via t est ing u nl ess we r un
enou gh t est s t o exha ust a ll poss ibl e s c ena r ios. But , even i n si mp l e pr ogr a ms, t
her e ma y b e bi l li ons of
diff er ent pa t hst ha tcouldpot ent ia l l y

bet r a ver sed. T hus,t est i nga llposs iblepa t hswit hinacomp l expr ogr a m
is a n i mp oss ib l e t a sk.
On t he ot her ha nd, soft wa r e engi neer s ha ve devel op ed t est i ng met hodologi es t ha t
i mpr ove t he odds of
r evea l i ng er r or s i n soft wa r e wit h a l i mit ed nu mb er of t est s.

One of t hes e is ba sed on t he obs er va t i on t ha t


er r or sins oft wa r et endt ob ec lu mp ed. T ha t is, exp er i enc eha sshownt ha t a sma l lnu
mb er ofmodu l eswit hi n
a la r ge soft wa r e syst em t end t o be mor e pr obl ema t i c t ha n t he r est . T hus, by ident
if yi ng t hes e modu l es
a nd

i n a unif or m, less
-
t hor ou gh ma nner . T his is a n inst a nc e of t he pr opos it i on known a s t he
Pare to pri nc ip le,
i n r ef er enc e t o t he ec onomist a nd

pr inc ip l e st a t es t ha t r esult s ca n oft en b e i ncr ea sed most r a pidl y by a pplyi ng e


ff or t s in a conc ent r a t ed a r ea .

Anot her soft wa r et est i ng met hodol ogy, ca ll ed


bas ispat htest i ng,
ist odevel opa set oft est da t at ha tinsur es
t ha t ea ch i nst r uct ion i n t he soft wa r e is ex ecut ed a t l ea st onc e. T ec hniqu es usi
ng a n ar ea of ma t hema t ics
knowna s
gr a pht heor y ha veb een devel op edf or i dent if yi ngsuc hs et s oft est da t a . T hus, a lt
hou ghit ma yb e
i mp oss ibl e t o ensur e t ha t ever y pa t h t hr ough a soft wa r e syst em is t est ed, it is
poss ibl e t o ensur e t ha t ever y
st a t ement wit hi n t he s yst em is ex ecut ed a t lea st
onc e du r ing t he t est i ng pr oc ess .

T ec hni qu es ba sed on t he P a r et o pr i nc ip l e a nd ba sis pa t h t est i ng r el y on knowl


edge of t he i nt er na l
comp osit i on of t he soft wa r e being t est ed. T hey t her ef or e fa ll wit hi n t he ca t egor y
ca ll ed
gl ass
-
box test i ng,

mea ning t ha t t he

soft wa r e t est er is a wa r e of t he i nt er i or st ruct ur e of t he s oft wa r e a nd us es t his


knowl edg e
when des i gni ng t he t est . In cont r a st is t he ca t egor y ca ll ed
bl ac k
-
bo x testi ng,
whic h r ef er s t o t est s t ha t do

it i on. Inshor t , bla ck


-
b oxt est i ng isper f or med fr o m

-
b ox t est i ng, one is not c onc er ned wit h how t he soft wa r e goes a bout it s
t a sk but mer el y wit h whet her t he soft wa r e p er for ms c or r ect l y in t er ms of a ccur
a cy a nd t i mel i ness .

An exa mp l e of bla ck
-
b ox t est i ng is t he t ec hni qu e, ca ll ed
bo und ary val ue analysis,
t ha t consist s of
i dent i f yi ngr a ngesofda t a , ca ll ed
eq uiv ale nce cl asses,
over whic ht hes oft wa r eshou l dp er for m i na si mi la r
ma nner a ndt hent est i ngt hes oft wa r eonda t a clo
s et ot he edge oft hos er a nges. F or exa mp l e, ift hes oft wa r e
is supposed t o a cc ept input va lu es wit hi n a spec if i ed r ange, t hen t he soft wa r e wou
l d be t est ed a t t he l owest
a nd hi ghest va lu es i n t ha t r a nge, or if t he soft wa r e is suppos ed t o coor di na t e mu
lt ip l
e a ct ivit i es, t hen t h e
soft wa r e wou ld b e t est ed on t he la r gest poss ib l e c ol l ec t ion of a ct ivit i es. T he
under l yi ng t heor y is t ha t by
i dent i f yi ng equ i va l enc e cla ss es, t he nu mb er of t est ca ses ca n be mi ni miz ed b
eca use c or r ect op er a t ion f or a
f ew exa mpl es wit hi
n a n equ iva l enc e c la ss t ends t o va l i da t e t he soft wa r e f or t he ent ir e c la ss . Mor
eover , t he
best c ha nc e of i dent if yi ng a n er r or wit hin a cla ss is t o use da t a at t he cla ss
edges.

Anot her met hodol ogyt ha t fa llswit hi nt hebla ck


-
b oxca tegor yis
bet atesti ng
in
whic ha pr el i mi na r yver sio n
of t he s oft wa r e is gi ven t o a s egment of t he i nt ended a udi enc e wit h t he goa l of l ea
r ni ng how t he s oft wa r e
per f or msi nr ea l
-
li f es it ua t i ons b ef or et hefi na lver s i onof t hepr oduct is s oli dif i eda ndr el ea s edt ot
hema r ket .
(S i mi la

al p ha test i ng.
) T he a dva nt a ges of bet a t est i ng
ext end fa r beyond t he t r a dit i ona l disc over y of er r ors. Gener a l cust omer f eedba ck
(b ot h p osit ive a n d
nega t i ve) is obt a ined t ha t ma y a ss ist in r ef i ni ng ma r ke
t st r at egi es. M or eover , ea r ly dist r ibut i on of b et a

Intr oduct i on t o Com put in g

CS101

VU

P ag e
235

of
3 81
C opy rig htVi rtual U ni v ersi ty ofP aki stan

soft wa r e a ss ist s ot her soft wa r e devel op er s in des i gni ng compa t ibl e pr odu ct s. F
or exa mp l e, i n t he ca se of a
new op er a t i ng syst em f or t he P C ma r ket , t he dist r ibut i on of a bet a ver sion enc
our a ges t he devel op m
ent of
compa t ibl eut i l it ysoft wa r esot ha t t hefi na lop er a t ingsys t emult i ma t elya ppea r
sonst or eshel vessurr ounded
bycompa nionpr oduct s. Mor eover , t heex ist enc eofbet a t est ingca ngener a t eafeel i
ngofa nt ic ipa t ionwit hin
t he ma r ket pla c e

a n a t mospher e
t ha t incr ea s es publi cit y a nd sa les.

Intr oduct i on t o Com put in g

CS101

VU

P ag e
236

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 143


36. 36.

143.

S oftware E ngi nee ri ng: Doc u me nt at io n

A soft wa r e syst em is of lit t l e use unl ess peopl e ca n l ea r n t o use a nd ma i nt a in it .


Henc e, docu ment a t ion is
a n i mp or t a nt par t of a fina l soft wa r e pa cka ge, a nd it s
devel op ment is, t her ef or e, a n i mp or t a nt t opic i n
soft wa r e engi neer i ng.

S oft wa r e docu ment a t i on s er ves t hr ee pur pos es, l ea di ng t o t hr ee ca t egor i es of


docu ment a t i on: us er
docu ment a t ion, syst em docu ment a t i on, a ndt ec hni ca ldocu ment a t i on. T hepur pos
e of
us e rdoc u me nt at io n
is t o expla in t he f ea t ur es of t he soft wa r e a nd descr ib e how t o use t hem. It is int
ended t o be r ea d by t he us er
oft hesoft wa r ea ndist her ef or e expr ess edi nt het er mi nol ogy oft hea pplica t i on. T oda
y, user docu ment a t i on
is r ec ogni z ed a s a
n i mp or t a nt ma r ket i ng t ool. Good user docu ment a t ion c omb i ned wit h a wel l
-
des i gne d
user int er fa c e ma kes a soft wa r e pa cka ge a cc ess ib l e a nd t hus i ncr ea ses it s sa l es.
R ec ogni zi ng t his, ma ny
soft
-

wa r edevel op er shir et ec hnica lwr it er st opr odu c et hispar toft


heir pr oduct , or t heypr ovi depr el i mi na r y
ver si onsoft heir pr oduct st oindep endent a ut hor ssot ha thow
-
t obooksar ea va ila bl ei n
bookst or es

whent h e
soft wa r e is r el ea s ed t o t he pub li c. Us er docu ment a t i on tr a dit i ona ll y t a kes t he
f or m of a phys ica l b ook or
bookl et , butinma nyca sest hesa mei nf or ma t i onisi nc lu deda spar toft hesoft wa r eit
self. T hisa llowsa user
t o r ef er t o t he docu ment a t i on whil e usi ng t he s oft wa re. In t his ca se t he inf or ma
t ion ma y b e br oken i nt o
sma llu nit s, somet i mesca l l edhelppa cka g
es, t ha t ma ya ppea r ont hedisp la yscr eena ut oma t ica l l yi ft heus er
da l li es t oo l ong bet ween c om ma nds.

T he pur pos e of
s ys te m doc u me nt at io n
soft wa r eca nb ema i nt a i nedla t er i nit sl if ec ycl e. A
ma j or comp onent ofs yst emdocu ment a t ionist hes our c e
ver si on of a l l t he pr ogr a ms i n t he s yst em. It is i mp or t a nt t ha t t hes e pr ogr a ms
b e pr es ent ed i n a r ea da bl e
for ma t , whi c h is why soft wa r e engi neer s suppor t t he use of wel l
-
des i gned, hi gh
-
l evel pr ogr a mmi n g

la ngua ges, t heus e ofc omment st a t ement sf or a nnot a t i nga pr ogr a m, a nda modu la r
des i gnt ha t a ll ows ea ch
modu l e t o b e pr es ent ed a s a coher ent u nit . I n fa ct , most compa ni es t ha t pr oduc
e s oft wa r e pr oduct s ha v e
a dopt ed convent i ons for t heir emp loyees t o fol l
ow when wr it i ng pr ogr a ms. T hes e i nc lu de i ndent a t i on
convent i ons for or ga ni zi ng a pr ogr a m on t he wr it t en pa ge; na mi ng convent i ons t
ha t est a blis h a dist i nct i on
bet ween na mes of diff er ent pr ogr a m c onst r uct s such a s va r ia bles, const a nt s, obj
ect s, a nd cla ss es;
a nd
docu ment a t ion c onvent i ons t o ensur e t ha t a ll pr ogr ams a r e suffic i ent ly docu
ment ed. S uch convent i ons

ma i nt ena nc e pr oc ess .

Anot her comp onent of s yst em docu ment


a t ion is a r ec or d of t he des i gn docu ment s i nclu di ng t he s oft wa r e
r equir ement ssp ec if ica t i ona ndr ec or dsshowinghowt he sesp ec if ica t i onswer eobt a
i neddur ingdes i gn. T his
i nf or ma t ion is useful dur i ng soft wa r e ma i nt ena nc e b eca use it i ndi ca t es why t he
soft wa
r e wa s i mp l ement ed
a s it wa s

inf or ma t ion t ha t r educ es t he c ha nc e t ha t cha nges ma de dur ing ma i nt ena nc e wi


ll disr upt t he
i nt egr it y of t he s yst em.

T he pur pos e of
te c hni c al doc u me nt at io n
is t o des cr i be ho w a s oft wa r e s ys t em s hou l d b e i ns t a l l ed a nd
ser vic ed (su
c h a s a djust i ng op er a t ing pa ra met er s, inst a ll i ng upda t es, a nd r epor t i ng pr obl
ems ba ck t o t h e

mec ha ni cs i n t he a ut omob il e i ndust r y. T his docu ment a t i on d


oes not discuss how t he ca r wa s des i gned a nd
const r uct ed (a na l ogous t o syst em docu ment a t i on), nor does it exp la i n how t o dr i
ve t he ca r a nd op er a t e it s

comp onent s, for exa mp l e, how t o r ep la c e t he t r a ns miss i on or how t o t r a ck


down a n i nt er mit t ent el ect r ica l
pr obl em.

T hedist i nct i onb et weent echnica ldocu ment a t i ona ndus er docu ment a t i onisblur r
edi nt heP C a r ena beca use
t heuser isoft ent heper sonwhoa ls
oi nst a llsa ndser vic es t hesoft wa r e. However , inmu lt ius er envir onment s,
t he dist i nct i on is sha r per .T her ef or e, t ec hni ca l docu men t a t ion is i nt ended for t
he syst em a dmi nist r a t or who

Intr oduct i on t o Com put in g


CS101

VU

P ag e
237

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

is r esp onsib l e f or ser vi ci ng a l l t he soft wa r e u nder his or her jur is dict i o


n, a ll owi ng t he us er s t o a cces s t he
soft wa r e pa cka ges a s a bstr a ct t ools.

Intr oduct i on t o Com put in g


CS101

VU

P ag e
238

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 144


37. 37.

144.

S oftware E ngi nee ri ng: H uman M ac hi ne I nt er face


One of t he t a sks dur i ng r equ ir ement s a na l ysis is t o def i ne how t he pr op os ed s oft
wa r e syst em wi l l i nt er a ct
wit h it s
envir onment . I n t his s ect i on we c ons i der t opic s a ssocia t ed wit h t his int er a ct i on
when it i nvol ves
com mu nica t i ng wit h hu ma ns

a subject wit h pr of ou nd signif ica nc es. Aft er a ll, hu ma ns shoul d b e a ll owe d


t o use a soft wa r e syst em a s a n a bst ra ct t ool. T his t ool s
houl d be ea sy t o a pply a nd desi gned t o mi ni mi z e
(i dea l l y eli mi na t e) c om mu nica t i on er r or s bet ween t he syst em a nd it s hu ma n
us er s. T his mea ns t ha t t he

th
e soft wa r e syst em.

t o ma ke a st r onger i mpr ess ion on a user t ha n a ny ot her syst em c ha r a ct er ist ic.


Aft er a ll, a huma n t ends t o
vi ew a syst em in t er m
s of it s usa bilit y, not in t er ms of how cl ever l y it per f or ms it s int er na l t a sks. Fr om
a

be t he det er mi ni ng fa ct or in t he succ es s
or fa ilur e of a soft wa r e engineer i ng pr oj ect .

F or t hes er ea sons, t hehu ma n


-
ma c hi nei nt er fa c eha sbec omea ni mp or t a nt conc er ni nt her equ ir ement sst a ge
of soft wa r e devel op ment pr oj ect s a nd is a gr owi ng subfi el d of so
ft wa r e engi neer i ng. I n fa ct , some woul d
a r gue t ha t t he st udy of hu ma n
-
ma chi ne i nt er fa ces is a n ent ir e f i el d i n it s own r ight .

Ab enef ic ia r yofr es ea r chi nt hisfi el dist hes ma r t phone i nt er fa ce. Inor der t oat ta int
he goa l ofa conveni ent
poc ket
-
s iz ed devi
c e, el ements of t he t r a dit iona l hu ma n
-
ma c hi ne i nt er fa ce (fu l l
-
si z ed keyboa r d, mous e,
scr ol l bar s, menus) ar e bei ng r epla c ed wit h new a ppr oaches; such a s gest ur es per
for med on a t ouch scr een,
voic ec om ma nds, a nd vir t ua lkeyb oa r dswit ha dva nc ed a ut o
-
comp l et i
on of wor dsa ndp hr a ses. Whi l et hes e
r epr es ent si gnif ica nt pr ogr ess , most sma r t phone us er s wou l d a r gue t ha t t her e
is pl ent y of r oom f or fur t her
i nnova t i on.

R es ea r ch i n hu ma n
-
ma c hi ne i nt er fa c e des i gn dr a ws hea vi l y fr om t he ar ea s of engi neer ing ca ll e d
ergo no
mi cs,
whic hdea lswit hdes i gnings yst emst ha t ha r moniz e wit ht hephys ica la bilit i esofhu ma
ns, a nd
cog net ics,
whic h dea ls wit h des i gni ng syst ems t ha t harmoni z e wit h t he ment a l a bilit i es of hu
ma ns. Of t he
t wo, er gonomics is t he bet t er under st ood, la r gel y beca use hu ma ns ha ve b een i nt
er a ct ing physi ca ll y wit h
ma c hi nes for cent ur i es. Exa mpl es ar e fou nd in a nc i ent t ools
, wea ponr y, a nd t r a nspor t at ion syst ems. Much
of t his hist or y is self
-
evi dent ; however , a t t i mes t he a ppli ca t ion of er gonomics ha s been cou nt er i nt uit i
ve.
An oft en
-
cit ed exa mpl e is t he des i gn of t he t yp ewr i t er keyb oa r d ( now r ei nca r na t ed a s t
he comput er
keyb o

syst em of l ever s used i n t he ea r ly ma c hi nes would not ja m. Ment a l int er a ct i on wit


h ma c hines, in c ont r a st,
isar ela t ivel ynewp henomenon, a ndt hus, itisc
ognet ics t ha toff er st hehi gher pot ent ia lfor fr uit fulr es ea r ch
a nd enli ght eni ng i nsi ght s. Oft en t he f i ndi ngs a r e i nt er est ing i n t heir subt l et y. F
or exa mp l e, hu ma ns f or m
ha bit s

a tr a it t ha t, on t he sur fa c e, is good b eca us e it ca n i ncr ea se eff ic i ency.


But

h
a bit s ca n a ls o l ea d t o
er r or s, even when t he des i gn of a n i nt er fa c e i nt ent i ona l l y a ddr ess es t he pr ob l
em. C ons ider t he pr oc ess of a
hu ma n a ski ng a t ypica l op er a t ing syst em t o del et e a fil e. T o a voi d uni nt ent i ona l
del et i ons, most int er fa c es
r espond t o such a

r equ est by a sking t he us er t o conf ir m t he r equ est

a ny pr ob l em of uni nt ent i ona l del et i ons. However , a ft er using t h


e syst em f or a n ext ended p er i od, a hu ma n

c ea ses t o b e a t wo
-
st ep pr oc ess c ons ist i ng of a del et e com ma nd f ol l owed b y a t hou ght fu l r esp ons e
toa
qu est i on
. Inst ea d, it bec omes a one
-

t ha t a nincor r ect del et er equ est ha sbeensubmit t ed, t herequ est ha sa lr ea dybeenc onf
ir meda ndt he del et i on
ha s occur r ed.

Intr oduct i on t o Com put in g

CS101

VU
P ag e
239

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

T he f or ma t i on of ha bit s ma y a ls o c
a use pr ob l ems when a hu ma n is r equ ir ed t o us e sever a l a ppli ca t io n
soft wa r e pa cka ges. T he i nt er fa ces of suc h pa c ka ges ma y b e s i mi la r yet diff er ent
. S i mila r user a ct ions ma y
r esult i n diff er ent syst emr esp ons es or si mi la r syst emr espons es ma yr equir edif f er
e
nt user a ct ions. Int hes e
ca ses ha bit s devel op ed in one a ppli ca t ion ma y l ea d t o er r or s in t he ot her a pplica t
i ons.

Anot her hu ma n c ha r a ct er ist ic t ha t c onc er ns r es ea r cher s i n hu ma n


-
ma c hi ne int er fa c e des i gn is t he
t o become mor e f ocus ed a s t he l evel of conc ent r a t io n
i ncr ea ses. As a hu ma n b ec omes mor e engr oss ed i n t he t a sk a t ha nd, br ea ki ng t
ha t f ocus b ec omes mor e
diff icu lt . In1972, a commer cia la ir cr a ft cra shedb eca uset hep il ot sb eca mes oa bsor b
ed wit ha la ndi ng
gea r
pr obl em (a ct ua ll y, wit h t he pr oc ess of cha ngi ng t he la ndi ng gea r indica t or li ght
bulb) t ha t t hey a ll owed t h e
pla ne t o f l y i nt o t he gr ou nd, even t hough wa r ni ngs wer e s oundi ng i n t he c oc kp
it .

Less cr it ica l exa mp l es a ppea r r out inel y i n P C int er fa c es. F or

pr ess ed). However , if t he key is a cc ident a ll y pr ess ed, a hu ma n r ar ely not i c es t he


st a t us of t he l i ght unt i l

st ra nge c ha r a ct er s begi n t o a ppea r on t he displa y sc r een. Even t hen, t he us er oft


en puzz l es over t he
pr edica ment f or a whi l eu nt i lr ea li zi ngt heca use oft he pr obl em. I na sens e, t hisis not
sur pr ising

t he li ght

of vi ew. However , user s oft en fa il t o not ic e i ndica t or s pla ced


dir ect l y i n t heir line of sight . F or exa mpl e, user s ca n become s o enga ged i n a ta sk t
ha t t hey fa il t o obs er v e
cha ngesi nt hea pp ea r a nce oft hecur sor ont he displa yscr een, event hou ght heir t a
skinvol ves wa t chi ngt h e
cur sor .
ca pa cit y t o dea l wit h mu lt ip l e fa ct s si mu lt a neousl y. I n a n a rt icl e i n
Psy chol ogi cal Revi e w
i n 1956, G eor ge
A. Mil l er
r epor t ed r es ea r ch indica t i ng t ha t t he hu ma n mi nd is ca pa ble of dea li ng wit h
only a bout seve n
det a i ls a t onc e. T hus, it is i mp or t a nt t ha t a n int er fa ce be des i gned t o pr es ent
a l l t he r el eva nt i nf or ma t i on
when a dec isi on is r equ ir ed ra t her t ha n t or el y on t he

des i gn t o r equir e t ha t a hu ma n r eme mb er pr ec is e det a ils fr om pr evi ous scr een i


ma ges. Mor eover , if a n
i nt er fa ce r equ ir es ext ens i ve na vi ga t ion a mong scr een i ma ges, a hu ma n ca n get l
ost i n t he ma z e. T hus,
t he
cont ent a nd a rr a ngement of scr een i ma ges bec omes a n i mp or t a nt desi gn iss u e.
Alt hou gh a pplica t i ons of
er gonomi cs a nd cognet ics gi ve t he f i el d of hu ma n
-

ma c hi ne i nt er fa c e des i gn a uni qu e f la vor , t he f i el d a lso


enc ompa ss es ma ny of t he mor e t r a dit i ona l t op
ics of soft wa r e engi neer i ng. In pa r t icula r , t he s ea r ch f or
met r ics is just a s imp or t a nt in t he f i el d of i nt er fa ce des i gn a s it is in t he mor e t r
a dit i ona l a r ea s of soft wa r e
engi neer i ng. I nt er fa ce c ha r a ct er ist icst ha t ha veb eensubj ect edt o mea sur ement i
nc lu
det het i mer equir edt o
l ea r n a n int er fa ce, t he t i me r equ ir ed t o per f or m t a sks vi a t he i nt er fa c e, t he r
a t e of user
-
i nt er fa ce er r or s, t he
degr ee t o whi c h a user r et a ins pr ofic i enc y wit h t he i nt er fa ce a ft er per iods of
nonus e, a nd even such
subj ect ive t r a it s
a s t he degr ee t o whic h us er s li ke t he int er fa c e.

T he
G O MS

met r icsi nt he fi el d of hu ma n
-

e
t a sksint er msofus er goa ls(sucha sdel et ea wor dfr om at ext ), oper a t or s(sucha sclic kt
he mous ebut
-

t on),
met hods (suc h a s doubl e
-
c li c k t he mous e but t on a nd pr ess t he del et e key), a nd sel ect i on r ul es (such a s
choos e b et ween t wo met hods of a ccomp lis
hi ng t he same goa l). T his, in fa ct , is t he or igi n of t he a cr ony m
GOMS

goa ls, op er a t or s, met hods, a nd sel ect i on r ul es. In shor t , GOMS is a met hodol ogy
t ha t a ll ows t h e
a ct ions of a huma n usi ng a n int er fa c e t o b e a na l yz ed a s sequ enc es of el ementa r y
st eps (pr e
ss a key, mov e
t he mous e, ma ke a dec is i on). T he per f or ma nc e of ea ch el em ent a r y st ep is a ss
igned a pr ec is e t i me p er i od,
a ndt hus, bya ddi ngt het i mesa ss i gnedt ot hest epsi na t ask, GOMS pr ovi desa mea nsofc
ompa r ingdiff er ent
pr opos ed i nt er fa c es i n t er ms
of t he t i me ea c h woul d r equir e when p er for mi ng si mi la r t a sks.

Under st a ndi ng t he t ec hni ca l det a i ls of syst ems suc h a sGOMS is not t he pur pos e of
our cur r ent st udy. T he
point i nour ca seist ha t GOMSisfoundedonf ea t ur esof hu ma nb eha vi or (movi ngha nds,
ma
ki ngdec is i ons,
a nd s o on). I n fa ct , t he devel op ment of GOMS wa s or igina ll y c ons i der ed a t op ic i
n ps yc hol ogy. T hus,

Intr oduct i on t o Com put in g

CS101

VU

P ag e
240

of
3 81
C opy rig htVi rtual U ni v ersi ty ofP aki stan

GOMS r eemp ha si z es t he r ol e t ha t hu ma n c ha r a ct er ist ics pla y i n t he f i el d of hu


ma n
-
ma c hi ne int er fa c e
des i gn, even i n t he t opi cs t ha t a r e car r y
over s fr om t r a di t iona l s oft wa r e engi neer ing.

T hedes i gnofhu ma n
-
ma c hinei nt er fa cespr omis est ob ea na ct ivef i el dofr es ea r chi nt hefor es eea b l efutur
e.

in
t he us e of t hr ee
-
di mens i ona l i nt er fa c es t ha t ar e now on t he hor iz on. Indeed, b eca us e t hes e i nt
er fa ces
pr omis et oc omb i nea udi oa ndt a ct il ec ommu nica t i on wit ht hr ee
-

di mens i ona lvisi on, t hesc op e ofp ot ent ia l


pr obl ems is enor mous.

Intr oduct i on t o Com put in g


CS101

VU

P ag e
241

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 145


38. 38.

145.

S oftware
E ngi nee ri ng: S oft ware O w ne rs hip and L i ab i l ity
Most wou l da gr eet ha t acompa nyor indi vi dua lshoul dbea ll owedt or ec oup, a ndpr ofit
fr om, t heinvest ment
needed t o devel op qua l it y s oft wa r e. Ot her wis e, it is u nli kel y t ha t ma ny woul d b
e wi ll i ng t o under t a ke
t he
t a sk of pr oduc i ng t he s oft wa r e our soci et y des ir es. In s hor t , soft wa r e devel op er
s need a l evel of owner ship
over t he soft wa r e t hey pr oduc e.

Lega l eff or t s t o pr ovi de su ch owner ship fa l l under t he ca t egor y of


i nte l lec t ual pro per ty
la w, mu ch of
whic h is ba sed on t he wel l
-
est a blis hed pr inc iples of cop yr i ght a nd pa t ent la w. Indeed, t he pur pos e of a
cop yr i ght or pa t ent is t o a ll ow t he devel op er of a pr oduct t o r el ea s e t ha t pr
oduct (or por t i ons t her eof) t o
i nt ended pa rt ies whi l e pr ot ect i
ng his or her owner s hip ri ght s . As s uch, t he devel op er of a pr odu ct (whet her
a n indi vi dua l or a cor por at ion) wil l a ss er t his or her owner ship by i nc ludi ng a
copyr i ght st a t ement i n a l l
pr oduc ed wor ks; i nclu di ng r equir ement speci fi ca t i ons, desi gn docu ment s,
sour ce c ode, t est pla ns, a nd i n
some visib l e pla c e wit hi n t he f ina l pr oduct . A cop yr i ght not i c e c l ea r ly i dent if i
es owner s hip, t he p er sonnel
a ut hor iz ed t o use t he wor k, a nd ot her r est r ict i ons. F urt her mor e, t he r i ght s of t
he devel op er a r e for ma l l y
expr ess ed
i n l ega l t er ms i n a
software l ice nse.
A soft wa r e li c ens e is a lega l a gr eement bet ween t he owner a nd us er of a soft wa r e
pr oduct t ha t gr a nt s t he
user cer t a inper miss i onst ouset hepr oduct wit hout t ra nsf er r ingowner shipr ight st ot
heint el l ect ua lpr op er t y.
T
hes e a gr eem ent s sp ell out , t o a fi ne l evel of det a il, t he r i ght s a nd obl i ga t i ons of
b ot h pa r t ies. T hus, it is
i mp or t a nt t o ca r eful l y r ea d a nd under st a nd t he t er ms of t he soft wa r e l ic ens e
b ef or e i nst a ll i ng a nd usi ng a
soft wa r e pr oduct .

Whi l e c op yr i ght s a nd
s oft wa r e li c ens e a gr eement s pr ovi de l ega l a venu es t o i nhib it out r i ght c opyi ng
a nd
una ut hor iz ed us e of s oft wa r e, t hey a r e gener a l l y i nsuff ic i ent t o pr event a not
her pa rt y fr om i ndep endent l y
devel op i ng a pr oduct wit h a nea r ly i dent ica l fu nct i on. It is sa d t ha
t over t he yea r s t her e ha ve b een ma ny
oc ca sions wher e t he devel op er of a tr uly r evolut i ona r y soft wa r e pr oduct wa s una
ble t o ca pit a liz e fu l ly o n
his or her i nvent i on (t wo not a bl e exa mp l es a r e spr ea dsheet s a nd web br ows er s).
In most of t hes e ca ses,
a not her c
ompa ny wa s succ ess ful i n devel op i ng a comp et it i ve pr oduct t ha t secur ed a domi
na nt s ha r e of t h e
ma r ket . A l ega l pa t h t o pr event t his i nt r usion by a compet it or is fou nd i n pa t ent
la w.

P a t ent la ws wer e est a blis hed t o a llow a n invent or t o benefit comm er c ia l l y


fr om a n invent i on. T o obta in a
pa t ent , t hei nvent or must dis cl os et hedet a i lsoft he i nvent i ona nddemonst r a t et ha t
itisnew, usefu l, a ndnot
ob vi ous t o ot her s wit h s i mi la r ba ckgr ounds (a r equir em ent t ha t ca n b e qu it e c
ha l l engi ng f or soft wa r e). If a
pa t en
t is gr a nt ed, t he invent or is gi ven t he r ight t o pr event ot her s fr om ma king, using,
sell i ng, or imp or t i ng
t he invent i on f or a li mit ed p er i od of t i me, whic h is t yp i ca ll y 20 yea r s fr om t he
da t e t he pa t ent a pplica t i on
wa s fil ed.

One dr a wba ck t o t he us e of pa t
ent s is t ha t t he pr oc ess t o obt a i n a pa t ent is exp ens i ve a nd t i me
-
c onsu mi ng,
oft en i nvol vi ng s ever a l yea r s. Dur ing t his t i me a soft wa r e pr odu ct cou l d bec
ome obs ol et e, a nd unt il t h e
pa t ent is gr a nt ed t he a pplica nt ha s only qu est i ona bl e a ut hor it y t o ex clu de
ot her s fr om a ppr opr ia t ing t he
pr oduct .

T he i mp or t a nc e of r ec ogni zi ng c op yr i ght s, soft wa r e l ic ens es, a nd pa t ent s is


pa ra mou nt i n t he s oft wa r e
engi neer i ng pr oc ess . When devel op i ng a soft wa r e pr oduct , soft wa r e engi neer s
oft en c hoos e t o i nc or por a t e
soft wa r e fr om ot her pr odu ct s, whet her it be a n ent
ir e pr oduct , subs et of comp onent s, or even por t i ons of
sour c ec odedownl oa dedover t heI nt er net . However , fa i lur et ohonor i nt ell ect ua lpr
op er t yr i ght sdur i ngt his
pr oc ess ma yl ea dt ohu gel ia bil it i esa ndc ons equ enc es. F or exa mp l e, in2004, alit t l e
-
known
c ompa ny, NPT
Inc. , success fu l l y won a la wsuit a ga inst R es ea r ch
in

M ot i on (R IM
t he ma ker s of t he B la c kB er r y

Intr oduct i on t o Com put in g

CS101

VU

P ag e
242

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

ju dgment i nc lu ded a n i nju nct i on t o sus pend ema i l


ser vic es t o a ll B la ckB er r y user s in t he Unit ed S t a t es !
R IM event ua l l y r ea c hed a n a gr eement t o pa y NP Ta t ota l of $612. 5 mi ll i on, t her
eby a ver t i ng a shut down.

F ina l l y, wes hou l da ddr esst heissu eoflia bil it y. T opr ot ect t hems el vesa ga inst l ia
bilit y, soft wa
r edevel op er s
oft eni nc lu dedisc la i mer si nt hesoft wa r eli c ens est ha t sta t et hel i mit a t i onsoft heir
lia bil it y. S uchsta t ement s

com mon. C our t s, however , r


ar el y r ec ogni z e a disc la i me r if t he pla i nt iff ca n show negli genc e on t he pa rt of
t he def enda nt .
T hus,

lia bil it y ca ses t end t o focus on whet her t he def enda nt used a level of ca r e compa t
ibl e
wit ht hepr oduct b ei ngpr odu c ed. Al evelofca r et ha t mi ght bedee m
eda cc ept a bl ei nt heca s eofdevel opi ng
a wor d pr ocess i ng syst em ma y be c onsi der ed negl i gent when devel op i ng soft wa r e
t o cont r ol a nucl ea r
r ea ct or . C ons equ ent l y, one of t he b est def ens es a ga i nst soft wa r e l ia bil it y cla i
ms is t o a pply sou nd soft wa r e
engi neer

Intr oduct i on t o Com put in g

CS101
VU

P ag e
243

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 146


39. 39.

146.

Dat a Abstr ac tio n: Arr ays and Aggreg at es

R eca l l t ha t a n
arr ay
ofa r ra yist he one
-
di mensi ona la r ra y, asingl er ow of el ement s wit h ea c hpos it i on i dent i fi edb ya n i
ndex. A
one
-
di mens iona l a rr a y wit h 26 el ement s coul d b e used t o st or
e t he nu mb er of t i mes ea c h a lpha bet l et t er
oc cur s in a pa ge of t ext , for exa mpl e. A t wo
-
di mensi ona l a rr a y consist s of mu lt ipl e r ows a nd c olu mns i n
whic h p osit i ons a r e ident if i ed b y pa ir s of i ndic es

t he f ir st index i dent if i es t he r ow a ss ocia t ed wit h t h e


pos
it i on;

t he sec ond i ndex i dent if i es t he c olu mn. An exa mp l e wou l d be a r ect a ngu la r arr a
y of nu mb er s
r epr es ent i ngt he mont hl ysa l esma deb ymemb er sofasa lesfor c e

t he ent r i esa cr ossea chr owr epr es ent i ng


t he mont hl ysa l es ma debya par t icula rmemb er a ndt he

ent r i esdown ea c hcolu mnr epr es ent i ngt hesa l esby


ea c h memb er for a par t icula r mont h. T hus, t he ent r y in t he t hir d r ow a nd f ir st
colu mn wou l d r epr es ent t he
sa les ma de b y t he t hir d sa lesp er son i n Ja nua r y.

Inc ont r a st t oa na rra y, r eca l lt ha t a n


aggreg ate
typ e
isabloc kof da t ait emst ha t mi ght beofdiff er ent t yp es
a nd siz es. T he it ems wit hin t he bl oc k a r e usua ll y ca ll ed
fie l ds.
An exa mp l e of a n a ggr ega t e t yp e woul d b e
t hebloc kofda t a r ela t i ngt oa single emp l oyee, t he fi el dsof whi c h mi ght bet he emp l o

of t yp e cha r a ct er ), a ge ( of t yp e i nt eger ), a nd skil l r a t ing (of t yp e fl oa t ). F iel ds


i n a n a ggr ega t e t yp e a r e
usua lly a cc ess ed by f i el d na me, r a t her t ha n by a nu mer i ca l i ndex nu mb er .

Mod ule 147


40. 40.

147.

Dat a Abstr ac tio n: L ist, S tac ks and Q ue ues

Anot her ba sic da t a st ruct ur e is a


list,
whic h is a col l ect i on whos e ent r i es a r e a rra nged s equ ent ia l l y (F igur e
104a ).T he b egi nni ng of a list is ca ll ed t he
he ad
of t he l ist . T he ot her end of a list is ca ll ed t he
t ai l.

Al most a ny c oll ect i on of da t a ca n be


envisi oned a s a list . F or exa mp l e, t ext ca n be envis i oned a s a list of
symb ols, a t wo
-
di mens i ona l a rra y ca n be envisi oned a s a list of r ows, a nd mus ic r ec or ded on a C D
ca n be
envisi oneda salist ofsou nds. Mor et ra dit i ona lexa mp l esinc lu degu est list s, sh
opp i nglist s, cla ss enr ol l ment
list s, a nd i nvent or yl ist s. Act i vit i esa ssoc ia t ed wit ha lis t va r ydep ending ont hes it
ua t ion. Ins omeca s es we

cha nge t he a r ra ngem ent of t he ent r i es i n a list , or per ha ps sea r ch t o s ee if a par t


icula r it em is i n a list . W e
wi ll i nvest i ga t e suc h op er a t ions la t er in t his cha pt er .

By r est r ict i ng t he ma nner in whic h t he ent r i es of a list ar e a ccess ed, we obt a i n t


wo sp
ec ia l t yp es of l ist s
known a s sta cks a nd qu eu es. A
stac k
is a list in whi c h ent r i es a r e ins er t ed a nd r emoved onl y a t t he hea d.
An exa mp l e is a st a ck of books wher e physi ca l r est r ict i ons di ct a t e t ha t a ll a ddit i
ons a nd del et i ons occur a t
t he t op (F igur e 104b
). F ol l owi ng c ol l oqu ia l t er mi nol ogy, t he hea d of a sta ck is ca ll ed t he
top
of t he st a ck.
T he t a il of a sta ck is ca ll ed it s
botto m
or
base.
Ins er t ing a new ent r y a t t he t op of a sta ck is ca ll ed
p us hi ng
a n ent r y. R emovi ng a n ent r y fr om t he t op of a st a ck i s
ca ll ed
po pp i ng
a n ent r y. Not e t ha t t he la st ent r y
pla c ed on a sta ck wi l l a lwa ys be t he fir st ent r y r emoved

a n obs er va t i on t ha t lea ds t o a st a ck bei ng kn own


a sa
last
-
i n, first
-
o ut,
or
L IFO

T his LIF O cha r a ct er ist ic mea ns t h


a t a st a ck is idea l for st or ing it ems t ha t must be r et r ieved i n t he r ever s e
or der fr om whic h t hey wer e st or ed, a nd t hus a sta ck is oft en us ed a s t he under p i
nni ng of ba ckt r a cki ng
a ct ivit i es. (T he t er m
b ac ktr ac ki ng
r ef er s t o t he pr oc es s of ba cki ng out of a s
yst em i n t he opp osit e or der

r ecur si ve pr oc ess . A
s ea c h new a ct i va t i on is st ar t ed, t he pr evi ous a ct iva t i on must be set a side. Mor
eover ,
a s ea ch a ct i va t ion is comp l et ed, t he la st a ct iva t ion t ha t wa s set a side must be r
et r i eved. T hus, if t h e
Intr oduct i on t o Com put in g

CS101

VU

P ag e
244

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

a ct iva t i ons a r e pushed on a st a ck a s t hey a r e s et a si de, t hen t he

pr op er a ct iva t i on wil l b e on t he t op of t h e
st a ck ea c h t i me a n a ct i va t ion needs t o b e r et r i eved.
A
q ue ue
is a list i n whic h t he ent r i es a r e r emoved onl y a t t he hea d a nd new ent r i es a r e i
ns er t ed onl y a t t he
t a il. An exa mp l e is a line, or qu eu e, of p eopl e w
a it i ng t o buy t ic ket s a t a t hea t er (F igur e 104c)

t he p er so n
a t t he hea d of t he qu eu e is ser ved whil e new a r r iva ls st ep t o t he r ea r (or t a il) of t
he qu eu e. A qu eu e is a
first
-
i n, fi rst
-
o ut,
or
FI FO

a r er emovedfr oma
qu eu e i n t he or der in whi c h t hey wer e st or ed.

Queu es a r e oft en used a s t he under l yi ng st r uct ur e of a buffer , whic h is a st ora ge a r


ea for t he t emp or a r y
pla c ement of da t a bei ng t r a nsfer r ed fr om one l oca t ion t o a not her . As t he it ems
of da t a

ar r ive a t t he buff er ,
t heya r epla ceda t t het a iloft hequ eu e. T hen, whenit comest i met ofor wa r dit emst ot
heir fina ldest i na t i on,
t heya r ef or wa r dedi nt he or der i n whic ht heya ppea r a tt he hea d oft he qu eu e. T hus,
it emsa r ef or wa r dedi n
t he sa me or de
r i n whic h t hey a r r ived.

Fi gure
104
: L i st s, st acks, and queues

Intr oduct i on t o Com put in g

CS101

VU

P ag e
245

of
3 81
C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule
148
41. 41.

148.

Dat a Abstr ac tio n: T rees

A
tr ee
isa col l ect i on whos e ent r i es ha vea hi er a r chica lor ga niza t i onsi mi la r t ot ha t ofa n
or ga niza t i onc ha r t
ofa t ypica lcompa ny(F igur e105). T hepr esi dent isr epr es ent eda t t het op, wit hli nesbr
a nchi ngdownt ot he
vic e
pr esi dent s, who ar e foll owed by r egi ona l ma na ger s, a nd so on. T o t his int uit i ve def
i nit i on of a tr ee
st r uct ur ewei mp os eonea ddit i ona lconst r a int , whi c h(i nt er msofa nor ga niza t i
oncha r t )ist ha tnoi ndi vi dua l
i n t he c ompa ny r epor t s t o t wo diff er ent supe
r i or s. T hat is, diff er ent bra nc hes of t he or ga ni za t ion do not
mer ge a t a lower l evel. (W e ha ve a lr ea dy s een exa mp l es of t r ees i n C ha pt er 6
wher e t hey a ppea r ed i n t he
for m of pa r se tr ees. )
Fi gure
105
: An example of anorganizati on chart

Ea ch pos it i on in a t r ee is ca l l ed a
nod e
(F i gur e 106). T he node a t t he t op is ca l l ed t he
root node
( if w e
t ur ned t he dr a wi ng upsi de down, t his node wou l d r epr es ent t he ba se or r oot of t
he t r ee). T he nodes a t t he
ot her ext r emea r e

ca l l ed
t er mi nal no des
( or somet i mes
le af no des
). W e oft enr ef er t ot he nu mb er ofnodes
i n t he l ongest pa t h fr om t he r oot t o a l ea f a s t he
de pt h
of t he t r ee. I n ot her wor ds, t he dept h of a t r ee is t h e
nu mb er of hor iz ont a l la yer s wit hi n it .

Fi gure
106
: T ree t er
mi nol ogy
At t i mes wer ef er t ot r eest r uct ur esa st hough ea c h nodegi vesbir t ht ot hos e nodesi
mm edia t el yb el ow it . In

r t o it s i m media t e desc enda nt s a s


it s
chi ld re n
a nd it s i mmedia t e a nc est or a s it s
pare nt.
Mor eover , we spea k of nodes wit h t he sa me pa r ent
a s bei ng
si b li ngs.
A t r ee i n whic h ea c h pa r ent ha s no mor e t ha n t wo c hil dr en is ca ll ed a
bi nary tree.

Intr oduct i on t o Com put in g

CS101

VU

P ag e
246

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Ifwes el ect a ny nodei na t r ee, we fi ndt ha t t ha t nodet oget her wit ht he nodesb el ow it a
lso
ha s

t hest r uct ur e
ofa t r ee. W eca l lt hes es ma l l er st r uct ur es
subtre es.
T hus, ea chc hi l d nodeist her oot ofa subtr eeb elowt he

is ca ll ed a
br anc h
fr om t he pa r ent . In a bina r y t r ee, we oft en sp ea k of a

Intr oduct i on t o Com put in g

CS101
VU

P ag e
247

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 149


42. 42.

149.

Dat a Abstr ac tio n: Po i nte rs


nu mer ic va lu es, t hes e a ddr ess es t hems el ves ca n b e encoded a nd st or ed i n memor
y c el ls. A
po i nter
is a
st or a gea r ea t ha t cont a i nssuc ha nenc odeda ddr ess . In
t heca s eofda t a str uct ur es, poi nt er sar eusedt or ec or d
t hel oca t i onwher eda t ait emsa r est or ed. F or exa mp l e, ifwe must r ep ea t edl ymovea
nit emofda t afr omon e
l oca t i ont oa not her , we mi ght des i gna t ea fix edl oca t i ont os er vea sa poi nt er . T
hen, ea cht
i me we movet h e
it em, we ca n upda t e t he p oi nt er t o r ef l ect t he new a ddr ess of t he da t a . Lat er ,
when we need t o a ccess t h e

W e ha ve a lr ea dy encou nt er ed

t he conc ept of a point er i n our st udy of C P Us in t he modu l e 36 . T her e we


fou nd t ha t a r egist er ca ll ed a pr ogr a m c ou nt er is used t o hol d t he a ddr ess of t
he next i nst r uct i on t o b e
ex ecut ed. T hus, t hepr ogr a mc ount er pla yst her ol eofa point er . Infa ct , a no
t her na mef or a pr ogr a mc ou nt er
is
i nst r uctio n poi nt er.

me mor y a lpha bet ica l l y by t it l e. Alt hou gh conveni ent in ma ny a pplica t ions, t his a
rra ngement ma kes i
t
diff icu lt t o fi nd a l l t he novels b y a pa rt icula r aut hor

t hey a r e sca t t er ed t hr ou ghout t he list . T o sol ve t his


pr obl em, we ca n r eser ve a n a ddit i ona l memor y c el l wit hi n ea c h bloc k of c ells r
epr es ent i ng a novel a nd use
t his c el l a s a poi nt er t o a not her bloc
k r epr es ent i ng a book by t he sa me a ut hor . In t his ma nner t he novel s
wit h c ommon a ut hor ship ca n be li nked i n a loop (F igu r e 8. 4). Once we fi nd one novel
by a gi ven a ut hor ,
we ca n f i nd a ll t he ot her s by f oll owi ng t he p oi nt er s fr om one b ook t o a not her .

Ma ny m
oder n pr ogr a mmi ng la ngua ges i nc lu de p oi nt er s as a pr imit i ve da t a t ype. T ha t
is, t hey a ll ow t he
decla r a t ion, a ll oca t i on, a nd ma nipula t i on of poi nt er s i n wa ys r emi nisc ent of i nt
eger s a nd c ha r a ct er str ings.
Us i ng suc h a la ngua ge, a pr ogr a mmer ca n desi gn ela bo

wher e poi nt er s ar e used t o l i nk r ela t ed it ems t o ea c h ot her .

Fi gu r e
107
: N ovel s arranged byt i tl e but l i nked according t o aut horshi p

Intr oduct i on t o Com put in g

CS101

VU
P ag e
248

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 150


43. 43.

150.

Dat ab ase S yste ms: T he S ig ni fi c anc e of D at ab ase S yste ms

T he t er m
d at abas e
r ef er s t o a col l ect i on of da t a t ha t is mult i di mens i ona l in t he s ens e t ha t int er na
l l inks
bet ween it s ent r i es ma ke t he i nf or ma t ion a cc ess ibl e fr om a va r i et y of p er spect i
ves. T his is i n cont r a st t o a
t ra dit i ona l f il e s yst em, somet i mes ca ll ed a
flat fi le,
whi
c h is a one
-
di mensi ona l st or a ge syst em, mea ni ng
t ha t it pr es ent sit si nf or ma t ionfr oma si ngl ep oi nt of vi ew. Wher ea sa fla tfil ec ont a i
ni ngi nf or ma t i ona bout
comp os er s a nd t heir c omp os it i ons mi ght pr ovi de a l ist of c omp osit i ons a rra
nged b y c omp os er , a da t
a ba se
mi ght pr es ent a ll t he wor ks by a singl e comp os er , a ll t he c omp os er s who wr ot e a
pa rt icula r t yp e of mus ic,

Hist or i ca ll y, a s comput ing ma c hi ner y f ou nd br oa der uses i n i nf or ma t io


n ma na gement , ea ch a ppli ca t io n
t endedt ob ei mp l ement eda sasepa ra t esyst em wit hit s ownc ol l ect i on ofda t a . P a yr
oll wa spr ocess edusi ng
t hepa yr ol lfi l e, t hep er s onneldepa r t ment ma i nt a inedit sownempl oyeer ec or ds, a
ndi nvent or ywa sma na ge d
via a n inven
t or y fi l e. T his mea nt t ha t muc h of t he i nf or ma t i on r equ ir ed by a n or ga niza t i
on wa s dupl ica t e d
t hr ou ghout t he c ompa ny, whil e ma ny diff er ent but r el a t ed it ems wer e st or ed i n
s epa r a t e syst ems. I n t his
set t i ng, da t a ba se syst ems emer ged a s a mea ns of i nt egr at in
g t he i nf or ma t i on st or ed a nd ma i nt a i ned b y a
pa rt icula r or ga ni za t ion (F i gur e 108). Wit h such a syst em, t he sa me sa l es da t a
coul d b e used t o pr oduc e
r est oc ki ng or der s; cr ea t e r epor t s on ma r ket t r ends, dir ect a dver t is ement s, a
nd pr oduct a nnou nc em ent s t o
cust
omer s who a r e most li kel y t o r esp ond fa vor a bly t o suc h i nf or ma t i on; a nd gener
a t e b onus c hec ks f or
me mb er s of t he sa l es for c e.

Fi gure
108
: A f il e vers us a database organi zati on

S uchi nt egr a t edpoolsof


i nf or ma t i onpr ovi deda va lua bler esour c ewit hwhic hma na gem ent decis i onsc oul d
be ma de, a ss umi ng t he i nf or ma t ion c ou ld b e a cc ess ed i n a mea ni ngful wa y. In t
ur n, da ta ba se r esea r ch
focus edon devel opingt ec hniqu esby whic ht he i nf or ma t ion i na da t a ba secou ld

b ebr ou ght t ot he dec isi on


-

Intr oduct i on t o Com put in g

CS101

VU
P ag e
249

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

ma ki ng pr oc ess . Much pr ogr ess ha s been ma de i n t his r ega r d. T oda y, da t a ba se t


ec hnol ogy, comb i ned wit h
da t a mi ning t ec hniqu es, is a n i mp or t a nt ma na gement t ool, a llowi ng t he ma na
gement of a n or ga ni za t ion t o
ext r a ct per t inent i nf or
ma t ion fr om enor mous a mou nt s of da t a cover i ng a l l a spect s of t he or ga ni za t ion
and
it s envir onment .

Mor eover , da t a ba se syst ems ha ve b ec ome t he u nder l yi ng t ec hnol ogy t ha t


suppor t s ma ny of t he mor e
popula r sit es on t he W or l d W i de W eb. T he u nder l yi ng t heme of
sit es suc h a s Googl e, eBa y, a nd Ama z on

i nt er r oga t es a da t a base, or ga niz es t he r esu lt s i n t he f or m of a W eb pa ge, a nd s


ends t ha t pa ge t o t he c l i ent .
S uch
Web i nt er fa c es ha ve popu la r iz ed a new r ol e f or da ta base t ec hnol ogy in whic h a
da ta base is no l onger
da t a base t ec hnol ogy wit h Web i nt er fa c es, t he Int er net ha
s bec ome a ma j or wor l d
-
wi de i nf or ma t i on sour c e.

Intr oduct i on t o Com put in g

CS101

VU

P ag e
250

of
3 81
C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 151


44. 44.

151.

Dat ab ase S yste ms: Role o f S c he ma

Amongt he disa dva nt a gesoft hepr ol if er a t i onofda t a ba set ec hnol ogyist hepot ent ia
lofsens it i ve da t abei ng

or sa les r ec or ds.
T hus ,

t he a bil it y t o cont r ol a cc ess t o t he i nf or ma t ion i n t he da t a ba se is a s imp or t a nt


as t he
a bilit y t o sha r e it .

T opr ovi de diff er ent us er sa ccess t odiff er ent i nfor ma t i on wit hi na da t aba se, da ta
basesyst emsoft enr el y on
schema s a nd subs chema s. A
sc he ma
is a

descr ipt i on of t he ent ir e da t a base st r uct ur e t ha t is used b y t he


da t a base soft wa r e t o ma i nt a i n t he da t a ba se. A
subs c he ma
is a descr ipt i on of onl y t ha t por t ion of t he

a t a ba se wou l d
i ndi ca t et ha t ea c hst udent r ec or dc ont a inssuc hit emsa sthecur r ent a ddr ess a
ndphonenu mb er oft ha t st udent

t ot her ec or d oft hest

ma i nt a inedt ha t ult i ma t elyconnect edt hei nf or ma t i ona bout a st udent t o


t heemp l oy ment his t or yofa fa cult y
me mb er .

ult y
r ec or ds does not i nc lude emp l oyment hist or y. Under t his subschema , t he r egist r ar
could f ind out whi c h

t ha t fa cult y memb er . In cont r a st ,t he su


bschema for t he pa yr ol l depa r t ment wou l d pr ovide t he emp l oyment
hist or y of ea c h fa cult y memb er but woul d not i nc lu de t he li nka ge b et ween st
udent s a nd a dvis er s. T hus t he

s of t he st udent s
a dvis ed by t ha t per son.

Intr oduct i on t o Com put in g


CS101

VU

P ag e
251

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 152


45. 45.

152.

Dat ab ase S yste ms: Dat ab ase M anage me nt S yste ms


A t ypi ca l da t a base a pplica t i on i nvol ves mult ipl e soft wa r e la yer s, whic h we wil l
gr oup i nt o t wo ma j or
la yer s

a n a pplica t i on la yer a nd a da ta ba se
ma na gement la yer (F i gur e 109). T he a ppli ca t ion s oft wa r e
ha ndl es t he c ommu ni ca t ion wit h t he us er of t he da t a ba se a nd ma y b e qu it e c
ompl ex, a s exemp li fi ed b y
a pplica t i onsi nwhic hus er sa ccess a da t a ba sebymea nsofa websit e. I nt ha t ca set
heent ir ea ppli ca
t ionla yer
cons ist s of c l i ent s t hr ou ghout t he I nt er net a nd a ser ver t ha t uses t he da t a ba se
t o fi l l t he r equ est s fr om t he
cl i ent s.

Fi gure
109
: T he concept ual l ayers of a dat abase i mpl ement at i on

Not e t ha t t he a pplica t i on soft wa r e does not dir ect l y ma nipula t e t he da t a


-

ba se. T he a ct ua l ma nipu la t i on of
t he da t a base is a ccompl is hed b y t he
dat ab ase man age me nt sys te m (DB MS ).
Onc e t he a pp li ca t io n
soft wa r e ha s det er mined wha t a ct ion t he user
is r equ est i ng, it uses t he DBMS a s a n a bstr a ct t ool t o obt a i n
t he r esu lt s. If t he r equ est is t o a dd or del et e da t a , it is t he DBMS t ha t a ct ua ll y
a lt er s t he da t a ba se. If t he
r equ est is t o r et r i eve i nf or ma t i on, it is t he D BMS t ha t per f or ms t he r equ ir ed s
ea r c
hes.

T hisdic hot omyb et weent hea pplica t i ons oft wa r ea ndt heD BMS ha ssev
-

er a lb enef it s. Oneist ha t it a ll ows


for t he c onst r uct ion a nd use of a bst ra ct t ools, whi c h we ha ve r ep ea t edl y fou nd t o
be a ma j or simp li f yi ng
conc ept i n s oft wa r e desi gn. If t he det a
ils of how t he da t a base is a ct ua ll y st or ed a r e is ola t ed wit hi n t he
DBMS , t he des i gnoft hea ppl ica t i onsoft wa r eca nb egr ea t l ysi mp li fi ed. F or i nst a nc
e, wit ha wel l
-
des i gned
DBMS , t he a ppli ca t ion soft wa r e does not ha ve t o be conc er ned wit h whet her t he
d
a t a bas e is s t or ed on a
singl e ma c hi ne or sca t t er ed a mong ma ny ma c hi nes wit hi n a net wor k a s a
distri b ut ed d atab ase.
I ns t ea d,
t he DBMS wou l d dea l wit h t hes e iss u es, a llowi ng t he a ppli ca t ion soft
-

wa r e t o a cc ess t he da t a ba se wit hout


conc er n f or wher e t he da t a

isa ct ua lly st or ed.

A s ec ond a dva nt a ge of s epa ra t ing t he a pplica t i on soft wa r e fr om t he D BMS is t ha


t such a n or ga niza t i on
pr ovi des a mea ns for cont r ol l ing a cc ess t o t he da t a ba se. By di ct a t ing t ha t t he
DBMS per for ms a ll a ccess t o
t he da t a ba se, t he D BMS ca n
enf or c e t he r est r ict i ons i m pos ed by t he va r ious subs chema s. In pa r t icula r , t he
DBMS ca nuset heent ir eda t a ba seschema for it sint er na lneedsbut ca nr equir et ha t t
hea ppli ca t i ons oft wa r e
emp l oyed b y ea ch us er r ema i n wit hin t he bou nds des cr i bed by t ha t use

S t illa not her r ea sonf or sepa r a t ingt heus er i nt er fa c ea nda ct ua lda t ama nipu la t
ioni nt ot wodi ff er ent soft wa r e
la yer s is t o a chi eve
d at a i nd epe nd e nce

t he a bi lit y t o cha ng e t he or ga niza t i on of t he da t a ba s e it s el f


wit hout c ha ngi ng t he a ppli ca
t ion s oft wa r e. F or exa mp l e, t he p er sonnel depa r t ment mi ght need t o a dd a n

a r e dea lt dir ect ly wit h

dea l i ng wit h t he da t a ba se. As a r esult , t he c ha nge i nst iga t ed by t he p er s onnel


depa r t ment mi ght ca us e

Intr oduct i on t o Com put in g

CS101

VU
P ag e
252

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

cha nges t o t he pa yr ol l pr

news l et t er .

T he s epa r a t ion b et ween a pplica t i on soft wa r e a nd a DBMS r emoves t he need f or


such r epr ogr a mmi ng. T o
i mp l ement a cha nge i n t he da t a ba ser equir ed by a singl e us er , one n
eeds t o cha nge onl y t he over a l l schema
a ndt hesubs chema soft hos euser sinvol vedi nt hec ha nge. T hesubs chema sofa llt heot
her user sr ema int h e
sa me, so t heir a pplica t ion soft wa r e, whi ch is ba sed on t he una lt er ed subs chema s,
does not need t o b e
modif i ed.
Intr oduct i on t o Com put in g

CS101

VU

P ag e
253

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 153


46. 46.

153.

Dat ab ase S yste ms: Rel atio nal D at ab as e mo de l


W e ha ve r ep ea t edl y seen how a bstr a ct ion ca n be used t o hide i nt er na l compl exit i
es. Da ta ba se ma na gement

a ll owing t he us er of t he da t a ba se t o i ma gi ne t ha t t he

i nf or ma t i on st or ed i n t he da t a ba se is arr a nged in a
mor e useful for ma t . In pa rt icula r , a DBMS cont a ins r out ines t ha t tr a nsla t e comma
nds st a t ed i n t er ms of a
conc ept ua lvi ew oft heda t a ba seint ot hea ct i onsr equ ir edbyt hea ct ua lda tast ora
gesyst em. T his
conc ept ua l
vi ew of t he da t a ba se is ca ll ed a
dat abas e mo de l.

R ela t iona l da t a base model por t r a ys da t a a s bei ng st or ed i n r ect a ngula r t a bles,


ca ll ed
re l at io ns,
whic h a r e
si mi la rt ot hefor ma t inwhi c hinf or ma t i onisdisp la yedbyspr ea dsheet pr ogr a ms. F
orexa m
p l e, t her ela t i ona l
model a l l ows i nf or ma t i on r ega r di ng t he empl oyees of a fir m t o b e r epr es ent ed b
y a r ela t ion suc h a s t ha t
shown i n F igur e 110.

Ar owi na r ela t i onisca ll eda


tup l e

-
110
, t uples cons ist of t he i nf or ma t i on a bout a pa rt icula r employee. C olu mns i n a r
ela t i on a r e r ef er r ed t o a s
att r ib utes
b eca us e ea ch ent r y i n a colu mn descr ib es some c ha r a ct er ist ic, or a t tr ibut e, of t
he ent it y
r epr es ent ed by t he c or r espondi ng t upl e.

Fi gure
110
:A
rel ati on contai ni ng empl oyee i nf ormat i on

Intr oduct i on t o Com put in g

CS101

VU
P ag e
254

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 154


47. 47.

154.

Dat ab ase S yste ms: Is sues of Re l at io nal Desig ns

Api vot a lst epindesi gni ngar ela t i ona lda t a ba seist odesignt her ela t ions ma ki ng
upt heda t a ba se.Alt hou gh
t his mi ght a ppea r t o be a simp l e t a sk, ma ny subt l et i es a r e wa it i ng t o t ra p t he
unwa r y des i gner .

S uppose t ha t i n a ddit i on t o t he i nf or ma t i on c ont a ined i n t he r ela t i on of F i gur


e 110, we wa nt t o i nc lu de
i nf or ma t ion a bout t he j obs hel
d by t he empl oy ees . We mi ght wa nt t o inc lud e a job his t or y a s s ocia t ed wit h
ea c hemp loyeet ha t consist sofsucha t tr ibut esa sjobt it le(s ecr et a r y,offi c e ma na ger ,
floor super vis or ), ajob
i dent i fi ca t ion c ode (u niqu e t o ea ch j ob), t he ski ll c ode a ssocia t ed
wit h ea c h job, t he depa r t ment i n whic h
t he j ob ex ist s, a nd t he p er iod dur i ng whic h t he empl oyee hel d t he j ob in t er ms of a
star t ing da t e a nd

posit i on
.)

Onea ppr oa cht ot hispr obl em ist o ext endt her ela t i oni nF igur e110t oinc lu det hes ea t
t r ibut esa sa ddit i ona l
colu mns i n t he t a bl e, a s shown i n F i gur e 111. Howev er , cl os e exa mi na t ion of t he
r esult r evea ls sever a l
pr oblems. One isa la ckof eff ic i enc yd
u et or edu nda nc y. T her ela t ion nol onger c ont a ins onet uplef or ea c h
emp l oyee but ra t her one t upl e for ea ch a ss ignment of an empl oyee t o a job. If a n
empl oyee ha s a dva nc e d
i nt hecompa nyt hr ou ghasequ enc eofs ever a ljobs, seve r a lt uplesi nt henewr ela t io
n must cont a i nt hesa me
i nf or ma t ion a bout t he emp loyee ( na me, a ddr ess , ident i fica t i on nu mb er , a nd S
oc ia l S ecur it y nu mb er ). F or
exa mp l e, t he p er sona l i nf or ma t ion a bout Ba ker a nd S mit h is r ep ea t ed b eca us e
t hey ha ve hel d mor e t ha n
one j ob. Mor eover , when a pa
r t icula r posit i on ha s been hel d b y nu mer ous empl oyees, t he depa r t ment
a ss ocia t ed wit h t ha t job a l ong wit h t he a ppr opr ia t e ski l l code must be r ep ea t ed
i n ea c h t upl e r epr es ent i ng
a na ssignment oft he j ob. F or exa mp l e, t he descr ipti on oft hef l oor ma na ger j ob

is duplica t edb eca us e mor e


t ha n one emp l oyee ha s hel d t his pos it i on.

Fi gure
111
: A rel ati on contai ni ng redundancy

Anot her , per ha ps mor e ser i ous, pr obl em wit h our ext ended r ela t i on sur fa ces
when

we cons i der del et i ng


i nf or ma t ion fr om t he da t a ba se. S uppose for exa mpl e t ha t Joe E. Ba ker ist he onl y
emp l oyee t o hol d t he job
i dent i fi ed a s D7. If he wer e t o l ea ve t he c ompa ny a nd be del et ed fr om t he da t a ba
se r epr es ent ed i n F igur e
111, we wou l d l os e t he
i nf or ma t ion a bout j ob D7. Aft er a ll, t he onl y t upl e c ont a ini ng t he fa ct t ha t job
D7
r equir es a skil l l evel of K2 is t he t upl e r ela t ing t o J oe B a ker .

You mi ght ar gue t ha t t he a bil it y t o er a se onl y a por t ion of a t uple c ou l d sol ve t


he pr obl em, but t his woul d

i n t ur n int r oduc e ot her comp l ica t i ons. F or inst a nc e, shoul d t he i nf or ma t i on r


ela t i ng t o job F 5 a lso be
r et a ined i n a pa r t ia l t uple, or does t his i nf or ma t i on r esi de els ewher e i n t he r
ela t i on? M or eover , t he
t empta t ion t o us e pa rt ia l t uples is a str ong i ndic
a t i on t ha t t he des i gn of t he da t a ba se ca n be i mpr oved.

Intr oduct i on t o Com put in g

CS101

VU
P ag e
255

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

T he ca us e of a l l t hes e pr ob l ems is t ha t we ha ve c omb i ned mor e t ha n one c onc ept


i n a singl e r ela t ion. As
pr opos ed, t he ext endedr ela t i oni nF igur e111cont a i nsi nf or ma t i ondea li ng dir ect l
ywit h emp l oyee
s( na me,
i dent i fi ca t ion nu mb er , a ddr ess , S ocia l S ecur it y nu mber ), inf or ma t i on a bout t
he j obs a va ila bl e i n t he
compa ny (j ob i dent if ica t i on, job t it l e, depa r t ment , ski l l code), a nd i nf or ma t
ion r ega r di ng t he r ela t i onship
bet ween emp l oyees a nd j obs (st ar t da t e
, t er mina t i on da t e). On t he ba sis of t his obs er va t ion, we ca n sol ve
our pr obl ems b y r edes i gni ng t he syst em us i ng t hr ee r ela t ions
one f or ea c h of t he pr ec edi ng ca t egor i es.
W e ca n keep t he or i gi na l r ela t i on i n F igur e 110 (whic h we now ca ll t he EMP LOYEE
r ela t
i on) a nd ins er t
t he a ddit i ona l i nf or ma t i on in t he f or m of t he t wo new r ela t i ons ca ll ed JOB a nd
AS S IGNMENT , whic h
pr oduc es t he da t a ba se in F i gur e 112

Fi gure
112
: An empl oyee dat abase consi sti ng of three rel at i ons

Intr oduct i on t o Com put in g

CS101

VU

P ag e
256

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 155


48. 48.

155.

Dat ab ase S yste ms: Rel atio nal op er ators

Now t ha t you ha ve a ba sic under st a nding of how da t a ca n be or ga ni z ed in t er ms of


t he r ela t i ona l model, it
is t i me t o s ee how i nf or ma t i on ca n b e ext r a ct ed fr om a da t a ba se cons ist i ng of r
ela t ions. W e
b egi n wit h a
l ook a t some op er a t ions t ha t we mi ght wa nt t o per f or m on r ela t ions.

At t i mes we need t o s el ect c er t a i n t upl es fr om a r ela t i on. T o r et r ieve t he i nf or


ma t i on a bout a n emp l oyee,
we must sel ect t he t upl e wit h t he a ppr opr ia t e i dent if i ca t ion a t t r ibut
e va lu e fr om t he EMP LOYEE r ela t ion,
or t o obta i n a list of t he j ob t it l es i n a c er t a in depa r t me nt , we must s el ect t he t
up l es fr om t he JOB r ela t i on
ha vi ng t ha t depa r t ment a s t heir depa r t ment a t t r ibut e. T he r esu lt of such a pr
oc ess is a not her r ela t i on
cons is
t i ng of t he t upl es s el ect ed fr om t he pa r ent r ela t i on. T he out come of s el ect i ng i
nf or ma t i on a bout a
pa rt icula r emp l oyee r esult s in a r ela t i on c ont a i ni ng onl y one t up l e fr om t he
EMP LOYEE r ela t i on. T he
out c ome of sel ect i ng t he t upl es a ss ocia t ed wit h a cer ta in

depa r t ment r esult s i n a r ela t i on t ha t pr oba bly


cont a i ns sever a l t upl es fr om t he JO B r ela t ion.

Intr oduct i on t o Com put in g


CS101

VU

P ag e
257

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 156


49. 49.

156.

Dat ab ase S yste ms: S elec t O per at io n


One op er a t ion we mi ght wa nt t o per f or m on a r ela t i on is t o sel ect t uples poss ess
i ng c er t a in
cha r a ct er ist ic s
a nd t o pla c e t hes e s el ect ed t upl es i n a new r ela t i on. T oexpr ess t his op er a t i on,
we a dopt t he synt a x

NE W <
-

S EL E CT fro m E M PL O YE E wher e E mp lI d = ' 34Y70'

T hes ema nt i csoft hisst a t ement ist ocr ea t ea newr ela t i onca l l edNEWc ont a ini ngt
hos e
t upl es(t her eshou l d
beonl yonei nt hisca s e)fr omt her ela t i onEMP LOYEEwhos eE mp lI da t t r ibut eequa ls34
Y70(F i gur e113).

Fi gure
113
: T he SEL ECT operat i on
Intr oduct i on t o Com put in g

CS101

VU

P ag e
258

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule
157
50. 50.

157.

Dat ab ase S yste ms: proj ect O per atio n

Inc ont r a st t ot heS ELEC Toper a t ion, whi c hext r a ct sr owsfr oma r ela t i on, t heP R
OJECTop er a t ion ext r a ct s
colu mns. S uppose, for exa mpl e, t ha t in sea r chi ng f or t he j ob t it l es i n a cer t a in
depa r t ment , we ha d a lr ea dy
sel ect ed t he t uples fr om t he JOB r ela t i on t ha t per t a ined t o t he t ar get depa r t
ment a nd pla c ed t hes e t upl es in
a new r ela t ion ca ll ed NEW1. T he l ist we a r e s eeki ng is t he JobT it l e c olu mn wit hi
n t his new r ela t ion. T he
P R OJECT oper a t ion a ll ows ust o ext r a ct t hi
s colu mn ( or colu mns if r equir ed) a nd pla c e t he r es u lt in a new
r ela t i on. We expr ess such a n op er a t ion a s

NE W2 <
-

PRO JE CT JobT itle fro m NE W1

T he r esult is t he cr ea t ion of a not her new r ela t i on (ca ll e d NEW2) t ha t cont a i ns t


he singl e c olu mn of va lu es
fr om t he

J obT it l e c olu mn of r ela t i on NEW1.

As a not her exa mp l e of t he P R OJEC T oper a t ion, t he st at ement


MAIL <
-

PROJE CT Name, Addr ess fro m E M PL OYE E

ca nb eusedt oobt a i na list ing oft he na mesa nda ddr ess es ofa l l emp l oyees. T hisl ist is
int he newl ycr ea t ed
(t wo
-
c olu mn) r ela t ion ca l l ed M AIL (F i gur e 114).

Fi gure
114
: T he PROJEC T operat i on

Intr oduct i on t o Com put in g

CS101

VU
P ag e
259

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 158


51. 51.

158.

Dat ab ase S yste ms: Joi n O pe ratio n

Anot her op er a t ionus edi nc onju nct i onwit hr ela t i ona lda ta basesist heJOINop er a t
ion. It isusedt oc ombi n e
diff er ent r ela t ions i nt o one r ela t i on. T he JOIN of t wo r ela t i ons pr odu c es a new r
ela t i on whos e a t t r ibut es
cons ist oft hea t t r ibut esfr omt he or i gi n
a lr ela t i ons(F i gur e115). T he na mes oft hes ea t t r ibut esa r et hesa me
a s t hos e i n t he or igi na l r ela t i ons ex c ept t ha t ea ch is pr ef ix ed by t he r ela t i on of
it s or igi n. (If r ela t i on A
cont a i ni ng a t t r ibut es V a nd W is JOIN ed wit h r ela t i on B cont a i ning a t t r ibut e
s X, Y, a nd Z, t hen t he r esu lt
ha sfivea t t r ibut esna medA. V, A. W, B. X,B. Y, a ndB. Z. )T hisna mi ngc onvent i onensur
est ha tt hea t tr ibut es
i n t he new r ela t i on ha ve u niqu e na mes, even t hou gh t he or i gi na l r ela t i ons mi ght
ha ve a t t r ibute na mes i n
com mon. T het u
pl es (r ows) oft he newr ela t i ona r epr oduc edbyc onca t ena t i ngt upl esfr omt het woor i
gi na l
r ela t i ons (s ee a ga i n F i gur e 115). Whi c h t upl es a r e a ctua ll y j oi ned t o f or m t upl
es i n t he new r ela t i on i s
det er mi ned b y t he condit i on u nder whic h t he JOIN is
const r uc
t ed?

One suc h condit i on is t ha t des i gna t ed


a t tr ibut es ha ve t he sa me va lu e. T his, in fa ct , is t he ca se r epr es ent ed i n F igur e
115, wher e we demonst r a t e
t he r esu lt of ex ecut i ng t he st a t ement

C<
-

JOI N A and B wher e A. W =B .X

Int hisexa mpl e, a t uplefr om


r ela t i onAs houl db ec onca t ena t edwit ha t upl efr omr ela t i onBi nexa ct l yt hos e
ca ses wher e t he a t t r ibut es W a nd X in t he t wo t upl es a r e equa l. T hus t he c onca t
ena t i on of t he t upl e (r , 2)
fr om r ela t i on A wit h t he t upl e (2, m, q) fr om r ela t i on B a ppea r s in t
he r esu lt beca use t he va lu e of a tt r ibut e
W i n t he fir st equa ls t he va lu e of a t t r ibut e X i n t he s ec ond. On t he ot her ha nd, t
he r esult of c onca t ena t in g
t he t upl e (r , 2) fr om r ela t i on A wit h t he t upl e (5, g, p) fr om r ela t i on B does not a
ppea r in t he fi na l r el
a t i on
beca use t hes e t uples do not sha r e c ommon va lu es in a t t r ibutes W a nd X.

Fi gure
115
: T he Joi n Operat i on

As a not her exa mp l e, F i gur e 116 r epr es ent s t he r esult of ex ecut i ng t he st a t


ement

Intr oduct i on t o Com put in g

CS101

VU

P ag e
260

of
3 81
C opy rig htVi rtual U ni v ersi ty ofP aki stan

C<
-

JO IN A
and B wher e A. W <B .X

Not e t ha t t he t upl es i n t he r esu lt ar e exa ct l y t hos e i n whic h a t t r ibut e W in r ela


t ion

A is l ess t ha n a t tr ibut e X in r ela t i on B.

Let us now s ee how t he JOIN op er a t i on ca n b e us ed wi t h t he da t a base of F i gur e


112 t o obt a in a list i ng of
a ll emp l oyee i dent if ica t i on nu mb er s a long wit h t he de pa rt ment i n whic h ea ch
emp l oyee wor ks. Our fir st
obs er va t i on is t ha t t he i nf or ma t i on r equ ir ed is dist r ibut ed over mor e t ha n one r
ela t i on, a nd t hus t he pr oc ess
of r et r i evi ng t he i nf or ma t i on must ent a il mo
r e t ha n S ELEC T ions a nd P R OJECT ions. In fa ct , t he t ool w e
need is t he st a t ement

NE W1 <
-
JO IN ASS IG NME NT and JO B

w her e AS S IG NME NT . JobId = JOB . JobId


Fi gure
116
: Another exampl e of t he JOIN operati on

th
a t pr odu c es t he r ela t i on NEW1, a s shown i n F i gur e 117. Fr om t his r ela t ion, our
pr obl em ca n b e sol ved

mp lI d a nd JOB. Dept . In shor t , t he


i nf or ma t ion we need ca n b e obt a i ned fr om t he da t a ba se in F i gur e 112 by ex ecut i
ng t he s equ enc e

NE W1 <
-
JO IN ASS IG NME NT and JO B

w her e AS S IG NME NT . JobId = JOB . JobId

NE W2 <
-

S EL E CT fro m NE W1 w her e AS S IG NMENT . T er mD ate = ' *'

L IST

<
-

PRO JE CT ASS IG NME NT .E mp lId, JO B. Dept fro m NE W2


Intr oduct i on t o Com put in g

CS101

VU

P ag e
261

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Fi gure
117
: An appl i cat i on of t he JOIN operat i on
Intr oduct i on t o Com put in g

CS101

VU

P ag e
262

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 159


52. 52.

159.

Dat ab ase S yste ms: O bjec t


O rie nte d Dat ab ases

Anot her da t a ba semodelisba sedont heob j ect


-
or i ent edpa ra digm. T hisa ppr oa chl ea dst oa nobj ect
-
or i ent e d
da t a base cons ist i ng of obj ect s t ha t a r e li nked t o ea c h ot her t o r efl ect t heir r ela
t ions hips. F or exa mp l e, a n
ob j ect
-
or i ent ed i mp l
ement a t i on of t he emp l oyee da t a base fr om t he pr evi ous sect i on c oul d c ons ist of t
hr ee
cla ss es (t yp es of ob j ect s) : E mp l oyee, Job, a nd Ass i gnment . An ob j ect fr om t he E
mp l oyee c la ss coul d
cont a i n such ent r i es a s Empl I d, Na me, Addr ess , a nd SS Num; a n obj ect fr om

t he cla ss Job coul d c ont a i n


such ent r i es a s JobId, JobT it l e, S ki llC ode, a nd D ept ; a nd ea c h ob j ect fr om t he c
la ss Ass i gnment c ou l d
cont a i n ent r i es such a s St ar t Da t e a nd T er mDa t e.

Ac onc ept ua lr epr es ent a t i onofsucha da t a ba seisshowni nF i gur e118wher et


hel i nksb et weent he va r ious
ob j ect s a r e r epr es ent ed b y l i nes c onnect i ng t he r ela t ed ob j ect s. If we focus on a
n obj ect of t yp e E mp l oyee,
we f i nd it l i nked t o a col l ect i on of obj ect s of t yp e Ass i gnment r epr es ent i ng t he
va r ious a ss ignment s t ha t
t ha t par t icul
a r emp l oyee ha s held. In t ur n, ea ch of t hese ob j ect s of t ype Ass i gnment is li nked t o
a n obj ect
of t yp e J ob r epr es ent i ng t he j ob a ss ocia t ed wit h t ha t a ssi gnment .
T hus,

a ll t he a s s ign ment s of a n emp l oy e e


ca nbefou ndbyfollowi ngt hel i nksfr omt heobject r epres ent i ngt ha t employee. S i mi la r
ly, a llt heemp l oyees
who ha ve hel d a par t icula r job ca n be fou nd by f ol lowi ng t he l i nks fr om t he ob j ect
r epr es ent i ng t ha t job.

Fi gure
118
: T he associ at i ons bet ween obj ect s i n an object
-
ori ent ed dat abase

T he l i nks bet ween obj ect s in a n obj ect


-
or i ent ed
da t a ba se ar e nor ma ll y ma i nt a i ned by t he DBMS , so t he
det a i ls of how t hes e li nks a r e i mp l ement ed a r e not a conc er n of t he pr ogr a
mmer wr it i ng a ppli ca t ion
soft wa r e. Inst ea d, whena newob j ect isa ddedt ot he da t a base, t hea pplica t i onsoft wa
r e mer el yspec if i
est h e
ot her obj ect s t o whi c h it shou ld b e li nked. T he DB MS t hen cr ea t es a ny li nka ge
syst em t ha t mi ght be
r equir ed t o r ecor d t hes e a ss ocia t i ons. In pa rt icula r , a DBMS mi ght li nk t he obj ect
s r epr es ent i ng t h e
a ss ignment s of a given emp l oyee in a ma nner si mi l
a r t o a li nked l ist .

Anot her t a sk of a n ob j ect


-
or i ent ed DBMS is t o pr ovi de per ma nent st or a ge f or t he obj ect s ent r ust ed t o it

a r equir ement t ha t mi ght seem ob vious but is i nher ent ly dist i nct fr om t he ma
nner i n whi c h ob j ect s ar e
nor ma l ly t r ea t ed. Nor ma l l y, w
hen a n ob j ect
-
or i ent ed p r ogr a m is ex ecut ed, t he object s cr ea t ed dur ing t h e

Intr oduct i on t o Com put in g

CS101

VU

P ag e
263

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

t ra nsi ent . But obj ect s t ha t ar e cr ea t ed a nd a dded t o a dat a ba se must be sa ved

a ft er t he pr ogr a m t ha t cr ea t ed
t hem t er mi na t es. S uch ob j ect s a r e sa id t o b e
p ers iste n t.
T hus ,

cr ea t ing p er sist ent ob j ect s is a signif ica nt


depa r t ur e fr om t he nor m.

P r oponent s of ob j ect
-
or i ent ed da t a ba ses off er nu mer ous a r gument s t o show why t he obj ect
-
or i ent ed
a ppr oa ch t o da t a ba se desi gn is bet t er t ha n t he r ela t iona l a ppr oa ch. One is t ha t
t he obj ect
-
or i ent ed a ppr oa ch
a ll ows t he ent ir e soft wa r e sys
-

t em (a pplica t i on s
oft wa re, DBMS ,a nd t he da t a ba se it sel f) t o be des igned i n
t he sa me pa r a digm. T his is in c ont r a st t o t he hist or ica ll y c ommon pr a ct ic e of usi
ng a n i mp er a t i ve
pr ogr a mmi ng la ngua ge t o devel op a ppl ica t i on soft wa r e for int er r oga t i ng a r ela
t i ona l da t a ba se. Inher e
nt i n
such a t a sk is t he cla sh b et ween i mp er a t i ve a nd r ela t i ona l par a digms. T his dist
inct i on is subt l e a t our l evel
of
st udy,

but t he di ff er enc e ha s been t he s our c e of ma ny soft wa r e er r or s over t he yea r s.


Even a t our level,
weca na ppr ec ia t et ha t a nobj ect
-
or i ent edda t a ba secomb i nedwit ha nobj ect ed
-
or i ent eda ppli ca t ionpr ogr a m
pr oduc es a homogeneous i ma ge of obj ect s com muni ca t i ng wit h ea ch ot her t hr ou
ghout t he s yst em. On t he
ot her ha nd, a r ela t i ona l da t a ba se c omb i ned wit h a n i m per a t ive a ppl ica t i on
pr ogr a m
con jur es a n i ma ge of
t wo inher ent l y di ff er ent or ga niza t i ons tr yi ng t o fi nd a common i nt er fa ce. T o a
ppr ec ia t e a not her a dva nt a g e
t ha t obj ect
-
or i ent ed da t a ba ses ha ve over t heir r ela t iona l c ou nt er pa rt s, cons i der t he pr obl
em of st or i n g
emp l oyee na mes i n a r ela t
i ona l da t a ba se. If a n ent ir e na me is st or ed a s a singl e a t tr ibut e in a r ela t i on, t he
n
i nquir i es r ega r di ng onl y sur na mes a r e a wkwa r d. However , if t he na me is st or ed
a s indi vidua l a t t r ibut es,
such a s fir st na me, mi ddl e na me, a nd sur na me, t hen t he nu mb er of a
t tr ibut es bec omes pr obl ema t i c beca us e
not a ll na mes c on
-

for m t o a spec if ic st r uct ur e

even when t he p opula t i on is r est r ict ed t o a singl e cu lt ur e.


Ina nobj ect
-

na me i n a va r iet y of f or ma t s. T hus, fr om out si de t hes e obj ect s, it woul d b e just


a s ea sy t o dea l wit h onl y
sur na mes a s wit h ent ir e na mes, ma i den na
mes, or ni c kna mes. T he det a i ls i nvol ved wit h ea c h p er spect i ve
wou l d b e enca psula t ed wit hi n t he ob j ect s. T his a bil it y t o enca psula t e t he t ec
hnica l it i es of di ff er ent da t a
for ma t s is a dva nt a geous i n ot her ca ses a s wel l. In a r el a t iona l da t a ba se, t he a t
tr ibut e
s i n a r ela t ion a r e pa rt
of t he over a ll desi gn of t he da t a ba se, a nd t hus t he t yp es a ss ocia t ed wit h t hes e a t
tr ibut es per mea t e t he ent ir e
DBMS . (Va r ia bles for t emp or ar y st or a ge must be dec l a r ed t o b e t he a ppr opr ia t
e t yp e, a nd funct i ons for
ma nipula t i ng da t a
of t he va r ious t yp es must b e des i gned. ) T hus, ext endi ng a r ela t iona l da t a ba se t o
i nc lu d e
a t tr ibut esofnewt yp es(a udi oa ndvi deo)ca nbepr obl ema t i c. Inpar t icula r ,a var iet
yoffu nct ionst hr ou ghout
t he da t a ba se des i gn mi ght need t o b e expa nded t o i nc or po
r at e t hes e new da t a t ypes. In a n object
-
or i ent e d

usedt or et r i evea nobj ect r epr es ent i nga mot i onpi ct ur ebeca uset hedist i nct i onsint
yp eca nb ehi ddenw
it hi n
t he obj ect s i nvol ved.
T hus,

t he ob j ect
-
or i ent ed a ppr oa ch a ppea r s t o be mor e c ompa t ibl e wit h t h e
const r uct i on of mu lt i media da t a ba ses

a fea t ur e t ha t isa lr ea dy pr ovi ng t o b e a gr ea t a dva nt a ge.

S t ill a not her a dva nt a ge t he obj ect


-
or i ent ed pa ra digm off er
s t o da ta ba se desi gn is t he pot ent ia l for st or ing
i nt el l i gent ob j ect s r a t her t ha n mer el y da t a .T ha t is, a n object ca n c ont a i n met
hods descr ib i ng how it shou l d
r espond t o mess a ges r ega r di ng it s cont ent s a nd r ela t ions hips. F or exa mp l e, ea
ch obj ect of t he c la
ss
E mpl oyee i n F i gur e 118 c oul d c ont a i n met hods for r ep or t i ng a nd up da t ing t he i
nf or ma t i on i n t he ob j ect a s
r omt heJobc la ss coul dha vea met hodf or r epor t ingt h e
spec if ics of t he j ob a nd p er ha ps a met hod f or r epor t i ng t hos e emp l oyees who ha
ve hel d t ha t par t icula r job.
T hus,

t ion. Inst ea d,
we c ou l d mer ely a sk t he a ppr opr ia t e emp l oyee obj ect t o r epor t it s job hist or y. T
his a bil it y t o const r uct
da t a bases whos e c omp onent s r espond i nt el l i gent l y t o inqu ir i es off er s a n ex cit i
ng a rr a y of poss ib i lit i es
beyond t hos e of mor e t r a dit i ona l

r ela t i ona l da t a bases.

Intr oduct i on t o Com put in g

CS101

VU
P ag e
264

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 160


53. 53.

160.

Dat ab ase S yste ms: Mai nt ai ni ng DB Int egr ity

Inexp ens i ve da t a ba se ma na gement syst ems f or per sona l use a r e r ela t ivel y s i mp
l e s yst ems. T hey t end t o
ha ve a si ngl e ob j ect i ve

t o shi el d t he us er fr om t he t ec hnica l det a ils of


t he da t a ba se i mp l ement a t ion. T he
da t a bases ma i nt a i ned b y t hes e s yst ems a r e r ela t i vel y sma ll a nd gener a l l y c ont
a i n i nfor ma t i on whos e l oss
or cor r upt ionwou l db ei nc onveni ent r a t her t ha ndisa st r ous. Whena pr obl emdoesa r
ise, t heus er ca nusua lly
cor r ect t he

er r oneous it ems dir ect ly or r el oa d t he da t a ba se fr om a ba ckup cop y a nd ma nua l


ly ma ke t he
modif i ca t ions r equir ed t o br ing t ha t copy up t o da t e. This pr ocess mi ght be i nc
onveni ent , but t he c ost of
a voidingt hei nc onvenienc et endst ob egr ea t er t ha nt hei nc o
nvenienc eit self. I na nyca s e, t heinc onvenienc e
is r est r ict ed t o onl y a few p eop l e, a nd a ny fi na ncia l l oss is gener a ll y l i mit ed.

In t he ca se of la r ge, mu lt ius er , commer c ia l da t a ba se syst ems, however , t he st a


kes a r e muc h higher . T he
cost of i nc or r ect or l o
st da t a ca n be enor mous a nd ca n ha ve deva st a t ing c ons equ enc es. In t hes e

pr obl ems such a s op er a t ions t ha t for some r ea son a r e onl y pa r t ia lly c ompl et ed
or diff
er ent op er a t ions t ha t
mi ght i nt er a ct ina dver t ent l y t o ca use ina ccur a t e i nf or ma t ion i n t he da t a ba se.

Intr oduct i on t o Com put in g

CS101

VU
P ag e
265

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 161


54. 54.

161.

Dat ab ase S yste ms: T he Co mmi t/ Ro l lb ac k Protoco l

A si ngl e t r a nsa ct ion, such a st he t ra nsf er of funds fr om one ba nk a ccou nt t o a not


her , t he
ca nc el la t ion of a n
a ir li ner es er va t i on, or t her egist r a t ion ofa st udent i na uni ver sit yc our se, mi ght i
nvolve mult ip l est epsa t t he
da t a base l evel. F or exa mp l e, a tr a nsfer of funds bet we en ba nk a ccou nt s r equ ir es
t ha t t he ba la nc e i n one
a ccou nt b e decr emen
t ed a nd t he ba la nc e i n t he ot her be i ncr ement ed. B et ween suc h st eps t he i nf or
ma t i on
i nt heda t a basemi ght bei nc onsist ent . Indeed, fu ndsa r emiss i ngdur i ngt hebr i efp er i
oda ft er t hef ir st a ccou nt
ha sbeendecr ement edbut bef or et heot her ha sbeeni ncr emen

sea t on a flight , t her e mi ght be a n inst a nt when t he pa ssenger ha s no sea t or a n


inst a nt when t he pa ssenger
list a ppea r s t o be one pa ss enger gr ea t er t ha n it a ct ua lly is.

In t he ca s e of la r ge da t a ba ses t ha t ar e
subj ect t o hea vy tr a nsa ct ion l oa ds, it is hi ghl y l i kel y t ha t a r a ndom
sna pshot wi ll f i nd t he da t a ba se i n t he mi ddl e of s ome t r a nsa ct ion. A r equ est f or
t he ex ecut i on of a
t ra nsa ct ion or a n equ ip ment ma lfu nct i on wi l l t her efor e li kel y oc cur a t a t i me
when t he

da t a base is i n a n
i nc onsist ent st a t e.

Let us fir st consi der t he pr ob l em of a ma lfu nct i on. T he goa l of t he D BMS is t o


ensur e t ha t such a pr obl e m
wi ll not fr eez e t he da t a ba se i n a n i nc ons ist ent st a t e. T his is oft en a ccomp lis hed
b y ma i nt a i ning a l og
cont a i ni

B ef or e a t ra nsa ct ion is a l l owed t o a lt er t he da t a ba se, t he a lt er a t ion t o b e p er


for med is f ir st r ec or ded i n t h e
l og. T hus t he l og cont a i ns a per ma nent r ec

T he point a t whic h a ll t he st eps i n a t ra nsa ct ion ha ve b een r ec or ded i n t he l og is


ca ll ed t he
co mmi t point.
It isat t hispoi nt t ha t t heDBMS ha st he i nf or ma t ionit needst or ec onst r uct t het r a nsa
ct ion onit sownift ha t
shoul d b ec ome nec ess a r y. At t his poi nt t he DBMS becomes commi t t ed t o t he t ra
nsa ct ion i n t he sens e t ha t

In t he ca se of a n equ ip ment ma lfu nct i o


n, t he DBMS ca n use t he i nf or ma t i on i n it s log t o r econst r uct t he
t ra nsa ct ions t ha t ha ve b een c omp l et ed (c om mit t ed) si nc e t he la st ba ckup wa s
ma de.

Ifpr oblemss houlda r is eb ef or ea t ra nsa ct ionha sr ea chedit scommit p oint , t heDBMS


mi ght fi ndit s elfwit h
a par t ia lly ex ecut ed t ra nsa ct ion t ha t ca nnot be c omp l et ed. In t his ca se t he l og ca
n be used t o
roll b ac k
(undo) t he a ct i vit i es a ct ua ll y p er for med b y t he t r a nsa cti on. In t he ca se of a ma
lfu nct i on, for i nst a nc e, t h e
DBMS coul d r ec over by r ol li ng ba ck t hos e t
r a nsa ct ions t ha t wer e inc omp l et e ( non
-
c ommi t t ed) a t t he t i m e
of t he ma lfu nct i on.

R ol lba cks of t r a nsa ct ions a r e not r est r ict ed, howeve r , t o t he pr oc ess of r ecover
i ng fr om equip ment

e, a tr a nsa ct ion mi ght be


t er mi na t edb ef or eit ha scomp l et eda l lit sst epsb eca use ofa na t t empt t oa cc ess pr i
vi l egedi nf or ma t i on, or it
mi ght be i nvolved in a dea dl oc k i n whic h c omp et i ng t r a nsa ct ions fi nd t hems el
ves wa it i ng f or da ta bei ng
used b y ea ch ot h
er . In t hes e ca s es , t he DBM S ca n us e t he log t o r oll ba c k a t ra ns a ct ion a nd t hus
a vo i d a n
er r oneous da t a ba se du e t o i nc ompl et e t r a nsa ct ions.

T o emp ha siz e t he deli ca t e na t ur e of DBMS des i gn, we shoul d not e t ha t t her e a r e


subt le pr obl ems lur ki ng
wit hint her ol lba ckpr oc ess. T her ol l ingba ckofonet ra nsa ct ionmi ght a ffect da t a ba
seent r i est ha tha vebee n
used by ot her t ra nsa ct ions. F or exa mp l e, t h
e t r a nsa ct ion b ei ng r ol l ed ba ck mi ght ha ve up da t ed a n a ccou nt
ba la nc e, a nd a not her tr a nsa ct ion mi ght ha ve a lr ea dy based it s a ct ivit i es on t his
upda t ed va lu e. T his mi ght
mea n t ha t t hes e a ddit i ona l t ra nsa ct ions must a lso be r oll ed ba ck, whic h might a
dver s el y

a ffect st ill ot her


t ra nsa ct ions. T he r esu lt is t he pr obl em known a s
casc adi ng rol lb ac k.

Intr oduct i on t o Com put in g

CS101

VU
P ag e
266

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 162


55. 55.

162.

Dat ab ase S yste ms: L oc ki ng

W e now cons i der t he pr obl em of a tr a nsa ct ion b ei ng ex ecut ed whil e t he da t a base


is in a sta t e of flux fr om
a not her t ra nsa ct ion, a sit uat iont ha t ca nl ea dt oi na dver t ent i nt er a ct ionb et weent
het r a nsa ct ionsa ndpr oduc e
er r oneous r esult s. F or inst a nc e, t he pr
obl em known a s t he
i ncorr ect s ummary prob le m
ca n a r ise if on e
t ra nsa ct ionisi nt hemi ddl eoft r a nsf er r ingfu ndsfr omonea cc ou nt t oa not her whena
not her t r a nsa ct iont r i es
t o comput e t he t ot a l dep osit s i n t he ba nk. T his cou l d r esu lt i n a t ot a l t ha t is eit
her t oo la r ge or t oo s ma l l
dep endi ng on t he or
der i n whic h t he t r a nsfer st eps ar e per f or med. Anot her poss ib il it y is known a s t
he
lost
upd ate pro b le m,
whic h is ex emp l if i ed by t wo t r a nsact i ons, ea ch of whic h ma kes a dedu ct i on fr om
t he

a t t he poi nt when t he ot her ha s just


r ea dt heba la nc ebut ha snot yet ca lcula t edt henewba la nc e, t henbot ht r a nsa ct ionswi
l lba set heir deduct ions
on t he sa me i nit ia l ba la nc e. In t ur n, t he ef f ect of one of t he deduct i ons wi l l not be
r efl ect ed i n t he da t a b
a se.

T o sol ve su ch pr obl ems, a DBMS coul d f or c e t r a nsa ct i ons t o ex ecut e i n t heir ent
ir et y on a one
-
at
-
a
-
t i me
ba sisbyhol di ng ea c hnewt r a nsa ct ion i na qu eu eunt i lt hos epr ec eding it ha ve c omp l
et ed. But a t ra nsa ct ion
oft en spends a lot of t i me wa it i ng for
ma ss st ora ge oper a t ions t o be p er for med. By i nt er
-

wea ving t he
ex ecut i on of t r a nsa ct ions, t he t i me dur i ng whi c h one t r a nsa ct ion is wa it ing ca n
be us ed b y a not her
t ra nsa ct ion t o pr oc ess da t a it ha s a lr ea dy r et r i eved. Most la r ge da t a ba se ma
na gement syst ems t
her ef or e
cont a i n a schedu l er t o c oor di na t e t i me
-
sha r i ng a mong t r a nsa ct ions i n mu c h t he sa me wa y t ha t a
mult ipr ogr a mmi ng op er a t ing syst em c oor di na t es i nt er wea vi ng of pr oc ess es.

T o gua r d a ga inst such a noma l i es a s t he i nc or r ect summa r y pr obl em a nd t he l


ost up
da t e pr obl em, t hes e
schedu l er s i nc or por a t e a
locki ng p rotoco l
i n whic h t he it ems wit hi n a da ta ba s e t ha t ar e curr ent l y b ein g
used by some t r a nsa ct ion a r e ma r ked a s such. T hes e ma r ks a r e ca ll ed locks; ma r
ked it ems a r e sa id t o be
l oc ked. T wo t yp es of loc ks ar
e common

s har ed loc k s
a nd
excl us ive loc ks.
T hey cor r esp ond t o t he t wo
t yp esofa cc ess t oda t a t ha ta t ra nsa ct ionmi ght r equir e

sha r eda cc ess a ndex clus i vea cc ess . Ifa t ra nsa ct ion
is not goi ng t o a lt er a da t a it em, t hen it r equir es sha r ed a cc ess , mea ning t
ha t ot her t ra nsa ct ions a r e a lso
a ll owed t o vi ew t he da t a. However , if t he t r a nsa ct ion is goi ng t o a lt er t he it em,
it must ha ve exc lus i ve
a ccess , mea ni ng t ha t it must be t he only t r a nsa ct ion wit h a cc ess t o t ha t da ta .

In a loc ki ng pr ot oc ol, ea ch t i me a tr a ns
a ct ion r equ est s acc ess t o a da ta it em, it must a lso t ell t he DBMS t he
t yp eofa ccess it r equ ir es. Ifa tr a nsa ct ionr equ est ssha r eda cc ess t oa nit emt ha t iseit
her unl oc ked or loc ke d
wit h a shar ed l oc k, t ha t a ccess is
gra nt ed,

a nd t he it em is ma r ked wit h a

sha r ed loc k. If, however , t he


r equ est ed it em is a lr ea dy ma r ked wit h a n ex clus i ve l ock, t he a ddit i ona l a ccess is
deni ed. If a t ra nsa ct ion
r equ est s exc lusi ve a cc ess t o a n it em, t ha t r equ est is gr ant ed only if t he it em ha s
no l oc k a ss ocia t ed wit h it .
Int his

ma nner , a t ra nsa ct iont ha t isgoi ngt oa lt er da ta prot ect st ha t da ta fr omot her t ra nsa
ct ionsbyobt a ini ng
ex clus i ve a cc ess , wher ea s sever a l t r a nsa ct ions ca n s ha r e a cc ess t o a n it em if
none of t hem a r e going t o
cha nge it . Of cour s e, onc e a t r a nsa ct ion is f
i nis hed wit h a n it em, it not if i es t he D BM S , a nd t he a s s oc ia t e d
l oc k is r emoved.

a lgor it hm is t ha t t he t ra nsa ct ion is mer el y for c ed t o wa it unt i l t he r eq


u est ed it em b ec omes a va ila bl e. T his
a ppr oa ch, however , ca n l ea d t o dea dl oc k, si nc e t wo t r ansa ct i ons t ha t r equ ir e
exc lusi ve a cc ess t o t he sa m e

t hen i ns
ist s on wa it i ng f or t he ot her . T o a voi d such dea d
-

l ocks, some da t a ba se ma na gement syst ems gi v e


pr ior it y t o ol der tr a nsa ct ions. T ha t is, if a n older t ra nsact i on r equ ir es a cc ess t o
a n it em t ha t is loc ked by a
you nger tr a nsa ct ion, t he you nger t ra nsa ct ion is
for c ed t o r el ea s e a ll of it s da t a it ems, a nd it s a ct ivit i es a r e
r ol l ed ba ck (ba sed on t he log). T hen, t he ol der t r a nsa cti on is gi ven a cc ess t o t he
it em it r equ ir ed, a nd t he
you nger t ra nsa ct ion is f or c ed t o st a r t a ga in. If a you nger t r a nsa ct ion is r ep ea t
edl
y pr eempt ed, it wil l gr ow
older in t he pr oc ess a nd ult i ma t el y b ec ome one of t he older t ra nsa ct ions wit h high
pr ior it y. T his pr ot oc ol,

Intr oduct i on t o Com put in g

CS101

VU

P ag e
267

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

known a s t he
wo und
-
w ait proto col
( ol d t ra nsa ct ions wou nd you ng t r a nsa ct ions, you ng t ra nsa ct ions wa it
for old ones), ensur e
s t ha t ever y t r a nsa ct ion wil l ult i ma t el y be a l l owed t o c omp l et e it s t a sk.

Intr oduct i on t o Com put in g

CS101

VU
P ag e
268

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 163


56. 56.

163.

Dat ab ase S yste ms: S eq ue nt i al Fil es

A
se q ue nt i al fi le
is a fil e t ha t is a cc ess ed i n a ser ia l ma nner fr om it s begi nni ng t o it s end a s t hou
gh t h e
i nf or ma t ion i n t he f il e
wer e a rr a nged in one l ong r ow. Exa mp l es i nc lu de a udi o f il es, vi deo f il es, f i l es
cont a i ni ng pr ogr a ms, a nd fil es cont a i ni ng t ext ua l docu ment s. In fa ct , most of t
he f il es cr ea t ed by a t ypica l
per sona l c omput er user ar e sequ ent ia l f i l es. F or inst a nc e, when a s
pr ea ds heet is sa ved, it s inf or ma t ion i s
enc odeda ndst or eda sasequ ent ia lfi l efr om whi c ht hes pr ea ds heet a pplica t i onsoft
wa r eca nr ec onst r uct t he
spr ea dsheet .

T ext fi l es, whic h a r e s equ ent ia l f il es i n whic h ea c h l ogi ca l r ec or d is a singl e s


ymb ol enc oded
usi ng AS C II
or Uni c ode, oft ens er vea sa ba sict oolfor c onst r uct i ngmor e ela bor a t esequ ent ia lf il
essuc ha sa nemp l oye e
r ec or ds fi l e. One onl y needs t o est a blis h a unif or m for ma t for r epr es ent i ng t he i
nf or ma t i on a bout ea c h
emp l oyee a s a str ing of t ext , en
c ode t he i nf or ma t i on a ccor di ng t o t ha t for ma t , a nd t hen r ec or d t he r esult in g
emp l oyee r ec or ds one a ft er a not her a s one singl e st r ing of t ext . F or exa mp l e, one
c ou l d const r uct a simp l e
emp l oyee f i l e by a gr eei ng t o ent er ea c h empl oyee r ec or d a s a st r ing of 3
1 cha r a ct er s, cons ist i ng of a fi el d
of 25 cha r a ct er s cont a in
-

-
c ha r a ct er

wou l
d be a l ong st r ing of enc oded c ha r a ct er s in whi ch ea c h 31
-
c ha r a ct er bloc k r epr es ent s t he i nf or ma t i on
a bout a singl e emp l oyee (F i gur e 119). Infor ma t i on wou ld b e r et r i eved fr om t he f
i l e i n t er ms of l ogica l
r ec or ds c onsist ing of 31
-
c ha r a ct er bloc ks. Wit hin ea
c h of t hes e b l oc ks, i ndi vi dua l fi el ds wou l d be i dent i
-

fi ed a cc or ding t o t he unif or m f or ma t wit h whic h t he b l oc ks wer e c onst r uct ed.

Fi gure
119
: The st ruct ure of a si mpl e empl oyee f il e i mpl ement ed as a t ext fi l e

T he da t a in a sequ ent ia l fi l e must be r ec or ded i n ma ss st or a ge i n suc h a wa y t ha


t t he sequ ent ia l na t ur e of
t hefi l eispr es er ved. Ift he ma ss st or a gesyst emisit s elfsequ ent ia l(a sint he
ca seofa ma gnet i ct a peorC D),
t his is a stra ight f or wa r d under t a ki ng. We need mer el y r ec or d t he fi l e on t he st or
a ge mediu m a ccor di ng t o
t he s equ ent ia l pr op er t i es of t he mediu m. T hen pr oc essing t he f il e is t he t a sk of
mer el y r ea ding a nd
pr oc ess i ng t he f i l e

pla yi ng a udio C Ds, wher e t he musi c is st or ed a s a sequ ent ia l fi l e sect or by sect or


a long one c ont i nu ous
spir a ling t r a ck.

In t he ca se of ma gnet i c disk st or a ge, however


, t he fi l e wou l d be sca t t er ed over di ff er ent sect or s t ha t coul d
be r et r i eved i n a va r iet y of or der s. T o pr eser ve t he pr oper or der , most op er a t
ing syst ems ( mor e pr ec is el y,
t hef i l e ma na ger ) ma i nt a ina l ist oft hes ect or son whicht hef i l e isst or ed. T his l i
st isr ec or deda spa rt oft h e
Intr oduct i on t o Com put in g

CS101

VU

P ag e
269

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

t hesect or sint hepr op er sequ enc ea st hou ght hefi l ewer est or eds equ ent ia l l y, event
hou ght hefi l eisa ct ua ll y
di
st r ibut ed over va r i ous por t ions of t he dis k.
Inher ent i npr ocess i ngasequ ent ia lfi l eist he needt odet ect whent he end oft hefi l eisr ea
ched. G ener ica l l y,
we r ef er t o t he end of a sequ ent ia l fi l e a s t he
e nd
-
of
-
fil e (E O F).
T her e a r e a var i et y of wa ys of
i dent if yi ng
t he EOF . One is t o pla ce a spec ia l r ec or d, ca ll ed a
senti ne l,
a t t he end of t he fi l e. Anot her is t o use t he

syst em knows whic h sect or s

cont a i n t he fi l e, it a lso knows wher e t he fil e t er mi na t es. A cla ss ic exa mp l e


i nvol vi ng sequ ent ia l fi l es is pa yr oll pr oc ess i ng i n a sma ll c ompa ny. Her e we i ma
gi ne a sequ ent ia l f i l e
cons ist
-

i ng of a ser i es of l ogica l r ec or ds, ea c h of whic h cont a ins t he i nf

(na me, emp l oyee i dent if ica t i on nu mb er , pa y sca le, a nd so on) fr om whi ch c hecks
must be pr int ed on a

chec k pr odu c ed.


Intr oduct i on t o Com put in g

CS101

VU

P ag e
270

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 164


57. 57.

164.
Dat ab ase S yste ms: I nde xed Fi les

st or ed. However , suchfil esa r ei neff i ci ent whenr ec or dswit hi nt hef il emust b er et r
ievedin
a nunpr edi ct a bl e
or der . Insuc hsit ua t i onswha t isneededisa wa yt oi dent i fyt hel oca t i onoft hedes ir edl
ogica lr ec or dqui c kl y.
A p opula r solut i on is t o us e a n i ndex f or t he f i l e i n mu ch t he sa me wa y t ha t a n i
ndex i n a book is us ed t o
l oca t e t op ics wit h
i n t he b ook. S uch a fil e s yst em is ca l l ed a n i ndex ed f i l e.

Ani ndexfor afil econt a i nsalist oft hekeysst or edint hefi l ea l ong wit hent r i esi ndi ca t i
ng wher et her ecor d
cont a i ni ng ea ch key is st or ed. T hus t o find a pa rt icula r r ec or d, one f i nds t he i den
t if yi ng key i n t he i ndex
a nd t hen r et r i eves t he bl ock of i nf or ma t i on st or ed a t t he loca t i on a ss oc ia t ed
wit h t ha t key.

i ndex is usua l l y t r a nsfer r ed

t o ma i n me mor y b ef or e f i l e pr oc ess i ng b egi ns so t ha t it is ea si ly a cc ess ib l e


when a cc ess t o r ec or ds i n t he f i l e is r equ ir ed (F i gur e 120).

A cla ss ic exa mpl e of a n index ed fi l e oc cur s in t he cont ext of ma i nt a i ni ng emp l


oyee r ec or ds. Her e a n index
ca n be used

t o a void l engt hy sea r ches when you a r e r et ri evi ng a n indi vi dua l r ec or d. In par t
icula r , ift he fil e
b er is kno wn. Anot her exa mpl e is foun dona udi o
C Ds wher e a n i ndex is used t o a l l ow r ela t ivel y qui ck a c c ess t o i ndi vi dua l r ec or
di ngs.

Fi gure
120
: Openi ng an i ndexed f il e

Over t he yea r s
nu mer ous va r ia t ionsoft heba sic i ndexc onc ept ha veb eenus ed. Oneva r ia t ion c onst r
uct sa n
i ndex i n a hi er ar chi ca l ma nner so t ha t t he i ndex t a kes on a la yer ed or tr ee st r
uct ur e. A pr omi nent exa mp l e
is t he hi er a r chica l dir ect or y syst em us ed b y most op er a t in
g syst ems for or ga niz i ng f i l e st or a ge. I n suc h a
ca se, t he dir ect or i es, or fol der s, pla yt her ol e of i ndex es, ea c hc ont a i ni ng li nkst oit
ssub
-
i ndex es. F r omt his
per sp ect i ve, t he ent ir e f i l e syst em is mer el y one la r ge i ndex ed f i l e.

Intr oduct i on t o Com put in g

CS101

VU
P ag e
271

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 165


58. 58.

165.

Dat ab ase
S yste ms: H as h Fi les

Alt hou gh i ndex i ng pr ovi des r ela t ivel y qu ic k a ccess t o ent r i es wit hi n a da ta st or
a ge st r uct ur e, it does so a t
t he exp ens e of i ndex ma i nt ena nc e.
H as hi ng
is a t ec hniqu e t ha t pr ovi des si mi la r a ccess wit hout such
over hea d. As in t he ca s e of

a n i ndex ed syst em, ha shi ng a ll ows a r ec or d t o be l oca t ed by mea ns of a key


va lu e. But , ra t her t ha n l ooki ng up t he key i n a n i ndex, ha shi ng i dent i fi es t he l
oca t ion of t he r ec or d dir ect l y
fr om t he key.

Aha shsyst emca nb esu mma r iz eda sfoll ows:T heda t a st


or a gespa c eisdivi dedi nt os ever a lsect i ons, ca ll e d
b uc kets,
ea ch of whic h isca pa ble of hol di ngs ever a lr ecor ds. T her ecor dsa r edisp er seda mongt
hebu cket s
a ccor di ng t o a n a lgor it hm t ha t conver t s key va lu es i nt o bucket nu mb er s. (T his
conver si on fr om key

va lu es
t obucket nu mb er sisca l l eda
has h func tio n.
)Ea chr ec or disst or edi nt hebu cket i dent ifi edb yt hispr oc ess .
T her ef or e, a r ec or d t ha t ha s been p la c ed i n t he st or a ge st r uct ur e ca n b e r et r i
eved b y fir st a pplyi ng t he ha s h

nt i f yi ng key t o det er mi ne t he a ppr opr ia t e bucket , t hen r et r i evi ng t he c ont ent s


of
t ha t bucket , a nd fi na l ly s ea r chi ng t hr ou gh t he da t a r et r i eved f or t he des ir ed r
ec or d.

Ha shi ng is not onl y us ed a s a mea ns of r et r i evi ng da t a fr om ma ss st or a ge but a


ls o a s a m
ea ns of r et r i evi ng
it ems fr om la r ge bl oc ks of da t a st or ed i n ma i n memor y. When ha shi ng is a ppli ed t
o a st or a ge st r uct ur e i n
ma ss st or a ge, t he r esu lt is ca ll ed a
has h fil e.
When a ppl i ed t o a st or a ge st r uct ur e wit hi n ma i n me mor y, t he
r esult is usua ll y ca ll ed

a
has h t abl e.

Intr oduct i on t o Com put in g

CS101

VU

P ag e
272

of
3 81
C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 166


59. 59.

166.

Dat ab ase S yste ms: H as h Fi le

E xamp l e

Let us a pply t he ha shi ng t ec hni qu e t o t he cla ss ic emp loyee f i l e i n whi c h ea c h r ec


or d c ont a i ns i nf or ma t io n
a bout a singl e emp l oyee i n a compa ny. F irst , we est a bl i sh sever a l a va ila bl e ar ea s
of

ma s s st or a ge t ha t wil l
pla y t he r ol e of buc ket s. T he nu mb er of buc ket s a nd t he s iz e of ea c h bucket a r e
desi gn dec is i ons t ha t we
wi ll c onsi der la t er . F or now, let us a ss ume t ha t we ha ve cr ea t ed 41 bucket s,
whic h we r ef er t o a s bucket
nu mb er 0, bucket nu mb e
r 1, t hr ough bucket nu mb er 40. (T he r ea s on we s el ect ed 41 bucket s r a t her t ha n
an
even 40 wi l l be exp la i ned shor t l y. )
is t o devel op a ha sh fu nct i on f or conver t i ng t hes e keys i nt o buc ket

t her ef or enot nu mer ic, t heya r est or eda sbit pa t t er ns, a ndweca ni nt er pr et t hebit
pa t t
er nsa snu mb er s. Usin g
t his nu mer ic i nt er pr et a t ion, we ca n di vide a ny key b y t he nu mb er of buc ket s a va
i la bl e a nd r ec or d t he
r ema i nder , whic h i n our ca se wi ll b e a n i nt eger i n t he r a nge fr om 0 t o 40. T hus
we ca n us e t he r ema i nder
of t his divisi on pr oc ess t o

i dent if y one of t he 41 bucket s (F igur e 121).

Fi gure
121
: Has hi ng t he key f i el d val ue 25 X3Z
t o one of 41 bucket s

Us i ng t his a s our ha sh funct i on, we pr oc eed t o c onst r uct t he f i l e by c onsi der i ng


ea c h r ec or d i ndi vi dua l l y,
a pplying our di vi de
-
by
-
41 ha sh fu nct i on t o it s key t o obt a in a bucket nu mb er , a nd t hen st or i ng t he r ec
or d
i n t ha t bucket (F i gur e

122). La t er , if we need t o r et r i eve a r ec or d, we need mer el y a pply our ha sh fu nct


i on
At t his poi nt l et us r ec onsi der our dec isi on t o di vi de t he

s t or a ge a r ea i nt o 41 bu cket s . F ir s t , not e t ha t t o
obt a i n a n eff ic i ent ha sh syst em, t he r ecor ds being st or ed shoul d b e dist r ibut ed
evenl y a mong t he bucket s.
Ifa dispr opor t i ona t enu m
-

b er ofkeysha pp ent oha sht ot hesa mebuc ket (a phenomenonca l l ed


cl u
ste ri ng
),
t hena dispr opor t i ona t enu mb er ofr ec or dswil lb est or edina singl ebucket . Int ur n, r
et r i evi nga r ec or dfr om
t ha t bucket cou l d r equir e a t ime
-
c onsu mi ng s ea r ch, ca using t he l oss of a ny b enef it s ga i ned by ha shi ng.

Now obs er ve t ha t if we ha d chos en t o divide t he st or a ge a r ea int o 40 bucket s r a t


her t ha n 41, our ha sh
funct i on wou l d ha ve i nvol ved di vi di ng t he keys b y t he va lu e 40 r a t her t ha n 41.
But , if a di vi dend a nd a
di vis or bot h ha ve a common fa ct or , t ha t fa ct or wil
l b e pr es ent i n t he r ema i nder a s wel l. In pa r t icula r , if t he
keys t o t he ent r i es st or ed i n our ha sh fil e ha ppened t o be mu lt ip l es of 5 (whi ch is a
lso a di visor of 40), t hen
t he fa ct or of 5 woul d a ppea r in t he r ema i nder s when di vi ded by 40, a nd t he ent r i
es
wou l d c lust er i n t hos e
bucket s a ss ocia t ed wit h t he r ema i nder s 0, 5, 10, 15, 20, 25, 30, a nd 35. S i mila r sit
uat ions wou l d oc cur in
t he ca se of keys t ha t ar e mu lt ipl es of 2, 4, 8, 10, and 20, beca use t hey a r e a ll a lso fa c
-

t or s of 40.

Intr oduct i on t o Com put in g

CS101

VU

P ag e
273

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

C ons equ ent l y, wec hoos e


t o di vi det hest or a gea r ea int o41bucket sbeca uset he choic e of41, bei nga pr im e
nu mb er , el i mi na t ed t he p oss ib i l it y of c ommon fa ct or s and t her ef or e r educ ed t
he c ha nc e of clust er i ng.

Fi gure
122
: T he rudi me
nt s of a hashi ngsyst em

Intr oduct i on t o Com put in g

CS101

VU

P ag e
274

of
3 81
C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 167


60. 60.

167.

Dat ab ase S yste ms: Dat a M i ni ng

A r a pidly expa ndi ng subj ect t ha t is clos el y a ss oc ia t ed wit h da t a ba se t ec hnol ogy


is da t a mi ni ng, whic h
cons ist sof
t ec hni qu esf or disc over i ngpa t t er nsi nc ol l ect i onsofda t a . Da ta mi ni ng ha sbec
omea ni mp or t a nt
t oolinnu mer ousa r ea sinc lu di ngma r ket i ng, i nvent or yma na gement , qua l it yc ont r
ol, loa nr iskma na gement ,
fr a ud det ect i on, a nd invest ment a na lysis. Da ta mi ni ng t
echni qu es even ha ve a pplica t i ons in wha t mi ght
seem u nl i kel y set t i ngs a s ex empl if i ed by t heir use i n i dent if yi ng t he fu nct i ons of
pa rt icula r genes enc oded
i n DNA mol ecul es a nd c ha r a ct er izi ng pr op er t i es of or ga nis ms.

Da t a mi ni ng a ct i vit i es diff er fr om t r a di
t i ona l da t a ba se i nt er r oga t i on i n t ha t da t a mi ni ng s eeks t o i dent if y
pr evi ous ly u nknown pa t t er ns a s oppos ed t o t r a dit i ona l da t a base i nquir i es t ha t
mer ely a sk f or t he r et r i eva l
of st or ed fa ct s. Mor e
-

over , da ta mi ning is pr a ct iced on st a t ic da ta col l ect i ons,

ca ll ed
data w are ho uses,

da t a bases beca use


f indi ng pa t t er ns i n a st at ic syst em is ea si er t ha n i n a dyna mic one.

W e shou l d a lso not e t ha t t he subj ect of da t a mi ni ng is not r est r ict ed t o t he doma


i n of c omput i ng but ha s
t ent a cl es t ha t ext end fa r int o st a t ist ics. In fa ct , ma ny wou ld a r gu e t ha t si nc e
da
t a mi ni ng ha d it s or igi ns i n
a t t empt s t o p er for m st a t ist ica l a na l ysis on la r ge, di ver se da t a col l ect i ons, it
is a n a ppl ica t i on of st a t ist ics
r at her t ha n a fi eld of c omput er sci enc e.

T woc ommonf or msofda t a mi ni nga r e


c l ass descr ip tio n
a nd
c l ass d iscr i mi na
t io n.
C la ss descr ipt i ondea l s
wit hi dent if yingpr oper t i est ha t cha ra ct er iz ea given gr oupofda t ait ems, wher ea scla
ssdiscr i mi na t i ondea ls
wit hi dent i f yi ngpr op er t i est ha t di vi det wogr oups. F or exa mp l e, cla ss descr ipt i
ont ec hni qu eswoul db eus ed
t o i dent
if y c ha r a ct er ist ics of p eopl e who bu y s ma l l economi ca l vehic l es, wher ea s cla ss
dis cr i mi na t i on
t ec hni qu es wou ldb eus edt of i ndpr op er
-

t i est ha t dist i ngu ish cust omer s whos hop for us edca r sfr omt hos e
who shop f or new ones.

Intr oduct i on t o Com put in g

CS101

VU

P ag e
275

of
3 81
C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 168


61. 61.

168.

Dat ab ase S yste ms:


Dat a M i ni ng

E xamp l es and I mp li c at io ns

Anot her for mofda t a mi ni ngis


c l ust eranal ysis,
whic hseekst odisc over cla ss es. Not et ha t t hisdiff er sfr om
cla ss descr ipt ion, whi ch s eeks t o disc over pr op er t i es of me mb er s wit hi n cla ss es
t ha t ar e a lr ea dy
i dent if i ed.
Mor epr ec is el y, clust er a na lysist r iest ofi ndpr op er t i esofda t ait emst ha t lea dt ot
hedis c over yofgr oup i ngs.

clust er a na lysis mi ght fi nd


t ha t t he cust omer ba se br ea ks down i nt o t wo a ge gr oups

a 4
-
to
-
0 a ge gr oup
a nd a 25
-
to
-
40 a ge gr oup. (P er ha ps t he mot i on pict ur e a t t ra ct ed c hi ldr en a nd t heir par ent
s?)

S t ill a not her for m of da t a mini ng is


ass oci atio n analy sis,
whic h i nvol ves l ooki ng for li n
ks bet ween da t a
gr oups. It is a ss ocia t ion a na l ys is t ha t mi ght r evea l t ha t cust omer s who bu y pot
a t o c hips a lso buy b eer a nd
soda or t ha t peop l e who shop dur i ng t he t r a dit i ona l weekda y wor k hour s a lso dr a
w r et ir ement b enef it s.

O ut l ie ranalys is
isa not her f or
mof da t a mi ni ng. It t r ies t oi dent if y da t a ent r i es t ha t do not c omp l y wit ht h e
nor m. Out li er a na lysis ca n be used t o i dent if y er r or s in da t a coll ect i ons, t o ident
if y cr edit ca r d t heft by

ns, a nd per ha ps t o ident i fy pot ent ia l


t er r or ist s by r ecogniz i ng unusua l b eha vior .

F ina l l y, t he for m of da t a mi ni ng ca ll ed
seq ue nt i al pat ter n analys is
t r ies t o ident if y pa t t er ns of beha vi or
over t i me. F or exa mpl e, s equ ent ia lpa t t er na na lys is mi ght r evea lt r
endsi n ec onomics yst emssuc ha sequ it y
ma r ket s or i n envir on
-

ment a l syst ems suc h a s cli ma t e condit i ons.

As i ndi ca t ed by our la st exa mpl e, r esult s fr om da t a mi ni ng ca n be used t o pr edict


fut ur e beha vi or . If a n
ent it y poss ess es t he pr oper t i es t ha t cha ra ct e
r iz e a cla s s , t hen t he ent it y will pr oba bly b eha ve l ike memb er s
of t ha t cla ss . However , ma ny da t a mi ni ng pr oj ect s are a i med a t mer el y ga i ning a
bet t er under st a ndi ng

oft heda t a, a swit ness edbyt heus eofda t a mi ningi nunr a vel i ngt hemyst er i esofDN A. I
na nyca s e,
t hescop eofda t a mi ni nga pplica t i onsispot ent ia ll yenor mous, a ndt husda t a mi ni ngpr
omis est obea na ct iv e
a r ea of r esea r ch f or yea r s t o come. Not e t ha t da t a ba se t ec hnol ogy a nd da t a mi
ni ng a r e cl os e c ous i ns, a nd
t hus r es ea r ch i n one wi l l ha ve

r ep er cus s i ons i n t he ot her . Da ta ba s e t ec hn i qu es a r e us ed ext ens i vel y t o gi v e


da t a wa r ehous es t he ca pa bil it y of pr es ent i ng da t a in t he f or m of
d at a c ubes
( da t a vi ewed fr om mult ipl e
per sp ect i ves

t het er m
cube
isusedt oconj ect ur et hei ma geofmu lt ipl e
di mens i ons )t ha t ma keda t a mi ni ng
poss ib l e. I n t ur n, a s r esea r cher s i n da t a mi ni ng i mpr ove t ec hni qu es f or i mp l
ement i ng da t a cubes, t hes e
r esult s wi ll pa y di vi dends i n t he f i el d of da t a ba se des i gn.

Inc l osi ng, weshou l dr ecogniz et ha t succ ess fulda t a mi ni ng

enc ompa ss esmuc hmor et ha nt hei dent i fi ca t io n


of pa t t er ns wit hi n a col l ect i on of da t a . Int el li gent ju dgment must be a ppli ed t o
det er mi ne whet her t hos e
pa t t er ns ar e signif ica nt or mer el y coinc i denc es. T he fa ct t ha ta par t icula r
convenienc e st or e ha s sol d a

hi gh
nu mb er of wi nni ng l ot t er y t ic ket s s houl d pr oba bl y not be c ons i der ed si gnif ica
nt t o s omeone p la nni ng t o
buy a lot t er y t ic ket , but t he disc over y t ha t cust omer s who buy sna ck food a lso t end
t o buy fr oz en di nner s
mi ght c onst it ut e mea ni ngful i nf or ma t i ont
oa gr oc er yst or e ma na ger . Likewis e, da t a mi ni ng enc ompa ss esa
va st nu mb er of et hica l iss u es i nvol vi ng t he r i ght s of i ndivi dua ls r epr es ent ed i n t
he da t a wa r ehous e, t he
a ccur a cy a nd use of t he c onc lusi ons dr a wn, a nd even t he a ppr opr ia t eness of da t a
mi ni ng i
n t he f ir st pla ce.

Intr oduct i on t o Com put in g

CS101

VU
P ag e
276

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 169


62. 62.

169.

Dat ab ase S yste ms: S oci al I mp act of D at abas e T ec hno logy

Wit h t he devel op ment of da t a base t echnol ogy, infor ma t i on t ha t wa s onc e bur ied
i n a r ca ne r ec or ds ha s
bec ome a cc ess ib l e. In ma ny ca ses, a ut oma t ed l ibr a r y syst ems p la c e
t
a genc i es, pol it i ca l pa r t ies, emp l oyer s, a nd pr i va t e i ndi vi dua ls.

T his is r epr es ent a t i ve of t he p ot ent ia l pr ob l ems t ha t per mea t e t he ent ir e spect


r um of da t a ba se a pplica t i ons.
T ec hnol ogy ha s ma de it ea sy t o c ol l ect enor mous a mount s of da t a a nd t o mer ge
or
compa r e dif f er ent da t a
col l ect i ons t o obt a in r ela t ions hips t ha t woul d ot her wis e r ema i n bur i ed in t he
hea p. T he r a mif ica t i ons, bot h
posit i ve a nd nega t i ve, a r e enor mous. T hes e r a mif ica t i ons a r e not mer el y subj
ect s f or a ca demi c deba t e

t hey a r e r ea lit i es.

In s
ome
ca ses,

t he da t a col l ect i on pr oc ess is r ea di ly a ppa r ent ; in ot her s it is subt le. Exa mpl es
of t he fir st
ca se occur when one is exp l ic it l y a sked t o pr ovi de i nfor ma t i on. T his ma y b e done
i n a volu nt a r y ma nner ,
a s in sur veys or cont est r egist r a t ion f or ms, or it ma y b
e done i n a n involu nt a r y ma nner , such as whe n

pr ovi di ngp er sona li nf or ma t ionwhena ppl yi ngf or a loa nvolu nt a r yor i nvolu nt a r
y?T hedist i nct i ondep ends
on whet her r ec ei ving t he l oa n is a conveni enc e or a nec ess it y. T o use a cr edit ca r
d a t some r et a i l er s now
r equir est ha t youa llowyour signa t ur et ober ecor dedi na digit i z edfor ma t . Aga i n, pr
ovi di ngt hei nf or ma t i on
is eit her volu nt a r y or involu nt a r y dep en
di ng on your sit ua t ion.

Mor esubt l eca sesofda t acol l ect i ona voi ddir ect commu nica t i onwit ht hesubj ect . Exa
mpl esi nc lu dea cr edit
compa ny t ha t r ec or ds t he pur c ha si ng pr a ct ices of t he holder s of it s cr edit ca r ds,
websit es t ha t r ecor d t h e
i dent it i es of t ho
s e who vis it t he s it e, a nd socia l a ct ivist s who r ecor d t he l ic ens e pla t e nu mb er s
on t he ca r s

c a ses,

t he subj ect of t he da t a col l ect i on mi ght not be


a wa r et ha t infor ma t i onisb ei ngc oll ect eda ndl ess
l i kel yt obea wa r eoft he ex ist enc e oft he da t a basesb ei ng
const r uct ed.

S omet i mes t he under l ying da t a


-
col l ect i on a ct ivit i es a r e self
-
evi dent if one mer el y st ops t o t hi nk. F or
exa mp l e, a gr oc er y st or e mi ght off er disc ou nt s t o it s regu la r cust omer s who r
egis
t er in a dva nc e wit h t h e
st or e. T he r egist r a t ion pr oc ess mi ght i nvol ve t he iss ua nc e of ident if i ca t ion ca r
ds t ha t must be pr es ent ed a t
t he t i me of pur cha se t o obt a i n t he disc ou nt . T he r esult is t ha t t he st or e is a bl e t
o compi l e a r ecor d of t he

cha ses
a r ec or d whos e va lu e fa r exc eeds t he va lu e of t he disc ou nt s a wa r ded.

Of cour se, t he f or c e dr i ving t his boom i n da t a col l ect i on is t he va lu e of t he da t a ,


which is a mplif i ed b y
a dva nc es i n da t a ba se t ec hnology t ha t a llow da t a t o be li nked i n wa ys t ha t

r evea l i nf or ma t i on t ha t wou l d
ot her wis er ema i nobscur e. F or exa mpl e, t hepur cha si ngpa t t er nsofcr edit ca r dhol
der sca nbec la ss if i eda nd
cr oss
-
l ist edt o obt a i ncust omer pr of il esofi m mens e ma r ket i ngva lu e. S ubscr ipt i onf or
msf or body
-
bui l di ng
ma ga zi nes c
a n b e ma i l ed t o t hos e who ha ve r ec ent l y pur cha sed ex er cis e equ ip ment , wher ea
s subs cr ipt ion
for ms for dog ob edi enc e ma ga z ines ca n be t a r get ed t owa r d t hos e who ha ve r ec
ent l y pur cha sed dog food.
Alt er na t i ve wa ys of comb i ni ng i nf or ma t i on ar e somet i mes ver y i ma
gi na t i ve. Welfa r e r ec or ds ha ve bee n
compa r ed t o cr i mi na l r ec or ds t o f i nd a nd a ppr ehend pa r ol e viola t or s, a nd i n
1984 t he S el ect i ve S er vic e i n
t he Unit ed S t a t es used old b ir t hda y r egist r a t ion list s fr om a popu la r ice cr ea m r
et a i l er t o i dent if y c it i z ens
who
ha d fa il ed t o r egist er for t he mi l it a r y dr a ft .

T her e a r e s ever a l a ppr oa ches t o pr ot ect i ng s oc i et y fr om a busive us e of da t a


-

ba ses. One is t o a pply l ega l


r emedi es. Unf or t una t el y, pa ss inga la wa ga i nst a na ct i ondoesnot st opt hea ct i onfr
omoc cur r ingbut me
r el y
ma kes t he a ct i on il l ega l. A pr i me exa mp l e in t he Unit ed S t a t es is t he P r iva c y Act
of 1974 whos e pur pos e
wa s t o pr ot ect cit iz ens fr om a busi ve us e of gover nment da t a ba ses. One pr ovis i on
of t his a ct r equ ir e d

Intr oduct i on t o Com put in g

CS101

VU

P ag e
277

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan


gover nment a genc i es t o publis h not ic e of t heir

da t a ba ses in t he F eder a l R egist er t oa ll ow cit iz ens t o a cc ess


a nd c or r ect t heir per sona l i nf or ma t i on. However , gover nment a genc i es wer e sl
ow t o c omp l y wit h t his
pr ovisi on. T his does not nec ess a r ily i mpl y ma l ic i ou s int ent . In ma ny ca ses t he pr
obl em wa s one

of
bur ea ucr a cy.
But

t he fa ct t ha t a bur ea ucr a cy mi ght be c onst r uct ing p er sonnel da t a bases t ha t it is


una ble t o
i dent i f y is not r ea ss ur ing.

Anot her , a nd p er ha ps mor e power fu l, a ppr oa ch t o cont r ol li ng da t a ba se a buse is


public opi ni on. Da ta ba ses
wi llnot be
a busedi ft hepena lt i esout wei ght hebenef it s; a ndt hep ena lt ybusi ness esfea r t he most
isa dver s e
publi c opi ni on

t his go es r i ght t o t he b ot t om li ne. I n t he ea r ly 19 90 s it wa s pu blic opi ni on t ha


t ult i ma t el y
st opp ed ma j or cr edit bur ea us fr om sel l i ng ma i l i ng

list s for ma r ket i ng pur poses. Mor e r ec ent ly, Googl e


disc ont i nu ed it s G oogle Buzz soc ia l net wor king t ool i n 2011 a ft er it s a utoma t ic
sha r ing of c ont a ct
i nf or ma t ion fr om t he popu la r Gma i l t ool wa s gr eet ed wit h ha r sh public cr it ic is m.
Even gover nment
a genc i e
s ha ve bowed t o publi c opi ni on. In 1997 t he S oc ia l S ecur it y Admi nist r a t ion i n t he
Unit ed S ta t es
modif i edit spla nt o ma keS oc ia lS ecur it yr ec or dsa va ila bl evia t heI nt er net whenpubl
icop i nion qu est i oned
t hesecur it yoft hei nf or ma t i on. Insome oft hes eca
sesr esu lt swer eobt a ined i nda ys

a s tar kcont r a s tt ot he
ext ended t i me p er i ods a ss ocia t ed wit h l ega l pr oc ess es.

Ofc our se, i n ma nyca ses da t a basea ppli ca t ionsa r eb enefic ia lt obot ht he hol der a ndt
hesubj ect oft he da t a ,
but in a ll
ca ses,

t her e is a loss

of pr iva cy t ha t s houl d not be t a ken l i ght l y. S uch pr iva cy is s u es a r e s er ious


whent he i nf or ma t ionisa ccur a t e, butt heybec ome gi ga nt i cwhent he i nf or ma t ion
iser r oneous. Ima gi net h e
f eeli ng of hop el ess ness if you r ea l iz ed t ha t your cr edit r a t ing wa s a d
ver s el y a ff ect ed by er r oneous
i nf or ma t ion. I ma gi ne how your pr obl ems woul d be a mpl if i ed i n a n envir onment i
n whi c h t his
mis i nf or ma t i on wa s r ea di l y sha r ed wit h ot her i nst it ut i ons. Pr iva c y pr obl ems
a r e, a nd wi l l b e, a ma j or sid e
eff ect of a dva nc i ng t ec hnol og
y in gener a l a nd da t a ba se t ec hni qu es i n pa r t icula r . T he s olut i ons t o t hes e
pr obl ems wi ll r equ ir e a n educa t ed, a ler t , a nd a ct ive c it i z enr y.
Intr oduct i on t o Com put in g

CS101

VU

P ag e
278

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 170


63. 63.

170.
Arti fic i al Inte ll ige nc e: I ntro d uc tio n and Vis io n

Ar t if ic ia l i nt ell i genc e is t he fi el d of c omput er sci enc e t ha t seeks t o buil d a ut


onomous ma chi nes
-

ma chi nes
t ha t ca ncarr yout comp l ext a skswit hout hu ma ni nt er ve nt i on. AI ishelpi ngt o ma keR
ob ot sa sshowni nt he
F igur e 123, a nd s el f
-
dr i vi ng ca r sa s shown

i n t he F i gur e 124.

Fi gur e
123
: Robot

Fi gure
124
: Sel f
Dri vi ngC ars

R obot s ca n help pa t i ent s, for exa mp l e one t yp ica l r ob ot shown i n t he F i gur e 125
ca n a ll evia t e a per son
even 40 t i mes a da y.
Intr oduct i on t o Com put in g

CS101

VU

P ag e
279

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Fi gure
125
: Medi cal robot hel pi ng t he pat i ents
P epp er R obot wor ks a s r ec ept i onist in B el gia n hosp it a l shown i n t he F i gur e 126.

Fi gure
126
: Recept i oni st Robot

Anot her r obot isshowni nt heF igur e127.T hisr obot isa blet ot a kebloodfr omt hevei nsoft
he hu ma nsa nd
it is mor e a ccura t e t ha n hu ma ns. It per for ms i ma ge pr oc ess i ng t o loca t e t he vei
ns a nd fur t her conf ir med b y
t he ult r a sound.

Intr oduct i on t o Com put in g

CS101

VU

P ag e
280

of
3 81
C opy rig htVi rtual U ni v ersi ty ofP aki stan

Fi gure
127
: Robot draws blood

Intr oduct i on t o Com put in g

CS101

VU

P ag e
281

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 171


64. 64.

171.

Arti fic i al Inte ll ige nc e: I nte l lig e nt Age nts

An
age nt

it s envir onment . It is na t ura l t o envisi on a n a gent a s


a n i ndi vi dua l ma c hi ne suc h a s a r obot , a lt hou gh a n a gent ma y t a ke ot her for ms
suc h a s a n a ut onomous
a ir pla ne, a char a ct er in a n i nt er a ct ive vi deo ga me, or a pr ocess c ommu nica t i ng
wit h ot her pr oc ess es o
ver
t he I nt er net (p er ha ps a s a cli ent , a ser ver , or a peer ). Most a gent s ha ve sens or s
by whic h t hey r ec ei ve da t a
fr om t heir envir onment s a nd a ct ua t or s by whic h t hey c a n a ffect t heir envir
onment s. Exa mp l es of s ens or s
i nc lu de mi cr op hones, ca mer a s, ra nge sens
or s, a nd a ir or soi l sa mp li ng devi c es. Exa mpl es of a ct ua t or s
i nc lu de wheel s, l egs, wi ngs, gr ipp er s, a nd speec h synt hes iz er s.

Much of t he r es ea r ch i n a r t ific ia l i nt el li genc e ca n b e c ha r a ct er iz ed i n t he c ont


ext of bui l ding a gent s t ha t
beha ve i nt el l i gent ly, m

r ec ei ved t hough it s s ens or s. In t ur n, we ca n c la ss ify t his r es ea r ch b y c onsi der


ing diff er ent l evels of t hes e
r espons es.

T hes i mp l est r esp ons eisa r efl exa ct i on, whic h


ismer el ya pr edet er minedr esp ons et ot hei nputda t a . Higher

a gent wit h knowl edge of it s envir onment a nd r equir e t ha t t he a gent a djust it s a ct


ions a cc or
di ngl y. T he
pr oc ess of t hr owing a ba seba ll is la r gel y a r ef l ex a ct ion but det er mi ni ng how a
nd wher e t o t hr ow t he ba ll
r equir esknowl edgeoft hecur r ent envir onment . (T her ei soneout wit hr unner sonf ir st a
ndt hir d. )Howsuc h
r ea l
-
wor l d knowl edge ca n b e st
or ed, upda t ed, a cc ess ed, a nd ult i ma t el y a ppli ed i n t he dec is i on
-
ma ki n g
pr oc ess cont inu es t o be a cha l l enging pr ob l em i n a rt ific ia l i nt ell i genc e.

Anot her level of r espons e is r equ ir ed if we wa nt t he a gent t o seek a goa l suc h a s wi


nni ng a ga me of chess
or ma
neu ver i ng t hr ou gh a cr owded pa ss a gewa y. S uch goa l
-
r espons e, or sequ enc e of r espons es, b e t he r esu lt of delib er a t el y f or mi ng a pla n
of a ct i on or sel ect i ng t h e
best a ct ion a mong t he cur r ent opt i ons.

In some
ca s es,

devel op i ng
pro ced ur al knowl edge

d ec l ar at ive know le dge

Lea r ning pr oc edur a l knowl edge usua ll y i nvol ves a tr ia l


-
a nd
-
er r or pr
ocess by whic h a n a gent l ea r ns
a ppr opr ia t e a ct ions by b ei ng punis hed f or poor a ct ions a nd r ewa r ded f or good
ones. F ol l owi ng t his
a ppr oa ch, a gent s ha ve been devel op ed t ha t , over t ime, i mpr ove t heir a bilit i es i n
comp et it i ve ga mes such a s
chec ker s a nd chess .
Lea r ni ng dec la r a t ive knowl edge u sua lly t a kes t he for m of expa ndi ng or a lt er i ng t
he

da t a base of knowl edge (t her e is st il l just one out , but now r unner
s ar e on f ir st a nd s ec ond) fr om whic h
r at iona l r esp ons es t o futur e event s a r e det er mi ned.
T ha t is, a n a gent must b e a bl e t o ext r a ct inf or ma t ion fr om t
he da t a pr oduc ed b y it s sens or s, or in ot her
wor ds, a na gent must be a ble t o per c ei ve. In some
ca s es,

t his is a st ra ight f or wa r d pr ocess . S igna ls obt a ine d


fr om a gyr osc op e a r e ea sil y enc oded i n f or ms compa t ibl e wit h ca lcu la t ions f or
det er mi ni ng r espons es. B
ut
i n ot her
ca ses,

ext r a ct ing i nf or ma t i on fr om input da t a is dif fi cult . Exa mp l es i nc lu de under st a


ndi ng sp eec h
a nd i ma ges. Likewis e, a gent s must be a ble t o for mu l a t e t heir r espons es in t er ms
compa t ible wit h t heir
a ct uat or s. T his mi ght be a str a ight f or wa r d
p
r oc es s ,

or it mi ght r equ ir e a n a gent t o f or mula t e r esp ons es a s


comp l et e spoken s ent enc es

mea ni ng t ha t t he a gent must gener a t e speec h. In t ur n, such t opics a s ima ge


pr oc ess i ng a nd a na l ys is, na t ura l la ngua ge u nder st a ndi ng, a nd sp eec h gener a t
ion a r e i mp or t a nt

ar ea s of
r es ea r ch. T he a gent a t tr ibut es t ha t we ha ve i dent if i ed her e r epr es ent pa st a s
wel l a s cur
-
r ent ar ea s of
r es ea r ch. Of cour se, t hey a r e not t ot a ll y i ndep endent of ea c h ot her . We woul d li
ke t o devel op a gent s t ha t
poss ess a lloft hem, pr oduc inga gen
t st ha t under st a ndt heda t a r ec ei vedfr omt heir envir onment sa nddevel op

t ies.

Intr oduct i on t o Com put in g

CS101

VU

P ag e
282

of
3 81
C opy rig htVi rtual U ni v ersi ty ofP aki stan

However , byis ola t i ngva r ioust yp esofr a t iona lb eha vi or a ndpur suingt hemindep end
ent ly, r es ea r cher sga i n
a t oehol d t ha t ca n la t er be c omb i ned wit h pr ogr ess i n ot her a r ea st o pr oduc e
mor e i nt ell i gent a gent s.

W e cl os e t his subsect i on b y i nt r oduc i ng a n a gent t ha t wi ll pr ovide a cont ext f or


our discussi on i n S ect i ons
65. 65.

11. 2 a nd 11. 3. T he a ge
nt is des i gned t o sol ve t he ei ght
-
puzzl e, whic h c ons ist s of ei ght squa r e t il es la bel ed
1t hr ough8mou nt edi nafra meca pa bleofhol di nga t ota lofni nesucht i l esint hr eer owsa
ndt hr eec olu mns
(F igur e 128). Among t he t i l es i n t he fr a me is a va ca ncy int o

whic h a ny of t he a dja c ent t i l es ca n b e pushed,


a ll owingt het i l esi nt hefr a met ob escr a mbl ed. T hepr obl emp os edist omovet het il esi
na scra mbl edpuzz l e
ba ck t o t heir init ia l p osit i ons (F igur e 128).

Fi gure
128
: T he ei ght
-
puzzl ei n it ssol ved confi gurat i on
Our a gent t a kes t he f or m of a box equ ipp ed wit h a gr ipper , a vi deo ca mer a , a nd
a fi nger wit h a r ubber en d
so t ha t it does not sl ip when pushi ng somet hi ng (F i gur e 129). When t he a gent is f ir
st t ur ned on, it s gr ipp er
begi nst oop ena ndcl os ea sifa ski ngf or t hepuz zl e. W henwepla c ea scr a mbl edei ght
-
pu zz l ei nt hegr ipp er ,
t he gr ipp er cl os es on t he puz z l e. Aft er a shor t
t i me,

t il es a r ound i n
t he fr a me u nt i l t hey a r e ba ck in t heir or i gi na l p osit ions. At t his poi nt t he ma c hi
ne r el ea s es
t he puzz l e a nd t ur ns it self of f.

T his puzzl e
-
s ol vi ng ma c hi ne ex hib it s t wo of t he a gent a t tr ibut es t ha t we ha ve i dent if i ed. F
ir st, it must be
a ble t o p er c ei ve i n t he s ens e t ha t it must ext r a ct t he cur rent puzz l e st a t e fr om
t he i ma ge it r ec ei ves fr om it s
ca mer a .

Intr oduct i on t o Com put in g

CS101

VU
P ag e
283

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Fi gure
129
: Our pu zz l e
-
sol vi ng machine

Intr oduct i on t o Com put in g


CS101

VU

P ag e
284

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 172


66. 66.

172.

Arti fic i al Inte ll ige nc e: Rese ar c h Met hodo logi es


T oa ppr ecia t et hefi el d ofa r t ificia li nt el l i genc e, it ishel pfult ounder st a ndt ha t it
isbei ngpur sueda longt w o
pa t hs.Oneist he
eng i neer ingt r a ckinwhi c hr es ea r cher s a r etr yingt odevel ops ys t ems t ha t exh ibit i
nt ell i gent
beha vi or . T he ot her isa t heor et ica lt r a cki n whic hr es ea r cher sar et r yi ngt o devel
opa comput a t iona lu nder
-

st a ndi ng of a ni ma l

esp ec ia ll y hu ma n

i nt el l i genc e. T hi
s di chot omy is cla r if i ed by cons ider i ng t he
ma nner in whic h t he t wo t r a cks ar e pur sued. T he engi neer ing a ppr oa ch l ea ds t o a
per for ma nc e
-
or i ent e d
met hodol ogyb eca uset heunder l yi nggoa list opr oduc ea pr oduct t ha t meet sc er t a inp
er for ma nc egoa ls. T he
t heor
et ica l a ppr oa ch l ea ds t o a simu la t i on
-
or i ent ed met hodol ogy b eca use t he u nder l ying goa l is t o expa nd
our under st a ndi ngofi nt el l i genc ea ndt hust heemp ha sisisont heunder lyi ngpr oc ess r
a t her t ha nt heext er i or
per f or ma nc e.

As a n exa mp l e, cons i der t he fi el d


s of na t ura l la ngua ge pr oc ess i ng a nd li ngu ist i cs. T hes e f i el ds a r e cl os el y
r ela t ed a nd b enef it fr om r es ea r ch i n ea c h ot her , yet t he u nder l yi ng goa ls ar e
diff er ent . Lingu ist s ar e
i nt er est ed in l ea r ni ng how hu ma ns pr oc ess la ngua ge a nd t hus t end t owa r d mor e
t
heor et ica l pur suit s.
R es ea r cher s in t he fi el d of na t ur a l la ngua ge pr oc essi ng a r e int er est ed in devel
op i ng ma c hi nes t ha t ca n
ma nipula t e na t ura l la ngua ge a nd t her ef or e l ea n i n t he engi neer ing dir ect i on. T
hus, lingu ist s oper a t e i n
si mu la t i on
-
or i ent ed mode
-

bui l di ng syst ems whos e goa ls ar e t o t est t heor i es. In c ont r a st, r esea r cher s i n
na t ura l la ngua ge pr oc ess i ng op er a t e i n p er for ma nc e
-
or i ent ed mode
-
bu i l di ng syst ems t o per for m t a sks.
S yst emspr oduc edi nt hisla t t er mode(suc ha sdocu ment t ra nsla t or sa ndsyst em
sbywhic hma c hi nesr espond

t o wor k i n t he r est r ict ed envir onment of t he pa r t icula r syst em.

As a n el ement a r y exa mp l e, c onsi der t he t a sk of devel op ing a shel l f or a n op er a t


ing syst em t ha t r ec ei ves
i nst r uct ionsfr omt heout si dewor l dt hr ou ghver ba lEngli shcom ma nds. Int hisca s e, t
heshel l(a na gent )does
not need t o wor r y a bout t he ent ir e E nglis h
la ngua ge. Mor e pr ec is ely, t he s hel l does not need t o dist i nguis h
bet ween t he va r i ous mea ni ngs of t he wor d
copy.
(Is it a nou n or a ver b? S houl d it ca r r y t he c onnot a t ion of
pla gia r ism?) Inst ea d, t he shell needs mer el y t o dist i nguish t he wor d
copy
fr om ot her comma nds such a s
rename
a nd
del et e.
T hus,

t heshel lcou l dper f or mit st askjust byma t chi ngit sinput st opr edet er mi neda udi o
pa t t er ns. T he per for ma nc e of such a syst em ma y be sa tisfa ct or y t o a n engi neer ,
but t he wa y it is obt a ine d
wou l d not be
a est het ica l l y pl ea si ng t o a t heor et i cia n.

Intr oduct i on t o Com put in g

CS101

VU

P ag e
285
of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 173


67. 67.

173.

Arti fic i al Inte ll ige nc e: T he T uri ng T est

In t he pa st t he
T ur i ng t est
(pr op os ed by Ala n T ur ing i n 1950) ha s ser ved a s a benchma r k i n mea sur i ng
pr ogr ess in t he fi el d of a r t ific ia l i nt ell i genc e. T oda y
t he signif ica nc e of t he T ur ing t est ha s fa ded a lt hou gh

whom weca l lt he int er r oga t or , t ocommu nica t ewit ha test subj ect by mea nsofa t
ypewr it er
syst em wit hout
bei ng t ol d whet her t he t est subject wa s a hu ma n or a ma c hi ne. In t his envir
onment , a ma chi ne wou l d b e
decla r ed t o b eha ve i nt el l i gent l y if t he i nt er r oga t or wa s not a bl e t o dist i ngu is
h it fr om a hu ma n. T ur ing
pr edict ed t ha t by t he yea r 2000 ma
c hines wou l d ha ve a 30 per c ent cha nc e of pa ssi ng a fi ve
-
mi nut e T ur ing
t est

a conj ect ur e t ha t t ur ned out t o b e sur pr isingl y a ccur at e.

One r ea son t ha t t he T ur ing t est is no longer cons i der ed t o be a mea ni ngfu l mea sur
e of i nt el l i genc e is t ha t
a n eer i e a ppea r a
nc e of i nt ell i genc e ca n be pr oduc ed wit h r ela t i ve ea s e. A wel l
-
known exa mp l e a r ose a s a
r esult oft hepr o
-

gr a mDOC T OR (a ver s i onoft hemor egener a ls ys t emca l l edELIZ A)devel op edb yJ os


ep h
W ei z enba u m i n t he mi d
-
1960s. T his int er a ct i ve pr ogr am wa s des i gne
d t o pr oj ect t he i ma ge of a R oger ia n
a na lyst c ondu ct i ng a psychologica l i nt er vi ew; t he c omput er pla yed t he r ole of t
he a na l yst whi l e t he us er
pla yed t he pa t ient . Int er na l l y, a ll t ha t DOCT OR did wa s r est r uct ur e t he st a t
ement s ma de by t he pa t i ent
a ccor di ng t
o some wel l
-
def ined r ul es a nd dir ect t hem b a ck t o t he pa t ient . F or exa mp l e, i n r espons e t o t
he
,

you

If DOCT OR wa s una ble t o r ec ogni z e t he sent enc e st r uct ur e, i

ura lla ngua gec ommu nica t i on.


T he subj ect of psyc hot her a py mer el y pr ovided a n envir onment i n whic h t he pr og
r a m c oul d

for a ct ua lpsychot her a py. (T heR oger ia nt hesisist ha t t hepa t i ent , not t hea na lyst ,
shou ldl ea dt hediscuss i on
dur i ng t he t her a peut ic sess i on, a nd t
hus, t hey a r gued, a comput er cou l d poss ib l y c ondu ct a discuss ion a s
wel l a s a t her a pist could. ) Mor eover , DOCT OR pr oj ect ed t he i ma ge of compr ehens
i on so st r ongl y t ha t

-
a nd
-

a nswer
dia l ogu e. In
a sens e, DOCT OR pa ss ed t he T ur ing t est . T he r esult wa s t ha t et hica l, a s well a s t
echnica l, iss u es wer e
r a ised, a nd W ei z enba u m beca me a n a dvoca t e f or ma i nt a ini ng hu ma n di gnit y i
n a wor l d of a dva nci ng
t ec hnol ogy.

Mor er ec ent exa mpl es ofT ur ingt

wit h a hu ma n vict i m i n or der t o t r ic k t he hu ma n i nt o dr oppi ng his or her ma l


wa r e gua r d. Mor eover ,
phenomena si mi la r t oT ur ingt est soccur int hec ont ext ofc omput er ga messucha s
chess
-
p la yi ngpr ogr a ms.
Alt hou gh t hes e pr ogr a ms sel ect moves mer el y by a ppl yi ng br ut e
-
f or c e t ec hni qu es, hu ma ns comp et i ng
a ga inst t he c omput er oft en exp er i enc e t he sensa t i on t ha t t he ma c hi ne p oss ess
es cr ea t ivit y a nd even a
per sona l it y. S i mi la r sensa t ions oc
cur i n r ob ot i cs wher e ma c hi nes ha ve b een bu i lt wit h phys ica l a t t r ibut es
t ha t pr oj ect i nt ell i gent c ha r a ct er ist ics. Exa mpl es i nc lu de t oy r obot dogs t ha t
pr oj ect a dor a bl e p er sona lit i es
mer el y b y t ilt i ng t heir hea ds or lift i ng t heir ea r s in r espons e t o a sound
.

Intr oduct i on t o Com put in g


CS101

VU

P ag e
286

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 174


68. 68.

174.

Arti fic i al Inte ll ige nc e: U nd erst and i ng I mag es

Let us consi der t he pr ob l ems p os ed by t he puz zl e


-
s ol vi ng ma c hi ne i nt r odu c ed i n t he modu l e nu mb er 171.
T he op eni nga ndc l osi ng oft hegr ipp er ont he ma c hi ne
pr es ent

nos er i ousobst a cl e, a ndt hea bil it yt o det ect


t he pr es enc e of t he puz zl e i n t he gr ipp er dur i ng t his pr oc ess is st ra ight f or wa r d
b eca use our a pplica t i on
r equir esver yl it t l epr ec is ion. Event hepr obl em off ocus i ngt heca mer a ont hepuzzl eca
nbeha ndl edsi
mp l y
by des i gni ng t he gr ipp er t o posit i on t he puzzl e a t a par t icula r pr edet er mi ned
pos it i on for vi ewi ng.
C ons equ ent l y, t hef ir st int el l i gent b eha vi or r equir edbyt hema c hi neist heext r a ct i
onofi nf or ma t i ont hr ou gh
a visua l mediu m.

It is i mp or t a nt t o r ea li
z e t ha t t he pr obl em fa c ed b y our ma c hi ne when l ooking a t t he puzz l e is not t ha t
of
mer el y pr odu ci ng a nd st or ing a n i ma ge. T ec hnol ogy ha s been a ble t o do t his for
yea r s a s in t he ca se of
t ra dit i ona l p hot ogr a phy a nd t el evisi on syst ems. Inst ea d, t he pr obl em i
s t o under st a nd t he i ma ge i n or der t o
ext r a ct t hecur
-

r ent st at usoft hepuzzl e(a ndp er ha psla ter t omonit or t he movement oft het il es ). Int
heca se
of our puzzl e
-
s ol vi ng ma c hi ne, t he poss ib l e i nt er pr et a t i ons of t he puzzl e i ma ge a r e r ela t i
vel y l i mit ed. W
e
ca n a ssume t ha t wha t a ppea r s is a lwa ys a n i ma ge conta ini ng t he digit s 1 t hr ou gh
8 in a well
-
or ga niz e d
pa t t er n. T he pr ob l em is mer el y t o ext r a ct t he a r r a ngement of t hes e di git s. F or
t his, we i ma gi ne t ha t t he
pict ur eoft hepuzzl eha sbeenenc odedi nt er ms

t he br ight ness l evel of a pa rt icula r pixel. Ass u mi ng a unif or m siz e of t he i ma ge (t


he ma chi ne hol ds t he
puzzl e a t a pr edet er mi ned l oca t i on i n fr ont of t he ca mer a ), our ma c hi ne ca n det
ect whic h t
i l e is i n whic h
posit i on by c ompa r ing t he diff er ent sect i ons of t he pi c t ur e t o pr er ecor ded t emp
la t es c onsist i ng of t he bit
pa t t er ns pr oduc ed b y t he indi vi dua l di git s used in t he puzzl e. As ma t ches a r e
found, t he condit i on of t h e
puzzl e is r evea l ed.

T his t e
c hni qu e of r ec ogniz i ng i ma ges is one met hod used i n opt ica l c ha r a ct er r ea der s.
It ha s t he dr a wba ck,
however , ofr equir i nga cer t a indegr eeofunif or mit yf or t hest yl e, siz e, a ndor i ent a t
ionoft hesymb olsbei ng
r ea d. In pa r t icula r , t he bit pa t t er n pr odu c ed

by a phys ic a ll y la r ge c ha r a ct er does not ma t ch t he t emp la t e f or


a sma l l er ver si on of t he sa me symb ol, even t hou gh t he sha pes ar e t he sa me. Mor
eover , you ca n i ma gi n e
how t he pr ob l ems incr ea s e i n dif fi cult y when t r yi ng t o pr oc ess ha ndwr it t en ma t
er ia l.
Anot h
er a ppr oa ch t o t he pr obl em of cha r a ct er r ecognit i on is ba sed on ma t chi ng t he
geomet r ic
cha r a ct er ist ics r at her t ha n t he exa ct a ppea ra nc e of t he symb ols. In such ca ses t
he di git 1 mi ght be
cha r a ct er iz ed a s a singl e ver t i ca l li ne, 2 mi ght be a n opened cur ved
l i ne j oi ned wit h a hor iz ont a l st ra ight
li ne a cr oss t he bot t om, a nd so on. T his met hod of r ec ogniz i ng symb ols invol ves t
wo st eps : T he f ir st is t o
ext r a ct t he f ea t ur es fr om t he i ma ge b ei ng pr oc ess ed, a nd t he s ec ond is t o c
ompa r e t he f ea t ur es t o t hos e of
know
n symb ols. As wit h t he t empla t e
-
ma t c hi ng a ppr oa ch, t his t ec hniqu e f or r ec ogni zi ng c ha r a ct er s is not
foolpr oof. F orinst a nc e, minor er r or sint hei ma geca npr oduc ea set ofent ir el ydif f er
ent geomet r i cfea t ur es,
a s in t he ca se of dist i ngu ishi ng bet ween a n O

a nd a C or , in t he ca se of t he ei ght
-
puzz l e, a 3 a nd a n 8. We
a r e for t una t e in our puzzl e a pplica t i on beca use we do not need t o under
-

st a nd i ma ges of gener a l t hr ee
-
di mens i ona l sc enes. C ons i der , for exa mp l e, t he a dva nt a ge we ha ve b y b ei ng a
ss ur ed t ha t t he

s ha pes t o b e
r ec ogni z ed (t he di git s 1 t hr ough 8) a r e isola t ed i n diff er ent pa rt s of t he pict ur e r
a t her t ha n a ppea r ing a s
over la ppi ng i ma ges, a s is common i n mor e gener a l s et t ings. In a gener a l p hot ogr
a ph, for inst a nc e, one is
fa ced not only wit h t he pr obl
em of r ec ogniz i ng a n object fr om diff er ent a ngles but a lso wit h t he fa ct t ha t
some p or t i ons of t he obj ect mi ght be hi dden fr om vi ew.

T he t a sk of under st a ndi ng gener a l i ma ges is usua ll y a ppr oa ched a s a t wo


-
st ep pr oc ess : (1)
i mag e
process i ng,
whi ch r ef er s t o

i dent i fyi ng c ha r a ct er ist ics of t he i ma ge, a nd (2)


i mage analys is,
whic h r ef er s
t o t he pr ocess of under st a ndi ng wha t t hes e cha r a ct er ist i cs mea n. We ha ve a lr ea
dy obs er ved t his di chot om y
i n t he c ont ext of r ec ogniz i ng symb ols by mea ns of t heir geomet r ic f ea t u
r es. In t ha t sit ua t ion, we f ou nd
i ma ge pr oc ess i ng r epr es ent ed by t he pr oc ess of i dent if ying t he geomet r ic f ea t ur
es f ou nd i n t he i ma ge a n d
i ma ge a na l ysis r epr es ent ed by t he pr oc ess of i dent if yi ng t he mea ni ng of t hos e f
ea t ur es.

Intr oduct i on t o Com put in g

CS101

VU
P ag e
287

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

I ma ge pr oc ess ing ent a i ls nu mer


ous t op ics. One is edge enha nc ement , whic h is t he pr oc ess of a ppl yi ng
ma t hema t i ca l t ec hni qu es t o cla r if y t he bou nda r i es bet ween r egi ons i n a n i ma
ge. I n a sens e, edge
enha nc ement is a n a t t empt t o c onver t a phot ogr a ph i nt o a line dr a wi ng. Anot
her a ct ivit y i n

i ma ge a na l ys is
is known a s r egion fi ndi ng. T his is t he pr oc ess of iden t if yi ng t hos e a r ea s in a n i ma
ge t ha t ha ve common
pr oper t i es such a s br ight ness , col or , or t ext ur e. S uch a r egi on pr oba bly r epr es
ent s a sect i on of t he i ma ge
t ha t bel ongs t o a singl e obj e
ct . (It is t he a bi l it y t o r ec ogniz e r egi ons t ha t a ll ows c omput er s t o a dd c ol or t o
ol d
-
fa shi onedbla c k
-
a nd
-

whit emot i onpi ct ur es. )S t illa not her a ct i vit ywit hi nt hesc op eofi ma gepr oc ess i ng
is s moot hi ng, whic h is t he pr oc ess of r emovi ng fla ws i n t he i ma ge
. S moot hi ng keeps er r or s in t he i ma g e
fr om confusi ng t he ot her i ma ge
-
pr oc ess i ng st eps, but too muc h smoot hing ca n ca use t he l oss of i mp or t a nt
i nf or ma t ion a s well.

S moot hi ng, edge enha nc ement , a nd r egi on fi ndi ng a r ea ll st eps t owa r d ident if yi
ng t he va r ious
comp onent s
i n a n i ma ge. I ma ge a na l ys is is t he pr oc ess of det er mi ni ng wha t t hes e c omp
onent s r epr es ent a nd ult i ma t el y
wha t t he i ma ge mea ns. H er e one fa c es suc h pr obl em s as r ec ogni zi ng pa r t ia lly
obst r uct ed obj ect s fr om
diff er ent per spect i ves. One a ppr oa ch t o
ima ge a na lys is is t o sta rt wit h a na ss umpt i on a bout wha t t he i ma ge
mi ght b e a nd t hen t r y t o a ss ocia t e t he c omp onent s i n t he i ma ge wit h t he ob j ect
s whos e pr es enc e is
conj ect ur ed. T his a ppea r st o be a na ppr oa ch a ppli ed by hu ma ns. F or inst a nc e, we
somet i mes f
i nd it ha r dt o
r ec ogni z e a n unexp ect ed ob j ect i n a set t i ng i n whic h ou r visi on is blur r ed, but
onc e we ha ve a clu e t o wha t
t he ob j ect mi ght b e, we ca n ea sil y i dent if y it .
T hepr ob l emsa ss ocia t ed wit h gener a li ma gea na lys isa re enor mous, a nd muc hr es
ea r ch i
nt hea r ea r ema i ns
t o b e done. I ndeed, i ma ge a na l ysis is one of t he f i el ds t ha t demonst r a t es how t a
sks t ha t ar e per f or med
qu ic kly a nd a ppar ent l y ea sil y b y t he hu ma n mi nd c ont i nu e t o c ha l l enge t he ca
pa bilit i es of ma c hi nes.

Mod ule 175


69. 69.

175.

Arti fic i al
Inte ll ige nc e: L ang uag e Process i ng

Anot her per c ept i on pr obl em t ha t ha s pr oven c ha l l engi ng is t ha t of under st a ndi


ng la ngua ge. T he succ ess
obt a i ned i n t r a nsla t ing f or ma l hi gh
-
l evel pr ogr a mmi ng la ngua ges i nt o ma chi ne la ngua ge l ed ea r l y
r es ea r cher s t o bel i eve
t ha t t he a bil it y t o pr ogr a m compu t er s t o under st a nd na t ura l la ngua ge wa s onl y
a few
yea r sa wa y. Indeed, t hea bil it yt ot ra nsla t epr ogr a msgivest hei l lusi ont ha t t hema
chinea ct ua ll yunder st a nds
t he la ngua ge b ei ng t r a nsla t ed.

Wha t t hes e r es ea r cher s fa il ed


t o un der s t a nd wa s t he de pt h t o whic h f or ma l pr ogr a mmi ng la ngua ges dif f er
fr om na t ura l la ngua ges suc h a s Englis h, G er ma n, a nd L a t in. P r ogr a mmi ng la
ngua ges a r e const r uct ed fr o m
wel l
-
des i gned pr i mit i ves so t ha t ea ch st at ement ha s onl y one gr a mma t ica l st r uct ur
e a nd onl y one mea n
-

i ng. In cont r a st, a sta t ement i n a na t ura l la ngua ge ca n ha ve mult ipl e mea ni ngs
dep endi ng on it s cont ext or
even t he ma nner i n whic h it is c ommu ni ca t ed. T hus, t o under st a nd na t ura l la
ngua ge, hu ma ns r el y hea vil y
on a ddit i ona l knowl edge.

F or exa mp l e, t he s ent enc es

Nor ma n R oc kwel l pa i nt ed peop l e.

a nd

C inder el la ha d a ba ll.

ha ve mu lt ip l e mea ni ngs t ha t ca nnot be dist i nguis hed by par sing or tra nsla t ing ea
ch wor d i ndep endent l y.
Inst ea d, t ou nder st a ndt hes es ent enc esr equir est hea bi l it yt oc omp
r ehendt hec ont ext i nwhic ht hest a t ement
is ma de. I n ot her
i nst a nc es,

t he t r ue mea ni ng of a sent enc e is not t he sa me a s it s lit er a l t r a nsla t ion. F or


exa mp l e,
Do you know wha t t i me it is?

Intr oduct i on t o Com put in g

CS101

VU

P ag e
288

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

been wa it i ng for a long t i me, it mi ght


T o unr a vel t he mea ning of a sta t ement i n a na t ura l la ngua ge t her ef or e r equir es
sever a l l evel s of a na l ys is.
T he fir st of t hes e is
synt ac ti c analysis,
whos e ma j or component is pa r sing. It is he
r e t ha t t he subj ect of t h e
sent enc e

Mar y ga ve John a bir t hda y ca r d. is r ecogniz ed a s


Mary
, whi l e t he subj ect of

John got a birt hda y ca r d fr om Ma r y.

is fou nd t o b e
John.

Anot her l evel of a na l ys is is ca ll ed


se ma nt ic analys is.
In cont r a st t o t he pa r sing
pr oc ess , whic h mer el y
i dent i fi es t he gr a mma t i ca l r ol e of ea ch wor d, sema nt ic a na lys is is c ha r ged wit h
t he t a sk of i dent if ying t he
sema nt ic r ol e of ea c h wor d i n t he st at ement . S ema nt ic a na lys is seeks t o i dent if y
suc h t hi ngs a s t he a ct ion
descr ib ed, t he a gen
t of t ha ta ct ion (whic h mi ght or mi ght not be t he subj ect of t he s ent enc e), a nd t he
ob j ect

ying t he sa me t hing.
A t hir d l evel of a na l ysis is
co nte xt ual analysis.
It is at this l evel t ha t t he cont ext of t he sent enc e is br ought
i nt o t he u nder st a ndi ng pr oc ess . F or exa mp l e, it is ea sy t o i dent if y t he gr a mma
t ica l r ol e of ea c h wor d i n t h e
sent enc e:

Th
e ba t fel l t o t he gr ou nd.

W e ca n even p er for m sema nt ic a na lys is by ident if ying t he a ct ion i nvolved a s


f alli ng,
t he a gent a s
bat ,
a nd
soon. But it isnot unt il wec ons i der t hecont ext oft hest a t ement t ha t t he mea ni ngoft
hest a t ement bec omes
cl ea r . In par
t icula r , it ha s a diff er ent mea ning i n t he c ont ext of a ba seba ll ga me t ha n it does in
t he c ont ext

W
eshou l dnot et ha t t heva r i ousl evelsofa na lysis

s ynt a ct ic, sema nt i c, a ndcont ext ua l

a r enot nec ess a r il y


i ndep endent . T he subj ect of t he s ent enc e
S t a mpedi ng ca t t l e ca n be da nger ous.

ist henoun
cat t l e
(modif i edbyt hea dj ect i ve
s t ampedi ng
)ifweenvisi on
t heca t t l es t a mp edi ngont heir own.
But t he subj ect is t he ger u nd
st ampedi ng
(wit h ob j ec t
cat t l e
) in t he c ont ext of a t r oubl ema ker whos e
ent er t a inment cons ist sofst ar t ingst a mp edes. T hust hes ent enc eha smor et ha none
gr a mma t i ca lst r uct ur e

whic h one is co
r r ect dep ends on t he c ont ext.

Anot her ar ea ofr es ea r chin na t ura lla ngua gepr oc ess i ngconc er nsa n ent ir edocu
ment r at her t ha nindi vidua l
sent enc es. Her e t he pr obl ems of conc er n fa l l i nt o t wo c a t egor i es :
i nfor mat io n ret ri eval
a nd
i nfor mat io n
extr act io n.
I nf
or ma t i onr et r i eva lr ef er st ot het a sk of i dent if yi ng docu ment st ha t r ela t et ot het
opi ca t ha nd.
An exa mp l e is t he pr obl em fa c ed by user s of t he Wor l d Wi de W eb a s t hey t r yt o
find t he sit es t ha t r ela t e t o
a par t icula r t opic. T he cur r ent st a t e of t he a r t is
t o sea r ch sit es for key wor ds, but t his oft en pr oduc es a n

i ng c onsi der ed.


T he diff icu lt y of obt a ini ngsuc hu nder
-

st a ndi ngist her ea son ma nya r et ur ni ngt ot ec hni qu essuc ha sXML


t o pr oduc e a sema nt i c W eb a s wa s int r oduc ed i n t he modu l e 75.

Intr oduct i on t o Com put in g

CS101

VU

P ag e
289

of
3 81
C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 176


70. 70.

176.

CS I mp ac t: CS i mp act o n S ocie ty

C omput er S ci enc e ha s i mpa ct ed l i ves of hu ma ns la r gel y. In t his modul e we wi ll l


ea r n t he pos it i ve a nd
nega t i ve i mpa ct s of C S on our soci et y.

Posi tiv e i mp act o f CS :

It ha s impr oved t he c ommu nica t i on bet ween p eop l e.

Incr ea s ed a ccess t o educa t i ona l


i nf or ma t i on via t he I nt er net
Incr ea s ed pr oduct i vit y of peop l e a s now t heir ma nua l wor k ha s r educ ed si gnif ica
nt l y.

Exponent ia l busi ness gr owt h

F a st er r espons e t i mes (for exa mp l e, ema i l, i nst a nt mess a gi ng a nd c ha t )

Negativ e I mp act:

P eopl e a r e wor ki ng in sit


t i ng p osit i on a nd t hus ha ve mor e cha nc e t o devel op ob es it y.

Exposur e t o i na ppr opr ia t e ma t er ia l via t he I nt er net

Incr ea s ed cr i me a nd a cc ess t o pr iva t e i nfor ma t i on

Ha cki ng ba nk a ccou nt a nd t r a nsfer money t o your a ccount


P eopl ea r enow over
-
dep endent ont ec hn
ology. T hey event r yt oca t cht hep eop l eonl i ne evenift h e
per son is sit t i ng nea r t hem geogr a phi ca ll y. T his ha s dec r ea sed t he s oc ia l i nt er a
ct ions a s wel l.

Intr oduct i on t o Com put in g

CS101

VU

P ag e
290

of
3 81
C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 177


71. 71.

177.

CS I mp ac t: CS Imp act o n H ealt h

C omput er S ci enc e ha s bot h pos it i ve a nd nega t i ve i mpa ct s on hea lt h.

Posi tiv e i mp act

Ea sy a ccess t o onli ne hea lt h c ent er s

W e ca n t a ke onl i ne a ppoi nt ment

W e ca n r ec ei ve r ep or t s via ema i l a t home


Hospit a ls ca n b e ma na ged mor e ef fi ci ent l y

Onli ne hea lt h
t ips/ iss u es a r e a va ila bl e.

Hea lt h news ca n b e vi ewed onl i ne.

Negativ e i mp act

C omput er wr ist s

T ypi ng t oo mu c h. T his cr ea t es iss u es in t he ha nds.

Eyes i ght

eye is not mea nt t o l ook 2D f or l ong a mount of t i me. T his i ncr ea ses t he r isk of ey e
dis ea ses.
Hea r i ng l oss is mor e c ommon i n t hos e
l ist ening t o

hi gh volu me musi c on c omput er .

S ocia l Isola t ion

C ommu ni ca t ion Iss u es

P ost ur e cou l d l ea d bone issu es

R a dia t ionDa ma gewhent hedevic eisr unni ng. It sbet t er t oputoffa llsuchdi git a ldevi c
esesp ec ia ll y
mo

Intr oduct i on t o Com put in g


CS101

VU

P ag e
291

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 178


72. 72.

178.

CS I mp ac t: CS Imp act o n E nvi ro nme nt


C omput er S ci enc e ha s bot h pos it i ve a nd nega t i ve i mpa ct s on t he envir onment a s
wel l.

Posi tiv e i mp act

P a per less

Onli ne r ea di ng a nd publ is hi ng.

Amer ica ns use a bout

680 pounds

of pa per

per per son, per yea r

T his a mou nt s t o a bout

85 mil l i on t ons of pa per or 2 bill i on t r ees.


T he a ver a ge Amer i ca n hous ehol d t hr ows a wa y

13, 000 pi ec es of pa p er

(
a r ound 1 b il l i on t r ees i n
t ot a l i n US A) ea ch yea r . Most in t he f or m of pa cka gi ng a nd ju nk ma il.

Due t o t he usa ge of c omput er , t he a bove wa st e of t r ees is mi ni mi zi ng in t he wor l d.

Negativ e i mp act

In off ic es, peop l e pr i nt unnec ess a r il y.

C omput er sar ema de


fr omhea vymet a ls(L ea d, mer cur y, B er yll iu m, C a dmiu m, P C V)whent hr own
-
a wa y ca use wa t er cont a mi na t i on

a nd a ir pol lut i on.

E
-
wa st e is sent t o devel op i ng cou nt r i es wher e peop l e ext ra ct ma t er ia ls fr om t hes
e el ect r oni cs such
a s gol d, sil ver , a nd c opp er .

T hey ex
t r a ct t hem b y bu r ni ng t he s ub s t a nces a nd t ha t pr oc es s r el ea s es ha za r dous s
mok e i nt o t he
a ir .

T hep eop l epr es ent a r oundt hee


-
wa st ega indis ea s essucha sski nca nc er , bra inda ma ge, lu ngca nc er ,
ki dney dis ea s e

Usa ge of ener gy ha s a lso incr ea s ed wit h t he use


of c omput er .

Intr oduct i on t o Com put in g

CS101

VU
P ag e
292

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 179


73. 73.

179.

CS I mp ac t: E t hi c al Is s ues

Ethi ca l iss ues a r e r ela t ed t o mor a l pr inc ipl es or t he branc h of knowl edge dea l i ng
wit h t hes e. Quest ions of
et hics a nd l ega lit y a r e ess ent ia l i n ma ny i ndust r ies. Doct or s, t ea cher s, gover
nment of fi c ia ls a nd
business p eop l e

a ll ha ve l ega l a nd et hica l over si gh


t t o cont r ol how t heir pr of ess i ons funct i on. Inf or ma t io n
t ec hnol ogy, by cont r a st , ha s no over a r chi ng st a nda r diz a t ion in pla c e. However ,
as inf or ma t i on t ec hnol ogy
bec omes i ncr ea si ngly i nflu ent ia l, t he et hica l a nd l ega l cons i der a t ions bec ome si
mi la r ly r el eva
nt . Her e a r e
t he fi ve most pr ess i ng et hica l a nd l ega l iss u es c onfr ont i ng t he i ndust r y t oda y.

Pr iv acy

Most peopl e ha vet heir per sona l da t aspr ea dt hr ou ghout t hedi git a lwor l d. Event hi
ngst hou ght t obesecur e,
such a s ema i l or pr iva t e a ccou nt s, ca n be
a cc ess ed by uni nt ended s our c es. Most emp l oyer s a ct ivel y c hec k

cons i der a t ions. Do p eop l e know how t heir a ccou nt s ar e monit or ed? T o wha t ext
ent is suc h moni
t or i n g

pr iva cy c ompl et el y.

Digi t al O w ne rs hip

Di git a l mediu ms ha ve a l lowed i nf or ma t i on t o f l ow mor e fr eel y t ha n b efor e. T


his exc ha nge of i dea s c omes
wit h

a lega l a nd et hi ca l ba ckla sh. How ca n owner ship be est a blis hed i n t he di git a l r ea l
m? T hi ngs ca n be
ea si l y c opi ed a nd pa st ed onl i ne, whic h ma kes i nt el l ect ua l pr oper t y ha r d t o c
ont r ol. L ega l not i ons suc h a s
cop yr i ght ha ve st r uggl ed t o keep up wit h t he di git
a l er a . C ompa ni es i n t he mus ic a nd ent er t a inment
i ndust r ies ha ve pushed f or gr ea t er l ega l pr ot ect i ons f or int el l ect ua l pr oper t i es
whi l e ot her a ct ivist s ha ve
sou ght t o pr ovide gr ea t er fr eedoms f or t he ex c ha nge of i dea s in t he di git a l r ea l
m.

Dat a G at he ri ng

O
n some l evel, ever yone knows t ha t t heir onl i ne l i ves a r e monit or ed. T he Unit ed S
ta t es ha s even pa ss ed
l egisla t i on a ll owing t he gover nment t o a ct ivel y monit or pr iva t e cit i z ens in t he na
me of na t i ona l secur it y.
T hes emea sur esha ver evi veda deba t ea bout wha t

inf or ma t i onca nbega t her eda ndwhy. T hisdeba t ea ppli es


on a sma l l er sca l e a s wel l b eca us e c ompa ni es need t o c onsi der wha t inf or ma t i
on t o c ol l ect fr om t heir
emp l oyees. T hisiss u einvokesaqu est i onofcons ent . Dopeop l eknowwha t inf or ma t
ionisbei ngmon
it or ed?
Do t hey ha ve a r ight t o know how t heir da t a is being us ed?

Intr oduct i on t o Com put in g


CS101

VU

P ag e
293

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 180


74. 74.

180.

CS I mp ac t: S oftw ar e L ice nses and I nfor matio n Pri vacy


S oft wa r e li c ens es t yp ica l l y pr ovi de end user s wit h t he r i ght t o one or mor e c opi
es of t he s oft wa r e wit hout
vi ola t i ng

c op yr i ght s
. T he li c ens e a ls o def i nes t he r esp onsib i l it i es of t he pa r t ies ent er i ng i nt o t he l
ic ens e
a gr eement a nd ma y i mp os e r est r ict i ons on how t he soft wa r e ca n b e us ed.

S oft wa r e l ic e
ns i ng t er ms a n d
condit i ons usua ll y i nc lude

fa ir use

of t he s oft wa r e, t he li mit a t i ons of l ia bi l it y, wa rr a nt i es a nd disc la i mer s


a nd pr ot ect ions i f t he soft wa r e or it s use infr i nges on t he

int el l ect ua l pr oper t y

r ight s of ot her s.

S oft wa r e li c ens es t yp ica l l y a r e eit her

pr opr iet a r y
,

fr ee

or
op en s our c e
, t he dist i nguis hing f ea t ur e bei ng t h e
t er ms under whic h us er s ma y r edist r ibut e or copy t he s oft wa r e f or fut ur e

devel op ment

or use.

Info r mat io n Pr iv acy

Da t a pr iva c y, a lso ca ll ed i nf or ma t i on pr iva c y dea ls wi t h t he a bi lit y a n or ga


niza t i on or i ndi vi dua l ha s t o

det er mi ne wha t da t a in a comput er syst em ca n be s ha r ed wit h t hir d pa r t ies.

(C OP P A)
-

gi ves pa r ent s c ont r ol over wha t inf or ma t i on websit es ca n c oll ect fr om t heir ki
ds.

H ealt h I ns ur ance Po rt ab i li ty and Acco unt abi l it


y Ac t

(HIP P A)
-

ensur es pa t ient confi dent ia l it y f or a ll hea lt hc a r e


-
r ela t ed da t a .
E lect ro nic Co mmu ni c at io ns Pr ivacy Act

EC P A ext ends gover nment r est r ict i ons on wir e t a ps t o inc lu de t r a nsmiss i ons of
el ect r onic da t a .

Vid eo Pr iv acy Prote ct io n Act

P r event s
wr ongfu l disc l osur e of a n i ndi vidua l 's p er sona ll y i dent if ia bl e i nf or ma t i on st em
mi ng fr om t heir
r ent a l or pur cha se of a udi ovisua l ma t er ia l.

G ramm
-
L e ac h
-
B li l ey Act

Ma nda t es how f i na nc ia l i nst it ut i ons must dea l wit h t he pr iva t e i nf or ma t i on of


i ndi vi dua ls.

Intr oduct i on t o Com put in g

CS101

VU
P ag e
294

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 181


75. 75.

181.

CS I mp ac t: I nte l lec t ual Pro pe rty

Int el l ect ua l pr op er t y (IP ) is idea s, inf or ma t ion a nd knowl edge. In t he Uni ver sit y
c ont ext IP ca n be vi ewe d
a s t he r esu lt s a nd out c omes of r es ea r ch
eca us e
it is vi ewed a s a t ra da ble c ommodi t y. Int ell ect ua l pr oper t y r i ght s (IP R ) a r e
spec if ic l ega l r ight s whic h
pr ot ect t he owner s of IP . IP R ca n be subdi vi ded i nt o t he ma jor ca t egor i es b el ow.

Pat e nt

A pa t ent is a l ega l monop ol y la st i ng 20 yea r s gr a nt ed i n

exc ha nge f or descr ib i ng a n i nvent i on a nd pa yi ng


f ees t o t he P a t ent Offic e. A pa t ent posit i on is dest r oyed by publ ic disc l osur e of t
he i dea bef or e a pa t ent
a pplica t i on is fi l ed ( exc ept for a shor t gr a ce p er iod in t he US ). T hink pa t ent bef
or e you publ is h.

C
opyrig ht

C opyr i ght a ppli es t o lit er a r y a nd dr a ma t ic wor ks, ar t istic a nd mus ica l wor ks, a
udi o a nd vi deo r ec or di ngs,
br oa dca st sa nd ca ble t r a ns missi ons. C opyr i ght is a lso t he usua l wa y of pr ot ect i
ng soft wa r e, a lt hou gh some
soft wa r e ma y b e pa t ent ed if it is a

funct i ona l pa r t of a n i nvent i on. C op yr i ght a r ises a ut oma t ica l l y

it does
not need t o be a ppli ed f or
a nd la st s 70 yea r s a ft er t he dea t h of t he a ut hor .

Dat ab ase rig ht

Da t aba se r ight s a pply t o da t a ba ses whic h a r e not pr ot ect ed by c op yr i ght (a n EU


r i ght on
ly

ma xi mu m
dur a t ion is 15 yea r s).

Desig n r ig ht

Des i gnr i ght a ppli est oa spect s oft hesha p e or conf i gur a t ionofa na r t icl e. Unr egist
er ed des i gnr i ght ( whi c h
cover s comput er chips, for exa mp l e) ca n pr ot ect i nt er na l or ext er na l f ea t ur es.
In t he ca se of r eg
ist er ed
des i gns, t he f ea t ur es must a ppea l t o a nd b e ju dged b y t he eye. (R egist er ed des i
gn r i ght s a r e pr ot ect ed for a
ma x i mu m of 25 yea r s. )

T rad e mar k

A
t r a dema r k

is a ma r k (l ogo) or ot her dist i nct i ve si gn a ppli ed t o or ass ocia t ed wit h pr odu ct s


or ser vic es,
whic h does not descr ib e t he pr odu ct s or ser vi c es. (Onc e r egist er ed t he t r a dema r
k IP R is unli mit ed. )

Confi de nt i al i nfo r mat io n

C onfi dent ia l i nf or ma t ion is knowl edge whi c h only you poss ess a nd which you ha ve
only r evea l ed u nder a
non
-
disc losur e/ c onf i dent ia l it ya gr eement . T hec ompr ehens i vet a bl eha sbeens hownt
ohi ghl i ght t he det a i ls
of a ll t he a bove i nt ell ect ua l pr op er t i es.

IPR

Covers

Need to
ap p ly?

Maxi mu m
d ur at io n

P a t ent

Invent i ons

Yes

20 yea r s
C opyr i ght

Lit er a r y,
musica l,
a rt ist icwor ks,
a nd soft wa r e

No

70yea r sa ft er
dea t h of
a ut hor

Intr oduct i on t o Com put in g

CS101

VU

P ag e
295
of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

R egist er ed
des i gn

I ma ge

l ook
a nd f eel

Yes

25 yea r s

R egist er ed
t ra dema r k

Na me, l ogo

Yes
Unli mit ed

C onfi dent ia l
i nf or ma t ion

Unpubl is hed
secr et
i nf or ma t ion

No

Unl i mit ed

Da t aba se
r ight

Da t aba ses

No

15 yea r s

S uccess fu l ma na gem ent ofIP Rpr ovi dest he mea nsbywhic hi ndi vi dua lsa ndi nst it ut i
onsa r ea blet opr ot ect
t heir cr ea t ive out put
fr om i mit a t or s.
An under st a ndi ng of IP a nd IP R s isa n incr ea si ngl y i mp or t a nt a spect of Univer sit
y a nd busi ness l if e. Now,
mor e t ha n ever , IP isr ec ogni z ed a sa tra da ble c ommodi t y.

Intr oduct i on t o Com put in g

CS101

VU

P ag e
296

of
3 81
C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 182


76. 76.

182.

CS I mp ac t: S ec ur ity

Co mp ut ersec ur ity
, a lsoknowna s

cyber
-
sec uri ty

or

IT sec ur ity
, ist hepr ot ect i onofinf or ma t i onsyst ems
fr om t heft or da ma ge t o t he ha r dwa r e, t he soft wa r e, a nd t o t he i nf or ma t i on on
t hem, a s well a s fr om
disr upt ion or misdir ect i on of t he ser vic es t hey pr ovi de. It inc ludes cont r oll i ng phy
si ca l a ccess t o t he
ha r dwa r e, a s wel l a s pr ot ect i ng a ga i nst ha r m t ha t ma y come via net wor k a cc
ess , da t a a nd c ode i nj ect i on,
a nd du e t o ma lpr a ct ic e by op er a t or s, whet her int ent i ona l, a ccident a l, or due t o
t hem b ei ng t r ic ked int o
devia t i ng fr om s ecur e pr oc ed
ur es.
What ar e t he co ncer ns of co mp ut er sec ur ity?

C omput er S ecur it y is conc er ned wit h f our ma i n a r ea s:


77. 77.

1. C onf i dent ia l it y:
-

O nl y a ut hor iz ed us er s ca n a ccess t he da t a r esour c es a nd i nf or ma t i on.


78. 78.

2. Int egr it y:
-

Only a uthor iz ed us er s shou l d b e a ble t o modif y


t he da t a when needed.
79. 79.

3. Ava i la bil it y:
-

Da t a s houl d b e a va i la bl e t o us er s when needed.


80. 80.

4. Aut hent i ca t ion:


-

a r e you r ea l l y com mu nica t i ng wit h whom you t hi nk you a r e commu nica t i ng wit h

Why is co mp ut er sec ur ity i mp ort ant?

P r event i on of da t a t heft such a s ba nk

a ccou nt nu mb er s, cr edit ca r d inf or ma t ion, pa sswor ds, wor k r ela t e d


dep end on t he s ecur it y of t he da t a pa t hs.

Da t a pr es ent in a comput er ca n a lso be misus e


d by una ut hor iz ed int r usi ons. An int r uder ca n modif y a nd
cha nge t he pr ogr a m sour c e c odes a nd ca n a ls o use your pict ur es or ema i l a ccou nt
s t o cr ea t e der oga t or y
cont ent such a s por nogr a phi c i ma ges, fa ke misl ea ding a nd of f ens ive s oc ia l a cc
ount s.

Ma lic i ousi nt
ent sca na lsob ea fa ct or incomput er secur i t y. Int r uder soft enus eyour comput er sfor a
tt a cki ng

comput er syst em t o cr ea t e da t a loss . DDOS a tt a cks ca n be ma d


e t o pr event a cc ess t o webs it es by cr a shin g
t he ser ver .

Ab ovefa ct or si mp l yt ha t your da t a shoul dr ema insa f ea ndc onf i dent ia l. T her ef or


e, it isnec ess a r yt opr ot ect
your comput er a nd henc e t he need for C omput er S ecur i t y a r ises.

What is fir ew al l?

A f ir ewa l
l is a secur it y
-
c onsc ious pi ec e of ha r dwa r e or soft
-
wa r e t ha t sit s bet ween t he I nt er net a nd your
net wor kwit ha singl e
-
mi ndedt a sk:pr event i ngt hemfr omget t i ngt ous. T hefir ewa l la ct sa sasecur it ygua r d
bet ween t he Int er net a nd your loca l a r ea net wor k (
LAN ). Al l net wor k t r a ffic int o a nd out of t he L AN must
pa ss t hr ough t he f ir ewa ll, whic h pr event s una ut hor iz ed a ccess t o t he net wor k.

Intr oduct i on t o Com put in g

CS101

VU

P ag e
297

of
3 81
C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 183


81. 81.

183.

CS I mp ac t: Priv acy

Indi vi dua l 'sr ight t o ownt he da t a gener a t edby hisor her lif ea nda ct i vit i es, a ndt o
r est r ict t he out wa r dfl o w
of t ha t da ta . Pr iva c y uses t he t heor y of na t ura l r ight s, a nd gener a ll y r esponds t o
new i nf or ma t ion a nd
com mu nica t i on t ec hnol ogi es. In Nor t h Amer i ca ,

Sa muel D. Warr en

a nd

Louis D. Bra ndeis

wr ot e t ha t
pr iva cy is t he "r i ght t o be l et a lone".

Fro m w here d at a co mes fro m:

S ocia l S it es
(F a ceb ook, t wit t er )
T el ep hone c ompa ni es ( mob il e net wor ks )

S ma r t cit y ca mer a s on r oa d

E ma ils

P er sona l S oft wa r e

P a sswor ds, logi ns et c

H ow to hand le o n i nte r ne t

E ma ils ca n b e encr ypt ed

Anonymiz i ng
pr oxies

Anonymiz i ng

net wor ks

Pr iv acy I nfor mat io n

P r iva cy i nf or ma t i on of fa mous websit es is gi ven b el ow:

Googl e:

ht t ps
:/ /
pol ic i es. googl e. c om/ pr i va c y

ms n:

ht t ps:/ /
www. msn. c om/ en
-
us/ a ut os/ pa rt ner / pr iva c yp ol i c y
Wha t sApp :

ht t ps:/ / www. wha t sa pp. com/ l ega l/ #


pr i va cy
-
pol ic y

E PIC

Elect r onic P r iva c y Inf or ma t i on C ent er

Indep endent non


-
pr of it r es ea r ch c ent er i n

Wa sgi ngon D. C .

It s miss i on is t o f ocus publi c a t t ent i on


on emer ging P r iva c y a nd r ela t ed

hu ma n r ight s
iss u es.

EP IC ha s pur sued sever a l succ ess fu l consu mer pr iva cy c omp la i nt s wit h t he

US F eder a l T ra de
C ommiss i on, conc er ni ng

S na pcha t

(fa ult y pr iva cy T echnol ogy), Wha t sAp

(pr iva c y pol i cy a ft er


a cquis it i on by F a cebook (c ha nges i n user pri va cy
set t i ngs ),

Googl e

(r ol l
-
out of
Googl eBu zz),

Micr os oft

(Ha i lst or m l og
-
i n), iss u es.

PI
P r iva cy I nt er na t i ona l

Intr oduct i on t o Com put in g

CS101

VU

P ag e
298

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan


C ha r it y or ga niza t i on of London, UK

Pr ior ity Are as:

C ha ll engi ng Da t a Exploit a t ion

Bui l di ng t he Gl oba l P r iva cy M ovement

C ont est i ng S ur veil la nc e

Intr oduct i on t o Com put in g

CS101

VU
P ag e
299

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule

184
82. 82.

184.

CS I mp ac t: S oci al Is s ues o f IT

T he gr owt h i n t he a va ila bi l it y of a ffor da bl e comput i ng t ec hnol ogy ha s ca used a


nu mb er of ma j or shift s i n
t he wa y t ha t soci et y op er a t es. T he ma j or it y of t hes e ha ve b een for t he bet t er ,
wit h home c omput er s a nd t he
i nt er net pr ovi di ng unli mit ed a cc ess t o a l l of t he i nf or ma t ion ever cr ea t ed a nd
disc over ed by hu ma nit y.
T her e a r e, however , some l ess pos it i ve s oc ia l iss u es gener a t ed a sa dir ect r esu
lt of t ec hnol ogica l a dva nc es.
In t he i nt er est s of ba la nc e, it is i mp or t a nt

t o a na lyz e t hes e a nd a ss ess t he sever it y of t heir i mpa ct so t ha t


st eps ca n be t a ken t o b et t er under st a nd a nd c omba t t he nega t i ve ef f ect s.
83. 83.

1.

Co mmuni c atio n B re akdow n

S ocia li zi ng wit hi n a fa mi l y unit ha s a lwa ys b een i mp or t a nt , as it str engt hens t


he b onds
b et ween us a nd
ensur es cohes i on wit hi n t he gr oup. But wit h mor e a nd mor e hous ehol ds owni ng
sever a l comput er s a nd
nu mer ouspor t a bledevic esgr a nt i nga cc ess t oi nf or ma t iona ndent er t a inment ,
somea r guet ha t t hisisl ea din g
t o a la ck of fa mi l y c ommu ni ca t i on.
84. 84.

2.

De famat io n o f C har ac ter

T he onl y mea ns of get t i ng i n t ouc h wit h ma j or cor por a ti ons or fa mous peop l e i n
t he publ ic eye pr ior t o t he
a dvent of di git a l c om mu ni ca t ion wa s via a st iffl y wr it t en l et t er . T his wa s, of c
our se, a cc ess ib l e onl y t o t he
i nt ended r ec ip i
ent a nd t hus a ver y pr iva t e wa y f or t he disgr unt l ed t o vent t heir spleen. But fir st
mess a g e
boa r ds a nd now socia l media s er vic es li ke F a c eb ook a nd T wit t er ar e bei ng us ed t
o defa me p eop l e a n d
business es i n a n int r i ns ica l l y publi c ma nner .
85. 85.

3.

Ide nt ity T he ft

F ra u
d is a not her spur ious a ct ivit y t ha t ha s been a bl e t o evol ve i n t he wa ke of ea si l y a
ccess ibl e c omput er s
a ndt hei nt er net . P er ha psmost pr obl ema t i ca ndpr eva l ent oft heva r i ousfra udul ent
a ct ivit i esisi dent it yt heft ,
i n whic h p er sona l det a i ls of i nnoc ent p e
opl e a r e ha r vest ed b y a t hir d pa r t y so t ha t t hey ca n b e us ed f or
ma li c ious pur pos es. T his inc ludes ca rr yi ng out il li c it onli ne t r a nsa ct ions a nd ot
her da ma gi ng a ct ivit i es t ha t
ca n ha ve s er i ous r a mi fi ca t ions.
86. 86.

4.

Cyber B ul ly i ng

As wit h t he defa ma t i on of publ ic f


i gur es, t he i nt er net a nd comput er s ha ve a lso ma de it ea si er for spit efu l
peop l et oa t t a ckpeopl et hey knowp er sona l l ya swel la sper f ect st r a nger svia t hea
nonymouspla t f or mst ha t
a r e a va ila bl e t o t hem.
87. 87.

5.

G ami ng Add ic tio n

Whilst comput er s a nd t he i nt er net ha


ve ma de it ea si er for ga mb l i ng a ddict s t o get t heir fix, a new t yp e of
a ddict i onha sa lsoa r is en, i nt hef or mofa ddict i ont o vi deoga mes. T his issomet hi ngt
ha t ca ni mpa ct p eop l e
of a ll a ges a nd l ea ds i nevit a bly t o a nu mb er of pr obl em s, fr om t he soc ia l t o
t he f i na nc ia l.
88. 88.

6.

Pr iv acy

Whi lst hi gh pr ofi l e ca ses of onl i ne i dent it y t heft a nd fr a ud shoul d ha ve ca used


peop l e t o b ec ome mor e
ca r eful a bout how t hey us e t heir per sona l i nf or ma t i on, issu es of pr i va cy a nd a la
ck of a ppr ec ia t ion f or t he

Intr oduct i on t o Com put in g

CS101

VU

P ag e
300

of
3 81
C opy rig htVi rtual U ni v ersi ty ofP aki stan

r isks a r e st il l wi despr
ea d. T his ext ends b eyond s i mp l y gi vi ng a wa y pr iva t e da t a via cha t r ooms, mess
a ge
boa r ds a nd e
-
c omm er c e s it es a nd ext ends i nt o t he c omp r omisi ng wor l d of soc ia l media .
89. 89.

7.

H ealt h & Fit ness

W e a r e l i vi ng i ncr ea si ngl y s edent a r y l if est yl es, b eca use c omput er s ar e r e


movi ng t he need f or us t o
physi ca ll y ca r r y out ma ny t a sks,a s well a s keepi ng us root ed t o one spot t hr ou
ghout our wor king da ys a nd
dur i ng our l eisur e t i me.
90. 90.

8.

E d uc at io n

T he educa t i ona l pr op er t i es of c omput er s ar e wel l known a nd uni ver sa ll y


la uded but
ha vi ng a ll t he
i nf or ma t ion i n exist enc e on t a p ha s it s own iss u es. In pa rt icula r , t he pr a ct ice of
pla gia r is m ha s bec ome a
ma j or pr obl em, a s st udent s ca n si mpl y c opy a nd pa st e whol e c hu nks of t ext fr om
onl i ne s our ces wit hout
a t tr ibut ing t he wor k t o a nyone
els e. T his ha s become t he ba ne of educa t i ona l i nst it ut i ons, whic h t end t o
come down ha r d on det ect ed pla gia r ist s in or der t o disc our a ge si mi la r a ct ivit i es
fr om ot her s.
91. 91.

9.

T error is m & Cr i me

C omput er s ha ve b een a posit i ve f or c e i n a l lowi ng f or t he cr ea t i on of g


l oba l movement s a nd r ight eous
a ct ivis mi na nu mb er offor ms. However , t he ot her si deoft hec oi nist ha t t er r or ist sa
ndor ga niz edcr i mi na l s
a lso expl oit t he web for t heir own nefa r i ous pur poses.
92. 92.

10.

Access to for b id de n li ter at ur e

C omput er ha sma dea va i la bl et


hea cc es s t ot hef or bi dd enl it er a t ur e. T his ha s l edus t oma nys oc ia lpr obl em s
i n t he soci et y.
Intr oduct i on t o Com put in g

CS101

VU

P ag e
301

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 185


93. 93.

185.

CS I mp ac t: Co nte nt Fi lt er i ng, E mai l


-
S p ams and L aws

C ont ent fi lt er i ng, in t he most gener a l sens e, i nvol ves u sing a pr ogr a m t o pr event
a cc ess t o
cer t a in it ems,
whic h ma y b e ha r mfu l if op ened or a cc ess ed. T he mos t common it ems t o f i lt er a r
e ex ecut a bl e, ema i ls or
webs it es.

H ow it works

C ont ent f i lt er ing wor ks b y ma t chi ng st r ings of c ha r act er s. When t he st r i ngs ma


t ch, t he c ont ent is not
a ll owed t hr ou gh. C ont ent fi lt er s ar e oft en pa r t of Int er net fir ewa lls. In suc h a
usa ge cont ent f ilt er i ng is
ser vi ng a secur it y pur pos e.
C ont ent filt er i ng
is a lso used t o i mp l ement compa ny poli ci es r ela t ed t o
i nf or ma t ion s yst em usa ge. F or exa mpl e, it 's c ommon t o f i lt er webs it es l i ke F a
ceb ook, yout ub e et c whic h
a r e consi der ed unr ela t ed t o wor k.

S pam e mails

As ema i l

spa m

cont i nu es t o b ec ome a ma j or is s ue, go ver nment s ar oun d t he wor l d ha ve pu t s


pec if ic
r egula t i ons
i n pla c e t o pr ot ect t heir cit iz ens fr om spa ms .

I mpo rt ant L aws

C AN
-
S P AM Act i n US

-
S pa m L egisla t i on (C AS L)

Ant i
-
spa m la w i n Eur op e

S pa m

Act of 2003 in Aust r a lia


Afr i ca , Asia a nd S out h Amer ica ha ve l oos er spa m
-
la w r equir ement s

CAN
-
S PAM Ac t
94. 94.

1.
95. 95.

2.
96. 96.

3.

Ident if y t he mess a ge a s a na d
97. 97.

4.
98. 98.

5.

Honor opt
-
out r equ est s pr omptl y
99. 99.

6.

Monit or wha t ot her s ar e doi ng on your beha lf

Majo r req ui re me nts


As k for per miss i on b ef or e a ddi ng ema i ls

Us er cou l d i dent if y you a s S ender

Do not gi ve ema i l a ddr ess t o ot her s

B e honest

Intr oduct i on t o Com put in g

CS101

VU
P ag e
302

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 186


100. 100.

186.

CS I mp ac t: C hil dre n
Prote ct io n and E le ctro ni c T he ft

T her ear elot sofr ea sonswhyp eopl est a r tusingpar ent a lcont r ols. P er ha pst ost opla t
eni ght phonec hec ki ng.

to
r educ e t he
t ot a l a mou nt of t i me b ei ng sp ent on scr eens i n gener a l. T her e a r e ma ny mor e ca
ses. Ult i ma t el y
i n t heir use of di git a l t ec hnol ogy.

W e hop e a nd a i m
t o enc our a ge a n a t t it ude a nd a ppr oa ch i n our kids t ha t wi ll r ender pa r ent a l c
ont r ol s

punis hment or a ut hor it a r ia n cont r ol but is a genu i ne t ool for buil di ng


r esp onsib i lit y a nd r i ght pr ior it i es i n

phone c ont r a ct.

T he f oll owi ng r isks a r e invol ved i n suc h sc ena r ios:

C ont ent R is ks.

C ont a ct R isks

Onli ne
Ma r ket i ng

Over sp endi ng
Elect r onic T heft

Inf or ma t i on P r iva cy

Inf or ma t i on S ecur it y

Conte nt Ris ks

Il l ega l C ont ent

Ha r mful C ont ent

Ha r mful Advi c e

Cont act R is ks

Onli ne Ha r a ss ment
C yb er bull yi ng

Il l ega l i nt er a ct i ons

P r obl ema t ic c ont ent sha r ing

O nl i ne M ar ket i ng

Ina ppr opr ia t e or unsuit a bl e pr oduct s

Il l ega l a nd Age
-
r est r ict ed pr oduct s

E lect ro nic T he ft

Onli ne F r a ud
Onli ne sca m

Ident if y t heft

Intr oduct i on t o Com put in g

CS101

VU

P ag e
303

of
3 81
C opy rig htVi rtual U ni v ersi ty ofP aki stan

Info r mat io n Pr iv acy

P er sona l da t a col l ect i on fr om c hil dr en

Info r mat io n S ec uri ty

Ma lic i ous code

C ommer cia l spywa r e

How to
protect

W eb F ilt er i ng

P ar ent a l c ont r ol s oft wa r e


Ena bl e sa fet y f ea t ur es

Gui de ki ds

Intr oduct i on t o Com put in g

CS101

VU

P ag e
304

of
3 81
C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 187


101. 101.

187.

Word Process i ng: MS Word

One of t he most i mp or t a nt a pplica t ion soft wa r e a r e t he wor d pr oc ess or s. T hes


e soft wa r e help i ndi vi dua ls
a nd c ompa ni es t o pr epa r e di git a l docu ment s i n a prop er for ma t . One of t he fa
mous wor d pr oc ess i ng
soft wa r e is MS Wor d, whic h is i nclu ded i n t he Micr os oft

Offic e.

F igur e 130 is t he scr een shor t for wi ndows XP t o open MS Wor d 2007.

Fi gure
130
: St art Menu t o l aunch MSW ord

T he O ffice

B utto n

F igur e 130 shows t he MS wor d home r ibb on.


Fi gure
131
: MSW ord Home ri bbon

Intr oduct i on t o Com put in g

CS101

VU

P ag e
305

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan


T hec olor fu lic onint het op
l eft
-
ha nd

cor ner oft he


Wo rd
wi ndow(F i gur e131)ist he
O ffi ceb utto n.
When you point t o t he Of fi c e butt on wit h t he mous e point er it wi ll t ur n or a nge
.
W hen you c li c k t he l eft
mous e but t on whi l e p oi nt i ng t o t he Of fi c e but t on, a menu wi l l op en t ha t cont a i
ns some of t he most
com monl yus edc omma ndswhic hus edt ob ef ou ndi nt he
File
dr op
-
downmenui nea r l i er ver si onsof
Word
.
Rece nt doc u me nts
a r e l ist ed i n t
he
R ece nt Doc u me n ts
pa ne on t he r i ght s i de of t he menu a s s ho wn i n
F igur e 132.
Fi gur e
132
: MSW ord home ri bbon aft er cl i ck

T he r ibbon is di vi ded i nt o T a bs, Gr oups, a nd C omma nds.

Ea ch t a b opens a dif f er en
t r ibbon wit h gr oups of comma nds i ns i de it . Micr osoft ha s tr ied t o ma ke t h e
pla c ement of t he c omma nds wit hi nb ot h gr oups a nd t a bsa s int uit i ve a s poss ibl e t
o ma ke t hem ea s y t ofi nd.
By usi ng t he R ibb on
syst em,

t he us er ha s ma ny l ess mouse c li c ks t o ex ecut e t he des ir ed c omma nd.

T he it ems on t he r ibbons a r e gr oup ed t oget her by c om mon t a sk. T he ma i n r ibbon


is t he H ome T a b/r ibbon.
T he home t a b/ r ibbon in Exc el a nd P ower P oi nt a r e simi l a r. Bel ow is t he i ma ge of
MS
Wor d Home R ibb on.

B el ow is t he expla na t ion of dif f er ent c omp onent s i n t he home r ibbon of MS Wor d


2007.

In t he l ower
r ight
-
ha nd

cor ner of s ome gr oups is a sma ll down poi nt i ng a rr ow. T hes e


a r e r ef er r ed t o a s
Di alogE xp ande rs
or
L aunc he rs
. C lic ki ngont hea r r owwil lop ena
Dialogwi ndow
or a
Comma ndp ane
.
T he dia l og box ma y pr ovide a ddit i ona l opti ons t ha t ma y not be cont a i ned on t he
a ct ive t a b. Most of t he
dia l og box es t ha t a ppea r shoul d
b e fa mi l ia r ; ma ny a r e ta ken dir ect l y fr om ea r li er ver si ons of t he pr ogr a m.

T he R ibb on ha s t hr ee t yp es of C omma nds :

S i mp l e But t ons

Dr op
-
do wn menu s

But t ons

La uncher s (or Dia l og Expa nder s)


Butt ons

S i mp le B utto ns
wor k a s
T oggles
or
on/ off switc hes
. When t he c omma nd is off it wil l b e sur r ounded b y
blu e a nd l ook l i ke a l l ot her c omma nds a s shown i n t he F igur e 133. When a comma
nd but t on is on, it wi l l
be sur r ounded by or a nge. A com ma nd wi l l onl y wor k when it is on.
B old
is a n exa mpl e of a but t on a s
shown i n F igur e 133.

Intr oduct i on t o Com put in g

CS101

VU

P ag e
306
of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Fi gure
133
: Font Panel

com ma nd

a nd hol d it t her e. A t ext box wi ll op en up. T he t ext box cont a i ns t he c omma nd na


me, t he
keyb oa r d shor t cuts for t he comma nd, a long wit h a n exp la na t i on of t he c omma nd
a s shown i n t he F i gur e
102. 102.

134.

Fi gure
134
: Bol dC l i cked i n Fon t Pan el
Drop
-
dow nme nub ut to ns
wi l lha vea downa rr owt ot her i ght oft hec omma nd. Jus t likebut t ons, t hedr op
-
down menu c omma nd wi l l be sur r ounded by or a nge a nd t he dr op
-
down list wi l l op en up.
Change c ase
cont r ol is a n exa mp l e of a
dr op
-
down menu a s shown i n t he F i gur e 135.

Fi gure
135
: Fon t Pan el C ha ng i ng C as e

S ome c omma nds a r e a comb i na t ion of a


si mp le b utto n
a nd a
drop
-
dow n me nu b ut to n
. T her e a r e t wo
butt ons for t hes e comma nds. T he l eft butt on is a simp l e butt on a nd t he r ight butt
ons is dr op
-
down menu
a rr ow but t on. If one c li c ks on t he s i mp l e but t on t he defa ult va lu e wil l b e us ed, if
one cl ic k on t he dr op
-
down menu a r r ow t her e wi l l b e a

nu mb er of opt i ons a va ila bl e fr om whic h t o c hoos e. T he defa ult va lu e i s


t he la st used va lu e f or t he c omma nd.
U nd er li ne
is a n exa mp l e of a comb i na t ion c omma nd a s shown i n t h e
F igur e 136.

Intr oduct i on t o Com put in g

CS101

VU

P ag e
307

of
3 81
C opy rig htVi rtual U ni v ersi ty ofP aki stan

Fi gure
136
: Underl i ne

Panel

L aunc her (or Di alog E xp ande rs)

b utto ns

La uncher ( or Dia logExpa nder s)but t onsa sshowni nfi gur e8ar eusua ll ydispla yedi nt
hebot t o m
r ight cor ner ofs ome gr oups. C lic ki ngt he
la unc her bu t t onwil lop enup as er i es ofopt i ons eit her
i n a Ta sk pa ne (suc h a st he C lipb oa r d) or a Dia log window such a s t he F ont gr oup.

Fi gure
137
: Panel L aunch Butt ons

Mi ni T ool B ar
T he
Mi ni T oolba r a ppea r s a ut oma t ica l l y whenever you sel ect t ext a nd c ont a ins c
ommon t ext
for ma t t i ngc omma ndsa sshowni nt heF i gur e138. T oUset heMi niT oolba r :S el ect t het
extyou
wa nt t ofor ma t a ndcl ic kt hedes ir edcomma ndont heM i niT oolba r .C lic ka nywhe
r eout si det h e
M ini T oolba r t o clos e

it .

Fi gure
138
: Mi niT oolbar

Intr oduct i on t o Com put in g

CS101

VU

P ag e
308

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 188


103. 103.

188.

Word Process i ng: MS Word (Q ui c k Acc ess bar)

T he Qu ic k Ac c ess T oolba r (F igur e 139)


pr ovi des ea sy a ccess t o t he c om ma nds you us e most fr equ ent l y.
T heS a ve, Undo, R edo/ R ep ea t ,a ndQuic kPr int but t onsa ppea ront heQuic kAc c ess T
oolba r bydefa ult , but
you ca n a dd a nd r emove com ma nds t o meet your needs. You ca n qui c kl y r ever se
most comma nds
you
ex ecut e by usi ng Undo. If you t hen c ha nge your mi nd a ga i n, a nd wa nt t o r ea ppl y a
comma nd, you ca n us e
R edo a s shown i n t he F i gur e 139.
Fi gure
139
: Quick Access t oolbar

E xerc ise
104. 104.

1.

T ype wor d
105. 105.

2.

C lic k t he Undo but t on on t he Qu ic k Acc ess menu. T he t ypi ng

disa pp ea r s.
106. 106.

3.

C lic k t he R edo but t on on t he Qui c k Acc ess menu. T he t ypi ng

r ea ppea r s.
107. 107.

4.

S el ect " Undo

exa mp l e. "
108. 108.

5.
P r ess C tr l+bt o bol d. Wor d bolds t he

t ext .
109. 109.

6.

P r ess C tr l+i. Wor d it a lic iz es t he

t ext .
110. 110.

7.

P r ess C tr l+u Wor d under li nes t he

t ext .
111. 111.

8.

C lic k t he down ar r ow next t o t he Undo ic on. You wi l l see t he a ct i ons you

p er for med
list ed. T o undo t he u nder l i ne, cl ic k Under l i ne; t o undo t he under li ne a nd it a l ic,
cl ic k
Under l i ne It a li c; t o undo t he
under li ne, it a l ic, a nd b ol d cl ic k B old

et c.
112. 112.

9.

T o r edo, cl ic k t he R edo ic on sever a l


t i mes.

Alte r nat e Met ho d


--

U ndo & Redo by Usi ng K eys


113. 113.

1.
114. 114.

2.

P r ess C tr l+z. T he t yp i ng

disa ppea r s.
115. 115.

3.

P r ess C tr l+y. T he t yping

r ea pp ea r s.
116. 116.

4.

S el ect " Undo

exa mp l e. "
117. 117.

5.
P r ess C tr l+ut o

under l i ne.
118. 118.

6.

P r ess C tr l+z. T he under l i ne is

r emoved.
119. 119.

7.

P r ess C tr l+y. T he u nder l i ne

r ea pp ea r s.

Intr oduct i on t o Com put in g

CS101

VU
P ag e
309

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 189


120. 120.

189.

Word Process i ng: MS Word (H o me R ib bo n)

T hehomer ibb onisoneoft hemost i mpor t a nt r ibbona va ila bl ei nt heMS Wor d. F igur
e140showst hehom e
r ibbon. It cont a i ns dif f er ent i mp or t a nt gr oups suc h a s: C lipb oa r d, F ont , P ara
gr a ph, St yl es a nd E dit i ng. W e
wi ll b e l ea r ni ng ea c h modu l e of home r ibb on i
n t he nex t modul es i n det a i ls.
Fi gure
140
: Home ri bbon

Intr oduct i on t o Com put in g

CS101

VU

P ag e
310

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan


Mod ule 190
121. 121.

190.

Word Process i ng: MS Word (Cl ip bo ar d G roup)

T he
H o me
r ibbon is ma de up of t he most used c omma nds i n Wor d. T he fir st gr oup on t he
H o me
r ibbon is
t he
Cl ip bo ar d. Copy
,
Cut
,
Past e
a nd
Fo r mat Past e
a r e t he c omma nds wit hi n t he C lipb oa r d gr oup a s
shown i n t he F igur e 141. T he C lipb oa r d comma nds a r e on t he H ome r ibbo
n of
Word
a nd a ll ot her Offic e
2007 a pplica t i ons t ha t use t he r ibbon. T he dia l og expa nder a rr ow of t he C l ipboa r
d gr oup wil l op en up t h e
Cl ip board p ane
, s howi ng a ll it ems t ha t ca n be pa s t ed.
Fi gure
141
: C l i pboard Group

C ut and

Past e

Youca nuseW or d'sC utfea t ur et or emovet extfr oma docu ment. Youca nuset heP a st efea
t ur et opla c et h e
i nf or ma t ion youcut a nywher e i nt hesa me or a not her docu ment . In ot her wor ds,
youca n move i nf or ma t io n
fr omonep la c ei na
docu ment t oa not her pla c ei nt hesa meor diff er ent docu ment b yus i ngt heC ut a ndP a
st e
f ea t ur es. T he Of fi c e C l ipboa r d is a st or a ge a r ea . When you cut , Wor d st or es t
he da t a you cut on t h e
C lipb oa r d. You ca n pa st e t he i nfor ma t i on t ha t is st or ed on t he C l ipbo
a r d a s oft en a s you l i ke.

Cut wit h t he Ribbo n


122. 122.

1.

T ype t he f ol l owi ng:

I want to move. I am co nt e nt w here I am.


123. 123.

2.
124. 124.
3.

C hoos e t he Home t a b.
125. 125.

4.

C lic k t he C ut but t on
in t he C lipb oa r d gr oup a s shown i n t he F i gur e 142. Wor d cut s t he
t ext you s el ect ed a nd pla c es it on t he C l ipboa r d. Your text shou l d now r ea d:

"I a m c ont ent wher e I a m. "

Intr oduct i on t o Com put in g

CS101

VU

P ag e
311

of
3
81
C opy rig htVi rtual U ni v ersi ty ofP aki stan

Fi gure
142
: C ut opt i on i n cl i p
board group

Paste wit h t he Ribbo n


126. 126.

1.

P la ce t he cur sor a ft er t he p er i od i n t he s ent enc e

"I a m c ont ent wher e I a m. "


127. 127.

2.

P r ess t he spa ceba r t o l ea ve a spa ce.


128. 128.

3.

C hoos e t he Home t a b.
129. 129.
4.

C lic k t he P a st e but t on
i n t he C l ipboa r d gr oup a s shown i n t he F i gur e 143. Wor d pa st es t he
t ext on t he C l ipb oa r d. Your t ext shoul d now r ea d:

"I a m c ont ent wher e I a m. I wa nt t o move. "

Fi gure
143
: Past i ng i n Document

Alter nate Met hod

Cut wit h a Co ntext Me nu


130. 130.

1.

T ype t he

f ol l owi ng:

I want to move. I am co nt e nt
w here I am.
131. 131.

2.

S el ect "I wa nt t o move. "


Intr oduct i on t o Com put in g

CS101

VU

P ag e
312

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan


132. 132.

3.

R ight
-
c l ic k. T he M i ni t oo lba r a nd a cont ext menu a pp ea r.
133. 133.
4.

C lic k C ut on t he menu a s shown i n t he F i gur e 144. You r t ext shoul d now r ea d: "I a
m c ont ent
wher e I a m. "

Fi gure
144
: Past i ng
i n Document (Alt ernat e Met hod)

Alter nate Met hod

Paste wit h a Context Menu


134. 134.

1.

P la ce t he cur sor a ft er t he p er i od i n t he s ent enc e "I a m cont ent wher e I a m. "


135. 135.

2.

P r ess t he spa ceba r t o l ea ve a spa ce.


136. 136.

3.

R ight
-
c l ic k. A M i ni t oo lba r a nd a cont ext menu a pp ea r a s s hown i n t he F igur e 14 5.
137. 137.

4.
C lic k P a st e. Your t ext shoul d now r ea d:

"I a m c ont ent wher e I a m. I wa nt t o move. "

Fi gure
145
: Past i ng i n Document (Alt ernat e Met hod)

Intr oduct i on t o Com put in g

CS101

VU

P ag e
313

of
3 81
C opy rig htVi rtual U ni v ersi ty ofP aki stan

Alter nate Met hod

Cut wit h K eys


138. 138.

1.

T ype t he f ol l owi ng:

I want to move. I am conte nt w here I am.


139. 139.

2.

S el ect "I wa nt t o move. "


140. 140.

3.

P r ess C tr l+x.

Your t ext shou l d now r ea d: " I a m cont ent wher e I a m. "

Alter nate Met hod

Paste wit h K eys


141. 141.

1.

P la ce t he cur sor a ft er t he
p er i od i n t he s ent enc e: "I a m cont ent wher e I a m. "
142. 142.

2.

P r ess t he spa ceba r t o l ea ve a spa ce.


143. 143.

3.

P r ess C tr l+v.
144. 144.

4.

Your

t ext s hou l d no w

r ea d:

"I a m c ont ent wher e I a m. I wa nt t o move. "

Intr oduct i on t o Com put in g


CS101

VU

P ag e
314

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 191


145. 145.

191.

Word Process i ng: MS Word (Fo nt G ro up )

T he s ec ond gr oup of com ma nds on


t he H ome r ibb on is t he F ont gr oup. T he font gr oup c omma nds a r e
for ma t enha nc i ng t ool t ha t inc lu des f ont t yp efa c es, font siz e, font eff ect s (bol d,
it a lics, under l i ne, et c. ),
col or s a nd mor e. R eme mb er t ha t you ca n pr evi ew how t he new font wi l l l ook by
hi ghl
i ght i ng t he t ext , a nd
hover i ngover t henewf ont t yp efa c ea sshowni nt heF i gur e146.T he expa nder ar r owi
nt heF ont gr oupwi l l
op en up t he F ont dia l og window.

Fi gure
1
46
: Font group
146. 146.

7.1.1

B asic T e xt E dit i ng (Fo nt G ro up T as k)

T ype your na me i n docu ment wi ndow a t inser t i on poi nt a s shown bel ow i n t he F i


gur e 147.

Fi gure
147
: T ypi ng y
our name

C ha nge t he f ont of your na me t o Ar ia l. (Home T a b


-
>F ont Gr oup
-
> F ont Ar r ow) a s shown i n t he F i gur e
147. 147.

148.

Fi gure
148
: C hanging f ont

Intr oduct i on t o Com put in g

CS101

VU

P ag e
315

of
3 81
C opy rig htVi rtual U ni v ersi ty ofP aki stan

By keep s el ect i ng t he na me, ma ke it bol d a nd under l i ned. (Home T a b


-
> F ont Gr oup
-
> Bol d & Under l i ne
But t ons) a s shown i n t he F i gur e 149.

Fi gure
149
: Appl yi ngbol d and under l i ne

C ha nge t he f ont si z e of your na me t o 24. (Home T a b


-
> F ont Gr oup
-
> F ont S iz e Ar r ow)

a s shown i n t h e
F igur e 150.

Fi gure
150
: C hangi ng Font Size

Intr oduct i on t o Com put in g

CS101

VU

P ag e
316

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan


Mod ule 192
148. 148.

192.

Word Process i ng: MS Word (Par agr ap h G ro up


-
I)

T he t hir d gr oup on t he H ome r ibb on is t he


Parag r ap h
gr oup. T he pa ra gr a ph gr oup a ll ows you t o c ha nge
Par agr ap h Al ig n me nt
(l eft , r ight , cent er ed, or just ifi ed), a djust
L ine S pac i ng
wit hi n a para gr a ph, a nd
a djust
spac i ng be for e and after p arag r ap hs,
a long wit h wor ki ng wit h pa r a gra ph
Inde nt at io n
a s shown
i n fi gur e 151
.
T his is a lso t he a r ea wher e you ca n a dd
b ul let l ists
, nu mb er
lists
, or
out li nes fo r m
toa
docu ment s. T he Dia l og expa nder ar r ow wi ll op en t he
Par agr ap h d i alog
wi ndow.

Fi gure
151
: Paragr aph Group

B ul lets and N u mbe rs

If you ha ve l ist s of da t a , you ma y wa nt t o bull et or numb er t hem. W hen usi ng

Micr os oft Wor d, bull et i ng


a nd nu mb er i ng a r e ea sy. T he fir st par t of t his l ess on t ea ches you t o bull et a nd nu
mb er .

In Mi cr osoft Wor d, you ca n ea si l y cr ea t e bull et ed or numb er ed l ist s of it ems. S


ever a l bull et i ng a nd
nu mb er i ngst yl esa r ea va ila bl e, a sshown
i nt he exa mp l es. Youca ns el ect t he one you wis ht ous ea sshown
i n t he F i gur e 152 a nd F i gur e 53.

Fi gure
152
: N umbers varri at i onsi n paragr aph group

Intr oduct i on t o Com put in g


CS101

VU

P ag e
317

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Fi gure
153
: Bull et s vari at ionsi n paragr aph group
Intr oduct i on t o Com put in g

CS101

VU

P ag e
318

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 193


149. 149.

193.
Word Process i ng: MS Word (Par agr ap h G ro up
-
II)

You ca n cr ea t e your own bull et libr a r y. P er for m t he f ol l owi ng st eps:


150. 150.

1.

T ype t he f ol l owi ng l ist a s shown:

App le

O rang e

G rap e

Mango

C her ry
151. 151.

2.

S el ect t he wor ds you just t yp ed.


152. 152.

3.

C hoos e t he Home t a b.
153. 153.

4.
In t he P a ra gr a ph gr oup, clic k t he down a rr ow next t o the Bu l l et s butt on
. T he Bull et Libr a r y
a ppea r s.
154. 154.

5.

C lic k t o s el ect t he t yp e of bull et you wa nt t o us e a s shown i n t he F i gur e 154. Wor


d
a dds bull et s t o your

list .

Not e: As you move your cur sor over t he va r ious bul l et st yl es, Wor d displa ys t he bu
ll et st yl e onscr een.

Fi gure
154
: Bull et sel ect i on

T o re move t he b ul l et i ng:
155. 155.

1.

S el
ect t he list a ga i n.
156. 156.

2.
C hoos e t he Home t a b.
157. 157.

3.

In t he P a ra gr a ph gr oup, clic k t he down a rr ow next t o t he Bu l l et s ic on. T he Bu l l


et dia l og box
a ppea r s.
158. 158.

4.

C lic k N one. Wor d r emoves t he bul l et s fr om your list .

Intr oduct i on t o Com put in g

CS101

VU

P ag e
319

of
3 81
C opy rig htVi rtual U ni v ersi ty ofP aki stan

N umb ers T as k
159. 159.

1.

T ype t he f ol l owi ng l ist a s shown:

App le O range

G r ape M ango C herry


160. 160.

2.

S el ect t he wor ds you just t yp ed.


161. 161.

3.

C hoos e t he Home t a b.
162. 162.

4.

In t he P a ra gr a ph gr oup, clic k t he down a rr ow next t o t he Nu mb er i ng but t on


.T he
Nu mb er i ng Libr a r ya ppea r s a s show
n i n t he F i gur e 155 .

C lic k t o sel ect t he t yp e of nu mb er i ng you wa nt t o use. Wor d nu mb er s your list .


Note:
As you move your
cur sor over t he va r ious nu mb er st yl es, W or d displa ys t he nu mb er st yl e onscr
een.

Fi gure
155
: Adding
N umberedL i sts

T o re move t he nu mb er i ng :
163. 163.

1.

S el ect t he list a ga i n.
164. 164.

2.

C hoos e t he Home t a b.
165. 165.

3.

In t he P a ra gr a ph gr oup, clic k t he down a rr ow next t o t he Nu mb er i ng ic on. T he


Nu mb er dia l og
box a ppea r s.
166. 166.

4.

C lic k N one. Wor d r emoves t he nu mb er ing fr om your li st .

Intr oduct i on t o Com put in g

CS101

VU

P ag e
320

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan


Mod ule 194
167. 167.

194.

Word Process i ng: MS Word (S tyle G ro up )

T hef our t h gr oup ont heH omer ibb onist he


S tyl e
gr oup a sshowni nt heF i gur e156. S t yl esa r ea col l ect i on
of for ma t t i ng opt i ons t ha t you ca n a pply
t o t ext . When you use st yl es t o for ma t your docu ment , you ca n
qu ic kly a nd ea si ly a ppl y a set of for ma t t ing c hoic es c onsist ent l y t hr ou ghout
your docu ment .

Fi gure
156
: St yl e Group

A
sty le
is a set of
for mat t i ng
c har act er ist ics
, such a s font na me, si z e, col or , para gr a ph a lignment a nd
spa cing. S omest yl es eveni nclu deb or der sa nds ha di ng. F or exa mpl e, i nst ea d oft a ki
ngt hr ees epa r a t est eps
t ofor ma t your hea di nga s16
-
poi nt , bold, C a mbr ia , you ca na chi evet hesa me
r esu lt i nonest epbya ppl yi ng
t he built
-
i n H ea ding 1 st yl e. You do not need t o r eme mb er t he c ha r a ct er ist ics of t he H ea
di ng 1 st yl e. F or

a nd t hen c l i
c k H ea di ng 1 in t he ga l l er y of st yl es.

Intr oduct i on t o Com put in g

CS101

VU

P ag e
321

of
3 81
C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 195


168. 168.

195.

Word Process i ng: MS Word (E dit i ng G roup)

T he F ift h a nd f ina l gr oup (F i gur e 157) on t he Home r i bbon is t he


E dit i ng
Gr oup. T he c omma nds i n t he
Edit i ng gr oup a r e
Find
,
Rep l ac e
, a nd
S el ect
. W hen you cr ea t e a docu ment i n M icr os oft W or d, you ma y
deci de t o cha nge a c er t a in wor d or phr a se t ha t is r epea t ed t hr ou ghout t he docu
ment . Let t he c omput er do
t he ha r d wor k wit h t he
Find
a nd
Rep l ace

Fi gure
157
: Edit i ng
group

Under t he
Find
c omma nd, t her e is t he
GoTo
comma nd. T he G o T o comma nd ca n b e used t o
i mmedia t el y go t o a pa ge, a sect i on or a ny ma r ked l oca t ion wit hi n your docu
ment .

T he
S el ect
c omma nd

ca n b e us ed for diff er ent pur pose.

T o sel ect a ll of t he t ext in t he docu ment, cl ic k


S ele ct Al l
.

T o sel ect sha pes t ha t a r e hi dden, st a cked, or behi nd t ext , clic k


S ele ct O bjec ts
, a nd t hen dr a w a
box over t he sha p es.

T o sel ect t ext wit h si mi la r for ma t t ing, cl ic k


S el ect T e xt wit h S i mi l ar For mat t i ng
.

Intr oduct i on t o Com put in g

CS101

VU

P ag e
322

of
3 81
C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 196


169. 169.

196.

Word Process i ng: MS Word (I nsert Func tio nal it ies )

Ins er t T a b ca n be used if you wa nt t o a dd t o gr a phics or li nk your docu ment wit h


a not her

docu ment . T he
i nit ia l pa r t of t he i ns er t ta b in wor d r ibbon ha s been shown i n t he F i gur e 158.

Fi gure
158
: Inert t ab

In t he i ns er t ta b, t he f oll owi ng gr oups a r e a va ila bl e whi ch wil l b e cover ed i n t he


next modu l es :

P a ges Gr oup
Ta bles Gr oup

Il lust r a t ions Gr oup

Media

Links

C omment s

Hea der &F oot er

T ext

S ymb ols
Intr oduct i on t o Com put in g

CS101

VU

P ag e
323

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 197


170. 170.
197.

Word Process i ng: MS Word (p age G ro up )

P a ges
gr oup is in t he fa r left of t he i ns er t ta b. You ca n ins er t fr om t he t hr ee ca t egor i es
for pa ges whic h a r e;
C over P a ge, Bla nk P a ge, a nd P a ge Br ea k a s shown in t he F i gur e 159. T hes e f ea t
ur es a r e usefu l if you a r e
cr ea t i ng a pr of ess i ona l or l ong docu ment .

Fi gure
159
: Pages group i
n t hei nsert t ab

Cover Page

C over P a ge is t he t it l e pa ge of t he docu ment . Wor d 2007 pr ovides a nu mb er of pr


ef or med c over pa ges t o
gi ve your docu ment a pr ofess i ona l l ook.

Cover pag e
E xer cis e: Cre at i ng a Cover Page
171. 171.

1.

C lic k t he
I ns ert

t a b t o ma ke it t he a ct ive t a b a s shown i n t he F i gur e 158.


172. 172.

2.

T oopent he
B ui lt
-
i nCover PageG all ery
, cl ic kt he
do w nar row
t ot her ight of
CoverPage
i nt h e
Pages
gr oup on t he
I nser t
t a ba s shown i n t he F i gur e 1 60.

Fi gure
160
: Insert i ngC over Page
173. 173.

3.

S cr oll down a nd
c l ic k
t he des ir ed c over for t he docu m ent fr om t he
Cover Page G al le ry
. Us e t he
sc
r ol l ba r or scr ol l a rr ow t o s ee a ll t he cover pa ge c hoi c es.
174. 174.

4.

A C over pa ge wi ll b e a dded t o your docu ment .

Re move t he Cover Page


175. 175.

1.

C lic k t he
I ns ert
t a b t o ma ke it t he a ct ive

t a b.
176. 176.

2.

T oop ent he
B ui lt
-
i nCoverPageG all ery
, cl ic kt he
do w nar row
t ot her i ght of
CoverPage
i n t he P a ges gr oup on t he
I nse rt

t a b.

Intr oduct i on t o Com put in g

CS101

VU

P ag e
324

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan


177. 177.

3.
S cr oll down a nd s el ect
Re move C urre nt Cover Page
a sshown i n t he F igur e

1
178. 178.

61.

Fi gure
161
: Removi ng cover page

B lank Page

Gener a l l y,

Wor d i ns er t sa bla nkpa gea ut oma t ica l l y whi l e youa r et ypi ng. B la nkP a gei nI ns er
t t a bca nhel p
you a dd a new pa ge a nywher e i n a docu ment when r equir ed.

Tr y ins er t i ng a bla nk pa ge t o your docu ment .


179. 179.

1.

C lic k wher e you wa nt t o i ns er t a new pa ge i. e. b ef or e or


a ft er s ome t ext .
180. 180.

2.
C lic k on Bla nk P a ge i n I ns er t T a b (F igur e 158).

Page B re ak

P a ge Br ea k but t on wi ll f or c e a pa ge br ea k a nywher e you sel ect i n your docu ment


.
181. 181.

1.

cl ic k wher e you wa nt t o i ns er t P a ge Br ea k
182. 182.

2.

C lic k pa ge br ea k (F i gur e 158).

Intr oduct i on t o Com put in g

CS101

VU
P ag e
325

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 198


183. 183.

198.

Word
Process i ng: MS Word (T ab le G ro up)

Wor d pr ovides t a bles opt i on for pla ci ng da t a in a mor e for ma l wa y.


184. 184.

1.

C lic k on t a ble i n i ns er t t a b. (F igur e 162).

Fi gur e
162
: T ables group
185. 185.

2.

T o a dd R ows a nd C olu mns, sel ect


t op t o b ot t om f or r ows & l eft t o r ight for colu mns (F i gur e . 163)
186. 186.

3.

C lic k t o a ppl y when ha ppy wit h t he s el ect i on.


187. 187.

4.

C lic k on t he box t o ent er t ext .


188. 188.

5.

Obser ve t he new t a b op ened "T a ble T ools". You ca n use t his t ool t o a pply fur t her f
or ma t t i ng t o
your cr ea t ed t a ble

Fi gure
163
: Sel ect i ng R
ows and Col umns
Intr oduct i on t o Com put in g

CS101

VU

P ag e
326

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 199


189. 189.

199.

Word Process i ng: MS Word (Il l ust r at io n G ro up )


Us i ngI l lust r a t ions(F i gur e164), youca na ddpi ct ur esofa llt yp esa ndst yl est o your
docu ment . F ol l owed is
det a i l des cr ipt i on on how t o a dd i l lust r a t ions.

Fi gure
164
: Il l ust rat i ons

Pict ure

T hef ir st sel ect i on i nI llust r a t ionsisI ns er t a pict ur efr oma fi l e. W hen youc li c kont
hisa
wi ndow wi l lop e n
for you t o br ows e t o a phot ogr a ph or ot her pict ur e you ha ve sa ved on your comput
er .

C l i p A rt

T o il lust r at e a speci fi c
conc ept ,

you ca n Ins er t C lip Ar t i n your docu ment , i nc lu di ng media fil e (s ou nd a nd


vi deo cl ips) a nd dr a wi ng.

S hapes

Wor d 2007 pr ovides a wide r a nge of sha pes (F i gur e 16 5) t o sel ect a nd i ns er t in
your docu ment a s per your
r equir ement . It a lso pr ovi des C a nva s t o pla c e a ll t he S ha pes a t one p la c e wit
hout bei ng dist ur bed when
fur t her c ha nges a r e ma de a s shown i n t he fi gur e
190. 190.

166. Ea ch sha p e b elongs t o one of t he f ol l owi n g


subca t egor y

i. e. Lines, Ba sic S ha pes, Bl oc k Ar r ows, F low C ha r t s, Ca llout s, S ta rsa nd Ba nner s.


191. 191.

1.

C lic k on S ha pes i n I ns er t T aba nd dr a w a new C a nva s F igur e


192. 192.

165.
193. 193.

2.

Ins er t sha pes gi ven i n F i gur e


194. 194.

166.
195. 195.

3.

Ar r a nge
i ns er t ed sha pe t o for m S now Ma n a s done i n F i gur e
196. 196.

167.

Intr oduct i on t o Com put in g


CS101

VU

P ag e
327

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Fi gure
165
: Shapes t ypesi nW ord

Fi gure
166
: Shapes required t o make snowman

Fi gure
167
: Snowman

Intr oduct i on t o Com put in g

CS101

VU

P ag e
328

of
3 81
C opy rig htVi rtual U ni v ersi ty ofP aki stan

S mart Art

A new f ea t ur e i nt r oduc ed i n Wor d 2007 is S ma r t Ar t. Us i ng S ma r t


Ar t ,

you ca n commu nica t e your idea s

t he F i gur e 168.

Fi gure
168
: Smart

Art

Exer c is e: H ow t o a dd C yc l e S ma r t Ar t
197. 197.

1.

C lic k on S ma r t Ar t But t on i n I l lust r at ion gr oup of I ns er t T ab


198. 198.

2.

C lic k C ycl e i n t he l eft pa ne of op ening wi ndow (F i gur e 169)


199. 199.
3.

S el ect Ba sic C ycl e F i gur e


200. 200.

169.
201. 201.

4.

C lic k O n [T EXT ] t o a dd t ext. "Ba by", "C hil d", "T een" a nd " Adu lt ". Not ic e t he extr
a C ir cle
l eft (F i gur e 170).

C lic k on t he r ema i ni ng c ir cl e a nd pr ess D el et e ( D el) K ey on your keyb oa r d t o r


emove it (F igur e 171).

Fi gure
169
: Basi c cycl e

Intr oduct i on t o Com put in g

CS101

VU
P ag e
329

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Fi gure
170
: Human Li f eC ycl e

Fi gure
171
: Adding and Removi ng Object s
Intr oduct i on t o Com put in g

CS101

VU

P ag e
330

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 200


202. 202.

200.

Word Process i ng: MS Word (Med i a and L i nks G roups)


Linkst oolb ox(F i gur e172)i nI ns er t t a bhelpsl i nkot her docu ment si nyour cur r ent
docu ment a nda lsohelps
you keep t ra ck of r ea di ng b y pr ovi di ng B ookma r k fa ci l it y.

Fi gure
172
: L i nks group

H yperl i nk

Hyp er l i nkisusedt oa ddl ink ofot her docu ment sor web pa gesi nyour Docu ment . H er
eishow youca na dd
Hyp er l i nk. C lic k on hyp er l ink in i ns er t r ibbon t a b, a wi ndow wi l l op en a s in
t he F i gur e 173.
203. 203.

1.

Ent er wor d or phr a se t o displa y hyp er l i nk


204. 204.

2.

C lic k t o a dd t ext disp la yed when mous e is over t he hyp er l i nk t ext


205. 205.

3.

S el ect B ookma r k
206. 206.

4.
S el ect r esp ect i ve opti on t o l oca t e fi l e or web l inks t ha t you wa nt t o a dd i n docu
ment
207. 207.

5.

Addr ess bar


208. 208.

6.

You ca n l i nk t o va
r ious f il es i. e. exist i ng fi l e i n your sys t em, l i nk t o pla c e wit hi n docu ment
(i dea l t o li nk t a bl e of c ont ent s wit h hea di ngs).

Fi gure
173
: Adding Hyperl i nk

B ookmar ks

Bookma r ks a r e a wa y t o keep t r a ck of r ea di ng.


T hey ar e si mila r t o bookma r ks you keep whil e r ea di ng a
fa vor it e novel or st or y book l ike, t ur n t he c or ner of t he pa ge or pla ce p en or penc i
l.

Bookma r ks Ex er cis e: H ow t o Us e B ookma r k


209. 209.

1.

C lic k wher e you wa nt t o pla c e bookma r k.


210. 210.

2.

F r om i ns er t r ibbon t a bsel ect


bookma r k (F i gur e 174)
211. 211.

3.

Ent er
bookma r k

Intr oduct i on t o Com put in g

CS101

VU

P ag e
331

of
3 81
C opy rig htVi rtual U ni v ersi ty ofP aki stan
212. 212.

4.

Fi gure
174
: Adding Bookmark

Intr oduct i on t o Com put in g

CS101

VU
P ag e
332

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 201


213. 213.

201.

Word Process i ng: MS Word (Co mme nts and H ead er & foote r)

Hea der a nd F oot er s ar e ar ea s wher e you ca n a dd T ext or Gra phics. Any f or ma t t i


ng a ppli ed i n t hes e a r ea s
wi ll b e s hown t hr ou ghout t he docu ment . A hea der is a t t he t op ma r gi n; a foot er
is
pr int ed i n t he b ot t om
ma r gi n F or Exa mpl e obs er ver t he t op of t his pa ge a nd a ll t he pa ges i n t he docu
ment you wi l l see sa m e
hea der a nd foot er for ma t .
Fi gure
175
: Header and Foot er

Exer c is e: H ow t o Us e H ea der

& F oot er s
214. 214.

1.

C lic k on i ns er t r ibbon t a b sel ect hea der .


215. 215.

2.

P a ge hea der wi ll op en i n edit mode. (F i gur e 176)


216. 216.

3.
217. 217.

4.

C los e hea der & foot er (F igur e 177).

S i mila r l y, you ca n a dd f oot er . P lea s e not e you

ca n even a dd i ma ges t o t he hea der , foot er or bot h.

Fi gure
176
: Header i n edit mode

Fi gure
177
: Aft er Header Inserti on

Intr oduct i on t o Com put in g

CS101

VU

P ag e
333

of
3 81
C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 202


218. 218.

202.

Word
Process i ng: MS Word (T ext G ro up ( Part
-
1) )

T ext Box in I ns er t R ibbon t a b ca n be used t o a dd gr a phica l for ma t t i ng. T his ha s


been shown i n t he F i gur e
219. 219.

178.

Fi gure
178
: T ext group

Exer c is e: H ow t o Us e T ext box (F ig


ur e 179)
220. 220.

1.
C lic k t he T ext Box but t on, loca t ed i n t he T ext gr oup on t he I ns er t t a b. Fr om t he
menu t ha t
a ppea r s, choos e Dr a w T ext Box.
221. 221.

2.

C lic k wher e you wa nt one c or ner of t he t ext box t o a ppea r a nd dr a g t o wher e you
wa nt t he
opp osit e c or ner .
222. 222.

3.

R el ea se t he mous e b
ut t on a nd t hen t yp e your t ext .

Fi gure
179
: Adding T ext Box

Q uic k p arts

Quic k P a r ts a r e a new f ea t ur e i n Wor d


2007 t ha t a llows you t o sa ve t ext or

ca ll it up quic kl y whe n
you need it . T his is esp ecia l l y ha ndy for
i ns er t ing i nfor ma t i on such a s a C ompa ny
Na me, Logo, C ompa ny Addr ess or a ny
ot her infor ma t i on t ha t you us e oft en.
Exer c is e: H ow t o C r ea t e a Quick P a r t
223. 223.

1.

S el ect t het extyou wa nt t or euse.


Toi
nc lude pa ra gr a ph for ma t t ing, ma k e
sur e you sel ect t he ending pa ra gr a ph
ma r k.
224. 224.

2.

C lic k t he I ns er t t a b on t he R ibb on.


225. 225.

3.

C lic k t he Qu ic k P a rt s but t on a nd c l ic k S a ve S el ect i on t o Quic k P a r t Ga ller y.


226. 226.

4.

Ent er in t he des ir ed pr oper t i es f or t he Quic k P a rt .


227. 227.

5.

T oins er t a Qu
ickP ar tt ha t youha vesa ved, cl ic kt heQu i ckP a r tsbut t ona ndchoos et heQuic k
P ar t you wa nt t o use.
Word Art

Wor dAr t ca n be us ed t o pr oduc e sp ec ia l t ext ef f ect s i n a Micr osoft Wor d docu


ment . F or exa mp l e, you ca n
cr ea t e cur ved, sla nt ed, or
t hr ee
-
di mens i ona l t ext by i ns er t i ng a Wor dAr t obj ect .

Intr oduct i on t o Com put in g

CS101

VU

P ag e
334

of
3 81
C opy rig htVi rtual U ni v ersi ty ofP aki stan

Exer c is e: H ow t o a dd Wor d Ar t
228. 228.

1.

On t he I ns er t t a ba nd t hen C l ic k W or dAr t .
229. 229.

2.

In t he W or dAr t Ga ll er y dia log b ox, doub l e


-
c li c k t he s t yl e t ha t you wa nt (F i gur e 18 0).
230. 230.

3.

In t he E dit Wor dAr t T ext dia l og box, t yp e your t ext a nd s el ect font a nd siz e.
231. 231.

4.

C lic k B ol d or It a lic t o ma ke a l l t he t ext bol d or it a l ic. (Not e you ca nnot a pply b ol


d or it a li c
t o onl y a par t of t he t ext . ).
232. 232.

5.
In t he E dit Wor dAr t T ext dia l og box, cl ic k OK. T o
ins e r t int o t he docu ment .

Fi gure
180
: W ord Art Gall ery

Intr oduct i on t o Com put in g

CS101

VU

P ag e
335

of
3 81
C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 203


233. 233.

203.

Word Process i ng: MS Word (T ext G ro up ( Part


-
II ) and S y mbo ls G ro up)

Drop Cap

A dr op ca p is a specia l l y for ma t t ed l et t er t ha t a ppea rs a t t he b egi nni ng of a para


gr a ph just like you see i n
newspa p er s or in b ooks. Micr osoft wor d off er s dr op c a ps in t wo st yl es.
Most c ommonl y us ed dr op ca p

begi ns t he pa ra gra ph wit h a lar ge l et t er t ha t sp


il ls down int o t he t ext . T hus, t he dr op ca p shift s t he fir st few
li nes of t he pa r a gra ph.

Exer c is e: H ow t o Us e Dr op C a p
234. 234.

1.
T ype t he pa r a gra ph a s you nor ma l l y wou l d.
235. 235.

2.

Open t he I ns er t t a b on t he R ibb on a nd cl ic k t he Dr op C a p but t on. (F i gur e 181)


236. 236.

3.

C hoos e t he dr op ca
p st yl e you wa nt t o us e.
237. 237.

4.

Adjust t he dr op ca p, if you wa nt t o.

S y mbo ls

Anot her fea t ur e fou nd is Micr os oft Wor d is S ymb ols. You ca n a dd pr e
-
ma de ma t hema t i ca l Equa t i ons a nd
va r ious S ymb ols wher e r equ ir ed i n your docu ment . However , if you ca nnot fi nd
wha t you

wa nt , you ca n
a lso cr ea t e your own equa t i ons.

Exer c is e: Us i ng S ymb ols


238. 238.
1.

Loca t e t he Equa t i on butt on i n t he S ymbols gr oup of t he Ins er t ta b on t he R ibbon.


239. 239.

2.

C lic k t he but t on ( not it s menu t r ia ngl e), a nd t wo t hings ha ppen. F ir st, a n equa t
ion c ont r ol
isi ns er t e
d i nt o your docu ment a t t hei ns er t i onpoi nt er 'sl oca t i on. S ec ond, t heEqua t i onT
ools
Des i gn t a ba ppea r s on t he R ibb on.

Fi gure
181
: Drop cap ' P'

Intr oduct i on t o Com put in g

CS101

VU
P ag e
336

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 204


240. 240.

204.

Word Process i ng:


MS Word (Desig n R i bbo n)

Des i gn r ibbon (a s shown i n t he F i gur e 182) cont a ins t he f oll owi ng gr oups:

Fi gure
182
: Desi gn Ribbon

T he mes

Dr op
-
D own. T hedr op
-
do
wnc ont a i nst hec om ma nds:Bui lt
-
i n, Mor eT hemesonMicr osoft Offi c e
Onli ne, Br ows ef or T hemesa ndS a veC ur r ent T heme. Thebu ilt
-
i nt hemesa r e:Of fi c e, Ap ex, Asp ect , C i vi c,
C onc our se, Equ it y, F l ow, F oundr y, M edia n, M et r o, Modul e, Opul ent , Or i el, Or
igi n, P ap
er , S olst ic e,
T ec hnic, T r ek, Ur ba na ndVer ve. T oolt ipi ndica t est hec urr ent t heme. T hedefa ult t
hemeis"Off ic e". T oolt ip
i ndi ca t est hecur r ent t heme. Quic kAc c ess t omor et hem essa veddownonMicr os oft
Offi c eOnl ine. D efa ult
t heme is "Off ic e". C ha nges t he

over a l l des i gn of t he ent ir e docu ment i nc lu di ng c ol or s, font s a nd eff ect s.


T his dr op
-
down ha s a n a ddit i ona l c omma nd not f ou nd in Exc el or P ower P oi nt whic h is "R es
et t o T heme
fr om T emp la t e".

S tyle S et

C ha nge t he l ook of your docu ment by c hoosing a new st


yl e s et . S t yl e s et s cha nge t he f ont a nd
pa ra gra ph pr oper t i es of your ent ir e docu ment .

Colors

Dr op
-
Down. Displa ys a list ofa ll t he a va ila bl e col or sa nd l et s you c ha nge t he col or comp
onent of
t he a ct ive t heme.

Fo nts

Dr op
-
D own. Displa ysa list ofa llt he

a va ila bl e f ont sa nd l et syouc ha nget hef ont comp onent oft he


a ct ive t heme.
Par agr ap h S p ac i ng

Dr op
-
D own. Quic kl y c ha nge t he li ne a nd pa ra gr a ph spa cing i n your docu ment . T he
dr op
-
downc ont a i nst hec om ma nds:N oP a ra gr a phS pa ce, C ompa ct , T ight , Open, R ela x
ed, D oubl e, C ust o m
P ara gr a ph S pa cing.

E ffe cts

Dr op
-
Down. Displa ys a list of a ll t he a va ila bl e ef f ect s a nd l et s you cha nge t he eff ect
comp onent
of t he a ct ive t hem e. T he dr op
-
down c ont a ins t he comma nds : Offi c e, Ap ex, Aspect , C ivic, C oncour s e,
Equ it y, F l ow,

F oundr y, M edia n, M et r o, Modul e, Opul ent , Or i el, Or i gi n, P a per , S olst ic e, T ec


hnic, T r ek,
Ur ba n a nd Ver ve.

S et As Default
-

Us e t he cur r ent l ook f or a ll new docu ment s.

PageB ac kgro und

T hista bcont a inswa t er ma r k, pa gecol or a ndpa gebor der sasshowni nt


heF igur e183.

Fi gure
183
: Page background group

Page Color

Dr op
-

em e
col or pa let t e.

Intr oduct i on t o Com put in g

CS101
VU

P ag e
337

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Page B orde rs

Dis pla ys t he " B or der a nd S ha di ng " dia l og box.

Wate r mar ks

wa y of l et t i ng t he r ea der know t ha t t he docu ment is


c onfi dent ia l.
Exer c is e: H ow t o a dd Wa t er ma r k
241. 241.

1.

C lic k t he Wa t er ma r k but t on on t he P a ge La yout t a b.


242. 242.

2.

C lic k one of t he wa t er ma r ks t o ins er t it or sel ect C ust om Wa t er ma r k fr om t he


bot t om of t he
ga l l er y.
243. 243.

3.

T o sel ect t ext for your cust om wa t er ma r k, sel ect t he T ext


Wa t er ma r k opt i on in t he P r int ed
Wa t er ma r kdia l ogbox. T henus et hec ont r olst os el ect t hela ngua gea ndt het ext t ob
eus ed. C lic k
OK.

You ca n a ls o s el ect a pict ur e t o b e us ed f or t he wa t er ma r k by sel ect i ng t he P i ct


ur e Wa t er ma r k opt i on a nd
t hen usi ng t he S e
l ect P ict ur e bu t t on t o f i nd t he i ma ge you wa nt t o us e. F or mos t i ma ges , you wa
nt t o l ea v e
t he Wa shout opt i on s el ect ed, whic h ma kes t he t ext on t op of t he i ma ge ea si er t o
r ea d.
Intr oduct i on t o Com put in g

CS101

VU

P ag e
338

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 205


244. 244.

205.

Word Process i ng: MS Word (Pag e S et up G ro up i n Page L ayo ut Rib bo n)


Us i ng pa ge set up gr oup (F igur e 184), you ca n ea sil y pl a ce ma r gi ns, displa y t ext in
t wo or t hr ee colu mns,
Add s ect i on br ea k or even s et pa ge s et up.

Fi gure
184
: Page set up group

Displa yi ng T ext i n t wo
C olu mns

Asyou mi ght ha ve obs er vedi nnewspa per st ext isdispl a yedint woor t hr eec olu mns. M
icr osoft
Wor d pr ovi des t his f ea t ur e in P a ge La yout R ibbon t a b. By defa ult t he t ext is disp
la yed i n on e

Exer c is e: H ow t o a dd C olu mns


245. 245.

1.

S el ect t ext t ha t you wa nt t o disp la y i n c olu mn f or m. ( Fi gur e

185)

In P a ge La yout T a b clic k on C olu mns a nd s el ect


Fi gure
185
: T ext sel ect i ons f or 2
-
col umns di splay

Fi gure
186
: T ext i n t wo col umns

Intr oduct i on t o Com put in g

CS101

VU

P ag e
339

of
3 81
C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 206


246. 246.

206.

Word Process i ng: MS Word (Pag e S et up G ro up i n Page L ayo ut Rib bo n)

You ca n qui c kl y disp la y t he


"P a ra gr a ph" dia l og box, Indent s a nd S pa cing t a b, by cli c ki ng on t he la unc her
i n t he bot t om r ight cor ner of t his gr oup. T hes e a r e opt i ons t a ken fr om t he (F or
ma t P ara gr a ph)(Indent s a nd
S pa cing t a b) for quick a cc ess .

Fi gu r e
187
: Paragr aph gro
up i n page layout

Inde nt L eft

-
T extBox. T his a utoma t ica ll y upda t es t o indica t e how muc h i ndent a t ion ha s been a
ppli ed t o
t he pa ra gr a ph of t he cur r ent sel ect i on. T his ca n be used t o c ha nge t h
e l eft i ndent a t i on for t he cur r ent
sel ect i on.

Inde nt Rig ht

T ext Box. T his a ut oma t ica l l y upda t es t o i ndi ca t e how muc h i ndent a t ion ha s
been a ppli ed t o
t he pa r a gra ph of t he cur r ent s el ect i on. T his ca n b e used t o c ha nge t he r i ght i
ndent a t i on f or t he cur r ent
sel ect i on.

S pac i ngB e fo re

T ext B ox. T hisa ut oma t ica l l yup da t es t oi ndica t ehow muc hspa ci ng is def i nedb efor
et he
pa ra gra ph of t he cur r ent sel ect i on. T his ca n be used t o cha nge t he spa ci ng for t he
cur r ent sel ect i on.

S pac i ng A fter

T ext B ox. T he a ut oma t ica


l l y upda t es t o i ndi ca t e how muc h spa ci ng is defi ned a ft er t he
pa ra gra ph of t he cur r ent sel ect i on. T his ca n be used t o cha nge t he spa ci ng for t he
cur r ent s el ect i on.

Intr oduct i on t o Com put in g

CS101

VU

P ag e
340

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan


Mod ule 207
247. 247.

207.

Word Process i ng: MS Word (Arr ang e G ro up i n Page L ayo ut Ri bbo n)

T his gr oup
a lso a ppea r s on t he Dr a wi ng T ools
-

F or ma t cont ext ua l t a b as shown i n t he F i gur e 188.

Fi gure
188
: Arrange Group

Posi tio n

Dr op
-
D own. Displa ys a list of pi ct ur e p osit i oning opt i ons. T he dr op
-
down c ont a i ns t he
com ma nds: I n Line
wit h
T ext a nd T ext Wra pping. You ca n sel ect Mor e La yout Opt i ons t o disp la y t h e
" Adva nc ed La yout" dia l og b ox.

Wrap T ext

Dr op
-
Down. T he dr op
-
down c on
t a i ns t he c om ma nds: I n L i ne wit h T ext , S quar e, T ight ,
T hr ough, T opa nd B ot t om, B ehi nd T ext , In F r ont of T ext , Edit Wra pP oi nt s a nd
Mor e La yout Opt i ons.

B ri ng Forw ard

But t on wit h Dr op
-
D own. T he but t on br i ngs t he s el ect ed obj ect f or wa r d one l evel. T h e
dr op
-
down pr ovi des a comma nd t o br i ng t he s el ect ed ob j ect i n fr ont of a l l t he ot her
ob j ect s.

S end B ac kw ar d

-
(S end t o Ba c k i n 2007). Butt on wit h Dr op
-
Down. T he butt on br ings t he s el ect ed object
ba ck one l evel. T he dr op
-
down pr ovi des a comma nd t o send t he s el ec
t ed ob j ect t o t he ba ck of a ll t he ot her
ob j ect s.

S elect io n Pane

(Added i n 2010). Displa ys t he S el ect i on P a ne t a sk pa ne.

Al ig n

Dr op
-
D own. T hedr op
-
downc ont a i nst he com ma nds: Al i gnL eft , Ali gnC ent er , Al i gnR ight , Al i gn
T op, Al ign M iddl e, Al i gn B ot t om,
Dist r ibut e Hor i z ont a ll y, Dist r ibut e Ver t ica l l y, Al i gn t o P a ge, Ali gn t o
Mar gi n, Al i gnS el ect edObject s, Vi ewGr i dli nesa ndGr i dS et t i ngs. T heGr i dS et t i
ngsdisp la yst he"Dr a wi ng
Gr id" dia l og box.

G roup
-

Dr op
-
Down. T he dr op
-
down c ont a i ns t he c omma nds: Gr ou
p, R egr oup a nd Ungr oup.

Rotat e

Dr op
-
D own. T he dr op
-
down c ont a i ns t he c omma nds : R ot a t e R i ght 90, R ot a t e Left 90, F lip
Ver t ica l, F lip Hor iz ont a l a nd M or e R ot a t ion Opt i ons.

Intr oduct i on t o Com put in g

CS101

VU
P ag e
341

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 208


248. 248.

208.

Word Process i ng: MS Word (Re fe re nces Ri bbo n)

T his t a b gi ves you


a cc ess t o a ll t he c om ma nds for cr ea t i ng r ef er enc es wit hi n your docu ment s.

T ab le o f Co nt e nts
-

Dr op
-
D own. P r ovide a n over vi e w of your docu ment by a ddi ng a ta ble of c ont ent s.
T he dr op
-
down c ont a i ns t he c omma nds : Bu ilt
-
i n, Ins er t T a ble of C ont ent s a nd S a ve
S el ect i on t o T a ble of
C ont ent s Ga ll er y a s shown i n t he F i gur e189.

Fi gure
189
: T abl e of C ont ent

AddT ext

Dr op
-
Down. T hedr op
-
downcont a i nst he

c omma nds :DoN ot S howi nT a bleofC ont ent s, Level


1, Level 2 a nd L evel 3.
Up da t e T a ble

Up da t es t he t a ble of c ont ent s so t ha t a ll t he ent r i es r ef er t o t he c or r ect pa ge nu


mb er s.

Foot no tes
-

You ca n qu ic kl y displa y t he "F oot not e a nd Endnot e" dia l og box by


c li c ki ng on t he dia l og box
la unc her i n t he b ot t om r i ght cor ner of t his gr oup a s shown i n t he F i gur e 190.

Fi gure
190
: Foot not es Group

Inse rt
Foot no te

( Alt + C t r l + F ). Ins er t s a foot not e a t t he cur r ent pos it i on. F oot not es a r e a ut
oma t ica l l y
r enu mb er ed a s you move t ext a r ound t he docu ment .

Inse rt E nd note

-
( Alt + C tr l + D). Ins er t s a n endnot e a t t he end of t he docu ment . End not es a r e a lwa
ys
pla
c ed a t t he end of a docu ment .

NextFoot note

But t on wit hDr op


-
D own. T hebutt on movest ot he nextfoot not e. T he dr op
-
downpr ovides
t he c omma nds N ext F oot not e, P r evi ous F oot not e, Next Endnot e a nd P r evi ous
Endnot e.

S how Notes

S hows wher e foot not es a nd endn


ot es a r e loca t ed.

Intr oduct i on t o Com put in g

CS101
VU

P ag e
342

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 209


249. 249.

209.

Word Process i ng: MS Word (Proo fi ng G ro up i n Re view Ri bbo n)

T he pr oof i ng gr oup is shown i n t he F i gur e 191.


Fi gure
191
: Proof i ng group

S pel l i ng & G rammar

Displa ys
t he "S pel l ing a nd Gr a mma r " dia l og box. T his a llows you t o c hec k t h e
spel li ng a nd gr a mma r i n t he a ct i ve docu ment .

T hes aur us

T oggl est hedisp la yoft heR es ea r cht a skpa nedefa ult i ngt her es ea r chs er vi c et ot het
hesa ur us.
S a me a s Excel.

WordCo unt

T his
displa yst he"W or dC ount "dia l ogb oxdisp la yingt hedocu ment st a t ist ics. T hisr epla c
es
t he W or d C ou nt t oolba r . T his dia log b ox ca n a lso b e di spla yed b y c l ic ki ng on t he
wor d c ou nt i ndi ca t or on
t he st a t us bar.
Intr oduct i on t o Com put in g

CS101

VU

P ag e
343

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 210


250. 250.

210.
Word Process i ng: MS Word (L ang uage

G ro up i n R eview R ib bo n)

T he la ngua ge gr oup ha s been shown i n t he F i gur e 192.

Fi gure
192
: L anguage group

T rans l ate

Dr op
-
D own. Displa ys t he R es ea r ch t a sk pa ne. T his dr op
-
down c ont a ins t he c omma nds :
Tr a nsla t
e Docu ment , Tra nsla t e S el ect ed T ext , Mini T ra nsla t or a nd C hoos e T ra nsla t ion
La ngua ge.

L ang uag e

-
Dr op
-
Down. T his dr op
-
down c ont a i ns t he comma nds : S et Pr oof i ng La ngua ge a nd La ngua ge
P r ef er enc es. S et Pr oof i ngLa ngua ge disp la yt he"La ngu a ge"dia l ogbox. La ng
ua geP r ef er enc es disp la yst he
"Opt i ons " dia l og box, La ngua ge T a b.

Intr oduct i on t o Com put in g

CS101

VU

P ag e
344

of
3 81
C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 211


251. 251.

211.

Word Process i ng: MS Word (Co mme nts G ro up i n Revie w Rib bo n)

T he c omm ent s gr oup ha s been shown i n t he F i gur e 193.

Fi gure
193
: C omment sgrou
p

New Co mme nt

(S hi ft +F 2). Inser t s a comment a t t he a ct ive c el l. T his comma nd does not c ha nge t


o Edit
C omment when a comm ent is s el ect ed l i ke it does i n Exc el.

Del ete
-

But t on wit h Dr op
-
D
own. Del et es t he s el ect ed comment . T he but t on del et es t he c om ment i n t he
a ct ive s el ect i on. T he dr op
-
down c ont a i ns t he c omma nds: D el et e Al l C omm ent s S hown a nd D el et e a ll
com ment s in D ocu ment . T his is disa bl ed when t he doc u ment does not c ont a in a ny
c omment s.

Pr evio us

Goest ot hepr evi ouscom ment int hea ct i vedocu ment . T hisisdisa bl edwhent he docu
ment does
not cont a i n a ny com ment s.

Next

Goes t o t he next comment i n t he a ct ive docu ment . T his is disa bled when t he docu
ment does not
cont a i n a ny com ment s.
Intr oduct i on t o Com put in g

CS101

VU

P ag e
345

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 212


252. 252.

212.
Word Process i ng: MS Word (T rac ki ng and C hange s G roups i n R evi ew Rib bo n)

T he T ra cki ng gr oup ha s been shown i n t he F i gur e 194.

Fi gure
194
: T racki nggroup

T rac k C hanges

(C tr l + S hift
+ E). But t on wit h Dr op
-
Down. T he but t on is t he Tra ck C ha nges c omma n d
fr om t he R evi ewi ng. It cont a i ns t he c omma nds T ra ck C ha nges, C ha nge T ra cki ng
Opt i ons a nd C ha ng e
Us er na me
. C ha nge T ra cki ng Opti ons displa ys t he T ra ck C ha nges Opti ons dia l og box. C ha nge
Us er na me

displa ys t he W or d Opt i ons dia l og box (P opu la r ta b).

S how M ar kup

-
Dr op
-
D own. T he dr op
-
down c ont a ins t he c omma nds : C omm ent s, Ink, Ins er t i ons a nd
Del et i ons, F or ma t t ing, Mar kup Ar ea Hi ghli ght .

Revie wi ng Pane

But t on wit h Dr op
-
D own. T he but t on t oggl e
s t he displa y of t he R evi ewi ng pa ne. T he
dr op
-
down c ont a ins t he c omma nds : R eviewi ng P a ne Ver t ica l a nd R eviewi ng P a ne Hor i
z ont a l l y. T her e i s
now a lso su mma r y i nfor ma t i on a t t he t op of t he pa ne.

T he c ha nges gr oup is shown i n t he F i gur e 195.

Fi gure
195
: C hanges group

Acce pt

-
Butt on wit hDr op
-
D own. T hebutt onist he Ac c epta ndMovet oN extcomma ndwhic ha cc epts t he
cur r ent cha nge a nd moves t o t he next pr opos ed c ha nge. T he dr op
-
down c ont a ins t he com ma nds
: Ac c ept
a nd Move t o Next , Acc ept C ha nge,
a ccept

a ll C ha nges S hown a nd Acc ept a ll C ha nges i n Docu ment . T his


dr op
-
down is disa bl ed when t he docu ment is pr ot ect ed.

Rejec t

But t on wit h Dr op
-
D own. T he but t on is t he R ej ect a nd Move t o N ext c omma nd whi c h r ej ect s t h e
cur r ent c ha ngea ndmovest ot henext pr opos edc ha nge. T hedr op
-
downcont a i nst hec omma nds:R ej ect a nd
Move t o N ext, R ej ect C ha nge,
r ej ect

a ll C ha nges S hown a nd R e
j ect a ll C ha nges i n Docu ment . T his dr op
-
down is disa bl ed when t he docu ment is pr ot ect ed.

Pr evio us

Movest ot hepr evi ousr evisi on i nt hea ct i ve docu ment . T hisisa bit c onfusi nga sit does
exa ct l y
t he sa me a s t he P r evi ous i n t he c omment s gr oup.

Next

Mov
es t o t he next r evis i on i n t he a ct i ve docu ment .

Intr oduct i on t o Com put in g

CS101

VU
P ag e
346

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 213


253. 253.

213.

Word Process i ng: MS Word (Co mp ar e and Prote ct G roups i n R evi ew Ri bbo n)

T he C ompa r e gr oup is shown i n t he F i gur e 196.

Fi gure
196
: C ompare group

Co
mp are

Dr op
-
D own. T he dr op
-
down c ont a i ns t he com ma nds: C ompa r e a nd C ombi ne. T he C ompa r e
com ma nd l et s you c ompa r e t wo ver si ons of t he sa me docu ment a nd disp la ys t he
"C ompa r e D ocu ment s "
dia l og box. T he C omb i ne c omma nd l et s you comb i ne r evisi ons fr om mu lt ipl
e a uthor s a nd displa ys t h e
"C ombi ne D ocu ment s " dia l og box. T his dr op
-
down is disa bl ed when t he docu ment is pr ot ect ed.

T he pr ot ect gr oup is s hown i n t he F i gur e 197.

B loc k A ut hors

Dr op
-
D own. Pr event ot her s fr om ma ki ng cha nges t o t he s el ect ed t ext .

Restr ic
t E d it i ng

-
T oggl es t he displa y of t he R est r ict Edit i ng t a sk pa ne.

Pro tect Doc u me nt

T he dr op
-
down c ont a i ns t he c omma nds : Unr est r ict ed Acc ess, R est r ict ed Acc ess,
Ma na ge C r edent ia ls.

Fi g
ure
197
: Prot ect group

Intr oduct i on t o Com put in g

CS101

VU
P ag e
347

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 214


254. 254.

214.

Word Process i ng: MS Word (Vi ew Rib bo n)

T heVi ewr ibb onc ont a i nsVi ewsgr oup, S howGr oup, ZoomGr oup, a ndWi ndowsgr oup.
T heVi ewsgr oup
cont a i ns a ll t he c omma nds r ela t i ng t o t he dif f er ent wa ys you ca n vi ew your docu
ment s a s shown i n t h e
F igur e
255. 255.

198.
Fi gure
198
: Vi e ws

group

Read Mode

It ma xi mi z es t he Wor d wi ndow on t he scr een a nd r emoves a ll t oolba r s et c t o a ll


ow ea s y
r ea ding.

Pr i nt L ayo ut

Disp la ys t he docu ment a s it woul d a ppea r if pr int ed a nd is


t he defa ult vi ew.

Web L ayo ut

Disp la ys t he docu ment a s it wou l d a ppea ra sa web pa ge.

O ut l i ne

-
Displa ys t he docu ment a sa n out l i ne is disp la ys t he Out l i ni ng c ont ext ua l t a b.

Draft

Displa ys t he docu ment i n dr a ft mode a l l owi ng f or quic k edit i ng. When usi n
g t his view c er t a i n
a spect s of t he docu ment a r e not vis ibl e, f or exa mpl e a ny hea der s or foot er s.

T he show gr oup is shown i n t he F i gur e 199.

Fi gure
199
: Show group

R ul er

T oggl es t he disp la y of t he

r ul er (s).

G rid l i nes

T oggl es t he displa y of gr i dl i nes.


Nav igatio n Pane

T oggl es t he disp la y of t he Na vi ga t ion t a sk pa ne. T his is a combi na t i on of t he F


ind,
Docu ment Ma pa nd T hu mb na i ls.

T he Z oom gr oup is shown i n t he F i gur e 200.

Fi gure
200
: Z oomgroup

Intr oduct i on t o Com put in g

CS101

VU

P ag e
348
of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Zoo m

D ispla ys t he "Z oom" dia l og box. T his ca n a lso be a ccess ed fr om t he st a t us bar by cl


ic king on t he
vi ew p er c ent a ge.

100%

Adjust s t he z oom t o 100% of it s nor ma l siz e. Let s you qu ic kly

r et ur n t o 100 %.

O ne Page

-
Adjust t he z oom so a n ent ir e pa ge fit s i n t he a ppli ca t ion wi ndow.

T wo Pages

Adjust t he z oom so t wo ent ir e pa ges f it in t he a ppl ica t i on wi ndow.

PageWi dt h

Adjust t hezooms ot he wi dt hoft hepa geist hesa mea st he wi dt hoft


hea pplica t i onwi ndow.

T he Wi ndows gr oup ha s been shown i n t he F i gur e 201. Ever y docu ment you op en i n
Wor d ca n b e t hought
of a s a wi ndow. It is poss ibl e t o op en mu lt ip l e wi ndows of t he sa me docu ment .

Fi gure
201
: W indows group

New Wi ndow

Let s you cr ea t e a new wi ndow of t he a ct i ve docu ment .

Arr angeAl l
-

T il ea llt heop enwi ndowssi debyside ont hescr een. T hiswil la lso
ma xi miz e

t hea ppli ca t ion


/ docu ment t o a

full scr een.

S pli t

S plit s t he cur r ent wi ndow i nt o t wo pa r t s.

View S ide by S ide

Displa ys t wo docu ment s si de by side so t hey ca n be ea si l y compa r ed. If you ha v e


mor e t ha n t wo docu ment s op en t he "C ompa r e S ide b y S ide" dia log box is disp la yed
so you ca n c
hoos e
whic h docu ment t o displa y next t o t he a ct i ve docu me nt , a llowi ng you t o scr oll mu
lt ip l e wi ndows a t t he
sa me t i me.

S ync hro no us S croll i ng

-
T oggl es t he sync hr oni z e scr oll i ng of t he t wo docu ment s t ha t ar e disp la yed si de
by si de. T his is only ena bl ed when

you a r e vi ewi ng t wo docu ment s si de b y side.

Reset Wi ndow Posit io n

R es et s t he wi ndows p osit ions so t hey t a ke up t he sa me a mou nt of spa ce on t h e


scr een when t wo docu ment s a r e displa yed si de b y s ide. T his is onl y ena bl ed when
you a r e vi ewi ng t w o
docu ment s
side b y si de.

S witc hWi ndows

Dr op
-
D own. Let syous wit chb et weena l lt hecur r ent l ya ct i vedocu ment s. T hisdispla ys
a ll t he window/ docu ment s t ha t ar e curr ent l y op en i n t he par t icula r sess i on.

Intr oduct i on t o Com put in g


CS101

VU

P ag e
349

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 215


256. 256.

215.

Prese nt at io ns: MS
-
Powe r Poi nt (I nt rod uct io n)
Micr os oft of f er s a not her power fu l t ool known a s MS
-
P ower P oi nt . T his is used t o devel op pr es ent a t i ons.
Micr os oft P ower P oi nt is a n ea sy pr ogr a m t o use a nd a power fu l t ool for gi vi ng a
pr es ent a t ion. Whet her
your pr es ent a t ionneedsavisua lkic k, t oolsfor co
lla bor a t ion, ea sya ccess or t hea bil it yt osha r einfor ma t i on
beyond t he i nit ia l me et i ng, P ower P oi nt is a good opt i on. It ca n even help r educ e
sp ea ki ng a nx i et y b y
dr a wi ng eyes a wa y fr om t he sp ea ker a nd t owa r ds a screen. Jus t do not exp ect t
his t echnol ogy t o

subs t it ut e
for sound a nd dyna mic sp ea ki ng skil ls. All r ibbons of MS P ower p oi nt a r e shown i n t
he F i gur e 202.

Fi gure
202
: MS: Po werpoi nt

S omeoft hefu nct i onsi ndif f e


r ent gr oupsinP ower p oi nt a r eexa ct lysa mea sper t hefunct i onsinM S :Wor d.
W e wil l onl y cover t hos e gr oups a nd funct i ons whi c h a r e new i n t he MS : P ower p
oi nt a s compa r ed t o t he
MS : Wor d. T hes e gr oups a nd t heir funct i ona lit i es wi l l be dis cussed in t he next

modu l es.
Intr oduct i on t o Com put in g

CS101

VU

P ag e
350

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 216


257. 257.

216.
Prese nt at io ns: MS
-
Powe r Poi nt (S l ides G ro up on H o me R ib bo n)

T he S l i des gr oup is shown i n t he F i gur e 203.

Fi gure
203
: Sl i des gr ou p i n home r i bb on

New S li de

Butt o
n wit h Dr op
-
D own. T he butt on i ns er t s a new bla nk T it l e a nd C ont ent S li de. T he dr op
-
downc ont a inst hes l i des:T it l eS l i de, T it l ea ndC ont ent , Duplica t eS el ect edS li des, S
li desfr omOut l i nea nd
R eus e S li des.

L ayo ut

Dr op
-
D own. T he dr op
-
down c ont a i ns t he c om
ma nds : T it l e S li de a nd T it l e a nd C ont ent .

Reset

R es et t he p osit i on, siz e a nd f or ma t t ing of t he sl i de pla c ehol der s t o t heir defa


ult set t i ngs.

Del ete

R emoves t he sl i des cur r ent l y s el ect ed.

Mod ule 217


258. 258.

217.

Prese nt at io ns: MS
-
Powe r Poi nt (Des ig n Ribbo n)

T hedes i gnr ibbonist her ibbont ha thelpsyout odesi gnyour slidesa sper your r equ ir
ement . T hefir st gr oup
pr es ent a t ion. You ca n t r y di ff er ent t hemes t o
see t he di f f er enc e.

Fi gure
204
: T hemes group

F ur her mor e, you ca n s el ect sl ide s iz e i n t he next gr oup a nd f or ma t ba ckgr ou nd a


ccor ding t o your
r equir em
ent s.

Intr oduct i on t o Com put in g

CS101

VU

P ag e
351
of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 218


259. 259.

218.

Prese nt at io ns: MS
-
Powe r Poi nt (T r ans it io n Ribbo n)

Ifyou' ve ever s eena P ower P oi nt pr es ent a t iont ha t ha dspecia l eff ect sbet ween ea c
hsl i de, you' ves een

sl id e
tr ans it io ns
. A t r a nsit i on ca n b e a s si mp l e a s fa di ng t o t he next sl i de or a s fla shy a s a n eye
-
ca t chi ng ef f ect .
P ower P oi nt ma kes it ea sy t o a ppl y t r a nsit i ons t o som e or a ll of your sli des, gi vi
ng your pr es ent a t ion a
polis hed, pr of ess i ona ll ook. T het ra nsit i onr ibbonh
260. 260.

205.

Fi gure
205
: T ransi t i on group

Onc e you a r e done wit h one t yp ica l t ra nsit i on st yl e, t he next t hi ng is t o c onf i gur
e ot her opt ions a va i la bl e
i n t he F i gur
e 206.

S ound

You ca n a dd a ny sou nd fi l e over her e whic h you need t o pla y i n t his t r a nsit i on

D ur at io n

you ca n set t he dur a t ion of t he t r a nsit i on.

App ly to All

S et t he t r a nsit i on b et ween a ll t he sl i des i n t he pr es ent a t i on t o b e t he sa me a s t


his sl i de.
O n Mo use C li c k

L et s you wa it unt il t her e is a mous e cl ic k b ef or e movi ng on t o t he next sl i de.

Fi gure
206
: T ransi t i on t i mi ng group

Intr oduct i on t o Com put in g

CS101

VU

P ag e
352

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 219


261. 261.

219.

Prese nt at io ns: MS
-
Powe r Poi nt (A ni mat io n R ib bo n)

Tr a nsit ion
discuss edi nt he la st modu l e

wer et hea ni ma t i onsa dded i nb et weens l i des. Wher ea s, Ifyou wa nt


t o a ni ma t e t ext , a n ima ge, sha pe, gr a ph or cha r t wit hi n t he sl i de, t his is t he t
yp e of a ni ma t i on you sel ect .

T her e a r e va r iet y of a ni ma t i ons a va i la bl e a s shown i n t he F i gur e 207.

Fi gure
207
: Animati ons group

Intr oduct i on t o Com put in g

CS101

VU

P ag e
353

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 220


262. 262.

220.

S preads he ets: MS E xcel (I ntrod uc tio n)

What is a S pre ads hee t?

S uppose you wou l d l i ke t o ma i nt a in


p er sona l fi na nc e regist er a lso known a s chec k r egist er t ha t wi l l keep
t ra ck of t he exp endit ur es t ha t you ha ve been ma king du r ing t he cur r ent semest er .
Anot her scena r io ca n b e
t he budget ma na gement of a sma ll hous e. You ma y be i nt er est ed i n qu est i on such a
s

how muc h money ha s


been sp ent on el ect r icit y bil ls a nd t el ep hone bi lls. How muc h sa ving ha s been ma
de? You ma y i ma gi ne a
book t ha t keeps r ec or d of a ll t r a nsa ct ion/ exp endit ur es a nd inc ome. S uc h a book
ca n b e ca l l ed a ma nua l or
pa per spr ea dsheet . A sa mp l e
is shown i n t he F igur e 208. In t his ca se you ma y ha ve t o sa ve da t a t ha t ca n be
nu mer ica l or a lpha nu mer i c (i nvol vi ng l et t er s or nu mb er s).

S pr ea dsheet is a t ool t ha t is used t o or ga ni z e da t a , such a s a check r egist er . S pr


ea ds heet s ha ve b een us e d
for ma ny, ma
ny yea r s in business t o keep t ra ck of exp ens es a nd ot her ca lcula t i ons.

E lect ro nic S pr e ads heet :


Micr os oft Exc el is a n exa mpl e of spr ea dsheet a ppli ca t ion pr ogr a m t ha t ca n b e
used for st or ing, or ga niz i ng a nd ma nipu la t i ng da t a . T he key b enef it t o using a
spr ea
dsheet pr ogr a m is t ha t
you ca n ma ke cha nges ea si l y, inc lu di ng cor r ect i ng spell i ng or va lu es, a ddi ng, del
et i ng a nd for ma t t ing. It
cons ist s of a gr id ma de fr om c olu mns a nd r ows si mila r t o wha t you ha ve s een i n
your Mat hema t ic s
not eb ooks in sc hool da ys. T his
gr i d envir onment ma kes nu mb er ma nipula t i on ver y ea sy.

Fi gure
208
: Spread Sheet Exampl e

P l ea se r ef er t o F igur e 209 t o obs er ve t he la yout of MS Exc el. On t he t op you wi l l


fi nd a r ibbon
s i mi la r t o
MS Wor d a nd P ower P oi nt t ha t we wi l l b e dis cuss i ng shor t ly. T he diff er ent t hi
ng you wi l l not ic e is t he
r ect a ngula r box es on t he scr een di vi ded wit h t he help of r ows a nd c olu mns

R ows a r e i dent i fi ed b y Nu mb er s a s shown i n t he l eft most c olu mns wher


ea s C olu mns a r e i dent i fi ed b y
Alp ha bet s a s shown i n t he t op most r ow.

If you wa nt t o sel ect a par t icula r cel l, you wi l l ha ve t o i dent if y it s a ddr ess . T he
sel ect ed c ell i n t he F i gur e
263. 263.

209. F or . e. g. is A1, A b ei ng t he f ir st colu mn a nd 1 bei ng t he f ir st r ow


Intr oduct i on t o Com put in g

CS101

VU

P ag e
35
4

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Fi gure
209
: Excel L ayout
Cel l Fo r matt i ng

T he c ell f or ma t t i ng is show i n t he F igur e 2010.

a cc or di ng t o t he f ont siz e of t he da t a you ha ve


i ns er t ed.

C harts

C ha r t sa llow you t o pr es ent inf or ma t i on cont a i ned i n t he wor ksheet in a gra phic
f or ma t . Excel off er s ma n y
t yp es of c ha r t s inclu di ng: C olu mn, Line, P i e, Ba r, Area , S cat t er a nd mor e. T o vi
ew
t he cha r t s a va ila bl e
cl ic k t he I ns er t Ta b on t he R ibb on.

C r ea t ing a C har t :

S el ect t he c el ls t ha t cont a i n t he da t a you wa nt t o us e i n t he c ha r t . In our exa


mpl e we ca n s el ect t he
shipp i ng c ost colu mn t o b e used a s cha r t da t a.

Fi gure
210
: C el l f ormatt i ng
Intr oduct i on t o Com put in g

CS101

VU

P ag e
355

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

C lic k

t he I ns er t t a b on t he
R ibb on

C lic k t he t yp e of C ha r t you wa nt t o cr ea t e. T her e a r e diff er ent cha r t t ypes a s


show i n t he F igur e
264. 264.

211.

Fi gure
211
: C harts group

C lic k t he C olu mn c ha r t but t on a nd t hen s el ect t he 2 d c ha rt

A ba r char t wil l a ppea r showi ng t he s hippi ng c ost a s cha rt a s shown i n F i gur e


212.

You ca n obs er ve t he c ost s a t t he Y


-
a xis a nd a s
t her e a r e four it ems so you ca n s ee 4 bar sa t X
-
a xis

T his cha r t ha s four comp onent s a nd you ca n r ight cl ock on t hem s epa ra t el y t o s
ee t he a dva nc e
opt i ons a va ila bl e.

Fi gure
212
: C hart exampl e i n Excel

Mod ule 221


265. 265.

221.

S preads he ets: MS E xcel ( Func tio ns


)

A f or mula is a set of ma t hema t i ca l i nst r uct ions t ha t ca n be used i n Exc el t o p er


for m ca lcu la t i ons. F or ma ls
a r e sta rt ed i n t he f or mula box st ar t ing wit h a n = sign. A sa mpl e f or mula is shown
i n F i gur e 213.

Fi gure
213
: Formula
Exampl e

Intr oduct i on t o Com put in g

CS101

VU

P ag e
356

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

T he f or mu la r ibbon is shown i n t he F i gur e 214. T his r ibbon gi ves you di ff er ent opt
i ons f or a pplyi n g
for mu la s. T he fir st sect i on r epr es ent s F unct i on l ibr ar y. F unct ion l ibr a r y cont a
i ns
di ff er ent for mula s fr om
va r ious ca t egor i es. F igur e 214 gi ves you a n over vi ew of t he F or mu la r ibbon.

Fi gure
214
: Formula ri bbon

Cre at i ng B as ic Fo r
mul a

T o cr ea t e a ba sic for mu la in Exc el we need t he da t a on whic h t o a pply t he f or mu


la . Da ta is r epr es ent ed i n
F igur e 215.

Fi gure
215
: Dat af or Sum F
ormula

T o cr ea t e a ba sic
for mula ,

you need t o do t he f ol l owi ng:

S el ect t he c el l f or t he f or mu la
T he f or mula is of su m whi c h wou l d su m t he va lu es.

C lic k E nt er

C r ea t ing a ba sic for mula is shown i n t he F i gur e 216.

Fi gure
216
: Sum Formula

Intr oduct i on t o Com put in g

CS101

VU

P ag e
357

of
3 81
C opy rig htVi rtual U ni v ersi ty ofP aki stan

When you cl ic k ent er you wou ld get t he r e


s ult a s s hown i n fi gur e 21 7 t he la bel 1 r epr es ent s t he for mu la
a ppli ed t o get t he des ir ed r esult a nd la bel 2 r epr es ent s t he r esu lt a ft er a pplyi ng
t he f or mula .

Fi gure
217
: Resul t of Sum Formula

Calc ul at e wit h
Func t io ns

Afu nct i onisa built inf or mu la inExc el. Afunct i onha sana mea nda r gument s(t he ma t
hema t ica lfu nct i on)
i n pa r ent hes es.

S um: Adds a ll c el ls i n t he a r gu ment

Aver a ge: C a lcula t es t he a ver a ge of t he c el ls i n t he a r gu ment


Min: F i nds t he mi ni mu m va l
ue

Ma x: F inds t he ma x i mu m va lu e

C ount : F inds t he nu mb er of c el ls t ha t cont a i n a numer ic a l va lu e wit hi n a ra nge


of t he a r gu ment

T o ca lcula t e a funct i on:

C lic k t he c ell wher e you wa nt t he funct i on a ppli ed

C lic k t he I ns er t F unct i on but t on

C hoos e t he funct i on
C lic k OK

T he pr oc ess of ca lcu la t ing t hr ough a funct i on is shown i n fi gur e 218.

Fi gure
218
: Funct i on C omput at i on

Intr oduct i on t o Com put in g

CS101

VU

P ag e
358

of
3 81
C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 222


266. 266.

222.

S preads he ets: MS E xcel (A pp l ic at io n S ce narios


-
I
)

Aft er l ea r ni ng t he f or mu la s in det a ils i n t he la st modul e . Let s a pply t hos e i n t


he r ea l sc ena r io.

C ons i der t he F igur e 219 whic h cont a i ns t he da t a of five st udent s a nd t heir ma r ks


in fi ve subj ect s. We wa nt
t o a dd t he t ot a l ma r ks of ea c h st udent . T he f or mul
a ha s been wr it t en for your r ef er enc e.

Fi gure
219
: Sum of marks

When t his f or mula is a ppli ed a nd cop i ed i n t he f ol l owi ng c ells, t he r esu lt ca n be s


een i n t he F i gur e 220.
Fi gure
220
: Resul t of sum f ormul a

Intr oduct i on t o Com put in g

CS101

VU

P ag e
359

of
3 81
C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 223


267. 267.

223.

S preads he ets: MS E xcel (A pp l ic at io n S ce narios


-
II
)

ment i oned a scena r io t ha t if you wa nt t o ma na ge your per sona l exp ens es on a r


egist er , it s ver y diff icu lt t o
per f or mdiff er ent qu er i es. Int hismodul e, wewil l

c onsi der t hisscena r i oa ndwil lp er for mnu mb er ofqu er i es


on t his exa mp l e.

T he F i gur e 221 cont a i ns t he p er sona l exp ens es det a i ls of t he yea r 2020 mont h
wis e i n di ff er ent hea ds.

Fi gure
221
: Pers onal expen
se sheet
Now our fir st qu er y is t o s ee t he t ot a l exp ens e f or t he J a nua r y mont h. T he a ppl i
ed f or mula ca n b e s een i n
t he F i gur e 222 a nd it s r esult ca n b e seen i n t he F i gur e 2 23.

Fi gure
222
: Fi ndi ng t otal expense f or

t he January mont h

Intr oduct i on t o Com put in g

CS101

VU

P ag e
360

of
3 81
C opy rig htVi rtual U ni v ersi ty ofP aki stan

Fi gu r e
223
: Resul t of queryf rom Fi gure 222

Now if we a r e i nt er est ed t o s ee wha t t he t ot a l exp ens e of t he Elect r i cit y B il l is,


we

ca n a ppl y t he fol l owi ng


for mu la a nd ca n cop y it i n t he next c el l t o see t he r esu lt a s shown i n t he F i gur e
224.

=su m(b3 :b14)

Fi gure
224
: T ot al bil l Expense
-
head wi se

S i mila r l y,

you ca n t r y t he f ol l owi ng for mu la s a s wel l :


=aver age (b3: b14)

= max( b3: b14)

= mi n(b3: b14)

T he t ot a l exp ens e f or t he yea r 2020 ca n be seen a ft er a ppl yi ng t he f ol l owi ng f or


mula :

=S UM(B 16:H 16)

Intr oduct i on t o Com put in g

CS101

VU

P ag e
361

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 224


268. 268.

224.

S preads he ets: MS E xcel (S ort i ng and Filter


)

S or t ing a nd F ilt er i ng a ll ow you t o ma nipu la t e da t a in a wor ks heet ba sed on gi


ven s et of cr it er ia . You ca n
sor t t he da t a in a scending a nd desc endi ng or der . T her e a r e t wo t yp es of sor t s in
Micr osoft Exc el i. e. Ba sic
S or t sa nd C ust om S or t s.

B asic S ort

To
ex ecut e a ba s ic des c endi ng or a s cend i ng s or t bas ed on on e c olu mn p er f or m t he
fol l owi ng s t eps :
Hi ghl i ght t he c el ls t ha t wi ll b e sor t ed

C lic k t he S or t & F ilt er but t on on t he H ome t a b

C lic k t he S or t Asc endi ng ( A


-
Z) but t on or S or t Desc endi ng (Z
-
A) but t on.

T hes
e st eps a r e shown i n t he F i gur e 225.

Fi gure
225
: Sort and Fi l t er

C ust om S or t

T o sor t on t he ba sis of mor e t ha n one c olu mn:

C lic k t he S or t & F ilt er butt on on t he H ome


tab
C hoos e whic h c olu mn you wa nt t o sor t by fir st

C lic k Add Level

C hoos e t he next colu mn you wa nt t o sor t

C lic k OK

T his pr oc ess is r epr es ent ed i n t he F i gur e 226.

Intr oduct i on t o Com put in g

CS101

VU

P ag e
362
of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Fi gure
226
: C ust om Sort

Intr oduct i on t o Com put in g

CS101

VU
P ag e
363

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 225


269. 269.

225.

Dat ab ase: MS Access (I nt rod uct io n


)

Da t aba se is col l ect i ons of fi l es whic h a r e a lsor ef er r ed a s ta bles. Inf or ma t ion is


or ga ni z ed i n t hes e t a bles i n
t he f or m of f i el ds a nd r ec or ds for ea sy a cc ess a nd
ma na gement pur pose.

S QL st a nds for str uct ur ed qu er y la ngua ge. In or der t o a ccess a nd r et r ieve da t a


fr om t he da t a ba se we us e
S QL.T his is t he most c ommonl y us ed synt a x for qu er yi ng a r ela t i ona l da t a ba se.

It is i mp or t a nt t o under st a nd t he di ff er enc e b et ween

wit h a n a na l ogy of off ic e C l er ic. Off ic e cl er ic or ga niz e a nd st or es diff er ent f il es i


n t he f i li ng ca bi net
whenever he needs t o a cc ess i nf or ma t i on fr om t he f i l e or a dd new i nfor ma t i on
in t he f i l e he goes t
o t he
fi ll i ng ca binet a nd r et r i eve t he fi l e whi c h he ha s a lr ea dy st or ed i n t he fi l li ng ca
bi net . Aft er upda t ing t he
i nf or ma t ion i n t he fi l e he st or es t he fi l e ba ck t o t he fil l i ng ca binet . In t he a bove
exa mp l e Da t a ba se is t he
fi ll i ng ca binet wher e t he i nf or m
a t i on is st or ed i n t he for m of fi l es. And t he a na l ogy of DBMS is t he off ic e
cl er i c, whos e j ob is t o or ga ni z e a nd r et r i eve f il es.

You shoul d be qu it e fa mi l ia r wit h t he r ibbon a s pr esent ed i n t he MS Wor d a nd MS


Excel. T he si mi la r
r ibbonisa va i la bl e i nMS Ac
c ess . T hesa mer ibb on isa lsopr es ent i n Acc ess wit hf ew modi f ica t i ons. T her e
is a ddit i on of t hr ee new t a bs i. e. C r ea t e, Exter na l da t a and Da t a ba se T ools a s
shown i n t he F i gur e 227.

Fi gure
227
: MS Access ri bb
on

T o cr ea t e a new da t a ba se
C lic k on Bla nk da t a base opt i on a s shown i n F i gur e 228

T ype Da t a ba se na me a nd br ows e t o l oca t i on wher e you sa ve t he new da t a ba se.

C lic k C r ea t e but t on t o cr ea t e da t
a ba se. (F igur e 229).

Fi gure
228
: C reat e Blank Dat abase

Intr oduct i on t o Com put in g

CS101

VU

P ag e
364
of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Fi gure
229
: N aming and savi ngdat abase

Nav igatio n Pane l

When your da t a ba seiscr ea t ed new wi ndowscr eena ppea r a ndb y defa ult t a bl e isa
dded. Ont he l eft s i de of
t he wi ndow is na vi ga t i on pa nel (F i gur e 230) her e you wi ll s ee a ll your sa ved t a
bles, for ms, qu er i es a nd
r epor t s. On t he R ight of t he na vi ga t i on pa ne i
s wor ki ng or vi ew pa nel. You ca n vi ew t a bl e da t a , quer y
out put , gener a t e r ep or t s a nd for m her e.

Fi gure
230
: Blank Dat abase

E xter nal d at a
Exter na lda t a ta bisusedt oi mp or t ,expor t , col l ect a ndsha r eda t a bet ween di ff er ent
da t a ba ses. Youca na lso
exp or t a nd i mp or t da t a fr om ex c el docu ment a s shown i n t he F i gur e 231.

Fi gure
231
: Ext ernal dat a
Ribbon

Intr oduct i on t o Com put in g

CS101

VU

P ag e
365

of
3 81
C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 226


270. 270.

226.

Dat ab ase: MS Access (Cre ati ng and M anag i ng T ab les


)

C r ea t eTa bint heR ibb onhelpsyout opr ovi dequi c ka ndea sywa yt ocr ea t et a bles, for
ms, r epor t a ndqu er i es
a sshown i n t he F igur e 232.

Fi gure
232
: C reat e tab

T ab les G ro up

Ta bles i n Ac c ess a r e
used t o st or e da t a . It is a set of c ol u mns a nd r ows. Ea ch colu mn i n t a ble is r ef er r
ed t o
a sa fiel d. Ea ch va lu e i n t he f i el d si gnif i es a singl e t yp e of da t a. Numb er s of R ec
or d a r e nu mb er of r ows i n
a Ta ble henc e ea c h r ow of a ta ble is r ef er r ed t o a sa sing
l e r ec or d.

E xerc ise : Cre ate Co urses T ab le


271. 271.

1.

C lic k on C r ea t e t a b (F igur e 232).


272. 272.

2.
273. 273.

3.
274. 274.

4.

R ena me t he
275. 275.

5.

In D es i gn vi ew c li c k on sec ond r ow i n f i el d na me c olu mn.


276. 276.

6.
277. 277.

7.
278. 278.

8.

Add a new f
279. 279.

9.

T o r et ur n t o da t asheet vi ew c l ic k on vi ew but t on a nd s el ect .


280. 280.

10.

A P opup dia l ogu e box wi l l a ppea r t o sa ve t he c ha nges, cl ic k yes t o cont i nu e.


281. 281.

11.

In da t a sheet vi ew your newl y a dded f i el


ds a r e vis ibl e.
282. 282.

12.

Ins er t 10 cour ses da t a .


283. 283.

13.

C los e t a ble.

Intr oduct i on t o Com put in g

CS101
VU

P ag e
366

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 227


284. 284.

227.

Dat ab ase: MS Access (Cre ati ng For ms


)
F or ms opt i on pr ovi des you t he a bi l it y t o ent er new r ecor d a nd na vi ga t e t hr ou
gh ex ist i ng r ec or ds ea si l y.
You ca n a rr a nge fi el ds i n di ff er ent la yout s
a dd Ic on a nd a lso a pply des i gns a s ca n be seen i n t he F i gur e
285. 285.

232.

Cre at i ng For m for S t ude nt T abl e


286. 286.

1.

S el ect st udent t a ble. Doub l e c li c k t o op en.


287. 287.

2.

C lic k C r ea t e t a b.
288. 288.

3.

F r om t he F or ms gr oup S el ect F or m (F i gur e 232).


289. 289.

4.

A F or m wi l l be cr ea t ed wit h T a ble F i el ds a s
La bels fol l owed b y T ext Box es (F i gur e 233)
290. 290.

5.
291. 291.

6.
292. 292.
7.

Your newl y cr ea t ed f or m wi l l show i n Na vi ga t i on P a ne. (F igur e 234)

Fi gure 233: St udent T abl e Form

Fi gure
233
4: Saved Form " student Form"

Intr oduct i on t o Com put in g

CS101

VU

P ag e
367
of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 228


293. 293.

228.

Dat ab ase: MS Access (Cre ati ng Repor ts


)

R ep or t sa r e or ga ni z ed a nd su mma r iz ed f or m of your dat a so you ca n pr int or vi


ew it onscr een. R ep or t sar e
oft en us e when you wa nt t o
a na l yz e your da t a or pr es ent it t o ot her s. It isa va ila bl e a sa n indep endent
gr oup of F igur e 232.

Cre at i ng Repo rt for S t ude nt T abl e


294. 294.

1.

S el ect st udent t a ble. Doub l e c li c k t o op en.


295. 295.
2.

C lic k C r ea t e t a b.
296. 296.

3.

F r om t he R ep or t s gr oup sel ect r ep or t (F igur e 235).


297. 297.

4.

A R ep or t
wil l b e gener a t ed a s shown i n F i gur e 236.
298. 298.

5.
299. 299.

6.
300. 300.

7.

In t he Na vi ga t i on P a ne you ca n see your newl y cr ea t ed for m b y t h


e na me you ha ve sa ved. (F i gur e
236)
301. 301.

8.

Fi gure
234
: Insert Report

Fi gure
235
: St udent T abl e Report

Intr oduct i on t o Com put in g

CS101

VU

P ag e
368

of
3 81
C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 229


302. 302.

229.

Dat ab ase: MS
Access (Q uery Wi zard )

Quer i es a r e t o r et r ieve or fet c h sp ec if ic da t a fr om your da t a base. T he qu er y


wiza r d gr oup ha s been shown
i n t he F i gur e 236.

Fi gure
236
: Query Group: Q
ueryW i zard

Que ry T ypes

T her e a r e four basic t yp es of qu er i es us ed t o ma nipula t e t he da t a ba ses. T hes e a


r e br ief l y des cr ib ed i n t h e
Ta ble 1 a long wit h gener ic synt a x.

Ta ble 1: Ba si c Quer i es
Q ue ry

Descr ipt io n

G ener ic S Q L S ynt ax

S elect

Us ed t o r et r i ev e
sel ect ed da t a one or
mor e f i el d ca n b e
sel ect ed by using
com ma a s sep er a t or or
use * t o s el ect a ll t a bl e
fi el ds, foll owedb yt a ble
na me fr om wher e t h e
da t a is t o be r et r i eved.
You ca n a lso a dd
W
HER E cla use t o set
cr it er ia for sel ect i on.

S ELECT

F R OM
t a ble_ na me1, t a bl e_na me2;

OR

S ELECT * F R OM
t a ble_ na me, t a ble_ na me2;

OR

S ELECT *F R OM
t a ble_ na me, t a bl e_na me2
WHER E some cr it er ia ;

Ins er t

Us ed t o a dd new
r ec or ds.

INS ERT INT O


t a ble_ na me ( fi el d1,
fi el d2, . . . fiel dN ) VAL UES

Up da t e

Us ed t o upda t e exist i ng
r ec or ds i n da t a ba se.
Gi ven some cr it er ia in
WHER E cla use.

UP D AT E ta ble_ na me
S ET fiel d1= newva lu e1,
fi el d2= newva lu e2

Del et e

Us ed t o r emove da t a
fr om da t a ba se.

DELET EF R OM
t a ble_ n
a me WHER E
some cr it er ia ;

Q ue ry S tude nt T ab le us i ng Wi zard
303. 303.

1.

C lic k C r ea t e t a b. Fr om t he Qu er y gr oup sel ect Quer y Wiza r d (F i gur e 236).


304. 304.

2.

F r om p opup wi ndow s el ect si mp l e qu er y a nd c l ic k OK.

Intr oduct i on t o Com put in g

CS101

VU
P ag e
369

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan


305. 305.

3.

Anot her window wil la ppea r . S el ect t a blefr om whi c hyouwa nt t oqu er y
r esult si nour ca seit ist h e
st udent t a ble.
306. 306.

4.

S el ect sna me a nd ss ems fr om t he disp la yed f i el ds a s shown i n F i gur e 237


307. 307.

5.

When done cl i ck next a nd next a ga in.


308. 308.

6.

B ef or e you cl ic k fi nis h
ent er i ng

t he na me you wa nt t o gi ve your qu er y. F or
exa mp l e,
309. 309.

7.

Your qu er y wi llb er epr es ent ed i na t a blef or m wit ht wosel ect edf i el dsst udent na
mea nds emest er .
310. 310.

8.

S a ve qu er y a s you sa ved your r epor t a nd for m (F i gur e 238).

Fi gure
237
: C reat i ng Query usi ng wi zar d

Fi gure
238
: Query Resul t af t ersavi ng

Intr oduct i on t o Com put in g


CS101

VU

P ag e
370

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

S QL st a nds for S tr uct ur ed Qu er y La ngua ge. T his is t he most commonl y us ed synt a


x for quer yi ng a
r ela t i ona l
da t a ba se. Micr osoft Ac c ess P r ovides S QL Vi ew f ea t ur e t o view t he S QL S ynt a x of
t he Qu er y
gener a t ed. T o vi ew t he S QL S ynt a x of your Quer y r ight clic k on qu er y t a b a nd S el
ect S QL Vi ew a s shown
i n t he F i gur e 239.
Fi gure
239
: SQL Vi ew

Q ue ry Desig n V iew

Quer y des i gn vi ew (s ee F i gur e 240) ca n b e us ed t o des i gn or cr ea t e a quer y wit h


a ddit i on of fur t her
pa ra met er s such a s Wher e C la use, S or t or Or der By c la use a nd ot her
usefu l f ea t ur es.

Fi gure
240
: SQL Vi ew Query Synt ax

E xerc ise : Q uery S t ude nt T abl e


311. 311.

1.

C lic k C r ea t e t a b. Fr om t he Qu er y gr oup sel ect Quer y Des i gn (F i gur


e 241).
312. 312.

2.

F r om p opup wi ndow s el ect t a bl e na me.


313. 313.

3.
You ca n a dd mu lt ip l e t a bl es t o p er for m qu er y a s wel l for si mp l ic it y we wi ll us e
one t a bl e, c li c k
Add a nd t hen cl os e.
314. 314.

4.

Ta ble wit h is a l l fi el ds wi l l be shown in a sma l l box.


315. 315.

5.

F r om t he opt i ons shown a t t he b ot t om. C


li c k on t ext box a nd fr om dr op down menu s el ect fi el d
316. 316.

6.

mest er . Her e our cr it er ia is

Intr oduct i on t o Com put in g

CS101

VU
P ag e
371

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan


317. 317.

7.

In t he cr it er ia box of t he f i el d ss ems t yp e 3.
318. 318.

8.

R ep ea t st ep 5 t o sel ect r ema ini ng fi el ds of t he t a bl e.


319. 319.

9.

When ha ppy wit h t he s el ect i on cl ic k R un on t he t op l eft cor ner of t he Qu er y T ools


(F igur e 240).
Fi gure
241
: Query Desi gn Vi e w

Fi gu r e
242
: C reat e Query Usi ng Desi gn Vi e w

Intr oduct i on t o Com put in g

CS101

VU

P ag e
372

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 23
0
320. 320.

230.

Web page Deve lop me nt (Note pad E dito r)

In t his modul e, you wil l l ea r n wha t is web pa ge, how it ca n be devel op ed usi ng not
epa d edit or .

What is a Webp ag e?

A web pa ge is not hi ng mor e t ha n a fi l e, a HT ML fil e t o b e exa ct . It 's ca ll ed HT ML


beca us e web pa g e
docu ment s ha ve t he fi l e ext ensi on
. ht ml
or
. ht m.
A web br ows er displa ys a web pa ge on a monit or or
mob i l e devic e. W e ca n us e W ebP a ges t o displa y i nf or ma t i on
t o a la r ge a udi enc e. W ebP a ges pr ovi des a n
opp or t unit y t o ma r ket your business a t a lar ger sca l e a nd l et t he wor l d know
your exist enc e.

Hyp er T ext Mar kup La ngua ge is a ma r kup la ngua ge t ha t web br ows er s use t o int er
pr et a nd comp os e t ext ,
i ma gesa ndot her ma t e
r ia li nt ovisua lor a udibl e webpages. Defa ult cha r a ct er ist icsfor ever yit emofHTML
ma r kupa r edefi nedi nt hebr ows er . T hepur poseofawebbr ows er ist or ea dHT MLdocu
ment sa ndcomp os e
t hem i nt o visib l e or a udibl e web pa ges. Whenever you op en a HTML doc
u ment i n a web br ows er , t he web
br ows er does not disp la y t he HT ML ta gs, but uses t he t a gs t o int er pr et t he c ont
ent of t he pa ge.

HT MLel ement sfor mt hebuil di ngbl oc ksofa llwebs it es.HT MLa ll owsi ma gesa ndobj ect
st obeemb edde d
a ndca nb eus edt ocr ea t e

i nt er a ct ive f or ms. It pr ovi desa mea nst ocr ea t est r uct ur eddocu ment sby denot in g
st r uct ura lsema nt i csf or t ext suc ha shea di ngs, par a gra phs, l ist s, li nks, qu ot esa ndot
her it ems. It ca n emb e d
scr ipt s wr it t en i n la ngua ges such a s Ja va S cr ipt whi c h a ff ect t
he b eha vi or of HT ML web pa ges.
321. 321.

1.1

H T ML E le me nts:
AnHT MLel ement ha sa sta rt inga nd endi ngt a g. C ont ent ispla cedbet weenst a r ta
ndendt a g. Element sca n
ha ve va r ious a t tr ibut es.
322. 322.

1.

T he t ext bet ween t a gs <ht ml> a nd </ ht ml> descr ib es t he st a r ta nd end of web
pa ge.
323. 323.

2.

T he t ext b et ween t a gs <body> a nd </ body> r epr es ent s t he c ont ent of t he pa ge t ha


t is vis ible t o t h e
end us er .
324. 324.

3.

T he t ext bet ween t a gs <h1> a nd </ h1> is pr es ent ed a s a fir st hea di ng.
325. 325.

4.

T het ext b et weent a gs<p>a nd</ p>ispr es ent ed oft he pa gea sonepa r a
gr a ph. Ea cht a gha sa sta t ing
t a g a nd a n endi ng t a g. S ome exc ept i ons a r e t her e whi c h wi l l be discuss ed la t er .

An el ement ca n ha ve mult ipl e el em ent s i n it b ef or e end t a g.

BLOC K el ement s a lwa ys st ar t a ft er a new l i ne a nd t he cont ent is displa yed i n t he


next
l i ne i n br ows er .
Exa mp l es: < h1>, <p>, <ul>, <ta ble>( wi ll b e us ed i n comi ng s ect i ons )

Inl i neel em ent sa r eusua llydisp la yedont hebr ows er wit hout st ar t inga newl i ne. Exa
mpl es:<b>, <t d>,<a >,
<i mg>

HT ML At t r ibutes

Element s ha ve a t tr ibut es t ha t pr ovi des a d


dit i ona l i nf or ma t i on a bout t ha t el em ent . At t r ibut es a r e cer t a in
na me t ha t comes i n b et ween st a r t ing a nd endi ng t a gs.

E xa mp le:

<i mg sr c=" VU l ogo. jp g" wi dt h= "100" hei ght ="150">

Intr oduct i on t o Com put in g

CS101

VU

P ag e
373
of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

i mg is
el ement .

sr c, wi dt h a nd hei ght a r e a t tr ibut es for i ma ge


t a g.

sr c defi nes t he l oca t i on of t he el ement .


Wi dt h a nd hei ght
r epr es ent

siz es of t he i ma ge.

Us i ng N ot epa d t o devel op HT MLpa ge


326. 326.

1.

Open a ny t ext edit or for exa mp l e

not epa d
327. 327.
2.

Wr it e t he code s hown i n t he F i gur e 243.

Fi gure
243
: HT ML code i n
N ot epad
328. 328.

3.

Now sa ve t he docu ment a s ht ml i llust r a t ed i n t he F i gur e 244.

Fi gure
244
: Savi ng as ht ml page

Doub l e cl i ck on t ha t ht ml f i l e a nd op en wit h a
ny of i nst a ll ed br ows er s. T he i c on wil l a ppea r as shown i n
t he F i gur e 245.

Fi gure
245
: Fi rs t web page out put
Intr oduct i on t o Com put in g

CS101

VU

P ag e
374

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 23
1
329. 329.

231.
Web page Deve lop me nt (I ntro d uct io n to Dre amwe aver)

Alt hou ght heHT MLma r kupof


a webpa geca nb e wr it t en wit ha nyt ext edit or sucha sNot epa da sweha ve
wr it t en in t he la st modul e. However , when we a r e ma ki ng la r ge webpa ges wit h ma
ny dif f er ent t a gs, in t ha t
ca se, t he code b ec omes c ompl ex. T o cop e wit h suc h sit ua t ion, spec ia li z ed HT ML

edit or s a r e used.

H T ML editor
is a soft wa r e a pplica t i on f or cr ea t i ng web pa ges, spec ia li z ed HT M L edit or s ca n
off er
conveni enc e a nd a dded funct i ona lit y. F or exa mpl e, ma ny HT ML edit or s wor k not
onl y wit h HT ML, but
a lso wit h r ela t ed t ec hnol ogi es such a sC SS

(Ca sca di ng S t yl e S heet s), XML(Extens ible Ma r kup La ngua ge)


a nd Ja va S cr ipt . Anyone who wa nt s t o ma ke pr of ess i ona l web pa ges, he ha s t o use t
hes e t ec hnol ogi es.
Al most a ll pa ges t ha t you s ee now a da ys on t he I nt er net c onsist of (fu ll y or par t
ia ll y) c omp onent
s t ha t a r e
ma de fr om C S S , XMLa nd Ja va S cr ipt.

In t his modu l e we wi l l be i nt r oduc i ng a t ol l known a s Adob e Dr ea mwea ver t ha t


ma kes it ea si er for web
pa ge devel op er s t o ut il iz e t he t ec hnol ogi es l i ke C S S a nd Ja va S cr ipt . We wi l l not
be ma king c ompl ex web
pa ges
int hisla b
however ;

wewil lbegoi ngt hr ou ghabasici nt r odu ct i onofAdob eDr ea mwea ver . Alt houg h
t her ear esever a lot her HT MLedit i ngt oolsa va ila bl e, weha vec hos ent hist oolbeca us
eit isa mongt he most
com monl y us ed t ool f or pr ofess i ona l web devel op men
t.

Adob eDr ea mwea ver isawebdes i gna nddevel op ment appli ca t iont ha t pr ovi desa visua
lWYS IW YGedit or
(Wha t You S ee Is Wha t You Get ) a nd a code edit or wit h st a nda r d f ea t ur es such a s
synt a x highl i ght i ng,
code c omp l et i on, a nd c ode c ol la psi ng a s wel l a s mor e

s op his t ica t ed f ea t ur es s uch a s r ea l


-
t i me s ynt a x
chec king a nd c ode i nt r osp ect i on for gener a t i ng c ode hi nt s t o a ss ist t he user i n
wr it i ng code.

Dr ea mwea ver is a power ful a pplica t i on for devel op i ng webs it es a nd mob i l e a


pplica t i ons. You ca n sa ve
t i me, wor k mo
r e eff ic i ent ly, a nd cr ea t e c omp el l i ng designs wit h t he c omp l et e s et of t ools. It is
lea di ng
soft wa r e for devel opi ng websit es a nd mob i l e a pplica t i ons. Usi ng it s power fu l HT
ML codi ng envir onment
a nd st a nda r d
-
s et t i ng visua l i nt er fa c e, you ca n cr ea t e enga gi ng
a nd dyna mic webs it es for a wi de r a nge of
devic es, wha t ever your level of des i gn or devel op ment exp er i enc e.

T he c om mon mi sc onc ept i on wit h Dr ea mwea ver is t ha t Dr ea mwea ver is des i


gned t o or is even ca pa bl e of
comp l et el y r emovi ng t he t ext edit or s li ke N ot epa d
f or HT ML a nd C S S codi ng fr om web des i gn. T his is
li ke sa yi ng t ha t a
ma c hi ne
-
ma de

f oot ba ll ca n c omp l et el y r ep la c e a
ma n
-
ma de

f oot ba ll A ma c hi ne ma d e
foot ba l l ca n ma ke good qua nt it y of f oot ba lls i n a com mer cia l pr oduct i on however ,
it ca nnot a chi eve t h e
dur a b
il it y a nd p er f ect i on of a ma n ma de f oot ba l l. As you ma y know, ma n
-
ma de f oot ba lls fr om S ia l kot a r e
st il l bei ng us ed i n i nt er na t i ona l t our na ment s even t hou gh we ha ve t he c hoi c e of
ma chi ne
-
ma de

f oot ba lls.
Dr ea mwea ver , li ke t he ma c hine t ha t ma kes foot ba l l, is des i gned t o ma ke your lif
e ea si er . You ma y never

T his is not a lt oget her a ba d t hi ng: it is si mp l y a sli


ght l y nar r ow p er spect i ve
on a la r ge f i el d. Dr ea mwea ver
is not desi gned t o c ompl et el y r emove t he ut i lit y of H T ML a nd C S S : it is mea nt t o
a ss ist you wit h your
HT ML a nd C SS a nd t o ma ke some of t he mor e mu nda ne a spect s of W eb P ublis hi ng l
ess t er r ibl e.

Dr ea mwea
ver i nt er fa c e ha s been shown i n t he F igur e 246.

Intr oduct i on t o Com put in g

CS101

VU

P ag e
375

of
3 81
C opy rig htVi rtual U ni v ersi ty ofP aki stan

Fi gure
246
: Dreamweaver i nterf ace

T heDoc u me nttoo lb ar :
C ont a i nsbut t onst ha t pr ovi deopt i onsf or di ff er ent vi ewsoft heD ocu ment wi ndow
(such a s Des i gn vi ew a nd
C ode vi ew), va r i ous vi ewi ng opt i ons, a nd some c ommon op er a t ions such a s
pr evi ewi ng i n a br ows er .

T heMe nuandInse rtbar


:Acr oss t het opoft hea pplica t ionwi ndowcont a i nsawor kspa c eswit c her , menus
a nd ot her a pplica t i on c ont r ols. T o displa y t he S t a nda r d
t oolba r , sel ect Vi ew

> T oolba r s >S t a nda r d. T he t oolba r cont a i ns but t ons f or common op er a t ions fr
om t he F i l e a nd E dit menus
ver y s i mi la r t o MS Wor d: N ew, Open, Br ows e i n Br i dge, S a ve, S a ve Al l, Pr int C
ode, C ut , C opy, P ast e,
Undo, a nd R edo.

T heDoc ume ntwi n


dow :
Displa yst hecur r ent docu men t a syoucr ea t ea nd edit it . T oswit c ht oadocu ment ,
cl ic k it s t ab. T he Docu ment Wi ndow is t he ma in wor ks pa ce wher e you ins er t a nd a
rra nge t he el em ent s on
your web pa ge. Most of your wor k i ns er t ing t ext a nd i ma ges on your
web pa ge is done i n t he D ocu ment
Wi ndow.

You ca n s el ect a ny of t he vi ews. Descr ipt i on of t he i mp or t a nt vi ews is gi ven b el


ow.

Desig n vi ew:
A desi gn envir onment for visua l page la yout , visua l edit i ng, a nd ra pid a pplica t i on
devel op ment . In t his vi ew, Dr ea mwea
ver disp la ys a full y edit a bl e, visua l r epr es ent a t i on of t he docu ment ,
si mi la r t o wha t you would s ee when viewi ng t he pa ge i n a br ows er .

Code view :
A ha nd
-
c odi ng envir onment for wr it i ng a nd edit i ng HT ML, Ja va S cr ipt ,

S pli t Code v iew :


A spl it ver si on of C ode

vi ew t ha t l et s you s cr oll t o wor k on di ff er ent s ect i ons of t he


docu ment a t t he sa me t i me.

Code and Desig n view :


Let s you s ee bot h C ode view a nd D esi gn view for t he sa me docu ment in a singl e
wi ndow.
L ive view:
S i mi la r t o Des i gn vi ew, Live vi ew displ a ys a m
or e r ea l ist ic r epr es ent a t ion of wha t your
docu ment wil l l ook li ke i n a br ows er , a nd l et s you i nt er a ct wit h t he docu ment
exa ct l y a s you wou l d i n a
br ows er . Live vi ew is not edit a bl e. However , you ca n e dit i n C ode vi ew a nd r efr es
h Live vi ew t o s ee your
cha ng
es.

Intr oduct i on t o Com put in g

CS101

VU

P ag e
376

of
3 81
C opy rig htVi rtual U ni v ersi ty ofP aki stan

L ive Code view:


Onl y a va ila bl e when vi ewi ng a doc u ment in Live vi ew. Live C ode vi ew disp la ys t he
a ct ua l code t ha t a br ows er uses t o ex ecut e t he pa ge, a nd ca n dyna mica l l y cha nge
a s you i nt er a ct wit h t h e
pa ge i n l ive vi ew. Live C ode vi ew is not edit a bl e.

Pro per ti es Ins pec tor


a s shown i n t he F i gur e 247 a lso ca ll ed t he T a g Inspect or . T he P r oper t y I nsp ect
or is
used t o displa y a nd edit a tt r ibut es or pr oper t i es of a ny el ement t ha t is sel ect ed i n
t he Docu ment Wi ndow.
C lic k t he P r op er t y I nsp ect or 's Hide but t on t
o hi de t he pa nel t emp or a r il y.

Fi gure
247
: Propert i es panel
Intr oduct i on t o Com put in g

CS101

VU
P ag e
377

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 23
2
330. 330.

232.

Web page Deve lop me nt (I nser ti ng T ab les us i ng

Dre amw eav er)

F ir st sa ve t he docu ment t ha t you got a ft er cl ic king new HT ML docu ment i n t he


welc ome scr een a s shown
i n t he F i gur e 248.

Fi gure
248
: Add new page

Now a dd HT ML pa ge a s shown i n t h
e F i gur e 249.

Fi gure
249
: Adding HT ML page

Intr oduct i on t o Com put in g

CS101

VU
P ag e
378

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Now gi ve a na me t o t he pa ge a s shown i n t he F i gur e 250.

Fi gure
250
: N ami ng t he page

T o ins er t t a ble, just go t o t he I ns er t t a b a nd a dd t he t a bl e a s shown i n t he F i


gur e 251.

Fi gure
251
: Insert T able

You ca n t hen sp ec if y nu mb er of r ows a nd c olu mns a s shown i n t he F i gur e 252.

Fi gure
252
: Rows and col umns

You ca n t hen a djust t he siz e of t he r ows a s shown i n t he F i gur e 253.

Intr oduct i on t o Com put in g

CS101

VU

P ag e
379

of
3 81
C opy rig htVi rtual U ni v ersi ty ofP aki stan

Fi gure
253
: Adjus ti ng row si zes

Intr oduct i on t o Com put in g

CS101

VU

P ag e
380

of
3 81
C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 23
3
331. 331.

233.

Web page Deve lop me nt (I nser ti ng L ists)

Bul l et ed l ist s mi ght b e fa mi lia r t o you if you ha ve wor ked wit h wor d pr oc ess i ng
or des kt op pub lis hi ng
a pplica t i ons. List s ar e a helpfu l wa y t o pr es ent i nf or ma t ion t o
a r ea der wit hout t he f or ma l c onst r a int s of a
pa ra gra ph. T heya r eesp ec ia l l yi mp or t a nt ont heW eb. S tudi esi ndica t et ha t peop l
et yp ica l l yski mwebpa ges
i nst ea d of r ea di ng t hem fr om b egi nni ng t o end. Cr ea t ing l ist s wi ll ma ke it ea si er
for your vis it or s t o g
et t he
most fr om your websit e wit hout sift i ng t hr ou gh sever a l pa ra gra phs of t ext .

On t he

event s. ht ml
pa ge, cl ic k a nd dr a g t o highli ght t he t ext whi c h you wa nt t o put in t he l ist .

Ma ke sur e you ha ve t he HT ML butt on s el ect ed i n t he P r oper t y Insp ect or a t t he

bot t om of your pa ge, a nd


cl ic k t he Unor der ed List but t on a s shown i n t he F igur e 254. T he hi ghl i ght ed t ext
bec omes i ndent ed, a nd a
bull et p oi nt is pla c ed a t t he b egi nni ng of ea c h l i ne.

Fi gure
254
: Adding unorder
ed li st

Us e t he Unor der ed List but t on i n t he P r oper t y I nsp ect or t o cr ea t e a bull et ed l


ist .

C lic k t he Or der ed List but t on t o t he r i ght of t he Unor der ed List but t on. T he bul l
et s cha nge t o s eq
u ent ia l
nu mb er s.

C hoos e F or ma t > List > Pr oper t i es t o op en t he L ist Prop er t i es dia l og box. C hoos
e Bul l et ed L ist fr om t h e
List t ype dr op
-
down menu t o r et ur n t o your fir st st yl e of list . T he Nu mb er ed List a nd Bull et ed L
ist opti ons
i n t he List t yp e dr op
-
down
menu a lso a l low you t o swit ch b et ween or der ed a nd u nor der ed l ist s.

F r om t he S t yl e dr op
-
down menu (s ee F i gur e 255), choose S qua r e. T his cha nges t he defa ult cir cula r
bull et s t o s qua r e bull et s. C lic k OK t o exit t he L ist P r oper t i es dia l og b ox.

Fi gure
255
: L i st of propert i es

Intr oduct i on t o Com put in g

CS101

VU

P ag e
381

of
3 81

C opy rig htVi rtual U ni v ersi ty ofP aki stan

Mod ule 23
4

You might also like