0% found this document useful (0 votes)
54 views124 pages

Dotnet Faqs1

dfs

Uploaded by

Aravind Bhombore
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views124 pages

Dotnet Faqs1

dfs

Uploaded by

Aravind Bhombore
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 124

(B)What is IL? Twist :- What is MSIL or CIL , What is JIT? (IL)Intermediate Language is also nown as MSIL (Mi!

roso"t Intermediate Language) or CIL (Common Intermediate Language)# $ll #%&T sour!e !ode is !om'iled to IL# This IL is then !on(erted to ma!hine !ode at the 'oint where the so"tware is installed, or at run-time )* a JustInTime (JIT) !om'iler# (B)What is the CL+? ,ull "orm o" CL+ is Common Language +untime and it "orms the heart o" the #%&T "ramewor #$ll Languages ha(e runtime and its the res'onsi)ilit* o" the runtime to ta e !are o" the !ode e-e!ution o" the 'rogram#,or e-am'le .C// has MSC+T01#2LL,.B3 has MS.B.M31#2LL , Ja(a has Ja(a .irtual Ma!hine et!# Similarl* #%&T has CL+#,ollowing are the res'onsi)ilities o" CL+ 4 5ar)age Colle!tion :- CL+ automati!all* manages memor* thus eliminating memor* lea es# When o)6e!ts are not re"erred 5C automati!all* releases those memor* thus 'ro(iding e""i!ient memor* management# 4 Code $!!ess Se!urit* :- C$S grants rights to 'rogram de'ending on the se!urit* !on"iguration o" the ma!hine#&-am'le the 'rogram has rights to edit or !reate a new "ile )ut the se!urit* !on"iguration o" ma!hine does not allow the 'rogram to delete a "ile#C$S will ta e !are that the !ode runs under the en(ironment o" ma!hines se!urit* !on"iguration# 4 Code .eri"i!ation :- This ensures 'ro'er !ode e-e!ution and t*'e sa"et* while the !ode runs#It 're(ents the sour!e !ode to 'er"orm illegal o'eration su!h as a!!essing in(alid memor* lo!ations et!# 4 IL( Intermediate language )-to-nati(e translators and o'timi7er8s :- CL+ uses JIT and !om'iles the IL !ode to ma!hine !ode and then e-e!utes# CL+ also determines de'ending on 'lat"orm what is o'timi7ed wa* o" running the IL !ode# (B)What is the CTS? In order that two language !ommuni!ate smoothl* CL+ has CTS (Common T*'e S*stem)#&-am'le in .B *ou ha(e 9Integer: and in C// *ou ha(e 9long: these datat*'es are not !om'ati)le so the inter"a!ing )etween them is (er* !om'li!ated# In order that two di""erent languages !an !ommuni!ate ; <ne o" the "irst =uestion as ed during inter(iew is 9Can *ou sa* something a)out *our sel" :?# ># Basi! #%&T ,ramewor ;?ow mu!h do *ou rate *oursel" in #%&T in one out o" ten ? >@ Mi!roso"t introdu!ed Common T*'e S*stem# So 9Integer: datat*'e in .B3 and 9int: datat*'e in C// will !on(ert it to S*stem#intAB whi!h is datat*'e o" CTS#CLS whi!h is !o(ered in the !oming =uestion is su)set o" CTS# I" *ou ha(e undergone C<M 'rogramming 'eriod inter"a!ing .B3 a''li!ation with .C// a''li!ation was a real 'ain as the datat*'e o" )oth languages did not ha(e a !ommon ground where the* !an !ome and inter"a!e , )* ha(ing CTS inter"a!ing is smooth# (B)What is CLS(Common Language S'e!i"i!ation)? This is a su)set o" the CTS whi!h all #%&T languages are e-'e!ted to su''ort#It was alwa*s a dream o" mi!roso"t to unite all di""erent languages in to one um)rella and CLS is one ste' towards that#Mi!roso"t has de"ined CLS whi!h are nothing )ut guidelines that language to "ollow so that it !an !ommuni!ate with other #%&T languages in a seamless manner#

(B)What is Managed Code? Managed !ode runs inside the en(ironment o" CL+ i#e# #%&T runtime#In short all IL are managed !ode#But i" *ou are using some third 'art* so"tware e-am'le .B3 or .C// !om'onent the* are unmanaged !ode as #%&T runtime (CL+) does not ha(e !ontrol o(er the sour!e !ode e-e!ution o" the language# (B)What is $ssem)l* ? 4 $ssem)l* is unit o" de'lo*ment li e &C& or a 2LL# 4 $n assem)l* !onsists o" one or more "iles (dlls, e-e8s, html "iles et!#), and re'resents a grou' o" resour!es, t*'e de"initions, and im'lementations o" those t*'es# $n assem)l* ma* also !ontain re"eren!es to other assem)lies# These resour!es, t*'es and re"eren!es are des!ri)ed in a )lo! o" data !alled a mani"est# The mani"est is 'art o" the assem)l*, thus ma ing the assem)l* sel"-des!ri)ing# 4 $n assem)l* is !om'letel* sel"-des!ri)ing#$n assem)l* !ontains metadata in"ormation, whi!h is used )* the CL+ "or e(er*thing "rom t*'e !he! ing and se!urit* to a!tuall* in(o ing the !om'onents methods#$s all in"ormation is in assem)l* itsel" it is inde'endent o" registr*#This is the )asi! ad(antage as !om'ared to C<M where the (ersion was stored in registr*# 4 Multi'le (ersions !an )e de'lo*ed side )* side in di""erent "olders# These di""erent (ersions !an e-e!ute at the same time without inter"ering with ea!h other#$ssem)lies !an )e 'ri(ate or shared# ,or 'ri(ate assem)l* de'lo*ment,the assem)l* is !o'ied to the same dire!tor* as the !lient 'rogram that re"eren!es it#%o registration is needed, and no "an!* installation 'rogram is re=uired# ; %e(er tal "or more than > minutes straight during inter(iew# ;2o not memori7e ea!h and e(er* answer o" this )oo #Just get the "undamentals straight and sa* in *our own words# >D When the !om'onent is remo(ed, no registr* !leanu' is needed,and no uninstall 'rogram is re=uired# Just delete it "rom the hard dri(e# 4 In shared assem)l* de'lo*ment, an assem)l* is installed in the 5lo)al $ssem)l* Ca!he (or 5$C)# The 5$C !ontains shared assem)lies that are glo)all* a!!essi)le to all #%&T a''li!ations on the ma!hine# ($) What are di""erent t*'es o" $ssem)l*? There are two t*'es o" assem)l* Eri(ate and Eu)li! assem)l*#$ 'ri(ate assem)l* is normall* used )* a single a''li!ation, and is stored in the a''li!ationFs dire!tor*, or a su)-dire!tor* )eneath# $ shared assem)l* is normall* stored in the glo)al assem)l* !a!he, whi!h is a re'ositor* o" assem)lies maintained )* the #%&T runtime# Shared assem)lies are usuall* li)raries o" !ode whi!h man* a''li!ations will "ind use"ul, e#g# Cr*stal re'ort !lasses whi!h will )e used )* all a''li!ation "or +e'orts## (B) What is %ameS'a!e? %ames'a!e has two )asi! "un!tionalit* :4 %ameS'a!e Logi!all* grou' t*'es#&-am'le S*stem#We)#GI logi!all* grou's our GI related "eatures# 4 In <)6e!t <riented world ma* times its 'ossi)le that 'rogrammers will use the same !lass name#B* =uali"*ing %ameS'a!e with !lassname this !ollision !an )e remo(ed# (B) What is 2i""eren!e )etween %ameS'a!e and $ssem)l*? ,ollowing are the di""eren!es )etween names'a!e and assem)l* : 4 $ssem)l* is 'h*si!al grou'ing o" logi!al units# %ames'a!e logi!all* grou's !lasses#

4 %ames'a!e !an s'an multi'le assem)l*# ($)I" *ou want to (iew a $ssem)l* how to *ou go a)out it ? Twist : What is IL2$SM ? When it !omes to understanding o" internals nothing !an )eat IL2$SM#IL2$SM )asi!all* !on(erts the whole e-e or dll in to IL !ode#To run IL2$SM *ou ha(e to go to HC:IErogram ,ilesIMi!roso"t ;Is *our e-'erien!e "ull* in #%&T , or do *ou ha(e an* 'rior e-'erien!e in other mi!roso"t te!hnolog* li e .B3,.C// et! ;Can *ou gi(e me two re"eren!es o" *our 're(ious !om'an* whom i !an !onta!t ? B1 .isual Studio #%&T B11AIS2JI(>#>IBinH# %ote that i had (>#> *ou ha(e to 'ro)a)l* !hange it de'ending on the t*'e o" "ramewor (ersion *ou ha(e# I" *ou run I2$SM#&C& "rom the 'ath *ou will )e 'o''ed with the I2$SM e-e 'rogram as shown in "igure IL2$SM#Cli! on "ile and )rowse to the res'e!ti(e dire!tor* "or the 2LL whose assem)l* *ou want to (iew#$"ter *ou sele!t the 2LL *ou will )e 'o''ed with a tree (iew details o" the 2LL as shown in "igure IL2$SM#<n dou)le !li! ing on mani"est *ou will )e a)le to (iew details o" assem)l* , internal IL !ode et! as shown in ,igure Mani"est .iew# %ote : The (ersion num)er are in the mani"est itsel" whi!h is de"ined with the 2LL or &C& thus ma ing de'lo*ment mu!h easier as !om'ared to C<M where the in"ormation was stored in registr*#%ote the (ersion in"ormation in ,igure Mani"est (iew# Kou !an e-'and the tree "or detail in"ormation regarding the 2LL li e methods et!# ; 2o not mention !lient name8s in resume#I" as ed sa* that it8s !on"idential whi!h )rings ahead =ualities li e honest*# ;When *ou ma e *our resume ee' *ou re!ent 'ro6e!ts at the to'# ;It must )e hard to lea(e the 're(ious !om'an* , as *ou ha(e s'end =uiet a lot time with them ? B> ,igure:- >#> IL2$SM %ote :- ; ,ind out what the em'lo*er is loo ing "or )* as ing him =uestions at the start o" inter(iew and )est is )e"ore going to inter(iew#&-am'le i" a !om'an* has 'ro6e!ts on ser(er 'rodu!ts em'lo*er will )e loo ing "or Bi7tal , CS CMS e-'erts# ; What8s *our "amil* )a! ground ? ; I" *ou are "resher this is a !ommon =uestion#Kou do not ha(e e-'erien!e in #%&T so wh* do *ou thin *ou are suita)le "or this 6o) ? BB ,igure :- >#B Mani"est .iew ($) What is Mani"est? $ssem)l* metadata is stored in Mani"est#Mani"est !ontains all the metadata needed to do the "ollowing things( See ,igure Mani"est .iew "or more details) : 4 .ersion o" assem)l* 4 Se!urit* identit* 4 S!o'e o" the assem)l* 4 resol(e re"eren!es to resour!es and !lasses# 4 The assem)l* mani"est !an )e stored in either a E& "ile (an #e-e or #dll) with Mi!roso"t intermediate language (MSIL) !ode or in a stand-alone E& "ile that !ontains onl* assem)l* mani"est in"ormation# ; ?a(e *ou heard a)out our !om'an* ? Sa* "i(e 'oints a)out our !om'an* ? Just read atleast on!e what !om'an* *ou are going "or ? ; Whi!h is the )est 'ro6e!t *ou ha(e done till now ? and in what sense the 'ro6e!t was the )est ?

BA (B)Where is (ersion in"ormation stored o" a assem)l* ? .ersion in"ormation is stored in assem)l* in mani"est# (I)Is (ersioning a''li!a)le to 'ri(ate assem)lies? .ersioning !on!e't is onl* a''li!a)le to glo)al assem)l* !a!he (5$C) as 'ri(ate assem)l* lie in there indi(idual "olders# (B) What is 5$C ? Twist :- What are situations when *ou register #%&T assem)l* in 5$C ? 5$C (5lo)al $ssem)l* Ca!he) is where shared #%&T assem)l* reside#5$C is used in the "ollowing situations :4 I" the a''li!ation has to )e shared among se(eral a''li!ation# 4 I" the assem)l* has some s'e!ial se!urit* re=uirements li e onl* administrators !an remo(e the assem)l*#I" the assem)l* is 'ri(ate then a sim'le delete o" assem)l* the assem)l* "ile will remo(e the assem)l*# %ote :- +egistering #%&T assem)l* in 5$C !an lead to the old 'ro)lem o" 2LL hell# Where C<M (ersion was stored in !entral registr*#So 5$C should )e used when a)solutel* ne!essar*# (I) What is !on!e't o" strong names ? Twist :- ?ow do we generate strong names or what is the 'ro!ess o" generating string names , What is use o" S%#&C& , ?ow do we a''l* strong names to assem)l* ? , ?ow do *ou sign an assem)l* ? Strong name is similar to 5GI2(It is su''osed to )e uni=ue in s'a!e and time) in C<M !om'onents#Strong %ame is onl* needed when we need to de'lo* assem)l* in 5$C#Strong %ames hel's 5$C to di""erentiate )etween two (ersions#Strong names use 'u)li! e* !r*'togra'h* (EJC) to ensure that no one !an s'oo" it#EJC use 'u)li! e* and 'ri(ate e* !on!e't# ,ollowing are the ste' to generate a strong name and sign a assem)l* :; Whi!h is the )iggest si7e o" team *ou ha(e wor ed with and was there an* lead in(ol(ed "rom *our side ? ; 2o *ou wor on staurda*8 and sunda*8s ? B0 4 5o to 9.isual Studio Command Erom't:#See )elow "igure to 9.isual studio Command Erom't:#%ote the sam'les are !om'iled in B11L )ut B11A users do not ha(e to worr* a)out it#Same t*'e o" !ommand 'rom't will )e seen in B11A also# ,igure :- >#A .isual Studio Command Erom't 4 $"ter *ou are in !ommand 'rom't t*'e sn#e-e - 9!:Itest#sn :# ,igure :- >#0 +unning S%#&C& ; ?a(e *ou done an* ind o" !erti"i!ation ? ; What8s the noti!e 'eriod "or *our 're(ious !om'an* ? BL ,igure :- >#L Su!!ess"ul out'ut o" S%#&C& ,igure :- >#3 Sam'le (iew o" test#sn "ile 4 $"ter generation o" the "ile *ou !an (iew the S%J "ile in a sim'le note'ad# 4 $"ter the S%J "ile is generated its time to sign the 'ro6e!t with this S%J "ile# ; 2o *ou ha(e 'ass'ort si7e 'hotos , 'ass'ort , "inal *ear graduation !erti"i!ate et!# et!#Be sure to ta e these do!uments with *ou#2o not now "or these small things some !om'anies do eliminate !andidates# ; ?a(e *ou wor ed with an* ser(er 'rodu!ts li e Bi7tal ,CMS , CS et!# B3

,igure:- >#M Cli! on 'ro6e!t and then !li! on 9!lassli)rar*> 'ro'erties: menu to sign the assem)l* 4 Cli! on 'ro6e!t -- 'ro'erties and the )rowse the S%J "ile to the res'e!ti(e "older and !om'ile the 'ro6e!t# ;Whi!h is *our "a(orite .B3 or .B#%&T#####Just do not get in to arguments ? ; What8s *our "a(orite .B#%&T or CN####Ere'are a di'lomati! answer#### 2o not get in to arguments# BM ,igure :- >#@ Cli! on Gse a e* "ile to sign the assem)l* with strong name (I)?ow to add and remo(e a assem)l* "rom 5$C? There are two wa*s to install #%&T assem)l* in 5$C:4 Gsing Mi!roso"t Installer Ea! age#Kou !an get download o" installer "rom htt':OOwww#mi!roso"t#!om# 4 Gsing 5a!util# 5oto 9.isual Studio Command Erom't: and t*'e 9ga!util Pi (assem)l*Qname):#Where (assem)l*Qname) is the 2LL name o" the 'ro6e!t# ; I" *ou "ail in one inter(iew does not mean *ou ha(e to disa''ointed#Jee' tr*ing IT industr* has lot in store# ; $s a inter(iewer alwa*s remem)er that *ou will also )e sitting sometimes at the other end#So do not as an* 's*!he =uestion whi!h does not 6udge an*thing o" a !andidate# B@ (B) What is 2ela* signing ? 2uring de(elo'ment 'ro!ess *ou will need strong name e*s to )e e-'osed to de(elo'er whi!h will is not a good 'ra!ti!e "rom se!urit* as'e!t 'oint o" (iew#In su!h situations *ou !an assign the e* later on and during de(elo'ment *ou an use dela* signing ,ollowing is 'ro!ess to dela* sign a assem)l*: 4 ,irst o)tain *our string name e*s using S%#&C&# 4 $nnotate the sour!e !ode "or the assem)l* with two !ustom attri)utes "rom S*stem#+e"le!tion: $ssem)l*Je*,ile$ttri)ute, whi!h 'asses the name o" the "ile !ontaining the 'u)li! e* as a 'arameter to its !onstru!tor# $ssem)l*2ela*Sign$ttri)ute, whi!h indi!ates that dela* signing is )eing used )* 'assing true as a 'arameter to its !onstru!tor# ,or e-am'le as shown )elow: R.isual Basi!S T$ssem)l*:$ssem)l*Je*,ile$ttri)ute(Hm*Je*#sn H)U T$ssem)l*:$ssem)l*2ela*Sign$ttri)ute(true)U RCNS Rassem)l*:$ssem)l*Je*,ile$ttri)ute(Hm*Je*#sn H)S Rassem)l*:$ssem)l*2ela*Sign$ttri)ute(true)S The !om'iler inserts the 'u)li! e* into the assem)l* mani"est and reser(es s'a!e in the E& "ile "or the "ull strong name signature# The real 'u)li! e* must )e stored while the assem)l* is )uilt so that other assem)lies that re"eren!e this assem)l* !an o)tain the e* to store in their own assem)l* re"eren!e# 4 Be!ause the assem)l* does not ha(e a (alid strong name signature, the (eri"i!ation o" that signature must )e turned o""# Kou !an do this )* using the P.r o'tion with the Strong %ame tool#The "ollowing e-am'le turns o"" (eri"i!ation "or an assem)l* !alled m*$ssem)l*#dll# Sn P.r m*$ssem)l*#dll BD

4 Just )e"ore shi''ing, *ou su)mit the assem)l* to *our organi7ationFs signing authorit* "or the a!tual strong name signing using the P+ o'tion with the Strong %ame tool#The "ollowing e-am'le signs an assem)l* !alled m*$ssem)l*#dll with a strong name using the sgJe*#sn e* 'air# Sn -+ m*$ssem)l*#dll sgJe*#sn (B)What is gar)age !olle!tion? 5ar)age !olle!tion 5ar)age !olle!tion is a CL+ "eature whi!h automati!all* manages memor*# Erogrammers "orget to release the o)6e!ts while !oding ##### la7iness ( +emem)er in .B3 where one o" the good 'ra!ti!es is to set o)6e!t to nothing)#CL+ automati!all* releases o)6e!ts when the* are no longer re"eren!ed and in use#CL+ runs on non-deterministi! to see the unused o)6e!ts and !leans them# <ne side e""e!t o" this non-deterministi! "eature is that we !annot assume an o)6e!t is destro*ed when it goes out o" the s!o'e o" a "un!tion# There"ore, we should not 'ut !ode into a !lass destru!tor to release resour!es# (I) Can we "or!e gar)age !olle!tor to run ? S*stem#5C#Colle!t() "or!es gar)age !olle!tor to run#This is not re!ommended )ut !an )e used i" situations arises# (B)What is re"le!tion? $ll #%&T assem)lies ha(e metadata in"ormation stored a)out the t*'es de"ined in modules#This metadata in"ormation !an )e a!!essed )* me!hanism !alled as 9+e"le!tion:#S*stem#+e"le!tion !an )e used to )rowse through the metadata in"ormation# Gsing re"le!tion *ou !an also d*nami!all* in(o e methods using S*stem#T*'e#In(o emem)er#Below is sam'le sour!e !ode i" needed *ou !an also get this !ode "rom C2 'ro(ided , go to 9Sour!e !ode: "older in 9+e"le!tion Sam'le: "older# Eu)li! Class ,orm> Eri(ate Su) ,orm>QLoad(B*.al sender $s S*stem#<)6e!t, B*.al e $s S*stem#&(ent$rgs) ?andles M*Base#Load 2im Eo)6t*'e $s T*'e 2im Eo)6<)6e!t $s <)6e!t 2im Eo)6Buttons $s %ew Windows#,orms#Button() Eo)6t*'e V Eo)6Buttons#5etT*'e() ,or &a!h Eo)6<)6e!t In Eo)6t*'e#5etMem)ers Lst2is'la*#Items#$dd(Eo)6<)6e!t#ToString()) %e-t &nd Su) &nd Class A1 %ote :- Sam'le sour!e !ode are !om'iled using .B#%&T B11L# ,igure:- >#D Sam'le re"le!tion dis'la* Sam'le sour!e !ode uses re"le!tion to )rowse through 9Button: !lass o" 9Windows#,orms:#I" *ou !om'ile and run the 'rogram "ollowing is out'ut as shown in 9Sam'le +e"le!tion 2is'la*:#Gsing re"le!tion *ou !an also d*nami!all* in(o e a method using 9S*stem#T*'e#In(o eMem)er:# %ote :- S*stem#T*'e#In(o eMem)er is le"t as homewor "or readers#Belie(e me *ou will en6o* doing it *oursel" and the !on!e't o" re"le!tion will )e more !learer# (E)What are di""erent t*'e o" JIT ? %ote :- This =uestion !an onl* )e as ed when the inter(iewer does not now what he wants#It was as ed to me in one o" inter(iew and "or >L minutes he was roaming around

the same =uestion in order to get answer "rom me (re=uirement was "or a sim'le data)ase 'ro6e!t)# Beware o" su!h !om'anies and inter(iewers *ou an land u' no where# JIT !om'iler is a 'art o" the runtime e-e!ution en(ironment# In Mi!roso"t #%&T there are three t*'es o" JIT !om'ilers: A> 4 Ere-JIT# Ere-JIT !om'iles !om'lete sour!e !ode into nati(e !ode in a single !om'ilation !*!le# This is done at the time o" de'lo*ment o" the a''li!ation# 4 &!ono-JIT# &!ono-JIT !om'iles onl* those methods that are !alled at runtime# ?owe(er, these !om'iled methods are remo(ed when the* are not re=uired# 4 %ormal-JIT# %ormal-JIT !om'iles onl* those methods that are !alled at runtime# These methods are !om'iled the "irst time the* are !alled, and then the* are stored in !a!he# When the same methods are !alled again, the !om'iled !ode "rom !a!he is used "or e-e!ution# (B) What are .alue t*'es and +e"eren!e t*'es ? .alue t*'es dire!tl* !ontain their data are either allo!ated on the sta! or allo!ated in-line in a stru!ture# +e"eren!e t*'es store a re"eren!e to the (alueFs memor* address, and are allo!ated on the hea'# +e"eren!e t*'es !an )e sel"-des!ri)ing t*'es, 'ointer t*'es, or inter"a!e t*'es# .aria)les that are (alue t*'es ea!h ha(e their own !o'* o" the data, and there"ore o'erations on one (aria)le do not a""e!t other (aria)les# .aria)les that are re"eren!e t*'es !an re"er to the same o)6e!tW there"ore, o'erations on one (aria)le !an a""e!t the same o)6e!t re"erred to )* another (aria)le#$ll t*'es deri(e "rom the S*stem#<)6e!t )ase t*'e# (B) What is !on!e't o" Bo-ing and Gn)o-ing ? Bo-ing 'ermits an* (alue t*'e to )e im'li!itl* !on(erted to t*'e o)6e!t or to an* inter"a!e t*'e im'lemented )* (alue t*'e#Bo-ing is 'ro!ess in whi!h a o)6e!t instan!es !reated and !o'*ing (alue t*'es (alue in to that instan!e# Gn)o-ing is (i!e (ersa o" )o-ing o'eration where the (alue is !o'ied "rom the instan!e in to a''ro'riate storage lo!ation# Below is sam'le !ode o" )o-ing and un)o-ing where integer data t*'e is !on(erted in to o)6e!t and then (i!e (ersa# 2im - $s Integer 2im * $s <)6e!t - V >1 X )o-ing 'ro!ess *VX un)o-ing 'ro!ess -V* AB (B) What8s di""eren!e )etween .B#%&T and CN ? Well this is the most de)ata)le issue in #%&T !ommunit* and 'eo'le treat there languages li e religion#Its a su)6e!ti(e matter whi!h language is )est#Some li e .B#%&T8s natural st*le and some li e 'ro"essional and terse CN s*nta-es#Both use the same "ramewor and s'eed is also (er* mu!h e=ui(alents # But still lets list down some ma6or di""eren!es )etween them :$d(antages .B#%&T :4 ?as su''ort "or o'tional 'arameters whi!h ma es C<M intero'era)ilit* mu!h eas*# 4 With <'tion Stri!t o"" late )inding is su''orted#Lega!* .B "un!tionalities !an )e used )* using Mi!roso"t#.isualBasi! names'a!e#

4 ?as the WIT? !onstru!t whi!h is not in CN# 4 The .B#%&T 'art o" .isual Studio #%&T !om'iles *our !ode in the )a! ground# While this is !onsidered an ad(antage "or small 'ro6e!ts, 'eo'le !reating (er* large 'ro6e!ts ha(e "ound that the I2& slows down !onsidera)l* as the 'ro6e!t gets larger# $d(antages o" CN 4 CML do!umentation is generated "rom sour!e !ode )ut this is now )een in!or'orated in Whid)e*# 4 <'erator o(erloading whi!h is not in !urrent .B#%&T )ut is )een introdu!ed in Whid)e*# 4 The using statement, whi!h ma es unmanaged resour!e dis'osal sim'le# 4 $!!ess to Gnsa"e !ode# This allows 'ointer arithmeti! et!, and !an im'ro(e 'er"orman!e in some situations# ?owe(er, it is not to )e used lightl*, as a lot o" the normal sa"et* o" CN is lost (as the name im'lies)#This is the ma6or di""eren!e that *ou !an a!!ess unmanaged !ode in CN and not in .B#%&T# ; ?ow mu!h e(er this )oo tries it !an not mat!h the huge (ariations o" =uestions thatFs )een as ed in#%&T inter(iews#But note the* will )e (ariations and the* will ma' to some =uestion o" this )oo # (I)What8s di""eren!e )etween S*stem e-!e'tions and $''li!ation e-!e'tions? $ll e-!e'tion deri(es "rom &-!e'tion Base !lass# &-!e'tions !an )e generated 'rogrammati!all* or !an )e generated )* s*stem# $''li!ation &-!e'tion ser(es as the )ase !lass "or all a''li!ationAA s'e!i"i! e-!e'tion !lasses# It deri(es "rom &-!e'tion )ut does not 'ro(ide an* e-tended "un!tionalit*# Kou should deri(e *our !ustom a''li!ation e-!e'tions "rom $''li!ation &-!e'tion# $''li!ation e-!e'tion are used when we want to de"ine user de"ined e-!e'tion# While s*stem e-!e'tion are all whi!h are de"ined )* #%&T# ,igure :- >#D &-!e'tion ?ierar!h* %ote:- ,ran l* I ha(e alwa*s relied on using Mi!roso"t e-!e'tion a''li!ation )lo! s# $s su!h I ha(e ne(er used a''li!ation e-!e'tionW I thin most o" the wor is done using S*stem e-!e'tion !lasses# (I)What is C<2& $!!ess se!urit*? C$S is 'art o" #%&T se!urit* model that determines whether or not a 'ie!e o" !ode is allowed to run and what resour!es it !an use while running# &-am'le C$S will allow a a''li!ation to read )ut now write and delete rights are gi(en to the a''li!ation# A0 (I)What is a satellite assem)l*? In multilingual a''li!ation in #%&T to su''ort multilingual "un!tionalit* *ou !an modules whi!h are !ustomi7ed "or lo!ali7ation#These assem)lies are !alled as satellite assem)lies# Kou !an distri)ute these assem)lies se'aratel* than the !ore modules#

#%&T Intero'era)ilit*
(I)?ow !an we use C<M Com'onents in #%&T? Twist : What is +CW ? #%&T !om'onents !ommuni!ate with C<M using +CW (+untime Calla)le Wra''er)#,ollowing are the wa*s with whi!h *ou !an generate +CW :-

4 $dding re"eren!e in .isual Studio#net#See "igure )elow ($dding re"eren!e using .S#%&T B11L)#Wra''er !lass is generated and 'la!ed in the 9BI%: dire!tor*# ,igure :- B#> $dding +e"eren!e using .S#%&T B11L B##%&T Intero'era)ilit* A3 4 Gsing T*'e li)rar* im'ort tool# Tl)im'#e-e *ourname#dll# 4 Gsing intero'ser(i!es#S*stem#runtime#Intero'ser(i!es names'a!e !ontains !lass T*'eLi) Con(erter whi!h 'ro(ides methods to !on(ert C<M !lasses and inter"a!e in to assem)l* metadata# 4 Ma e *our !ustom wra''ers#I" *our C<M !om'onent does not ha(e t*'e li)rar* then the onl* wa* to !ommuni!ate is writing !ustom wra''ers# That means !ommuni!ating dire!tl* with C<M !om'onents# (I) <n!e i ha(e de(elo'ed the C<M wra''er do i ha(e to still register the C<M in registr*? Kes# ($)?ow !an we use #%&T !om'onents in C<M? Twist :- What is CCW (C<M !alla)le wra''er) ?, What !aution needs to )e ta en in order that #%&T !om'onents is !om'ati)le with C<M ? #%&T !om'onents !an not )e used in straight "orward wa* with C<M#Kou will need to !reate CCW in order that C<M !om'onents !ommuni!ate with #%&T assem)lies#,ollowing are the di""erent a''roa!hes to im'lement it :4 &-'li!itl* de!lare inter"a!es## Eu)li! Inter"a!e ICustomer Ero'ert* Customer%ame() $s String Ero'ert* CustomerCode() $s String Su) $ddCustomer() &nd Inter"a!e Eu)li! Class Customer Im'lements ICustomer Eri(ate EstrCustomer%ame $s String Eri(ate EstrCustomerCode $s String Eu)li! Su) $ddCustomer() Im'lements ICustomer#$ddCustomer Tr* X addin o" data)ase !ode !an go here Cat!h e- $s &-!e'tion Throw e&nd Tr* AM &nd Su) Eu)li! Ero'ert* CustomerCode() $s String Im'lements ICustomer#CustomerCode 5et +eturn EstrCustomerCode

&nd 5et Set(B*.al (alue $s String) EstrCustomerCode V (alue &nd Set &nd Ero'ert* Eu)li! Ero'ert* Customer%ame() $s String Im'lements ICustomer#Customer%ame 5et +eturn EstrCustomer%ame &nd 5et Set(B*.al (alue $s String) EstrCustomer%ame V (alue &nd Set &nd Ero'ert* Eu)li! Su) %ew() &nd Su) &nd Class %ote :- Sour!e !ode o" this is 'ro(ided in C2 in C<2& "older in C<MC$LL$BL&W+$EE&+ The a)o(e !ustomer !lass is going to )e used )* C<M !om'onents so all the 'ro'erties and methods are de!lared in inter"a!e and im'lemented in the !ustomer !lass#Customer %ame#Customer Code and $ddCustomer are "irst de!lared in ICustomer and then im'lemented in Customer Class#%ote also the !lass must ha(e a de"ault !onstru!tor# %ote :- $ll sour!e !ode in this )oo is 'ro(ided in .B#%&T that does not mean that author o" the )oo does not li e CN# In "a!t the main 'rogramming language o" author is CN#In order to ee' things small i ha(e onl* used one language#But the !on(ersion is so seamless its o" least matter# A@ 4 The se!ond wa* to !reate CCW using Intero'Ser(i!es attri)utes#?ere inter"a!es are !reated automati!all*# ,ollowing are di""erent t*'e o" !lass attri)utes : %one :%o !lass inter"a!e is generated "or the !lass#This is de"ault setting when *ou do not s'e!i"* an*thing# $uto2is'at!h :- Inter"a!e that su''orts I2is'at!h is !reated "or the !lass# ?owe(er, no t*'e in"ormation is 'rodu!ed# $uto2ual :- $ dual inter"a!e is !reated "or the !lass# T*'ein"o is 'rodu!ed and made a(aila)le in the t*'e li)rar*# In )elow sour!e !ode we ha(e used the third attri)ute# Im'orts S*stem#+untime#Intero'Ser(i!es TClassInter"a!e$ttri)ute(ClassInter"a!eT*'e#$uto2ual)U Q Eu)li! Class ClsCom'liant &nd Class

<ther than !lass attri)utes de"ined u' there are other attri)utes with whi!h *ou !an go(ern other 'art o" assem)l*#&-am'le 95uid$ttri)ute: allows *ou to s'e!i"* the 5GI2,:Com.isi)le$ttri)ute 9 !an )e used to hide #%&T t*'es "rom C<M et!#$ll attri)utes are not in s!o'e o" the )oo as this is a inter(iew =uestions )oo re"er MS2% "or more details# 4 <n!e #%&T assem)l* is !reated using either inter"a!e or using intero'ser(i!es method we need to !reate a C<M t*'e li)rar* using T*'e li)rar* e-'ort tool# Tl)e-' ($ssem)l*%ame) 4 The "inal thing is registering the CCW in registr* using regasm tool# regasm $ssem)l*%ame R<'tionsS 4 ,inall* re"er the TLB in *our C<M I2& Below is "igure showing .B3 I2& re"eren!ing the 2LL %ote :- 2LL and TLB should )e in same dire!tor* where the a''li!ation is e-e!uted# AD ,igure :- B#B .B3 I2& re"eren!ing the CCW ($)?ow !an we ma e Windows $EI !alls in #%&T? Windows $EI !all are not C<M )ased and are in(o ed through Elat"orm In(o e Ser(i!es# 2e!lare StringCon(ersionT*'e (,un!tion Y Su)) Method%ame Li) H2ll%ameH (R$rgsS) $s T*'e 4 StringCon(ersionT*'e is "or what t*'e o" !on(ersion should ta e 'la!e#&ither we !an s'e!i"* Gni!ode to !on(ert all strings to Gni!ode (alues, or $uto to !on(ert strings a!!ording to the #%&T runtime rules# 4 Method%ame is the name o" the $EI to !all# 4 2ll%ame is the name o" the 2LL# 4 $rgs are an* arguments to the $EI !all# 01 4 T*'e is the return t*'e o" the $EI !all# Below is a sam'le !ode "or .B#%&T whi!h uses Slee' windows $EI "or dela*ing# Eu)li! Class ,orm> 2e!lare $uto Su) Slee' Li) 9 ernelAB#dll: (B*.al dwMillise!onds $s Long) Eri(ate Su) ,orm>QLoad(B*.al sender $s S*stem#<)6e!t, B*.al e $s S*stem#&(ent$rgs) ?andles M*Base#Load MessageBo-#Show(9 start slee'ing "or L111 Milli se!onds#####:) Slee'(L111) MessageBo-#Show(9 end o" slee'ing#####:) &nd Su) &nd Class In .B#%&T we use de!lare e*word )ut in CN it goes little )it di""erent we use 2LLIME<+T here# %ote :- We ha(e intero'ser(i!es in this and &CT&+% e*word# Nregion Gsing dire!ti(es using S*stemW

using S*stem#Colle!tions#5eneri!W using S*stem#Com'onentModelW using S*stem#2ataW using S*stem#2rawingW using S*stem#Windows#,ormsW using S*stem#+untime#Intero'Ser(i!esW Nendregion names'a!e CShar'Code Z 'artial !lass ,orm> : ,orm Z R2llIm'ort(9JernelAB#dll:)S stati! e-tern int Slee'(long dwMillise!onds)W 'u)li! ,orm>() Z Initiali7eCom'onent()W [ 'ri(ate (oid ,orm>QLoad(o)6e!t sender, &(ent$rgs e) 0> Z MessageBo-#Show(9Starting o" L111 ms###:)W Slee'(L111)W MessageBo-#Show(9&nd o" L111 ms###:)W [ [ [ (B)When we use windows $EI in #%&T is it managed or unmanaged !ode ? Windows $EI in #%&T is unmanaged !ode# %ote:- &(en though .B3 and . C// has gone o"" still man* 'eo'le do as these old =uestions again and again#Still there are de!ent old a''li!ation whi!h are wor ing with C<M (er* mu!h "ine#So inter(iewer still as s *ou these =uestions so that those a''li!ation8s !an )e 'orted to #%&T#So let8s 'la* some old musi!##### B* the wa* m* "a(ourite musi! is Jishore what8s *ours???? (I)What is C<M ? Mi!roso"t8s C<M is a te!hnolog* "or !om'onent so"tware de(elo'ment# It is a )inar* standard whi!h is language inde'endent# 2C<M is a distri)uted e-tension o" C<M# ($) What is +e"eren!e !ounting in C<M ? +e"eren!e !ounting is a memor* management te!hni=ue used to !ount how man* times an o)6e!t has a 'ointer re"erring to it# The "irst time it is !reated, the re"eren!e !ount is set to one# When the last re"eren!e to the o)6e!t is nulled, the re"eren!e !ount is set to 7ero and the o)6e!t is deleted# Care must )e e-er!ised to 're(ent a !onte-t swit!h "rom !hanging the re"eren!e !ount at the time

o" deletion# In the methods that "ollow, the s*nta- is shortened to ee' the s!o'e o" the dis!ussion )rie" and managea)le# ($) Can *ou des!ri)e IGJ%<W% inter"a!e in short ? &(er* C<M o)6e!t su''orts at least one inter"a!e, the IGn nown inter"a!e# $ll inter"a!es are !lasses deri(ed "rom the )ase !lass IGn nown# &a!h inter"a!e su''orts methods a!!ess data and 'er"orm o'erations trans'arentl* to the 'rogrammer# ,or e-am'le, IGn nown su''orts three methods, $dd+e", +elease(), and \uer*Inter"a!e()# Su''ose that 'inter" is a 'ointer to an IGn nown# 'inter"-U$dd+e"() in!rements the re"eren!e !ount# 'inter"-U+elease() de!rements the re"eren!e !ount, deleting the o)6e!t when the re"eren!e !ount rea!hes 7ero# 'inter"U\uer*Inter"a!e( I2esired, 0B '2esired) !he! s to see i" the !urrent inter"a!e (IGn nown) su''orts another inter"a!e, I2esired, !reates an instan!e ((ia a !all to CoCreateInstan!e()) o" the o)6e!t i" the re"eren!e !ount is 7ero (the o)6e!t does not *et e-ist), and then !alls '2esired-U$dd+e"() to in!rement the re"eren!e !ount (where '2esired is a 'ointer to I2esired) and returns the 'ointer to the !aller# (I)Can *ou e-'lain what is 2C<M ? 2C<M di""ers "rom C<M in that it allows "or !reating o)6e!ts distri)uted a!ross a networ , a 'roto!ol "or in(o ing that o)6e!t8s methods, and se!ure a!!ess to the o)6e!t# 2C<M 'ro(ides a wra''er around C<M, hen!e it is a )a! wards !om'ati)le e-tension# 2C<M uses +emote Ero!edural Calls (+EC) using <'en So"tware ,oundation8s 2istri)uted Com'uting &n(ironment# These +EC are im'lemented o(er TCEOIE and named 'i'es# The 'roto!ol whi!h is a!tuall* )eing used is registered 6ust 'rior to use, as o''osed to )eing registered at initiali7ation time# The reason "or this is that i" a 'roto!ol is not )eing used, it will not )e loaded# In order to in"orm an o)6e!t that the !lient is still ali(e, 'eriodi! 'inging is used# ?en!e, when the !lient has died and no 'ing has )een re!ei(ed (to re"resh it) )e"ore the e-'iration time, the ser(er o)6e!t will 'er"orm some !lean u' tas s (in!luding de!rementing its re"eren!e !ount)# Sin!e +EC a!ross a networ are t*'i!all* slow (!om'ared to 'ro!esses residing on the same ma!hine), 2C<M sends multi'le re=uests in the same !all# ,or e-am'le, in C<M, the 'rogram 'er"orms a \uer*Inter"a!e, one inter"a!e at a time# In 2C<M, multi'le \uer*Inter"a!es are all !lustered into one !all# This !lustering o'timi7ation tri! is also used when !reating an instan!e o" the o)6e!t and seriali7ing it with data# Sin!e these two o'erations usuall* o!!ur together, 2C<M allows one method whi!h will 'er"orm )oth o'erations in one !all without waiting "or an a! nowledgment "rom the "irst tas )e"ore 'er"orming the se!ond one# Similarl*, when a !lient 'ings its ser(er o)6e!t, he !an do it in one !all# Moreo(er, i" there are multi'le !lients sending 'ings to multi'le ser(ers, an o'timi7ation is made where the multi'le 'ings going to the same o)6e!t are !onsolidated into 6ust one 'ing# This is to !ut down on the use

o" 're!ious )andwidth used onl* "or 'inging# The !lient has the !ontrol to set the !om'uter whi!h will )e res'onsi)le "or the li"etime o" the o)6e!t# That is to sa*, these o)6e!ts are not !reated 6ust somewhere where the s*stem resour!es and a!!ess 'ri(ileges allow "or it# Call se!urit* is im'lemented in all "our wa*s: authenti!ation (to 're(ent "alse !lients "rom im'ersonating the true !lient), authori7ation (to insure that a !lient onl* does what it is authori7ed to do), data integrit* (to insure that data was not tam'ered with during transit) and data 'ri(a!* (to insure that onl* designated sour!es !an read it)# The se!urit* issues are handled as the* are on 0A o'erating s*stems# The !lient gi(es the ser(er (arious a!!ess 'ri(ileges to a!!ess memor* or dis s'a!e (B)?ow do we !reate 2C<M o)6e!t in .B3? Gsing the Create<)6e!t method *ou !an !reate a 2C<M o)6e!t# Kou ha(e to 'ut the ser(er name in the registr*# ($)?ow to im'lement 2TC in #%&T ? 2TC is im'lemented using C<M/ # ,ollowing are the ste's to im'lement C<M / in #%&T :4 9&nter'riseSer(i!e: names'a!e has all the !lasses )* whi!h we !an im'lement 2TC in #%&T# Kou ha(e to add re"eren!e 9&nter'riseSer(i!e: names'a!e# 00 ,igure :- B#A $dd re"eren!e to &nter'riseSer(i!es# 4 Kou !lass must deri(e "rom 9Ser(i!ed Com'onent: o)6e!t# 4 Then *ou ha(e to de"ine *our !lass with the transa!tion attri)ute (,or all transa!tion attri)ute loo the down =uestion) R Transa!tion(Transa!tion<'tion#+e=uires%ew) S 4 $"ter the !lass le(el transa!tion t*'e is de"ined#Its time to de"ine at the method le(el the $utoCom'lete attri)ute# $uto!om'lete attri)ute sa*s that i" no e-!e'tion is thrown then mar its 'art o" the transa!tion as )eing o a*# This hel's !ut down on the amount o" !ode re=uired# I" the im'lementation sets $utoCom'lete to "alse, or 0L omits it all together, then we would need to manage the transa!tion manuall*# To manuall* !ontrol the transa!tion *ou will need to use the Conte-tGtil !lass and its stati! mem)ers#,ollowing is small sni''et o" Conte-tGtil: 'u)li! (oid Sam'le,un!tion() Z tr* Z OO 2o something to a data)ase OO ### OO &(er*thing o a* so "ar Commit the transa!tion

Conte-tGtil#SetCom'lete()W [ !at!h(&-!e'tion) Z OO Something went wrong $)ort and +oll)a! the Transa!tion# Conte-tGtil#Set$)ort()W [ [ 4 Com'onent deri(ed "rom 9Ser(i!edCom'onent: should )e strong named as the* run under C<M/# 4 <n!e the !lasses are !om'iled using the string name#+egister the Com'onent in C<M/ ser(i!es using regs(!s !:I2llEathITransa!tionCom'onent#dll 4 Kou !an see that the !om'onent is registered using the C<M/ e-'lorer# ($)?ow man* t*'es o" Transa!tions are there in C<M / #%&T ? 03 There are L transa!tions t*'es that !an )e used with C<M/# Whene(er an o)6e!t is registered with C<M/ it has to a)ide either to these L transa!tion t*'es# 2isa)led: - There is no transa!tion# C<M/ does not 'ro(ide transa!tion su''ort "or this !om'onent# %ot Su''orted: - Com'onent does not su''ort transa!tions# ?en!e e(en i" the !alling !om'onent in the hierar!h* is transa!tion ena)led this !om'onent will not 'arti!i'ate in the transa!tion# Su''orted: - Com'onents with transa!tion t*'e su''orted will )e a 'art o" the transa!tion i" the !alling !om'onent has an a!ti(e transa!tion#I" the !alling !om'onent is not transa!tion ena)led this !om'onent will not start a new transa!tion# +e=uired: - Com'onents with this attri)ute re=uire a transa!tion i#e# either the !alling should ha(e a transa!tion in 'la!e else this !om'onent will start a new transa!tion# +e=uired %ew: - Com'onents ena)led with this transa!tion t*'e alwa*s re=uire a new transa!tion# Com'onents with re=uired new transa!tion t*'e instantiate a new transa!tion "or themsel(es e(er* time# ($)?ow do *ou do o)6e!t 'ooling in #%&T ? C<M/ redu!es o(erhead )* !reating o)6e!t "rom s!rat!h# So in C<M/ when o)6e!t is a!ti(ated its a!ti(ated "rom 'ool and when its dea!ti(ated it8s 'ushed )a! to the 'ool# <)6e!t 'ooling is !on"igures )* using the 9<)6e!tEooling$ttri)ute: to the !lass# %ote:- When a !lass is mar ed with o)6e!t'ooling attri)ute it !an not )e inherited# <)6e!tEooling(MinEoolSi7e :V B, Ma-EoolSi7e :V L, CreationTimeout :V B1111)U Q Eu)li! Class testing!lass Inherits Ser(i!edCom'onent

Eu)li! Su) 2oWor () F Method !ontents go here# &nd Su) &nd Class $)o(e is a sam'le !ode whi!h has the 9<)6e!tEooling: attri)ute de"ined# Below is a sam'le !ode whi!h uses the !lass# 0M Eu)li! Class $'' <(erloads Eu)li! Shared Su) Main(args() $s String) 2im -*7 $s %ew Test<)6e!tEooling() -*7#doWor () Ser(i!edCom'onent#2is'ose<)6e!t (-*7) &nd Su) &nd Class $)o(e is a sam'le !ode whi!h uses the o)6e!t 'ooled o)6e!t# %ote the 2is'ose<)6e!t() This ensures its sa"e return to the o)6e!t 'ool# ($)What are t*'es o" !om'ati)ilit* in .B3? There are three 'ossi)le 'ro6e!t !om'ati)ilit* settings: 4 %o Com'ati)ilit* 4 Ero6e!t Com'ati)ilit* 4 Binar* Com'ati)ilit* %o Com'ati)ilit* With this setting, new !lass I28s, new inter"a!e I28s and a new t*'e li)rar* I2 will )e generated )* .B ea!h time the $!ti(eC !om'onent 'ro6e!t is !om'iled# This will !ause an* !om'iled !lient !om'onents to "ail (with error 0BD]) and re'ort a missing re"eren!e to the F.B $!ti(eC Test Com'onentF when a !lient 'ro6e!t is loaded in the .B I2&# %ote :- Gse this setting to !om'ile the initial release o" a !om'onent to other de(elo'ers# Ero6e!t Com'ati)ilit* With this setting, .B will generate new inter"a!e I28s "or !lasses whose inter"a!es ha(e !hanged, )ut will not !hange the !lass I28s or the t*'e li)rar* I2# This will still !ause an* !om'iled !lient !om'onents to "ail (with error 0BD]) )ut will not re'ort a missing re"eren!e to the F.B $!ti(eC Test Com'onentF when a !lient 'ro6e!t is loaded in the .B I2&# +e!om'ilation o" !lient !om'onents will restore them to wor ing order again# %ote:- Gse this setting during the initial de(elo'ment and testing o" a !om'onent within the I2& and )e"ore the !om'onent is released to other de(elo'ers# 0@ Binar* Com'ati)ilit* .B ma es it 'ossi)le to e-tend an e-isting !lass or inter"a!e )* adding new methods and 'ro'erties et!# and *et still retain )inar* !om'ati)ilit*# It !an do this, )e!ause it silentl* !reates a new inter"a!e I2 "or the e-tended inter"a!e and adds registration !ode to register the original inter"a!e I2 )ut

with a new ,orward e* !ontaining the (alue o" this new inter"a!e I2# C<M will then su)stitute !alls ha(ing the old I2 with the new I2 and hen!e a''li!ations )uilt against the old inter"a!e will !ontinue to wor (assuming the inner wor ings o" the !om'onent remain )a! ward !om'ati)le])# With this setting, .B will not !hange an* o" the e-isting !lass, inter"a!e or t*'e li)rar* I28s, howe(er in order that it !an do so, .B re=uires the 'ro6e!t to s'e!i"* an e-isting !om'iled (ersion that it !an !om'are against to ensure that e-isting inter"a!es ha(e not )een )ro en ($)What is e=ui(alent "or regs(rAB e-e in #%&T ? +egasm

Threading
(B)What is Multi-tas ing ? Its a "eature o" modern o'erating s*stems with whi!h we !an run multi'le 'rograms at same time e-am'le Word,&-!el et!# (B)What is Multi-threading ? Multi-threading "orms su)set o" Multi-tas ing instead o" ha(ing to swit!h )etween 'rograms this "eature swit!hes )etween di""erent 'arts o" the same 'rogram#&-am'le *ou are writing in word and at the same time word is doing a s'ell !he! in )a! ground# (B)What is a Thread ? $ thread is the )asi! unit to whi!h the o'erating s*stem allo!ates 'ro!essor time# (B)2id .B3 su''ort multi-threading ? While .B3 su''orts multi'le single-threaded a'artments, it does not su''ort a "reethreading model, whi!h allows multi'le threads to run against the same set o" data# (B)Can we ha(e multi'le threads in one $'' domain ? <ne or more threads run in an $''2omain# $n $''2omain is a runtime re'resentation o" a logi!al 'ro!ess within a 'h*si!al 'ro!ess#&a!h $''2omain is started with a single thread, )ut !an !reate additional threads "rom an* o" its threads# %ote :- $ll threading !lasses are de"ined in S*stem#Threading names'a!e# (B)Whi!h names'a!e has threading ? S*stems#Threading has all the !lasses related to im'lement threading#$n* #%&T a''li!ation who wants to im'lement threading has to im'ort this names'a!e# %ote :- #%&T 'rogram alwa*s has atleast two threads running one the main 'rogram and se!ond the gar)age !olle!tor# (I)Can *ou e-'lain in )rie" how !an we im'lement threading ? A# Threading L1 Eri(ate Su) ,orm>QLoad(B*.al sender $s S*stem#<)6e!t, B*.al e $s S*stem#&(ent$rgs) ?andles M*Base#Load 2im 'thread> $s %ew Thread($ddress<" Thread>)

2im 'threadB $s %ew Thread($ddress<" ThreadB) 'thread>#Start() 'threadB#Start() &nd Su) Eu)li! Su) Thread>() 2im 'int!ount $s Integer 2im 'str $s String 'str V 9This is "irst thread: 2o Gntil 'int!ount U L lstThread2is'la*#Items#$dd('str) 'int!ount V 'int!ount / > Loo' &nd Su) Eu)li! Su) ThreadB() 2im 'int!ount $s Integer 2im 'str $s String 'str V 9This is se!ond thread: 2o Gntil 'int!ount U L lstThread2is'la*#Items#$dd('str) 'int!ount V 'int!ount / > Loo' &nd Su) $)o(e is a sam'le !ode whi!h shows sim'le sam'le !ode "or threading##$)o(e sam'le !ode !an )e "ound in 9Threading: "older in C2 'ro(ided#$)o(e sam'le has two methods 9Thread>(): and 9ThreadB(): whi!h are started in multi-threaded mode in ,orm load e(ent o" the sam'le# %ote :- I" *ou run the sam'le *ou will see that sometimes the "irst thread runs "irst and then the se!ond thread#This ha''ens )e!ause o" thread 'riorities #The "irst thread is run with highest 'riorit*# ($)?ow !an we !hange 'riorit* and what the le(els o" 'riorit* are 'ro(ided )* #%&T ? Thread Eriorit* !an )e !hanged )* using Threadname#Eriorit* V ThreadEriorit*#?ighest#In the sam'le 'ro(ided loo out "or !ode where the se!ond thread is ran with a high 'riorit*# L> ,ollowing are di""erent le(els o" Eriorit* 'ro(ided )* #%&T :4 ThreadEriorit*#?ighest 4 ThreadEriorit*#$)o(e%ormal 4 ThreadEriorit*#%ormal 4 ThreadEriorit*#Below%ormal 4 ThreadEriorit*#Lowest ($)What does $ddresso" o'erator do in )a! ground ? The $ddress<" o'erator !reates a delegate o)6e!t to the Ba! groundEro!ess method# $ delegate within .B#%&T is a t*'e-sa"e, o)6e!t-oriented "un!tion 'ointer# $"ter the thread

has )een instantiated, *ou )egin the e-e!ution o" the !ode )* !alling the Start() method o" the thread ($)?ow !an *ou re"eren!e !urrent thread o" the method ? HThread#CurrentThreadH re"ers to the !urrent thread running in the method#HCurrentThreadH is a 'u)li! stati! 'ro'ert*# (I) WhatFs Thread#Slee'() in threading ? ThreadFs e-e!ution !an )e 'aused )* !alling the Thread#Slee' method# This method ta es an integer (alue that determines how long the thread should slee'#&-am'le Thread#CurrentThread#Slee'(B111)# ($)?ow !an we ma e a thread slee' "or in"inite 'eriod ? Kou !an also 'la!e a thread into the slee' state "or an indeterminate amount o" time )* !alling Thread#Slee' (S*stem#Threading#Timeout#In"inite)#To interru't this slee' *ou !an !all the Thread#Interru't method# ($) What is Sus'end and +esume in Threading ? It is Similar to Slee' and Interru't# Sus'end allows *ou to )lo! a thread until another thread !alls Thread#+esume# The di""eren!e )etween Slee' and Sus'end is that the latter does not immediatel* 'la!e a thread in the wait state# The thread does not sus'end until LB the #%&T runtime determines that it is in a sa"e 'la!e to sus'end it# Slee' will immediatel* 'la!e a thread in a wait state# %ote :- In threading inter(iews most 'eo'le get !on"used with Slee' and Sus'end#The* loo (er* similar# ($)What the wa* to sto' a long running thread ? Thread#$)ort() sto's the thread e-e!ution at that moment itsel"# ($) ?ow do i de)ug thread ? ,igure :- A#> 2e)ug thread window This window is onl* seen when the 'rogram is running in de)ug mode#In windows one o" the window is 9Threads:# ($)WhatFs Thread#Join() in threading ? LA There are two (ersions o" Thread#Join :4 Thread#6oin()# 4 Thread#6oin(Integer) this returns a )oolean (alue# The Thread#Join method is use"ul "or determining i" a thread has !om'leted )e"ore starting another tas # The Join method waits a s'e!i"ied amount o" time "or a thread to end# I" the thread ends )e"ore the time-out, Join returns TrueW otherwise it returns ,alse#<n!e *ou !all Join the !alling 'ro!edure sto's and waits "or the thread to signal that it is done# &-am'le *ou ha(e HThread>H and HThreadBH and while e-e!uting FThread>H *ou !all HThreadB#Join()H#So HThread>H will wait until HThreadBH has !om'leted its e-e!ution and the again in(o e HThread>H# Thread#Join(Integer) ensures that threads do not wait "or a long time#I" it e-!eeds a s'e!i"i! time whi!h is 'ro(ided in integer the waiting thread will start# ($)What are 2aemon threadFs and how !an a thread )e !reated as

2aemon? 2aemon threadFs run in )a! ground and sto' automati!all* when nothing is running 'rogram#&-am'le o" a 2aemon thread is H5ar)age !olle!torH#5ar)age !olle!tor runs until some #%&T !ode is running or else its idle# Kou !an ma e a thread 2aemon )* Thread#Is)a! groundVtrue ($) When wor ing with shared data in threading how do *ou im'lement s*n!hroni7ation ? There are a somethings *ou need to )e !are"ul with when using threads# I" two threads (e#g# the main and an* wor er threads) tr* to a!!ess the same (aria)le at the same time, *ouFll ha(e a 'ro)lem# This !an )e (er* di""i!ult to de)ug )e!ause the* ma* not alwa*s do it at e-a!tl* the same time# To a(oid the 'ro)lem, *ou !an lo! a (aria)le )e"ore a!!essing it# ?owe(er, i" two threads lo! the same (aria)le at the same time, *ouFll ha(e a deadlo! 'ro)lem# L0 S*n!Lo! F2o something with &nd S*n!Lo! (I)Can we use e(ents with threading ? Kes *ou !an use e(ents with threads , this is one o" the te!hni=ue to s*n!hroni7e one thread with other# ($)?ow !an we now a state o" a thread? HThreadStateH 'ro'ert* !an )e used to get detail o" a thread#Thread !an ha(e one or !om)ination o" status#S*stem#Threading#Threadstate enumeration has all the (alues to dete!t a state o" thread#Some sam'le states are Isrunning,Is$li(e,sus'ended et!# ($) What is use o" Interlo! ed !lass ? Interlo! ed !lass 'ro(ides methods )* whi!h *ou !an a!hie(e "ollowing "un!tionalities :4 in!rement .alues# 4 2e!rement (alues# 4 &-!hange (alues )etween (aria)les# 4 Com'are (alues "rom an* thread# in a s*n!hroni7ation mode# &-am'le :- S*stem#Threading#Interlo! ed#In!rement(Int$) ($) what is a monitor o)6e!t? Monitor o)6e!ts are used to ensure that a )lo! o" !ode runs without )eing interru'ted )* !ode running on other threads# In other words, !ode in other threads !annot run until !ode in the s*n!hroni7ed !ode )lo! has "inished# S*n!Lo! and &nd S*n!Lo! statements are 'ro(ided in order to sim'li"* a!!ess to monitor o)6e!t# ($) what are wait handles ? LL Twist :- What is a mute- o)6e!t ? Wait handles sends signals o" a thread status "rom one thread to other thread#There are

three ind o" wait modes :4 Wait<ne# 4 Wait$n*# 4 Wait$ll# When a thread wants to release a Wait handle it !an !all Set method#Kou !an use Mute(mutuall* e-!lusi(e) o)6e!ts to a(ail "or the "ollowing modes#Mute- o)6e!ts are s*n!hroni7ation o)6e!ts that !an onl* )e owned )* a single thread at a time#Threads re=uest ownershi' o" the mute- o)6e!t when the* re=uire e-!lusi(e a!!ess to a resour!e# Be!ause onl* one thread !an own a mute- o)6e!t at an* time, other threads must wait "or ownershi' o" a mute- o)6e!t )e"ore using the resour!e# The Wait<ne method !auses a !alling thread to wait "or ownershi' o" a mute- o)6e!t# I" a thread terminates normall* while owning a mute- o)6e!t, the state o" the mute- o)6e!t is set to signaled and the ne-t waiting thread gets ownershi' ($) what is Manual+eset&(ent and $uto+eset&(ent ? Threads that !all one o" the wait methods o" a s*n!hroni7ation e(ent must wait until another thread signals the e(ent )* !alling the Set method# There are two s*n!hroni7ation e(ent !lasses# Threads set the status o" Manual+eset&(ent instan!es to signaled using the Set method# Threads set the status o" Manual+eset&(ent instan!es to nonsignaled using the +eset method or when !ontrol returns to a waiting Wait<ne !all# Instan!es o" the $uto+eset&(ent !lass !an also )e set to signaled using Set, )ut the* automati!all* return to nonsignaled as soon as a waiting thread is noti"ied that the e(ent )e!ame signaled# ($) What is +eaderWriter Lo! s ? Kou ma* want to lo! a resour!e onl* when data is )eing written and 'ermit multi'le !lients to simultaneousl* read data when data is not )eing u'dated# The +eaderWriterLo! !lass en"or!es e-!lusi(e a!!ess to a resour!e while a thread is modi"*ing the resour!e, )ut it allows none-!lusi(e a!!ess when reading the resour!e# +eaderWriter lo! s are a use"ul alternati(e to e-!lusi(e lo! s that !ause other threads to wait, e(en when those threads do not need to u'date data# L3 (I) ?ow !an *ou a(oid deadlo! in threading ? $ good and !are"ul 'lanning !an a(oid deadlo! s#There so man* wa*s mi!roso"t has 'ro(ided )* whi!h *ou !an redu!e deadlo! s e-am'le Monitor ,Interlo! ed !lasses , Wait handles, &(ent raising "rom one thread to other thread , ThreadState 'ro'ert* whi!h *ou !an 'oll and a!t a!!ordingl* et!# (B) What8s di""eren!e )etween thread and 'ro!ess? $ thread is a 'ath o" e-e!ution that run on CEG, a 'ro!ess is a !olle!tion o" threads that share the same (irtual memor*# $ 'ro!ess has at least one thread o" e-e!ution, and a thread alwa*s run in a 'ro!ess !onte-t# %ote:- Its di""i!ult to !o(er threading inter(iew =uestion in this small !ha'ter#These =uestions !an ta e onl* to a )asi! le(el#I" *ou are attending inter(iews where 'eo'le are loo ing "or threading s'e!ialist , tr* to get more dee' in to s*n!hroni7ation issues as thatFs the im'ortant 'oint the* will stres

+emoting and We)ser(i!es


(B)What is an a''li!ation domain? Ere(iousl* 9E+<C&SS: where used as se!urit* )oundaries#<ne 'ro!ess has its own (irtual memor* and does not o(er la' the other 'ro!ess (irtual memor* , due to this one 'ro!ess !an not !rash the other 'ro!ess#So an* 'ro)lem or error in one 'ro!ess does not a""e!t the other 'ro!ess#In #%&T the* went one ste' ahead introdu!ing a''li!ation domains#In a''li!ation domains multi'le a''li!ation !an run in same 'ro!ess with out in"luen!ing ea!h other#I" one o" the a''li!ation domains throws error it does not a""e!t the other a''li!ation domains#To in(o e method in a o)6e!t running in di""erent a''li!ation domain #%&T remoting is used# ,igure :- 0#> <ne 'ro!ess !an ha(e multi'le $''li!ation domains (B) What is #%&T +emoting ? #%&T remoting is re'la!ement o" 2C<M#Gsing #%&T remoting *ou !an ma e remote o)6e!t !alls whi!h lie in di""erent $''li!ation 2omains#$s the remote o)6e!ts run in di""erent 'ro!ess !lient !alling the remote o)6e!t !an not !all it dire!tl*#So the !lient uses a 'ro-* whi!h loo s li e a real o)6e!t# When !lient wants to ma e method !all on the remote o)6e!t it uses 'ro-* "or it#These method !alls are !alled as 9Messages:#Messages are seriali7ed using 9"ormatter: !lass and sent to !lient 9!hannel:#Client Channel !ommuni!ates with Ser(er Channel#Ser(er Channel uses as "ormatter to deseriali7e the message and sends to the remote o)6e!t# 0# +emoting and We)ser(i!es L@ ,igure :- 0#B Channels,,ormatters and Ero-* in a!tion# (B) Whi!h !lass does the remote o)6e!t has to inherit ? $ll remote o)6e!t should inherit "rom S*stem#Marshal)*+e"<)6e!t# (I) What are two di""erent t*'es o" remote o)6e!t !reation mode in #%&T ? There are two di""erent wa*s in whi!h o)6e!t !an )e !reated using +emoting :4 S$< (Ser(er $!ti(ated <)6e!ts) also !alled as Well-Jnown !all mode# 4 C$< (Client $!ti(ated <)6e!ts) S$< has two modes 9Single Call: and 9Singleton:#With Single Call o)6e!t the o)6e!t is !reated with e(er* method !all thus ma ing the o)6e!t stateless#With Singleton the o)6e!t is !reated onl* on!e and the o)6e!t is shared with all !lients# C$< are state"ul as !om'ared to S$<# In C$< the !reation re=uest is sent "rom !lient side#Client holds a 'ro-* to the ser(er o)6e!t !reated on ser(er# ($) 2es!ri)e in detail Basi! o" S$< ar!hite!ture o" +emoting? ,or these t*'e o" =uestions inter(iewer e-'e!ts small and sweet answers#?e is )asi!all* loo ing at what *ou now a)out the s'e!i"i! su)6e!t#,or these t*'e o" =uestion this )oo will 'ro(ide detail !ode whi!h is not ne!essar* to )e said during inter(iew#<nl* the )asi! ste's and o(erall )rie" are enough to !on(in!e that *ou ha(e nowledge a)out the su)6e!t#&(en though this =uestion has detail !ode and answer sa* onl* what is needed in inter(iew#

LD +emoting has atleast three se!tions :4 Common Inter"a!e whi!h will )e shared )etween them# 4 Ser(er# 4 Client# ,igure :- 0#A Solution &-'lorer o" +emoting Ero6e!t In C2 9+emotingSam'le(S$<): 'ro6e!t is 'ro(ided whi!h gi(es a insight o" remoting#$)o(e is the "igure whi!h shows the three im'ortant 'ro6e!t se!tions needed to im'lement remoting# ,irst im'ortant se!tion is the !ommon inter"a!e )etween Ser(er and Client#:Inter,a!e+emoting: 'ro6e!t has the inter"a!e !ode#,or sam'le 'ro6e!t inter"a!e is (er* sim'le with onl* two methods :- Set.alue and 5et.alue# Eu)li! Inter"a!e Inter,a!e+emoting Su) Set.alue(B*.al (alue $s String) ,un!tion 5et.alue() $s String &nd Inter"a!e Se!ond im'ortant se!tion is the ser(er#In this sam'le ser(er is using ?TTE !hannel and the ser(er o)6e!t is singleton# Im'orts S*stem Im'orts S*stem#+untime#+emoting Im'orts S*stem#+untime#+emoting#Channels#?tt' Im'orts S*stem#+untime#+emoting#Channels Im'orts Inter,a!e+emoting Eu)li! Class +emotingSer(er Inherits MarshalB*+e"<)6e!t 31 Im'lements Inter,a!e+emoting#Inter,a!e+emoting Eri(ate str2ata $s String Eu)li! ,un!tion 5et.alue() $s String Im'lements Inter,a!e+emoting#Inter,a!e+emoting#5et.alue +eturn str2ata &nd ,un!tion Su) %ew() str2ata V 9testing##: &nd Su) Eu)li! Su) Set.alue(B*.al (alue $s String) Im'lements Inter,a!e+emoting#Inter,a!e+emoting#Set.alue str2ata V (alue &nd Su) &nd Class Module Module+emotingStartG' Su) Main() 2im o)6?tt'Channel $s ?tt'Channel

Console#WriteLine(9Ser(er Started####:) o)6?tt'Channel V %ew ?tt'Channel(>BA0) ChannelSer(i!es#+egisterChannel(o)6?tt'Channel) +emotingCon"iguration#+egisterWellJnownSer(i!eT*'e(5etT*'e(+emotingSer(er), 9+emote<)6e!t:, WellJnown<)6e!tMode#Singleton) Console#WriteLine(9Ser(er registered and listening waiting "or !lients###:) Console#+eadLine() &nd Su) &nd Module ,ollowing is detail e-'lanation :4 Channel o)6e!t is !reated and registered#,ollowing is the !ode# 2im o)6?tt'Channel $s ?tt'Channel Console#WriteLine(9Ser(er Started####:) o)6?tt'Channel V %ew ?tt'Channel(>BA0) ChannelSer(i!es#+egisterChannel(o)6?tt'Channel) 4 Ser(er then hosts the o)6e!t so that !lient !an !onne!t to it#This is the time when we s'e!i"* what mode the ser(er o)6e!t will )e !reated i#e# Singleton or SingleCall#This is done )* the "ollowing )elow gi(en !ode#%ote in sam'le we are hosting the ser(er o)6e!t in singleton mode that means that the same o)6e!t 3> will )e shared )etween all !lients#$lso note the ser(er o)6e!t is im'lementing 9Inter,a!e+emoting: and inheriting "rom 9MarshalB*+e"<)6e!t:# +emotingCon"iguration#+egisterWellJnownSer(i!eT*'e(5etT*'e(+emotingSer(er), 9+emote<)6e!t:, WellJnown<)6e!tMode#Singleton) %ow !omes the "inal se!tion that is third se!tion the !lient whi!h will !onne!t to this hosted remoting o)6e!t# ,ollowing is a detail e-'lanation o" !lient !ode :4 ,irst we !reate the !hannel i#e# ?TTE#%ote whate(er !hannel the ser(er is using same will )e used )* the !lient# ChannelSer(i!es#+egisterChannel(o)6?tt'Channel) 4 $s said )e"ore the !ommon inter"a!e i#e#9Inter,a!e+emoting: will )e used to !ommuni!ate with !lient# 4 $"ter that we !an get the ser(er o)6e!t re"eren!e using "ollowing !ode o)6+emoting V CT*'e($!ti(ator#5et<)6e!t(5etT*'e(Inter,a!e+emoting#Inter,a!e+emoting), 9htt':OOlo!alhost:>BA0O+emote<)6e!t:), Inter,a!e+emoting#Inter,a!e+emoting) 4 Then the !lient !an ma e method !all as i" the o)6e!t is lo!al#But a!tuall* the o)6e!t is a 'ro-*# Console#WriteLine(9.alue on ser(er :- 9 ^ o)6+emoting#5et.alue#ToString()) Im'orts S*stem Im'orts S*stem#+untime#+emoting Im'orts S*stem#+untime#+emoting#Channels#?tt' Im'orts S*stem#+untime#+emoting#Channels

Im'orts Inter,a!e+emoting Module ModuleStartClient Su) Main() 2im o)6?tt'Channel $s %ew ?tt'Channel 2im o)6+emoting $s Inter,a!e+emoting#Inter,a!e+emoting ChannelSer(i!es#+egisterChannel(o)6?tt'Channel) o)6+emoting V CT*'e($!ti(ator#5et<)6e!t(5etT*'e(Inter,a!e+emoting#Inter,a!e+emoting), 9htt':OOlo!alhost:>BA0O+emote<)6e!t:), Inter,a!e+emoting#Inter,a!e+emoting) 3B Console#WriteLine(9+e"eren!ed the main o)6e!t#### %ow dis'la*ing 2ata:) Console#WriteLine(9.alue on ser(er :- 9 ^ o)6+emoting#5et.alue#ToString()) Console#WriteLine(9Eress enter to Terminate:) Console#+eadLine() &nd Su) &nd Module Kou an run the 'rogram and see the out'ut#,or running the 'rogram run the ser(er 'rogram whi!h is in ser(er dire!tor*#+un 9Ser(er#e-e: "rom BI% dire!tor*#I" the &C& runs 'ro'erl* "ollowing will )e the s!reen as shown )elow# ,igure :- 0#0 +unning Ser(er Erogram o" +emoting %ow run 9Client#e-e: "rom !lient "older in BI% dire!tor*#,ollowing will )e the out'ut seen#This means that the !lient !onne!ted to the ser(er 'rogram and dis'la*ed the data in the ser(er o)6e!t#In the ser(er o)6e!t we ha(e initiali7ed (alue 9testing######: In !onstru!tor o" !lass 9+emotingSer(er:#Same (alue is dis'la*ed at the !lient side as shown in "igure )elow# 3A ,igure :- 0#L Client Erogram out'ut o" +emoting ($) What is the situation *ou will use singleton ar!hite!ture in remoting ? I" all remoting !lients ha(e to share the same data singleton ar!hite!ture will )e used# ($) What is "undamental o" 'u)lished or 're!reated o)6e!ts in +emoting ? In s!enarios o" singleton or single !all the o)6e!ts are !reated d*nami!all*#But in situations where *ou want to 're!reate o)6e!t and 'u)lish it *ou will use 'u)lished o)6e!t s!enarios# 2im o)6 as new o)6+emote o)6#Init(alue V >11 +emotingSer(i!es#Marshal(o)6,:+emote<)6e!t:) $s shown in a)o(e sam'le "ollowing !hanges will )e needed on ser(er side#+emotingCon"iguration#+egisterWellJnownSer(i!eT*'e is re'la!ed )* +emotingSer(i!es#Marshal(o)6,:+emote<)6e!t:) where 9o)6: is the 're!reated o)6e!ted on the ser(er whose (alue is initiali7ed to >11#

($) What are the wa*s !lient !an !reate o)6e!t on ser(er in C$< model ? There are two wa*s )* whi!h *ou !an !reate Client o)6e!ts on remoting ser(er :4 $!ti(ator#CreateInstan!e()# 4 B* Je*word 9%ew:# 30 ($) $re C$< state"ul in nature ? Kes#In C$< remoting model !lient !reates a instan!e on ser(er and instan!e (aria)le set )* !lient on ser(er !an )e retrie(ed again with !orre!t (alue# ($) In C$< model when we want !lient o)6e!ts to )e !reated )* 9%&W: e*word is there an* 're!autions to )e ta en ? +emoting Clients and +emoting Ser(er !an !ommuni!ate )e!ause the* share a !ommon !ontra!t )* im'lementing Shared Inter"a!e or Base Class ($s seen in 're(ious e-am'les)# But a!!ording to <<E8s !on!e't we !an not !reate a o)6e!t o" inter"a!e or Base Classes ($)stra!t Class)# Shi''ing the ser(er o)6e!t to !lient is not a good design 'ra!ti!e#In C$< model we !an use S<$ESG2S utilit* to generate Metadata 2LL "rom ser(er whi!h !an )e shi''ed to !lient , !lients !an then use this 2LL "or !reating o)6e!t on ser(er#+un the S<$ESG2S utilit* "rom (isual studio !ommand 'rom't "or s*nta- see )elow :soa'suds -ia:+emotingSer(er -now' -oa:ClientMeta2ata#dll Where +emotingSer(er is *our ser(er !lass name# ClientMeta2ata#dll is the 2LL name )* whi!h *ou will want to !reate the metadll# Ser(er !ode will !hange as "ollows :ChannelSer(i!es#+egisterChannel(o)6?tt'Channel) +emotingCon"iguration#$''li!ation%ame V 9+emote<)6e!t: +emotingCon"iguration#+egister$!ti(atedSer(i!eT*'e(5etT*'e(Inter,a!e+emoting#Inter,a!e+e moting)) %ote :- We ha(e to 'ro(ide a''li!ationname and register the o)6e!t as $!ti(atedSer(i!eT*'e# <n !lient side we ha(e to re"eren!e the generated ClientMeta2ata#dll "rom S<$ESG2S utilit*#Below are !hanges whi!h are needed to )e in!or'orated at the +emoting Client :+emotingCon"iguration#+egister$!ti(atedClientT*'e(t*'eo"(+emote<)6e!t),9htt':OO lo!alhost:>BA0OM*Ser(er:) 2im o)6+emote<)6e!t as new +emote<)6e!t()# +emote<)6e!t is !lass whi!h is o)tained "rom ClientMeta2ata#dll whi!h we !reated using S<$ESG2S utilit*#%ow *ou !an re"eren!e the o)6e!t as normal o)6e!t# 3L (I) Is it a good design 'ra!ti!e to distri)ute the im'lementation to +emoting Client ? It8s ne(er ad(isa)le to distri)ute !om'lete im'lementation at !lient , due to "ollowing reasons :4 $n* one !an use IL2$SM and de!r*'t *our logi!# 4 It8s a )ad ar!hite!ture mo(e to ha(e "ull im'lementation as !lient side as an* !hanges in im'lementation on ser(er side *ou ha(e to redistri)ute it again# So the )est wa* is to ha(e a inter"a!e or S<$ESG2S generated meta-data 2LL at !lient side rather than ha(ing "ull im'lementation#

($) What is LeaseTime,S'onsorshi'Time ,+enewonCallTime and LeaseManagerEollTime? This is a (er* im'ortant =uestion "rom 'ra!ti!al im'lementation 'oint o" (iew#Com'anies who ha(e s'e!i"i! re=uirement "or +emoting 'ro6e!t8s will e-'e!t this =uestion to )e answered# In normal #%&T en(ironment o)6e!ts li"etime is managed )* gar)age !olle!tor#But in remoting en(ironment remote !lients !an a!!ess o)6e!ts whi!h is out o" !ontrol o" gar)age !olle!tor#5ar)age !olle!tor )oundar* is limited to a single EC on whi!h "ramewor is running , an* remote !lient a!ross 'h*si!al EC is out o" !ontrol o" 5C (5ar)age Colle!tor)# This !onstraint o" gar)age !olle!tor leads to a new wa* o" handling li"etime "or remoting o)6e!ts , )* using !on!e't !alled as 9LeaseTime:#&(er* ser(er side o)6e!t is assigned )* de"ault a 9LeaseTime: o" "i(e minutes#This leasetime is de!reased at !ertain inter(als#$gain "or e(er* method !all a de"ault o" two minutes is assigned#When i sa* method !all means e(er* !all made "rom !lient#This is !alled as 9+enewal<nCallTime:# Let8s 'ut the whole thing in e=uation to ma e the !on!e't more !lear# Total +emoting o)6e!t li"e time V LeaseTime / (%um)er o" method !alls) C (+enewalTime)# I" we ta e %um)er<"MethodCalls as one# Then de"ault +emote <)6e!t Li"e Time V L / (>) C B V >1 minutes (&(er*thing is in minutes) 33 When total o)6e!t li"etime is redu!ed to 7ero , it =ueries the s'onsor that should the o)6e!t )e destro*ed#S'onsor is a o)6e!t whi!h de!ides should o)6e!t Li"etime )e renewed#So it =ueries an* registered s'onsors with the o)6e!t , i" does not "ind an* then the o)6e!t is mar ed "or gar)age !olle!tion#$"ter this gar)age !olle!tion has whole !ontrol on the o)6e!t li"etime#I" we do not "oresee how long a o)6e!t will )e needed s'e!i"* the 9S'onsorShi'Time<ut: (alue# S'onsorShi'Time<ut is time unit a !all to a s'onsor is timed out# 9LeaseManagerEollTime: de"ines the time the s'onsor has to return a leasetime e-tension# ($) Whi!h !on"ig "ile has all the su''orted !hannelsO'roto!ol ? Ma!hine#!on"ig "ile has all the su''orted !hannels and "ormatter su''orted )* #%&T remoting#Ma!hine#!on"ig "ile !an )e "ound at 9C:IWI%2<WSIMi!roso"t#%&TI,ramewor I(CCCCCIC<%,I5: 'ath#,ind Ts*stem#runtime#remotingU element in the Ma!hine#!on"ig "ile whi!h has the !hannels and the "ormatters#Below is a "igure shown whi!h !an gi(e a !lear idea o" how the "ile loo s li e# %ote :- Inter(iewer will not as *ou to name all !hannels and "ormatters in ma!hine#!on"ig )ut will de"initel* li e to now in whi!h "ile are all the "ormatter and !hannels s'e!i"ied one sweet answer 9Ma!hine#!on"ig: !an "et!h *ou handsome 6o)# 3M ,igure :- 0#3 Channels and ,ormatter in ma!hine#!on"ig "ile ($) ?ow !an *ou s'e!i"* remoting 'arameters using Con"ig "iles ? Both remoting ser(er and remoting !lient 'arameters !an )e 'ro(ided through !on"ig "iles#Below is a sam'le o" ser(er !on"ig "ile whi!h 'ro(ides all remoting 'arameter (alues

whi!h we where 'ro(iding through !ode# T!on"igurationU Ts*stem#runtime#remotingU Ta''li!ation nameV:Ser(er:U Tser(i!eU Twell nown 3@ modeV:SingleCall: t*'eV:Ser(er#ClsSer(er, Ser(er: o)6e!tGriV:+emote<)6e!t: OU TOser(i!eU T!hannelsU T!hannel re"V:t!' ser(er: 'ortV:D111H OU TO!hannelsU TOa''li!ationU TOs*stem#runtime#remotingU TO!on"igurationU Later this !on"ig "ile !an )e loaded using the "ollowing !ode# +emotingCon"iguration#Con"igure($''2omain#Current2omain#Setu'In"ormation#$''li!ationB ase ^ 9Ser(er#!on"ig:) Same wa* we also ha(e !lient#!on"ig "ile "or loading the !lient remoting 'arameters# T!on"igurationU Ts*stem#runtime#remotingU Ta''li!ation nameV:Client:U T!lient urlV:t!':OOlo!alhost:D111O+emote<)6e!t:U Twell nown t*'eV:CommonInter"a!e#I!ommon, I!ommon: url V 9t!':OOlo!alhost:D111OSer(erO+emote<)6e!t:OU TO!lientU T!hannelsU T!hannel re"V:t!' !lient: OU TO!hannelsU TOa''li!ationU TOs*stem#runtime#remotingU TO!on"igurationU !lient remoting !an then load the !on"iguration "ile )* using :2im Io)6Common $s CommonInter,a!e#I!ommon 2im Str2ata $s String 2im o)6Ser(i!e&ntries $s WellJnownClientT*'e&ntr*() +emotingCon"iguration#Con"igure($''2omain#Current2omain#Setu'In"ormation#$''li!ationB ase ^ 9Client#!on"ig:)

o)6Ser(i!e&ntries V +emotingCon"iguration#5et+egisteredWellJnownClientT*'es() Io)6Common V $!ti(ator#5et<)6e!t(5etT*'e(I!ommon), o)6Ser(i!e&ntries(1)#<)6e!tGrl#ToString()) Str2ata V Io)6Common#5et.alue() 3D Console#WriteLine(9 Ser(e side 2ata is 9 ^ Str2ata) Console#+eadLine() %ote :- Com'lete sour!e is 'ro(ided in C2 in "older 9+emoting<)6e!tLi"eTime:#I" *ou run Ser(er and Client "ollowing out'ut !an )e seen#$ll sour!e is !om'iled using .SB11L B&T$> ,igure : - 0#M <ut'ut o" Ser(er and Client "or +emoting<)6e!tLi"eTime 'ro6e!t ($) Can %on-2e"ault !onstru!tors )e used with Single Call S$<? Twist :- What are the limitation o" !onstru!tors "or Single !all S$< ? M1 %on-2e"ault !onstru!tors !an not )e used with single !all o)6e!ts as o)6e!t is !reated with e(er* method !all, there is no wa* to de"ine %on-de"ault !onstru!tors in method !alls# It8s 'ossi)le to use %on-2e"ault !onstru!tor with Client a!ti(ated o)6e!ts as )oth methods :9%&W: e*word and 9$!ti(ator#CreateInstan!e: 'ro(ide a wa* to s'e!i"* %on-2e"ault !onstru!tors# (I) ?ow !an we !all methods in remoting $s*n!hronousl* ? $ll 're(ious e-am'les are s*n!hronous method !alls , that means !lient has to wait until the method !om'letes the 'ro!ess#B* using 2elegates we !an ma e $s*n!hronous method !alls# ($) What is $s*n!hronous <ne-Wa* Calls ? <ne-wa* !alls are a di""erent "rom as*n!hronous !alls "rom e-e!ution angle that the #%&T ,ramewor does not guarantee their e-e!ution# In addition, the methods used in this ind o" !all !annot ha(e return (alues or out 'arameters#<ne-wa* !alls are de"ined )* using R<neWa*()S attri)ute in !lass# (B) What is marshalling and what are di""erent inds o" marshalling ? Marshaling is used when an o)6e!t is !on(erted so that it !an )e sent a!ross the networ or a!ross a''li!ation domains#Gnmarshaling !reates an o)6e!t "rom the marshaled data#There are two wa*s to do marshalling :4 Marshal-)*-(alue (MB.) :- In this the o)6e!t is seriali7ed into the !hannel, and a !o'* o" the o)6e!t is !reated on the other side o" the networ # The o)6e!t to marshal is stored into a stream, and the stream is used to )uild a !o'* o" the o)6e!t on the other side with the unmarshalling se=uen!e# 4 Marshaling-)*-re"eren!e (MB+):- ?ere it !reates a 'ro-* on the !lient that is used to !ommuni!ate with the remote o)6e!t# The marshaling se=uen!e o" a remote o)6e!t !reates an <)6+e" instan!e that itsel" !an )e seriali7ed a!ross the networ #

<)6e!ts that are deri(ed "rom 9MarshalB*+e"<)6e!t: are alwa*s marshaled )* re"eren!e#$ll our 're(ious sam'les ha(e !lasses inherited "rom 9MarshalB*+e"<)6e!t: M> To marshal a remote o)6e!t the stati! method +emotingSer(i!es#Marshal() is used#+emotingSer(i!es#Marshal() has "ollowing o(erloaded (ersions:'u)li! stati! <)6+e" Marshal(MarshalB*+e"<)6e!t o)6) 'u)li! stati! <)6+e" Marshal(MarshalB*+e"<)6e!t o)6, string o)6Gri) 'u)li! stati! <)6+e" Marshal(MarshalB*+e"<)6e!t o)6, string o)6Gri,T*'e re=uestedT*'e) The "irst argument o)6 s'e!i"ies the o)6e!t to marshal# The o)6Gri is the 'ath that is stored within the marshaled o)6e!t re"eren!eW it !an )e used to a!!ess the remote o)6e!t# The re=uestedT*'e !an )e used to 'ass a di""erent t*'e o" the o)6e!t to the o)6e!t re"eren!e# This is use"ul i" the !lient using the remote o)6e!t shouldnFt use the o)6e!t !lass )ut an inter"a!e that the remote o)6e!t !lass im'lements instead# In this s!enario the inter"a!e is the re=uestedT*'e that should )e used "or marshaling# ($) What is <)6+e" o)6e!t in remoting ? $ll Marshal() methods return <)6+e" o)6e!t#The <)6+e" is seriali7a)le )e!ause it im'lements the inter"a!e ISeriali7a)le, and !an )e marshaled )* (alue# The <)6+e" nows a)out :4 lo!ation o" the remote o)6e!t 4 host name 4 'ort num)er 4 o)6e!t name# (B) What is a We)Ser(i!e ? We) Ser(i!es are )usiness logi! !om'onents whi!h 'ro(ide "un!tionalit* (ia the Internet using standard 'roto!ols su!h as ?TTE# We) Ser(i!es uses Sim'le <)6e!t $!!ess Eroto!ol (S<$E) in order to e-'ose the )usiness "un!tionalit*#S<$E de"ines a standardi7ed "ormat in CML whi!h !an )e e-!hanged )etween two entities o(er standard 'roto!ols su!h as ?TTE#S<$E is 'lat"orm inde'endent so the !onsumer o" a We) Ser(i!e is there"ore !om'letel* shielded "rom an* im'lementation details a)out the 'lat"orm e-'osing the We) Ser(i!e#,or the !onsumer it is sim'l* a )la! )o- o" send and re!ei(e CML o(er ?TTE#So an* we)ser(i!e hosted on windows !an also )e !onsumed )* G%IC and LI%GC 'lat"orm# MB (B) What is G22I ? ,ull "orm o" G22I is Gni(ersal 2es!ri'tion,2is!o(er* and Integration#It is a dire!tor* that !an )e used to 'u)lish and dis!o(er 'u)li! We) Ser(i!es#I" *ou want to see more details *ou !an (isit the htt':OOwww#G22I#org # (B) What is 2ISC< ? $))re(iation o" 2ISC< is 2is!o(er*#It is )asi!all* used to !lu) or grou' !ommon ser(i!es together on a ser(er and 'ro(ide lin s to the s!hema do!uments o" the ser(i!es it des!ri)es ma* re=uire# (B) What is WS2L?

We) Ser(i!e 2es!ri'tion Language (WS2L)is a WAC s'e!i"i!ation whi!h de"ines CML grammar "or des!ri)ing We) Ser(i!es#CML grammar des!ri)es details su!h as:4 Where we !an "ind the We) Ser(i!e (its G+I) 4 What methods and 'ro'erties that ser(i!e su''orts 4 2ata t*'e su''ort# 4 Su''orted 'roto!ols In short its a )i)le o" what the we)ser(i!e !an do#Clients !an !onsume this WS2L and )uild 'ro-* o)6e!ts that !lients use to !ommuni!ate with the We) Ser(i!es# ,ull WS2L s'e!i"i!ation is a(aila)le at htt':OOwww#wA#orgOT+Owsdl# ($) What the di""erent 'haseOste's o" a!=uiring a 'ro-* o)6e!t in We)ser(i!e ? The "ollowing are the di""erent ste's needed to get a 'ro-* o)6e!t o" a we)ser(i!e at the !lient side :4 Client !ommuni!ates to G2I node "or We)Ser(i!e either through )rowser or G22IFs 'u)li! we) ser(i!e# 4 G2II res'onds with a list o" we)ser(i!e# 4 &(er* ser(i!e listed )* we)ser(i!e has a G+I 'ointing to 2ISC< or WS2L do!ument# MA 4 $"ter 'arsing the 2ISC< do!ument, we "ollow the G+I "or the WS2L do!ument related to the we)ser(i!e whi!h we need# 4 Client then 'arses the WS2L do!ument and )uilds a 'ro-* o)6e!t whi!h !an !ommuni!ate with We)ser(i!e# (B) What is "ile e-tension o" We)ser(i!es ? #$SMC is e-tension "or We)ser(i!es# %ote :- $"ter this we are going to deal with a sam'le o" we)ser(i!e#In .SB11L we)'ro6e!t is !reated "rom the menu itsel" as !om'ared to B11A where it was 'resent in the e-'lorer# M0 ,igure :- 0#@ Create We) 'ro6e!t menu in .SB11L (B)Whi!h attri)ute is used in order that the method !an )e used as We)Ser(i!e ? We)Method attri)ute has to )e s'e!i"ied in order that the method and 'ro'ert* !an )e treated as We)Ser(i!e# ($) What are the ste's to !reate a we)ser(i!e and !onsume it ? %ote :- ,or this =uestion this )oo will ma e a attem't )* !reating a sim'le we)ser(i!e and e-'laining ste's to a!hei(e it#$ sim'le we)ser(i!e will )e !reated whi!h ta es two num)er and gi(es addition result o" the two num)er#In C2 sam'le we)ser(i!e 'ro6e!t with "older name 9MathsWe)Ser(i!e: is 'ro(ided and same will )e e-'lained )elow# 2e"initel* the ML inter(iewer will not e-'e!t su!h a detail answer )ut this )oo will e-'lain *ou in detail so that *ou are on right tra! during inter(iew# This we)ser(i!e will add two num)ers and gi(e to the !alling !lient#$ll the )elow ste's are a!!ording to .SB11L )eta editor :-

4 ,irst !reate a we)site )* !li! ing on ,ile -- %ew We)Site# 4 ,rom 9.isual Studio Installed Tem'lates: !li! on 9$s'#%&T We) Ser(i!e:#See "igure )elow#%ame the "igure as 9Maths We) Ser(i!e:# ,igure :- 0#D Create We)Ser(i!e Ero6e!t M3 4 B* de"ault the #%&T editor has made a de"ault we)ser(i!e method !alled as H?elloWordH whi!h returns a string datat*'e#LetFs rename HSer(i!e#()H to HMaths#()H and HSer(i!e#asm-H to HMaths#asm-H#Let8s re'la!e the 9?elloWorld: with "ollowing !ode )elow :TWe)Method()U Q Eu)li! ,un!tion $ddTwo%um)ers(B*.al %um)er> $s Integer, B*.al %um)erB $s Integer) $s Integer +eturn %um)er> / %um)erB &nd ,un!tion MM ,igure :- 0#>1 +ename all *our de"ault 9Ser(i!e: to 9Maths: 4 4 $"ter the we)ser(i!e is done !li! on add We)re"eren!e#%ormall* "or !om'onents we do a 9$dd +e"eren!e: and "or We)ser(i!es we do 9$dd We) +e"eren!e:# ,igure :- 0#>> Cli! on $dd We) +e"eren!e M@ 4 Kou will )e shown with a list o" we)ser(i!es whi!h are nown to the solutions#$s we are loo ing "or our 9Maths: we)ser(i!e whi!h e-ist in the same solution , we !li! 9We)ser(i!es in this solution:# MD ,igure :- 0#>B List o" we)ser(i!es "or )rowsing 4 Kour editor has lo!ated the 9Maths: we)ser(i!e#Sele!t the we)ser(i!e# ,igure :- 0#>A Solution showing the a(aila)ilit* o" Maths We)ser(i!e# @1 @> 4 $"ter *ou ha(e !li! ed on 9Maths: we)ser(i!e *ou will see a sear!h 'rogress )ar as shown in "igure )elow#This 'ro!ess will start the we)ser(i!e , re"eren!e it and !reate a 'ro-* "or the !lient , so that using it !lient !an a)sor) the we)ser(i!e# ,igure :- 0#>0 Starting the we)ser(i!e and !reating the 'ro-* "or *our solution# @B 4 ,inall* *ou are a)le to see *our we)ser(i!e whi!h is read* "or use#Cli! on $dd +e"eren!e and *ou will see a 9Lo!alhost: re"eren!e in *our #%&T solution# ,igure :- 0#>L Starting the we)ser(i!e and !reating the 'ro-* "or *our solution# 4 We need to ma e a !lient who will a)sor) this 9Maths We)ser(i!e:#$dd 9We)ser(i!eClient#as'-: and !reate a GI as shown )elow#In the )utton !li! 'ut in the "ollowing !ode#:Lo!al?ost#ClsMaths: is the 'ro-* o)6e!t )* whi!h

*ou !an ma e !alls to the we)ser(i!e# Su) !mdCal!ulateQCli! (B*.al sender $s <)6e!t, B*.al e $s @A S*stem#&(ent$rgs) 2im 'o)6Maths $s %ew lo!alhost#ClsMaths l)l+esult2is'la*#Te-t V Con(ert#ToString('o)6Maths#$ddTwo%um)ers(Con(ert#ToInt>3(t-t%um)er>#Te-t), Con(ert#ToInt>3(t-t%um)erB#Te-t))) &nd Su) ,igure :- 0#>3 Com'lete We)ser(i!e in a!tion# %ote :- The whole 'oint o" !reating this 9Maths We)ser(i!e: ste' )* ste' was to ha(e a understanding o" 'ra!ti!al angle o" how we)ser(i!es are !reated#It8s (er* (er* rare that *ou will )e as ed to e-'lain e(er* ste' o" how to write a we)ser(i!e#But in !ase *our inter(iewer is too )end down to also now what are the a!tual ste's in !reating a We)ser(i!e# ($) 2o we)ser(i!e ha(e state ? Twist :- ?ow !an we maintain State in We)ser(i!es ? We)ser(i!es as su!h do not ha(e an* me!hanism )* whi!h the* !an maintain state#We)ser(i!es !an a!!ess $SE#%&T intrinsi! o)6e!ts li e Session , a''li!ation et!# i" the* inherit "rom 9We)Ser(i!e: )ase !lass# T_` We)ser(i!e !lassVHTestWe)Ser(i!eClassH _U Im'orts S*stem#We)#Ser(i!es @0

(B) What is a''li!ation o)6e!t ? $''li!ation o)6e!t !an used in situation where we want data to )e shared a!ross users glo)all*# (I)What8s the di""eren!e )etween Ca!he o)6e!t and a''li!ation o)6e!t ? The main di""eren!e )etween the Ca!he and $''li!ation o)6e!ts is that the Ca!he o)6e!t 'ro(ides !a!he-s'e!i"i! "eatures, su!h as de'enden!ies and e-'iration 'oli!ies# (I)?ow !an get a!!ess to !a!he o)6e!t ? The Ca!he o)6e!t is de"ined in the S*stem#We)#Ca!hing names'a!e# Kou !an get a re"eren!e to the Ca!he o)6e!t )* using the Ca!he 'ro'ert* o" the ?tt'Conte-t !lass in the S*stem#We) names'a!e or )* using the Ca!he 'ro'ert* o" the Eage o)6e!t# ($)What are de'enden!ies in !a!he and t*'es o" de'enden!ies ? When *ou add an item to the !a!he, *ou !an de"ine de'enden!* relationshi's that !an "or!e that item to )e remo(ed "rom the !a!he under s'e!i"i! a!ti(ities o" de'enden!ies#&-am'le i" the !a!he o)6e!t is de'endent on "ile and when the "ile data !hanges *ou want the !a!he o)6e!t to )e u'date#,ollowing are the su''orted de'enden!* :4 ,ile de'enden!* :- $llows *ou to in(alidate a s'e!i"i! !a!he item when a dis )ased "ile or "iles !hange# 4 Time-)ased e-'iration :- $llows *ou to in(alidate a s'e!i"i! !a!he item de'ending on 'rede"ined time# 4 Je* de'enden!* :-$llows *ou to in(alidate a s'e!i"i! !a!he item de'ending when another !a!hed item !hanges# L# Ca!hing Con!e'ts @L (E)Can *ou show a sim'le !ode showing "ile de'enden!* in !a!he ? Eartial Class 2e"aultQas'Eu)li! Su) dis'la*$nnoun!ement() 2im announ!ement $s String I" Ca!he(9announ!ement:) Is %othing Then 2im "ile $s %ew Q S*stem#I<#Stream+eader Q (Ser(er#Ma'Eath(9announ!ement#t-t:)) announ!ement V "ile#+eadTo&nd "ile#Close() 2im de'ends $s %ew Q S*stem#We)#Ca!hing#Ca!he2e'enden!* Q (Ser(er#Ma'Eath(9announ!ement#t-t:)) Ca!he#Insert(9announ!ement:, announ!ement, de'ends) &nd I" +es'onse#Write(CT*'e(Ca!he(9announ!ement:), String)) &nd Su) Eri(ate Su) EageQInit(B*.al sender $s <)6e!t, B*.al e $s S*stem#&(ent$rgs) ?andles Me#Init dis'la*$nnoun!ement() &nd Su) &nd Class %ote :- $)o(e sour!e !ode !an )e o)tained "rom C2 in 9Ca!heSam'le: "older#:$nnoun!ement#t-t: is in the same "older whi!h *ou !an 'la* around to see the results# $)o(e gi(en method dis'la*$nnoun!ement() dis'la*s )anner te-t "rom $nnoun!ement#t-t

"ile whi!h is l*ing in a''li!ation 'ath o" the we) dire!tor*#$)o(e method "irst !he! s is the Ca!he o)6e!t nothing , i" the !a!he o)6e!t is nothing then it mo(es "urther to load the !a!he data "rom the "ile#Whene(er the "ile data !hanges the !a!he o)6e!t is remo(ed and set to nothing# ($) What is Ca!he Call)a! in Ca!he ? Ca!he o)6e!t is de'endent on its de'enden!ies e-am'le "ile )ased , time )ased et!#Ca!he items remo(e the o)6e!t when !a!he de'enden!ies !hange#$SE#%&T 'ro(ides !a'a)ilit* to e-e!ute a !all)a! method when that item is remo(ed "rom !a!he# @3 ($) What is s!a(enging ? When ser(er running *our $SE#%&T a''li!ation runs low on memor* resour!es , items are remo(ed "rom !a!he de'ending on !a!he item 'riorit*#!a!he item 'riorit* is set when *ou add item to !a!he#BK setting the !a!he item 'riorit* !ontrols whi!h items s!a(enging is remo(ed "irst# (B) What are di""erent t*'es o" !a!hing using !a!he o)6e!t o" $SE#%&T? Kou !an use two t*'es o" out'ut !a!hing to !a!he in"ormation that is to )e transmitted to and dis'la*ed in a We) )rowser: 4 Eage <ut'ut Ca!hing Eage out'ut !a!hing adds the res'onse o" 'age to !a!he o)6e!t#Later when 'age is re=uested 'age is dis'la*ed "rom !a!he rather than !reating the 'age o)6e!t and dis'la*ing it#Eage out'ut !a!hing is good i" the site is "airl* stati!# 4 Eage ,ragment Ca!hing I" 'arts o" the 'age are !hanging, *ou !an wra' the stati! se!tions as user !ontrols and !a!he the user !ontrols using 'age"ragment !a!hing# (B) ?ow !an *ou !a!he di""erent (ersion o" same 'age using $SE#%&T !a!he o)6e!t ? <ut'ut !a!he "un!tionalit* is a!hie(ed )* using 9<ut'utCa!he: attri)ute on $SE#%&T 'age header#Below is the s*ntaT_` <ut'utCa!he 2urationVHB1H Lo!ationVHSer(erH .ar*B*EaramVHstateH .ar*B*CustomVHminor(ersionH .ar*B*?eaderVH$!!e't-LanguageH_U 4 .ar*B*Earam :- Ca!hes di""erent (ersion de'ending on in'ut 'arameters send through ?TTE E<STO5&T# 4 .ar*B*?eader:- Ca!hes di""erent (ersion de'ending on the !ontents o" the 'age header# @M 4 .ar*B*Custom:-Lets *ou !ustomi7e the wa* the !a!he handles 'age (ariations )* de!laring the attri)ute and o(erriding the 5et.ar*B*CustomString handler# 4 .ar*B*Control:-Ca!hes di""erent (ersions o" a user !ontrol )ased on the (alue o" 'ro'erties o" $SE o)6e!ts in the !ontrol# ($) ?ow will im'lement Eage ,ragment Ca!hing ? Eage "ragment !a!hing in(ol(es the !a!hing o" a "ragment o" the 'age, rather than the entire 'age# When 'ortions o" the 'age need to )e d*nami!all* !reated "or ea!h user re=uest this is )est method as !om'ared to 'age !a!hing#Kou !an wra' We) ,orms user !ontrol and !a!he the !ontrol so that these 'ortions o" the 'age don8t need to )e re!reated ea!h time# (B) What are $SE#%&T session and !om'are $SE#%&T session with !lassi! $SE session (aria)les? $SE#%&T session !a!hes 'er user session state#It )asi!all* uses 9?tt'SessionState: !lass# ,ollowing are the limitations in !lassi! $SE sessions :-

4 $SE session state is de'endent on IIS 'ro!ess (er* hea(il*#So i" IIS restarts $SE session (aria)les are also re!*!led#$SE#%&T session !an )e inde'endent o" the hosting en(ironment thus $SE#%&T session !an maintained e(en i" IIS re)oots# 4 $SE session state has no inherent solution to wor with We) ,arms#$SE#%&T session !an )e stored in state ser(er and S\L S&+.&+ whi!h !an su''ort multi'le ser(er# 4 $SE session onl* "un!tions when )rowser su''orts !oo ies#$SE#%&T session !an )e used with )rowser side !oo ies or inde'endent o" it# (B) Whi!h (arious modes o" storing $SE#%&T session ? 4 InEro!:- In this mode Session state is stored in the memor* s'a!e o" the $s'netQw'#e-e 'ro!ess#This is the de"ault setting#I" the IIS re)oots or we) a''li!ation restarts then session state is lost# @@ 4 StateSer(er:-In this mode Session state is seriali7ed and stored in a se'arate 'ro!ess ($s'netQstate#e-e)W there"ore, the state !an )e stored on a se'arate !om'uter(a state ser(er)# 4 S\L S&+.&+:- In this mode Session state is seriali7ed and stored in a S\L Ser(er data)ase# Session state !an )e s'e!i"ied in TsessionStateU element o" a''li!ation !on"iguration "ile#Gsing State Ser(er and S\L S&+.&+ session state !an )e shared a!ross we) "arms )ut note this !omes at s'eed !ost as $SE#%&T needs to seriali7e and deseriali7e data o(er networ again and again# ($) Is SessionQ&nd e(ent su''orted in all session modes ? SessionQ&nd e(ent o!!urs onl* in 9In'ro! mode:#:State Ser(er: and 9S\L S&+.&+: do not ha(e SessionQ&nd e(ent# ($) What are the 're!autions *ou will ta e in order that StateSer(er Mode wor 'ro'erl* ? ,ollowing are the things to remem)er so that StateSer(er Mode wor s 'ro'erl* :4 StateSer(er mode session data is stored in a di""erent 'ro!ess so *ou must ensure that *our o)6e!ts are seriali7a)le# 4 Tma!hineJe*U elements in We)#!on"ig should )e indenti!al a!ross all ser(ers#So this ensures that en!r*'tion "ormat is same a!ross all !om'uters# 4 IIS meta)ase (ILMIWAS.CIB) must )e identi!al a!ross all ser(ers in that "arm# ($) What are the 're!autions *ou will ta e in order that S\LS&+.&+ Mode wor 'ro'erl* ? ,ollowing are the things to remem)er so that S\LS&+.&+ Mode wor s 'ro'erl* :4 S\LS&+.&+ mode session data is stored in a di""erent 'ro!ess so *ou must ensure that *our o)6e!ts are seriali7a)le# 4 IIS meta)ase (ILMIWAS.CIB) must )e indenti!al a!ross all ser(ers in that "arm# @D 4 B* de"ault Session o)6e!ts are stored in 9Tem'd): , *ou !an !on"igure it store outside 9Tem'2B: )* running mi!roso"t 'ro(ided S\L s!ri't# %ote :- 9Tem'2B: data)ase is re-!reated a"ter S\L S&+.&+ !om'uter re)oot#I" *ou want to maintain session state with e(er* re)oot )est is to run S\L S!ri't and store session o)6e!ts outside 9Tem'2B: data)ase# ($) Where do *ou s'e!i"* session state mode in $SE#%&T ? TsessionState modeV:S\LSer(er:

stateConne!tionStringV:t!'i'V>DB#>3@#>#>:0B0B0H s=lConne!tionStringV:data sour!eV>DB#>3@#>#>W Integrated Se!urit*VSSEI: !oo ielessV:"alse: timeoutV:B1H OU $)o(e is sam'le session state mode s'e!i"ied "or S\L S&+.&+# (B) What are the other wa*s *ou !an maintain state ? <ther than session (aria)les *ou !an use the "ollowing te!hni=ue to store state : 4 ?idden "ields 4 .iew state 4 ?idden "rames 4 Coo ies 4 \uer* strings (B) What are )ene"its and Limitation o" using ?idden "ields ? ,ollowing are the )ene"its o" using ?idden "ields :4 The* are sim'le to im'lement# 4 $s data is !a!hed on !lient side the* wor with We) ,arms# 4 $ll )rowsers su''ort hidden "ield# 4 %o ser(er resour!es are re=uired# ,ollowing are limitations o" ?idden "ield :D1 4 The* !an )e tam'ered !reating a se!urit* hole# 4 Eage 'er"orman!e de!reases i" *ou store large data , as the data is stored in 'ages itsel"# 4 ?idden "ields do not su''ort ri!h stru!tures as ?TML hidden "ields are onl* single (alued#Then *ou ha(e to wor around with delimiters et! to handle !om'le- stru!tures# Below is how *ou will a!tuall* im'lement hidden "ield in a 'ro6e!t Tin'ut idVH?idden.alueH t*'eVHhiddenH (alueVHInitial .alueH runatVHser(erH%$M&VH?idden.alueHU (B) What is .iewState ? .iewstate is a )uilt-in stru!ture "or automati!all* retaining (alues among multi'le re=uests "or the same 'age# The (iew state is internall* maintained as a hidden "ield on the 'age )ut is hashed, 'ro(iding greater se!urit* than de(elo'er-im'lemented hidden "ields do# ($) 2o 'er"orman!e (ar* "or (iewstate a!!ording to Gser !ontrols ? Eer"orman!e o" (iew state (aries de'ending on the t*'e o" ser(er !ontrol to whi!h it is a''lied# La)el, Te-tBo-, Che! Bo-, +adioButton, and ?*'erLin are ser(er !ontrols that 'er"orm well with .iewState# 2ro'2ownList, ListBo-, 2ata5rid, and 2ataList su""er "rom 'oor 'er"orman!e )e!ause o" their si7e and the large amounts o" data ma ing roundtri's to the ser(er# (B) What are )ene"its and Limitation o" using .iewstate "or state management? ,ollowing are the )ene"its o" using .iewstate :4 %o ser(er resour!es are re=uired )e!ause state is !ontained in a stru!ture in the 'age !ode# 4 Sim'li!it*# 4 States are retained automati!all*# 4 The (alues in (iew state are hashed, !om'ressed, and en!oded, thus re'resenting a higher state o" se!urit* than hidden "ields#

D> 4 .iew state is good "or !a!hing data in We) "arm !on"igurations )e!ause the data is !a!hed on the !lient# ,ollowing are limitation o" using .iewstate:4 Eage loading and 'osting 'er"orman!e de!reases when large (alues are stored )e!ause (iew state is stored in the 'age# 4 $lthough (iew state stores data in a hashed "ormat, it !an still )e tam'ered with )e!ause it is stored in a hidden "ield on the 'age# The in"ormation in the hidden "ield !an also )e seen i" the 'age out'ut sour!e is (iewed dire!tl*, !reating a 'otential se!urit* ris # Below is sam'le o" storing (alues in (iew state# this#.iewStateRH&nterTimeHS V 2ateTime#%ow#ToString()W (B) ?ow an *ou use ?idden "rames to !a!he !lient data ? This te!hni=ue is im'lemented )* !reating a ?idden "rame in 'age whi!h will !ontain *our data to )e !a!hed# T,+$M&S&T !olsVH>11_,;,;HU T,+$M&S&T rowsVH>11_HU T,+$M& sr!VHdataQo"Q"rame>#htmlHUTO,+$M&S&TU T,+$M& sr!VHdataQo"QhiddenQ"rame#htmlHU T,+$M& sr!VHdataQo"QhiddenQ"rame#htmlH "rame)orderVH1H noresi7e s!rollingVH*esHU TO,+$M&S&TU $)o(e is a sam'le o" hidden "rames where the "irst "rame 9dataQo"Q"rame>#html: is (isi)le and the remaining "rames are hidden )* gi(ing whole !ol se!tion to "irst "rame# See allo!ation where >11 _ is allo!ated to "irst "rame and remaining "rames thus remain hidden# (I) What are )ene"its and Limitation o" using ?idden "rames? ,ollowing are the )ene"its o" using hidden "rames: 4 Kou !an !a!he more than one data "ield# DB 4 The a)ilit* to !a!he and a!!ess data items stored in di""erent hidden "orms# 4 The a)ilit* to a!!ess JS!ri'ta (aria)le (alues stored in di""erent "rames i" the* !ome "rom the same site# The limitations o" using hidden "rames are: 4 ?idden "rames are not su''orted on all )rowsers# 4 ?idden "rames data and )e tam'ered thus !reating se!urit* hole# (I) What are )ene"its and Limitation o" using Coo ies? ,ollowing are )ene"its o" using !oo ies "or state management :4 %o ser(er resour!es are re=uired as the* are stored in !lient# 4 The* are light weight and sim'le to use ,ollowing are limitation o" using !oo ies :4 Most )rowsers 'la!e a 01D3-)*te limit on the si7e o" a !oo ie,although su''ort "or @>DB-)*te !oo ies is )e!oming more !ommon in the new )rowser and !lient-de(i!e (ersions a(aila)le toda*# 4 Some users disa)le their )rowser or !lient de(i!e8s a)ilit* to re!ei(e !oo ies, there)* limiting the use o" !oo ies# 4 Coo ies !an )e tam'ered and thus !reating a se!urit* hole# 4 Coo ies !an e-'ire thus leading to in!onsisten!*# Below is sam'le !ode o" im'lementing !oo ies +e=uest#Coo ies#$dd(%ew ?tt'Coo ie(9name:, 9user>:)) (I) What is \uer* String and What are )ene"its and Limitation o" using

\uer* Strings? $ =uer* string is in"ormation sent to the ser(er a''ended to the end o" a 'age G+L# ,ollowing are the )ene"its o" using =uer* string "or state management:4 %o ser(er resour!es are re=uired# The =uer* string is !ontained in the ?TTE re=uest "or a s'e!i"i! G+L# DA 4 $ll )rowsers su''ort =uer* strings# ,ollowing are limitations o" =uer* string :4 \uer* string data is dire!tl* (isi)le to user thus leading to se!urit* 'ro)lems#4 Most )rowsers and !lient de(i!es im'ose a BLL-!hara!ter limit on G+L length# Below is a sam'le 9Login: =uer* string 'assed in G+L htt':OOwww#=uer*string#!omO login#as'?loginVtesting#This =uer*string data !an then )e re=uested later )* using +e=uest#\uer*String(9login:)#

<<ES
(B) What is <)6e!t <riented Erogramming ? It is a 'ro)lem sol(ing te!hni=ue to de(elo' so"tware s*stems#It8s a te!hni=ue to thin real world in terms o" o)6e!ts#<)6e!t ma's the so"tware model to real world !on!e't#These o)6e!ts ha(e res'onsi)ilities and 'ro(ide ser(i!es to a''li!ation or other o)6e!ts# (B) What8s a Class ? $ !lass des!ri)es all the attri)utes o" o)6e!ts , as well as the methods that im'lement the )eha(ior o" mem)er o)6e!ts#Its a !om'rehensi(e data t*'e whi!h re'resent a )lue 'rint o" o)6e!ts#It8s a tem'late o" o)6e!t# (B) What8s a <)6e!t ? It8s a )asi! unit o" a s*stem#$n o)6e!t is an entit* that has attri)utes, )eha(ior, and identit*# <)6e!ts are mem)ers o" a !lass#$ttri)utes and )eha(ior o" an o)6e!t are de"ined )* the !lass de"inition# ($) What8s the relation )etween Classes and <)6e!ts ? The* loo (er* mu!h same )ut are not same#Class is a de"inition , while o)6e!t is a instan!e o" the !lass !reated#Class is a )lue 'rint while o)6e!ts are a!tual o)6e!ts e-isting in real world#&-am'le we ha(e !lass C$+ whi!h has attri)utes and methods li e S'eed,Bra es,T*'e o" Car et!#Class C$+ is 6ust a 'rotot*'e , now we !an !reate real time o)6e!ts whi!h !an )e used to 'ro(ide "un!tionalit* # &-am'le we !an !reate a Maruti !ar o)6e!t with >11 m s'eed and urgent )ra es# (B) What are di""erent 'ro'erties 'ro(ided )* <)6e!toriented s*stems ? Twist :- Can *ou e-'lain di""erent 'ro'erties o" <)6e!t <riented S*stems? %ote:- 2i""eren!e )etween a)stra!tion and en!a'sulation is one o" the "a(orite inter(iew =uestion and =uiet !on"using as )oth the terminolog* loo ali e#Best is i" *ou !an )rainstorm with *our "riends or do a little reading# ,ollowing are !hara!teristi!8s o" <)6e!t <riented S*stem8s :; Who moti(ates *ou ?

DL $)stra!tion It allows !om'le- real world to )e re'resented in sim'li"ied manner#&-am'le !olor is a)stra!ted to +5B#B* 6ust ma ing the !om)ination o" these three !olors we !an a!hie(e an* !olor in world#It8s a model o" real world or !on!e't# &n!a'sulation The 'ro!ess o" hiding all the internal details o" an o)6e!t "rom the outside world# Communi!ation using messages When a''li!ation wants to a!hie(e !ertain tas it !an onl* )e done using !om)ination o" o)6e!ts#$ single o)6e!t !an not do all the tas #&-am'le i" we want to ma e order 'ro!essing "orm# We will use Customer o)6e!t , <rder o)6e!t , Erodu!t o)6e!t and Ea*ment o)6e!t to a!hie(e this "un!tionalit*#In short these o)6e!ts should !ommuni!ate with ea!h other#This is a!hie(ed when o)6e!ts send messages to ea!h other# <)6e!t li"etime $ll o)6e!ts ha(e li"e time#<)6e!ts are !reated , initiali7ed , ne!essar* "un!tionalities are done and later the o)6e!t is destro*ed#&(er* o)6e!t ha(e there own state and identit* , whi!h di""er "rom instan!e to instan!e# Class hierar!hies (Inheritan!e and aggregation) Twist :- What8s di""eren!e )etween $sso!iation , $ggregation and Inheritan!e relationshi's? In o)6e!t oriented world o)6e!ts ha(e relation and hierar!hies in )etween them#There are )asi!all* three ind o" relationshi' in <)6e!t <riented world :$sso!iation This is the sim'lest relationshi' )etween o)6e!ts#&-am'le e(er* !ustomer has sales#So Customer o)6e!t and sales o)6e!t ha(e a asso!iation relation )etween them# $ggregation This is also !alled as !om'osition model#&-am'le in order to ma e a 9$!!ounts: !lass it has use other o)6e!ts e-am'le 9.ou!her:,:Journal: and 9Cash: o)6e!ts#So a!!ounts !lass is aggregation o" these three o)6e!ts# ;Whi!h uni(ersit* are *our "rom ? D3 Inheritan!e ?ierar!h* is used to de"ine more s'e!iali7ed !lasses )ased on a 'ree-isting generali7ed !lass#&-am'le we ha(e .&?ICL& !lass and we !an inherit this !lass ma e more s'e!iali7ed !lass li e C$+, whi!h will add new attri)utes and use some e-isting =ualities o" the 'arent !lass#Its shows more o" a 'arent-!hild relationshi' #This ind o" hierar!h* is !alled inheritan!e# Eol*mor'hism When inheritan!e is used to e-tend a generali7ed !lass to a more s'e!iali7ed !lass,it in!ludes )eha(ior o" the to' !las(5enerali7ed !lass)#The inheriting !lass o"ten im'lement a )eha(ior that !an )e somewhat di""erent than the generali7ed !lass, )ut the name o" the )eha(ior !an )e same#It is im'ortant that a gi(en instan!e o" an o)6e!t use the !orre!t )eha(ior, and the 'ro'ert* o" 'ol*mor'hism allows this to ha''en automati!all*# (B) ?ow !an we a!hei(e inheritan!e in .B#%&T ?

%ote:- The "ollowing e-'lanation is "or .B#%&T Inheritan!e is a!hie(ed )* using 9Inherits: e*word in .B#%&T (,or CN it is 9::)#Sim'le Sam'le is 'ro(ided in C2 "or understanding inheritan!e in "older 9Windows$''li!ationInheritan!e:#There are two !lasses one is the 'arent 9ClsEarent: and se!ond is the !hild 9ClsChild:#Earent !lass has a string whi!h has to 'arsed "or 6un data 9`: and 9O:#ClsEarent has the "un!tionalit* whi!h 'arses onl* !leans u' 9`:#:ClsChild: then inherits "rom 'arent and adds e-tra "un!tionalit* )* 'arsing 9O:# Eu)li! Class ClsEarent Erote!ted str2ata $s String V 96 sdh 6`dadadOOOa6 dhs6a d: Eu)li! ,un!tion Earse() $s String 2im Estr2ata $s String Estr2ata V str2ata Estr2ata V +e'la!e(Estr2ata, 9`:, 9:) +eturn Estr2ata &nd ,un!tion Eu)li! ,un!tion 5et$!tualString() $s String +eturn str2ata &nd ,un!tion &nd Class $)o(e is the sour!e whi!h 'arses onl* 9`: o" str2ata (aria)le# ; What gi(es *our greatest satis"a!tion in so"tware 'ro"ession ? DM Eu)li! Class ClsChild Inherits ClsEarent X this is !hild and a s'e!ial 'arse "un!tion is added whi!h will also 'arse 9O: Eu)li! ,un!tion EarseBa! Slash() 2im Estr2ata $s String Estr2ata V Me#Earse() Estr2ata V +e'la!e(Estr2ata, 9O:, 9:) +eturn Estr2ata &nd ,un!tion &nd Class $)o(e is the sour!e !ode "or 9ClsChild: whi!h does the remaining wor #It adds e-tra "un!tionalit* )* 'arsing 9O: 6un !hara!ter8s o" the data# %ote:- Strdata was a!!essi)le onl* )e!ause it was de"ined as 'rote!ted in the 'arent !lass# ,igure :- 3#> Inheritan!e in a!tion (I) What are a)stra!t !lasses ? ,ollowing are "eatures o" a a)stra!t !lass :4 Kou !an not !reate a o)6e!t o" a)stra!t !lass ; ?ow would *ou des!ri)e *oursel" ? D@ 4 $)stra!t !lass is designed to a!t as a )ase !lass (to )e inherited )* other !lasses)#

$)stra!t !lass is a design !on!e't in 'rogram de(elo'ment and 'ro(ides a )ase u'on whi!h other !lasses are )uilt# 4 $)stra!t !lasses are similar to inter"a!es# $"ter de!laring an a)stra!t !lass, it !annot )e instantiated on itFs own, it must )e inherited# 4 In .B#%&T a)stra!t !lasses are !reated using 9MustInherit: e*word#In CN we ha(e 9$)stra!t: e*word# 4 $)stra!t !lasses !an ha(e im'lementation or 'ure a)stra!t methods whi!h should )e im'lemented in the !hild !lass# %ote:- In order to understand the !on!e't sim'le sam'le o" add and multi'l* "un!tionalit* is im'lemented in 9Windows$)stra!t: "older in C2# ,rom inter(iew 'oint o" (iew 6ust sa*ing using 9MustInherit: e*word is more than enough to !on(in!e that *ou ha(e used a)stra!t !lasses#But to !lear sim'le "undamental let8s tr* to understand the sam'le !ode#There are two !lasses one is 9Cls$)stra!t: !lass and other is 9ClsChild: !lass#:Cls$)stra!t: !lass is a a)stra!t !lass as *ou !an see the mustinherit e*word#It has one im'lemented method 9$dd: and other is a)stra!t method whi!h has to )e im'lemented )* !hild !lass 9Multi'l*%um)er:#In the !hild !lass we inherit the a)stra!t !lass and im'lement the multi'l*num)er "un!tion# 2e"initel* this sam'le does not ta e out a!tuall* how things are im'lemented in li(e 'ro6e!ts#Basi!all* *ou 'ut all *our !ommon "un!tionalities or hal" im'lemented "un!tionalit* in 'arent a)stra!t !lass and later let !hild !lass de"ine the "ull "un!tionalit* o" the a)stra!t !lass#&-am'le i alwa*s use a)stra!t !lass with all m* S&T 5&T 'ro'erties o" o)6e!t in a)stra!t !lass and later ma e s'e!iali7e !lasses "or insert,u'date,delete "or the !orres'onding entit* o)6e!t# Eu)li! MustInherit Class Cls$)stra!t X use the mustinherit !lass to de!lare the !lass as a)stra!t Eu)li! ,un!tion $dd(B*.al intnum> $s Integer, B*.al intnumB $s Integer) $s Integer +eturn intnum> / intnumB &nd ,un!tion X le"t this se!on" "un!tion to )e !om'leted )* the inheriting !lass Eu)li! Must<(erride ,un!tion Multi'l*%um)er(B*.al intnum> $s Integer, B*.al intnumB $s Integer) $s Integer &nd Class ; What t*'e o" en(ironment *ou are loo ing "or ? DD Eu)li! Class ClsChild Inherits Cls$)stra!t X !lass !hild o(errides the Multi'l*num)er "un!tion Eu)li! <(errides ,un!tion Multi'l*%um)er(B*.al intnum> $s Integer, B*.al intnumB $s Integer) $s Integer +eturn intnum> ; intnumB &nd ,un!tion

&nd Class ,igure :- 3#B $)stra!t !lasses in a!tion M* attitude towards a)stra!t !lass has )een that i 'ut all m* !ommon "un!tionalit* in a)stra!t !lass# (B) What8s a Inter"a!e ? Inter"a!e is a !ontra!t that de"ines the signature o" the "un!tionalit*#So i" a !lass is im'lementing a inter"a!e it sa*s to the outer world , that it 'ro(ides s'e!i"i! )eha(ior # &-am'le i" a !lass is im'lementing Idis'osa)le inter"a!e that means it has a "un!tionalit* to release unmanaged resour!es # %ow e-ternal o)6e!ts using this !lass nows that it has !ontra!t )* whi!h it !an dis'ose unused unmanaged o)6e!ts# 4 Single Class !an im'lement multi'le inter"a!es# 4 I" a !lass im'lements a inter"a!e then it has to 'ro(ide im'lementation to all its methods# >11 %ote:- In C2 sam'le 9WindowsInter,a!e: is 'ro(ided , whi!h has a sim'le inter"a!e im'lemented# In sam'le there are two "iles#<ne has the inter"a!e de"inition and other !lass im'lements the inter"a!e#Below is the sour!e !ode 9IInter"a!e: is the inter"a!e and 9Cls2osomething: im'lements the 9IInter"a!e:#This sam'le 6ust dis'la*s a sim'le message )o-# Eu)li! Inter"a!e IInter,a!e Su) 2oSomething() &nd Inter"a!e Eu)li! Class Cls2oSomething Im'lements IInter,a!e Eu)li! Su) 2oSomething() Im'lements WindowsInter,a!e#IInter,a!e#2oSomething MsgBo-(9Inter"a!e im'lemented:) &nd Su) &nd Class ,igure:- 3#A Inter"a!e in a!tion ; 2o *ou ha(e an* e-'erien!e in !reating Gse !ases , re=uirement do!uments et! ? >1> ($) What is di""eren!e )etween a)stra!t !lasses and inter"a!es? ,ollowing are the di""eren!es )etween a)stra!t and inter"a!es :4 $)stra!t !lasses !an ha(e !on!rete methods while inter"a!es ha(e no methods im'lemented# 4 Inter"a!es do not !ome in inheriting !hain , while a)stra!t !lasses !ome in inheritan!e# (B) What is a delegate ? 2elegate is a !lass that !an hold a re"eren!e to a method or a "un!tion#2elegate !lass has a signature and it !an onl* re"eren!e those methods whose signature is !om'liant with the !lass#2elegates are t*'e-sa"e "un!tions 'ointers or !all)a! s#

Below is a sam'le !ode whi!h shows a e-am'le o" how to im'lement delegates# Eu)li! Class ,rm2elegates Inherits S*stem#Windows#,orms#,orm Eu)li! 2elegate Su) 2elegate$ddString() Eri(ate Su) ,rm2elegatesQLoad(B*.al sender $s S*stem#<)6e!t, B*.al e $s S*stem#&(ent$rgs) ?andles M*Base#Load &nd Su) Eri(ate Su) $ddString() lst2elegates#Items#$dd(9+unning $ddString() method:) &nd Su) Eri(ate Su) !md2elegatesQCli! (B*.al sender $s S*stem#<)6e!t, B*.al e $s S*stem#&(ent$rgs) ?andles !md2elegates#Cli! 2im o)62elegate$ddString $s 2elegate$ddString o)62elegate$ddString V $ddress<" $ddString o)62elegate$ddString#In(o e() &nd Su) &nd Class In the a)o(e there is a method !alled 9$ddString(): whi!h adds a string to a list)o-#Kou !an also see a delegate de!lared as :Eu)li! 2elegate Su) 2elegate$ddString() This delegate signature is !om'ati)le with the 9$ddString: method#When i mean !om'ati)ilit* that means that there return t*'es and 'assing 'arameter t*'es are same#Later >1B in !ommand !li! o" the )utton o)6e!t o" the 2elegate is !reated and the method 'ointer is re!ei(ed "rom 9$ddress<" : e*word#Then )* using the 9In(o e: method the method is in(o ed# ,igure :- 3#0 2elegate in $!tion (B) What are e(ent8s ? $s !om'ares to delegates e(ents wor s with sour!e and listener methodolog* # So listener8s who are interested in re!ei(ing some e(ents the* su)s!ri)e to the sour!e#<n!e this su)s!ri'tion is done the sour!e raises e(ents to all o" it8s listener when needed#<ne sour!e !an ha(e multi'le listeners# In e-am'le sam'le gi(en )elow !lass 9ClsWith&(ents: is a e(ent sour!e !lass , whi!h has a e(ent 9&(ent$ddString():#%ow the listener8s who are interested in re!ei(ing this e(ent8s the* !an su)s!ri)e to this e(ent#In !lass 9,rmWith&(ents: *ou !an see the handles !lause whi!h is asso!iated with the 9mo)6ClsWith&(ents: o)6e!ts# Eu)li! Class ClsWith&(ents &(ent &(ent$ddString(B*.al .alue $s String) Eu)li! Su) $ddString() +aise&(ent &(ent$ddString(9String added )* &(ent:) &nd Su) &nd Class ;?ow well do *ou wor with 'eo'le? 2o *ou 're"er wor ing alone or in teams?

>1A Eu)li! Class ,rmWith&(ents Inherits S*stem#Windows#,orms#,orm Eri(ate With&(ents mo)6ClsWith&(ents $s %ew ClsWith&(ents() Eri(ate Su) ,rmWith&(entsQLoad(B*.al sender $s S*stem#<)6e!t, B*.al e $s S*stem#&(ent$rgs) ?andles M*Base#Load &nd Su) Eri(ate Su) mo)6ClsWith&(entsQ&(ent$ddString(B*.al .alue $s String) ?andles mo)6ClsWith&(ents#&(ent$ddString Lst2ata#Items#$dd(.alue) &nd Su) Eri(ate Su) Cmd+un&(entsQCli! (B*.al sender $s S*stem#<)6e!t, B*.al e $s S*stem#&(ent$rgs) ?andles Cmd+un&(ents#Cli! mo)6ClsWith&(ents#$ddString() &nd Su) &nd Class ,igure :- 3#L &(ents in a!tion ; 2es!ri)e the )est 'ro6e!t manager *ouF(e e(er had ? >10 (I) 2o e(ents ha(e return t*'e ? %o e(ents do not ha(e return t*'e# ($) Can e(ent8s ha(e a!!ess modi"iers ? &(ent8s are alwa*s 'u)li! as the* are meant to ser(e e(er* one registering to it#But *ou !an a!!ess modi"iers in e(ents#Kou !an ha(e e(ents with 'rote!ted e*word whi!h will )e a!!essi)le onl* to inherited !lasses#Kou !an ha(e 'ri(ate e(ents onl* "or o)6e!t in that !lass# ($) Can we ha(e shared e(ents ? Kes *ou !an ha(e shared e(ent8s note onl* shared methods !an raise shared e(ents# (I) What is shadowing ? When two elements in a 'rogram ha(e same name , one o" them !an hide and shadow the other one#So in su!h !ases the element whi!h shadowed the main element is re"eren!ed# Below is a sam'le !ode , there are two !lasses 9ClsEarent: and 9ClsShadowedEarent:#In 9ClsEarent: there is a (aria)le 9-: whi!h is a integer#:ClsShadowedEarent: o(errides 9ClsEarent: and shadows the 9-: (aria)le to a string# %ote:- In Sam'le C2 9WindowsShadowing: is "older whi!h has the sam'le !ode#I" *ou run the 'rogram *ou !an ha(e two out'ut8s one whi!h shows a integer and other whi!h shows a string# Eu)li! Class ClsEarent Eu)li! - $s Integer &nd Class Eu)li! Class ClsShadowedEarent Inherits ClsEarent Eu)li! Shadows - $s String

&nd Class ; Wh* should i hire *ou ? >1L ,igure :- 3#3 Shadowing in $!tion ($) What8s di""eren!e )etween Shadowing and <(erriding ? ,ollowing are the di""eren!es )etween shadowing and o(erriding :4 <(erriding rede"ines onl* the im'lementation while shadowing rede"ines the whole element# 4 In o(erriding deri(ed !lasses !an re"er the 'arent !lass element )* using 9M&: e*word , )ut in shadowing *ou !an a!!ess it )* 9MKB$S&:# (I) What8s di""eren!e )etween delegate and e(ents? 4 $!tuall* e(ents use delegates in )ottom# But the* add an e-tra la*er on the delegates, thus "orming the 'u)lisher and su)s!ri)er model# 4 $s delegates are "un!tion to 'ointers the* !an mo(e a!ross an* !lients# So an* o" the !lients !an add or remo(e e(ents , whi!h !an )e 'rett* !on"using# But e(ents gi(e the e-tra 'rote!tion )* adding the la*er and ma ing it a 'u)lisher and su)s!ri)er model# ;?a(e *ou e(er )een "ired or "or!ed to resign? >13 Just imagine one o" *our !lients doing this !#C*7Call)a! V null This will reset all *our delegates to nothing and *ou ha(e to ee' "iguring where the error is# (B) I" we inherit a !lass do the 'ri(ate (aria)les also get inherited ? Kes the (aria)les are inherited )ut !an not )e a!!essed dire!tl* )* the !lass inter"a!e# (B) What are di""erent a!!essi)ilit* le(els de"ined in #%&T ? ,ollowing are the "i(e le(els o" a!!ess modi"iers :4 Eri(ate : <nl* mem)ers o" !lass ha(e a!!ess# 4 Erote!ted :-$ll mem)ers in !urrent !lass and in deri(ed !lasses !an a!!ess the (aria)les# 4 ,riend (internal in CN) :- <nl* mem)ers in !urrent 'ro6e!t ha(e a!!ess to the elements# 4 Erote!ted "riend ('rote!ted internal in CN) :- $ll mem)ers in !urrent 'ro6e!t and all mem)ers in deri(ed !lass !an a!!ess the (aria)les# 4 Eu)li! :- $ll mem)ers ha(e a!!ess in all !lasses and 'ro6e!ts# (I) Can *ou 're(ent a !lass "rom o(erriding ? I" *ou de"ine a !lass as 9Sealed: in CN and 9%otInherita)le: in .B#%&T *ou !an inherit the !lass an* "urther# (I) What8s the use o" 9MustInherit: e*word in .B#%&T ? I" *ou want to !reate a a)stra!t !lass in .B#%&T it8s done )* using 9MustInherit:

e*word#This a!ts onl* as )ase t*'e and !an not )e inherited an* "urther#Kou !an not !reate a o)6e!t o" a !lass whi!h is mar ed as 9MustInherit:# ;What ha(e *our learnt "rom *our 'ast 'ro6e!t e-'erien!es ? >1M (I) Wh* !an not *ou s'e!i"* a!!essi)ilit* modi"ier in Inter"a!e ? $ll elements in Inter"a!e should )e 'u)li!#So )* de"ault all inter"a!e elements are 'u)li! )* de"ault# ($) What are similarities )etween Class and stru!ture ? ,ollowing are the similarities )etween !lasses and stru!tures :4 Both !an ha(e !onstru!tors, methods, 'ro'erties, "ields, !onstants, enumerations, e(ents, and e(ent handlers# 4 Stru!tures and !lasses !an im'lement inter"a!e# 4 Both o" them !an ha(e !onstru!tors without 'arameter and with 'arameter# 4 Both !an ha(e delegates and e(ents# ($) What8s the di""eren!e )etween Class and stru!ture8s ? ,ollowing are the e* di""eren!es )etween them :4 Stru!ture are (alue t*'es and !lasses are re"eren!e t*'es#So stru!tures use sta! and !lasses use hea'# 4 Stru!tures mem)ers !an not )e de!lared as 'rote!ted , )ut !lass mem)ers !an )e#Kou !an not do inheritan!e in stru!tures# 4 Stru!tures do not re=uire !onstru!tors while !lasses re=uire# 4 <)6e!ts !reated "rom !lasses are terminated using 5ar)age !olle!tor#Stru!tures are not destro*ed using 5C# (B) What does (irtual e*word mean ? That method and 'ro'ert* !an )e o(erridden# (B) What are shared (.B#%&T)OStati!(CN) (aria)les? ;WhatFs the logi! o" lin list ? >1@ Stati!OShared !lasses are used when a !lass 'ro(ides "un!tionalit* whi!h is not s'e!i"i! to an* instan!e#In short i" *ou want a o)6e!t to )e shared )etween multi'le instan!es *ou will use a stati!OShared !lass# ,ollowing are "eatures o" Stati!OShared !lasses :4 The* !an not )e instantiated#B* de"ault a o)6e!t is !reated on the "irst method !all to that o)6e!t# 4 Stati!OShared !lasses !an not )e inherited# 4 Stati!OShared !lasses !an ha(e onl* stati! mem)ers# 4 Stati!OShared !lasses !an ha(e onl* stati! !onstru!tor# %ote :- In C2 there is a "older 9WindowsShared: whi!h has a sam'le !ode "or shared (aria)les#Below is a sni''et#It has a 9$ddCount: "un!tion whi!h in!rements a stati! 9intCount: (aria)le#In "orm there are two )uttons whi!h !reates a new o)6e!t and dis'la*s the !ount o" the stati! (aria)le#&(en though the o)6e!t is !reated and destro*ed , the (aria)le

(alues does not !hange#It retains its old (alue# Eu)li! Class ClsShared Shared intCount $s Integer Eu)li! ,un!tion $ddCount() $s Integer intCount V intCount / > +eturn intCount &nd ,un!tion &nd Class Eu)li! Class ,rmSharedClasses Inherits S*stem#Windows#,orms#,orm Eri(ate Su) CmdInstan!e>QCli! (B*.al sender $s S*stem#<)6e!t, B*.al e $s S*stem#&(ent$rgs) ?andles CmdInstan!e>#Cli! 2im 'o)6ClsShared $s %ew ClsShared() MessageBo-#Show(9The !ount at this moment is: ^ 'o)6ClsShared#$ddCount#ToString()) &nd Su) Eri(ate Su) CmdInstan!eBQCli! (B*.al sender $s S*stem#<)6e!t, B*.al e $s S*stem#&(ent$rgs) ?andles CmdInstan!eB#Cli! 2im 'o)6ClsShared $s %ew ClsShared() MessageBo-#Show(9The !ount at this moment is: ^ 'o)6ClsShared#$ddCount#ToString()) ; Can *ou e-'lain logi! o" )inar* sort ? >1D &nd Su) &nd Class ,igure :- 3#M SharedOStati! In $!tion (B) What is 2is'ose method in #%&T ? #%&T 'ro(ides 9,inali7e: method in whi!h we !an !lean u' our resour!es#But rel*ing on this is not alwa*s good so the )est is to im'lement 9Idis'osa)le: inter"a!e and im'lement the 92is'ose: method where *ou !an 'ut *our !lean u' routines# (B) Whats the use o" 9<(er+ides: and 9<(errida)le: e*words ? <(errida)le is used in 'arent !lass to indi!ate that a method !an )e o(erridden#<(errides is used in the !hild !lass to indi!ate that *ou are o(erriding a method ($) Where are all #%&T Colle!tion !lasses lo!ated ? ;Whats di""eren!e )etween 'ro!edural and o)6e!t oriented 'rogramming ? >>1 S*stem#Colle!tion names'a!e has all the !olle!tion !lasses a(aila)le in #%&T# ($) What is $rra*List ? $rra* whose si7e !an in!rease and de!rease d*nami!all*#$rra*list !an hold item o" di""erent t*'es#$s $rra*list !an in!rease and de!rease si7e d*nami!all* *ou do not ha(e to use the +&2IM e*word#Kou !an a!!ess an* item in arra* using the I%2&C (alue o" the arra* 'osition#

($) What8s a ?ashTa)le ? Twist :- What8s di""eren!e )etween ?ashTa)le and $rra*List ? Kou !an a!!ess arra* using I%2&C (alue o" arra* , )ut how man* times *ou now the real (alue o" inde-#?ashta)le 'ro(ides wa* o" a!!essing the inde- using a user identi"ied J&K (alue , thus remo(ing the I%2&C 'ro)lem# ($) What are =ueues and sta! s ? \ueue is "or "irst-in, "irst-out (,I,<) stru!tures# Sta! is "or last-in, "irst-out (LI,<) stru!tures# (B) What is &%GM ? It8s used to de"ine !onstants# ($) What is nested Classes ? %ested !lasses are !lasses with in !lasses#In sam'le )elow 9Cls%ested: !lass has a 9Child%ested: !lass nested inside it# Eu)li! Class Cls%ested Eu)li! Class Child%ested Eu)li! Su) ShowMessage() MessageBo-#Show(9?i this is nested !lass:) &nd Su) &nd Class &nd Class This is the wa* we !an instantiate the nested !lass and ma e the method !all# 2im 'o)6Child%ested $s %ew Cls%ested#Child%ested() 'o)6Child%ested#ShowMessage() >>> %ote:-In C2 the a)o(e sam'le is 'ro(ided in 9Windows%estedClasses:# (B)What8s <'erator <(erloading in #%&T? It 'ro(ides a wa* to de"ine and use o'erators su!h as /, -, and O "or user-de"ined !lasses or stru!ts# It allows us to de"ineOrede"ine the wa* o'erators wor with our !lasses and stru!ts# This allows 'rogrammers to ma e their !ustom t*'es loo and "eel li e sim'le t*'es su!h as int and string# .B#%&T till now does not su''ort o'erator o(erloading# <'erator o(erloading is done )* using the 9<'erator: e*word# %ote:- <'erator o(erloading is su''orted in .B#%&T B11L (I) In )elow sam'le !ode i" we !reate a o)6e!t o" !lassB whi!h !onstru!tor will "ire "irst ? Eu)li! Class Class> Su) %ew() &nd Su) &nd Class Eu)li! Class !lassB Inherits Class> Su) %ew() &nd Su)

&nd Class ; I lea(e this to the readers###### (B)What8s the signi"i!an!e o" ,inali7e method in #%&T? #%&T 5ar)age !olle!tor does almost all !lean u' a!ti(it* "or *our o)6e!ts# But unmanaged resour!es (e-: - Windows $EI !reated o)6e!ts, ,ile, 2ata)ase !onne!tion o)6e!ts, C<M o)6e!ts et!) is outside the s!o'e o" #%&T "ramewor we ha(e to e-'li!itl* !lean our resour!es# ,or these t*'es o" o)6e!ts #%&T "ramewor 'ro(ides <)6e!t#,inali7e method >>B whi!h !an )e o(erridden and !lean u' !ode "or unmanaged resour!es !an )e 'ut in this se!tion# ($)Wh* is it 're"erred to not use "inali7e "or !lean u'? Ero)lem with "inali7e is that gar)age !olle!tion has to ma e two rounds in order to remo(e o)6e!ts whi!h ha(e "inali7e methods# Below "igure will ma e things !lear regarding the two rounds o" gar)age !olle!tion rounds 'er"ormed "or the o)6e!ts ha(ing "inali7ed methods# In this s!enario there are three o)6e!ts <)6e!t>, <)6e!tB and <)6e!tA# <)6e!tB has the "inali7e method o(erridden and remaining o)6e!ts do not ha(e the "inali7e method o(erridden# %ow when gar)age !olle!tor runs "or the "irst time it sear!hes "or o)6e!ts whose memor* has to "reed# ?e sees three o)6e!ts )ut onl* !leans the memor* "or <)6e!t> and <)6e!tA# <)6e!tB it 'ushes to the "inali7ation =ueue# %ow gar)age !olle!tor runs "or the se!ond time# ?e see8s there are no o)6e!ts to )e "reed and then !he! s "or the "inali7ation =ueue and at this moment it !lears o)6e!tB "rom the memor*# So i" *ou noti!e that o)6e!tB was "reed "rom memor* in the se!ond round and not "irst# That8s wh* the )est 'ra!ti!e is not to write !lean u' %on#%&T resour!es in ,inali7e method rather use the 2ISE<S&# ; Where *ou a 'art o" some unsu!!ess"ul 'ro6e!ts , then wh* was the 'ro6e!t unsu!ess"ul ? >>A ,igure :- 3#@ 5ar)age !olle!tion in a!tions (I)?ow !an we su''ress a "inali7e method? 5C#Su''ress,inali7e () (B)What8s the use o" 2ISE<S& method? 2is'ose method )elongs to I2is'osa)le inter"a!e# We had seen in the 're(ious se!tion how )ad it !an )e to o(erride the "inali7e method "or writing the !leaning o" unmanaged resour!es# So i" an* o)6e!t wants to release its unmanaged !ode )est is to im'lement >>0 I2is'osa)le and o(erride the 2is'ose method o" I2is'osa)le inter"a!e# %ow on!e *our !lass has e-'osed the 2is'ose method it8s the res'onsi)ilit* o" the !lient to !all the 2is'ose method to do the !leanu'# ($)?ow do I "or!e the 2is'ose method to )e !alled automati!all*, as !lients !an "orget to !all 2is'ose method?

%ote :- I admire this =uestion# Call the 2is'ose method in ,inali7e method and in 2is'ose method su''ress the "inali7e method using 5C#Su''ress,inali7e# Below is the sam'le !ode o" the 'attern# This is the )est wa* we do !lean our unallo!ated resour!es and *es not to "orget we do not get the hit o" running the 5ar)age !olle!tor twi!e# %ote:- It will su''ress the "inali7e method thus a(oiding the two tri'# Eu)li! Class ClsTesting Im'lements I2is'osa)le Eu)li! <(erloads Su) 2is'ose()Im'lements I2is'osa)le#2is'ose F write *tour !lean u' !ode here 5C#Su''ress,inali7e(Me) &nd Su) Erote!ted <(errides Su) ,inali7e() 2is'ose() &nd Su) &nd Class (I)In what instan!es *ou will de!lare a !onstru!tor to )e 'ri(ate? When we !reate a 'ri(ate !onstru!tor, we !an not !reate o)6e!t o" the !lass dire!tl* "rom a !lient# So *ou will use 'ri(ate !onstru!tors when *ou do not want instan!es o" the !lass to )e !reated )* an* e-ternal !lient# &-am'le GTILITK "un!tions in 'ro6e!t will ha(e no >>L instan!e and )e used with out !reating instan!e, as !reating instan!es o" the !lass would )e waste o" memor*# (I)Can we ha(e di""erent a!!ess modi"iers on getOset methods o" a 'ro'ert* ? %o we !an not ha(e di""erent modi"iers same 'ro'ert*# The a!!ess modi"ier on a 'ro'ert* a''lies to )oth its get and set a!!essors# (I)I" we write a goto or a return statement in tr* and !at!h )lo! will the "inall* )lo! e-e!ute ? The !ode in the "inall* alwa*s runs e(en i" there are statements li e goto or a return statements# ($)What is Inde-er ? $n inde-er is a mem)er that ena)les an o)6e!t to )e inde-ed in the same wa* as an arra*# ($)Can we ha(e stati! inde-er in CN ? %o# ($)In a 'rogram there are multi'le !at!h )lo! s so !an it ha''en that two !at!h )lo! s are e-e!uted ? %o on!e the 'ro'er !at!h se!tion is e-e!uted the !ontrol goes to "inall* )lo! #So there will not )e an* s!enarios in whi!h multi'le !at!h )lo! s will )e e-e!uted# ($) What is the di""eren!e )etween S*stem#String and S*stem#StringBuilder !lasses?

S*stem#String is immuta)leW S*stem#StringBuilder !an ha(e muta)le string where a (ariet* o" o'erations !an )e 'er"ormed#

$SE#%&T
(B) What8s the se=uen!e in whi!h $SE#%&T e(ents are 'ro!essed ? ,ollowing are the se=uen!e in whi!h the e(ents o!!ur :4 EageQInit# 4 EageQLoad# 4 Control e(ents 4 EageQGnload e(ent# EageQinit e(ent onl* o!!urs when "irst time the 'age is started , )ut EageQLoad o!!urs in su)se=uent re=uest o" the 'age# (B) In whi!h e(ent are the !ontrols "ull* loaded ? EageQload e(ent guarantees that all !ontrols are "ull* loaded#Controls are also a!!essed in EageQInit e(ents )ut *ou will see that (iewstate is not "ull* loaded during this e(ent# (B) ?ow !an we identi"* that the Eage is EostBa! ? Eage o)6e!t has a 9IsEostBa! : 'ro'ert* whi!h !an )e !he! ed to now that is the 'age 'osted )a! # (B) ?ow does $SE#%&T maintain state in )etween su)se=uent re=uest ? +e"er !a!hing !ha'ter# ($) What is e(ent )u))ling ? Ser(er !ontrols li e 2atagrid , 2ataList , +e'eater !an ha(e other !hild !ontrols inside them#&-am'le 2ata5rid !an ha(e !om)o )o- inside datagrid#These !hild !ontrol do not raise there e(ents )* themsel(es , rather the* 'ass the e(ent to the !ontainer 'arent (whi!h !an )e a datagrid , datalist , re'eater) , whi!h 'assed to the 'age as 9ItemCommand: e(ent# >>M (B) ?ow do we assign 'age s'e!i"i! attri)utes ? Eage attri)utes are s'e!i"ied using the `Eage dire!ti(e# ($) $dministrator wants to ma e a se!urit* !he! that no one has tam'ered with .iewState , how !an we ensure this ? Gsing the `Eage dire!ti(e &na)le.iewStateMa! to True# (B) What8s the use o" ` +egister dire!ti(es ? `+egister dire!ti(e in"orms the !om'iler o" an* !ustom ser(er !ontrol added to the 'age# (B) What8s the use o" Smart%a(igation 'ro'ert* ? It8s a "eature 'ro(ided )* $SE#%&T to 're(ent "li! ering and redrawing when the 'age is 'osted )a! # %ote:- This is onl* su''orted "or I& )rowser#Ero6e!t8s who ha(e )rowser !om'ati)ilit* as

re=uirement ha(e to thin some other wa*s o" a(oiding "li! ering# (B) What is $''Setting Se!tion in 9We)#Con"ig: "ile ? We)#!on"ig "ile de"ines !on"iguration "or a we)'ro6e!t#Gsing 9$''Setting: se!tion we !an de"ine user de"ined (alues#&-am'le )elow de"ined is 9Conne!tionString: se!tion whi!h will )e used through out the 'ro6e!t "or data)ase !onne!tion# T!on"igurationU Ta''SettingsU Tadd e*VHConne!tionStringH (alueVHser(erV-*7W'wdVwwwWdata)aseVtestingH OU TOa''SettingsU (B) Where is .iewState in"ormation stored ? In ?TML ?idden ,ields# >>@ (I) What8s the use o" ` <ut'utCa!he dire!ti(e in $SE#%&T? It8s )asi!all* used "or !a!hing#See more "or Ca!hing !ha'ter# (B) ?ow !an we !reate !ustom !ontrols in $SE#%&T ? Gser !ontrols are !reated using #$SCC in $SE#%&T#$"ter #$SCC "ile is !reated *ou need to two things in order that the $SCC !an )e used in 'ro6e!t:# 4 +egister the $SCC !ontrol in 'age using the T_` +egister dire!ti(e#&-am'le T_` +egister tag're"i-VH$!!ountingH TagnameVH"ooterH Sr!VH,ooter#as!-H _U 4 %ow to use the a)o(e a!!ounting "ooter in 'age *ou !an use the )elow dire!ti(e# T$!!ounting:"ooter runatVHser(erH OU (B) ?ow man* t*'es o" (alidation !ontrols are 'ro(ided )* $SE#%&T ? There are main si- t*'es o" (alidation !ontrols :+e=uired,ield.alidator It !he! s does the !ontrol ha(e an* (alue#ItFs used when *ou want the !ontrol should not )e em't*# +ange.alidator Che! s i" the (alue in (alidated !ontrol is in that s'e!i"i! range#&-am'le T-tCustomerCode should not )e more than eight length# Com'are.alidator Che! s that the (alue in !ontrols should mat!h the (alue in other !ontrol#&-am'le Te-t)oT-tEie should )e e=ual to A#>0# +egular&-'ression.alidator When we want the !ontrol (alue should mat!h with a s'e!i"i! regular e-'ression# >>D Custom.alidator Gsed to de"ine Gser2e"ined (alidation# .alidationSummar* 2is'la*s summar* o" all !urrent (alidation errors# %ote:- ItFs rare that some one will as ste' )* ste' all the (alidation !ontrols#&-am'le in one o" the inter(iews i was as ed how do *ou dis'la* summar* o" all errors in the (alidation !ontrol###So there goes the last one#

(B) Can *ou e-'lain what is 9$utoEostBa! : "eature in $SE#%&T ? I" we want the !ontrol to automati!all* 'ost)a! in !ase o" an* e(ent , we will need to !he! this attri)ute as true#&-am'le on a Com)oBo- !hange we need to send the e(ent immediatel* to the ser(er side then set the 9$utoEostBa! : attri)ute to true# (B) ?ow !an *ou ena)le automati! 'aging in 2ata5rid ? ,ollowing are the 'oints to )e done in order to ena)le 'aging in 2atagrid :4 Set the 9$llowEaging: to true# 4 In EageInde-Changed e(ent set the !urrent 'ageinde- !li! ed# %ote:- The answers are (er* short , i" *ou ha(e im'lemented 'ra!ti!all* its 6ust a re(ision#I" *ou are "resher 6ust ma e sam'le !ode using 2atagrid and tr* to im'lement this "un!tionalit*# (B) What8s the use o" 95L<B$L#$S$C: "ile ? It allows to e-e!ute $SE#%&T a''li!ation le(el e(ents and set a''li!ation-le(el (aria)les# (B) What8s the di""eren!e )etween 9We)#!on"ig: and 9Ma!hine#Con"ig: ? 9We)#!on"ig: "iles a''l* settings to ea!h we) a''li!ation , while 9Ma!hine#!on"ig: "ile a''l* settings to all $SE#%&T a''li!ations# >B1 (B) What8s a S&SSI<% and $EELIC$TI<% o)6e!t ? ($) What8s di""eren!e )etween Ser(er#Trans"er and res'onse#+edire!t ? ,ollowing are the ma6or di""eren!es )etween them:4 +es'onse#+edire!t sends message to the )rowser sa*ing it to mo(e to some di""erent 'age#While ser(er#trans"er does not send an* message to the )rowser )ut rather redire!ts the user dire!tl* "rom the ser(er itsel"# So in ser(er#trans"er there is no round tri' while res'onse#redire!t has a round tri' and hen!e 'uts a load on ser(er# 4 Gsing Ser(er#Trans"er *ou !an not redire!t to a di""erent "rom the ser(er itsel"# &-am'le I" *our ser(er is www#*ahoo#!om *ou !an use ser(er#trans"er to mo(e to www#mi!roso"t#!om )ut *es *ou !an mo(e to www#*ahoo#!omOtra(els , i#e# within we)sites# This !ross ser(er redire!t is 'ossi)le onl* using +es'onse#redire!t# 4 With ser(er#trans"er *ou !an 'reser(e *our in"ormation# It has a 'arameter !alled as 9'reser(e,orm:# So the e-isting =uer* string et!# will )e a)le in the !alling 'age# In res'onse#redire!t *ou !an maintain the state# Kou !an )ut has lot o" draw)a! s# I" *ou are na(igating with in the same we)site use 9Ser(er#trans"er: or else go "or 9res'onse#redire!t(): ($)What8s di""eren!e )etween $uthenti!ation and authori7ation? This !an )e a tri! * =uestion# These two !on!e'ts seem altogether similar )ut there is wide range o" di""eren!e# $uthenti!ation is (eri"*ing the identit* o" a user and authori7ation

is 'ro!ess where we !he! does this identit* ha(e a!!ess rights to the s*stem# In short we !an sa* the "ollowing authenti!ation is the 'ro!ess o" o)taining some sort o" !redentials "rom the users and using those !redentials to (eri"* the user8s identit*# $uthori7ation is the 'ro!ess o" allowing an authenti!ated user a!!ess to resour!es# $uthenti!ation is alwa*s 're!edes to $uthori7ationW e(en i" *our a''li!ation lets anon*mous users !onne!t and use the a''li!ation, it still authenti!ates them as )eing anon*mous# >B> (I) What is im'ersonation in $SE#%&T ? B* de"ault, $SE#%&T e-e!utes in the se!urit* !onte-t o" a restri!ted user a!!ount on the lo!al ma!hine# Sometimes *ou need to a!!ess networ resour!es su!h as a "ile on a shared dri(e, whi!h re=uires additional 'ermissions# <ne wa* to o(er!ome this restri!tion is to use im'ersonation# With im'ersonation, $SE#%&T !an e-e!ute the re=uest using the identit* o" the !lient who is ma ing the re=uest, or $SE#%&T !an im'ersonate a s'e!i"i! a!!ount *ou s'e!i"* in we)#!on"ig# (B) Can *ou e-'lain in )rie" how the $SE#%&T authenti!ation 'ro!ess wor s? $SE#%&T does not run )* itsel" it run inside the 'ro!ess o" IIS# So there are two authenti!ation la*ers whi!h e-ist in $SE#%&T s*stem# ,irst authenti!ation ha''ens at the IIS le(el and then at the $SE#%&T le(el de'ending on the W&B#C<%,I5 "ile# Below is how the whole 'ro!ess wor s:4 IIS "irst !he! s to ma e sure the in!oming re=uest !omes "rom an IE address that is allowed a!!ess to the domain# I" not it denies the re=uest# 4 %e-t IIS 'er"orms its own user authenti!ation i" it !on"igured to do so# B* de"ault IIS allows anon*mous a!!ess, so re=uests are automati!all* authenti!ated, )ut *ou !an !hange this de"ault on a 'er P a''li!ation )asis with in IIS# 4 I" the re=uest is 'assed to $SE#net with an authenti!ated user, $SE#net !he! s to see whether im'ersonation is ena)led# I" im'ersonation is ena)led, $SE#net a!ts as though it were the authenti!ated user# I" not $SE#net a!ts with its own !on"igured a!!ount# 4 ,inall* the identit* "rom ste' A is used to re=uest resour!es "rom the o'erating s*stem# I" $SE#net authenti!ation !an o)tain all the ne!essar* resour!es it grants the users re=uest otherwise it is denied# +esour!es !an in!lude mu!h more than 6ust the $SE#net 'age itsel" *ou !an also use #%et8s !ode a!!ess se!urit* "eatures to e-tend this authori7ation ste' to dis "iles, +egistr* e*s and other resour!es# >BB ($) What are the (arious wa*s o" authenti!ation te!hni=ues in $SE#%&T? Sele!ting an authenti!ation 'ro(ider is as sim'le as ma ing an entr* in the we)#!on"ig "ile "or the a''li!ation# Kou !an use one o" these entries to sele!t the !orres'onding )uilt in authenti!ation 'ro(ider: 4 Tauthenti!ation modeV:windows:U

4 Tauthenti!ation modeV:'ass'ort:U 4 Tauthenti!ation modeV:"orms:U 4 Custom authenti!ation where *ou might install an IS$EI "ilter in IIS that !om'ares in!oming re=uests to list o" sour!e IE addresses, and !onsiders re=uests to )e authenti!ated i" the* !ome "rom an a!!e'ta)le address# In that !ase, *ou would set the authenti!ation mode to none to 're(ent an* o" the #net authenti!ation 'ro(iders "rom )eing triggered# Windows authenti!ation and IIS I" *ou sele!t windows authenti!ation "or *our $SE#%&T a''li!ation, *ou also ha(e to !on"igure authenti!ation within IIS# This is )e!ause IIS 'ro(ides Windows authenti!ation# IIS gi(es *ou a !hoi!e "or "our di""erent authenti!ation methods: $non*mous, )asi! digest and windows integrated I" *ou sele!t anon*mous authenti!ation, IIS doesn8t 'er"orm an* authenti!ation, $n* one is allowed to a!!ess the $SE#%&T a''li!ation# I" *ou sele!t )asi! authenti!ation, users must 'ro(ide a windows username and 'assword to !onne!t# ?ow e(er this in"ormation is sent o(er the networ in !lear te-t, whi!h ma es )asi! authenti!ation (er* mu!h inse!ure o(er the internet# I" *ou sele!t digest authenti!ation, users must still 'ro(ide a windows user name and 'assword to !onne!t# ?owe(er the 'assword is hashed )e"ore it is sent a!ross the networ # 2igest authenti!ation re=uires that all users )e running Internet &-'lorer L or later and that windows a!!ounts to stored in a!ti(e dire!tor*# I" *ou sele!t windows integrated authenti!ation, 'asswords ne(er !ross the networ # Gsers must still ha(e a username and 'assword, )ut the a''li!ation uses either the Jer)eros >BA or !hallengeOres'onse 'roto!ols authenti!ate the user# Windows-integrated authenti!ation re=uires that all users )e running internet e-'lorer A#1> or later Jer)eros is a networ authenti!ation 'roto!ol# It is designed to 'ro(ide strong authenti!ation "or !lientOser(er a''li!ations )* using se!ret- e* !r*'togra'h*# Jer)eros is a solution to networ se!urit* 'ro)lems# It 'ro(ides the tools o" authenti!ation and strong !r*'togra'h* o(er the networ to hel' to se!ure in"ormation in s*stems a!ross entire enter'rise Eass'ort authenti!ation Eass'ort authenti!ation lets *ou to use Mi!roso"t8s 'ass'ort ser(i!e to authenti!ate users o" *our a''li!ation# I" *our users ha(e signed u' with 'ass'ort, and *ou !on"igure the authenti!ation mode o" the a''li!ation to the 'ass'ort authenti!ation, all authenti!ation duties are o""-loaded to the 'ass'ort ser(ers# Eass'ort uses an en!r*'ted !oo ie me!hanism to indi!ate authenti!ated users# I" users ha(e alread* signed into 'ass'ort when the* (isit *our site, the*8ll )e !onsidered authenti!ated )* $SE#%&T# <therwise the*8ll )e redire!ted to the 'ass'ort ser(ers to log in# When the* are su!!ess"ull* log in, the*8ll )e redire!ted )a! to *our site To use 'ass'ort authenti!ation *ou ha(e to download the Eass'ort So"tware 2e(elo'ment Jit (S2J) and install it on *our ser(er# The S2J !an )e "ound at htt':OO msdn#mi!roso"t#!omOli)rar*Ode"ault#as'?urlVOdownloadsOlistOwe)sr('ass#a's#It in!ludes "ull details o" im'lementing 'ass'ort authenti!ation in *our own a''li!ations#

,orms authenti!ation ,orms authenti!ation 'ro(ides *ou with a wa* to handle authenti!ation using *our own !ustom logi! with in an $SE#%&T a''li!ation# The "ollowing a''lies i" *ou !hoose "orms authenti!ation# 4 When a user re=uests a 'age "or the a''li!ation, $SE#%&T !he! s "or the 'resen!e o" a s'e!ial session !oo ie# I" the !oo ie is 'resent, $SE#%&T assumes the user is authenti!ated and 'ro!esses the re=uest# 4 I" the !oo ie isn8t 'resent, $SE#%&T redire!ts the user to a we) "orm *ou 'ro(ide >B0 Kou !an !arr* out whate(er authenti!ation, !he! s *ou li e in *our "orm# When the user is authenti!ated, *ou indi!ate this to $SE#%&T )* setting a 'ro'ert*, whi!h !reates the s'e!ial !oo ie to handle su)se=uent re=uests# ($)?ow does authori7ation wor in $SE#%&T? $SE#%&T im'ersonation is !ontrolled )* entries in the a''li!ations we)#!on"ig "ile# The de"ault setting is 9no im'ersonation:# Kou !an e-'li!itl* s'e!i"* that $SE#%&T shouldn8t use im'ersonation )* in!luding the "ollowing !ode in the "ile Tidentit* im'ersonateV:"alse:OU It means that $SE#%&T will not 'er"orm an* authenti!ation and runs with its own 'ri(ileges# B* de"ault $SE#%&T runs as an un'ri(ileged a!!ount named $SE%&T# Kou !an !hange this )* ma ing a setting in the 'ro!essModel se!tion o" the ma!hine#!on"ig "ile# When *ou ma e this setting, it automati!all* a''lies to e(er* site on the ser(er# To user a high-'ri(ileged s*stem a!!ount instead o" a low-'ri(ileged, set the user%ame attri)ute o" the 'ro!essModel element to SKST&M# Gsing this setting is a de"inite se!urit* ris , as it ele(ates the 'ri(ileges o" the $SE#%&T 'ro!ess to a 'oint where it !an do )ad things to the o'erating s*stem# When *ou disa)le im'ersonation, all the re=uest will run in the !onte-t o" the a!!ount running $SE#%&T: either the $SE%&T a!!ount or the s*stem a!!ount# This is true when *ou are using anon*mous a!!ess or authenti!ating users in some "ashion# $"ter the user has )een authenti!ated, $SE#%&T uses it own identit* to re=uest a!!ess to resour!es# The se!ond 'ossi)le setting is to turn on im'ersonation# Tidentit* im'ersonate V:true:OU In this !ase, $SE#%&T ta es on the identit* IIS 'asses to it# I" *ou are allowing anon*mous a!!ess in IIS, this means $SE#%&T will im'ersonate the IGS+QCom'uter%ame a!!ount that IIS itsel" uses# I" *ou aren8t allowing anon*mous a!!ess,$SE#%&T will ta e on the !redentials o" the authenti!ated user and ma e re=uests "or resour!es as i" it were that user# Thus )* turning im'ersonation on and using a non-anon*mous method o" authenti!ation in IIS, *ou !an let users log on and use their identities within *our $SE#%&T a''li!ation# ,inall*, *ou !an s'e!i"* a 'arti!ular identit* to use "or all authenti!ated re=uests Tidentit* im'ersonateV:true: usernameV:2<M$I%Iusername: 'asswordV:'assword:O U >BL

With this setting, all the re=uests are made as the s'e!i"ied user ($ssuming the 'assword it !orre!t in the !on"iguration "ile)# So, "or e-am'le *ou !ould designate a user "or a single a''li!ation, and use that user8s identit* e(er* time someone authenti!ates to the a''li!ation# The draw)a! to this te!hni=ue is that *ou must em)ed the user8s 'assword in the we)#!on"ig "ile in 'lain te-t# $lthough $SE#%&T won8t allow an*one to download this "ile, this is still a se!urit* ris i" an*one !an get the "ile )* other means# (B)What8s di""eren!e )etween 2atagrid , 2atalist and re'eater ? $ 2atagrid, 2atalist and +e'eater are all $SE#%&T data We) !ontrols# The* ha(e man* things in !ommon li e 2ataSour!e Ero'ert* , 2ataBind Method Item2ataBound and ItemCreated# When *ou assign the 2ataSour!e Ero'ert* o" a 2atagrid to a 2ataSet then ea!h 2ata+ow 'resent in the 2ata+ow Colle!tion o" 2ataTa)le is assigned to a !orres'onding 2ata5ridItem and this is same "or the rest o" the two !ontrols also#But The ?TML !ode generated "or a 2atagrid has an ?TML T$BL& T+<WU element !reated "or the 'arti!ular 2ata+ow and its a Ta)le "orm re'resentation with Columns and +ows# ,or a 2atalist its an $rra* o" +ows and )ased on the Tem'late Sele!ted and the +e'eatColumn Ero'ert* (alue We !an s'e!i"* how man* 2ataSour!e re!ords should a''ear 'er ?TML Tta)leU row# In short in datagrid we ha(e one re!ord 'er row, )ut in datalist we !an ha(e "i(e or si- rows 'er row# ,or a +e'eater Control,The 2atare!ords to )e dis'la*ed de'ends u'on the Tem'lates s'e!i"ied and the onl* ?TML generated is the due to the Tem'lates# In addition to these , 2atagrid has a in-)uilt su''ort "or Sort,,ilter and 'aging the 2ata ,whi!h is not 'ossi)le when using a 2ataList and "or a +e'eater Control we would re=uire to write an e-'li!it !ode to do 'aging# ($),rom 'er"orman!e 'oint o" (iew how do the* rate ? +e'eater is "astest "ollowed )* 2atalist and "inall* datagrid# >B3 (B)What8s the method to !ustomi7e !olumns in 2ata5rid? Gse the tem'late !olumn# (B)?ow !an we "ormat data inside 2ata5rid? Gse the 2ata,ormatString 'ro'ert*# ($) ?ow will de!ide the design !onsideration to ta e a 2atagrid , datalist or re'eater ? Man* ma e a )lind !hoi!e o" !hoosing datagrid dire!tl* , )ut thatFs not the right wa*# 2atagrid 'ro(ides a)ilit* to allow the end-user to sort, 'age, and edit its data#But it !omes at a !ost o" s'eed#Se!ond the dis'la* "ormat is sim'le that is in row and !olumns# +eal li"e s!enarios !an )e more demanding that With its tem'lates, the 2ataList 'ro(ides more !ontrol o(er the loo and "eel o" the dis'la*ed data than the 2ata5rid#It o""ers )etter 'er"orman!e than datagrid +e'eater !ontrol allows "or !om'lete and total !ontrol# With the +e'eater, the onl* ?TML emitted are the (alues o" the data)inding statements in the tem'lates along with the ?TML mar u' s'e!i"ied in the tem'latesbno He-traH ?TML is emitted, as with the

2ata5rid and 2ataList# B* re=uiring the de(elo'er to s'e!i"* the !om'lete generated ?TML mar u', the +e'eater o"ten re=uires the longest de(elo'ment time#But re'eater does not 'ro(ide editing "eatures li e datagrid so e(er*thing has to )e !oded )* 'rogrammer # ?owe(er, the +e'eater does )oast the )est 'er"orman!e o" the three data We) !ontrols# +e'eater is "astest "ollowed )* 2atalist and "inall* datagrid# (B) 2i""eren!e )etween $SE and $SE#%&T? $SE#%&T new "eature su''orts are as "ollows :Better Language Su''ort 4 %ew $2<#%&T Con!e'ts ha(e )een im'lemented# 4 $SE#%&T su''orts "ull language (CN , .B#%&T,C//) and not sim'le s!ri'ting li e .BSC+IET## >BM Better !ontrols than $SE 4 $SE#%&T !o(ers large set8s o" ?TML !ontrols## 4 Better 2is'la* grid li e 2atagrid , +e'eater and datalist#Man* o" the dis'la* grid ha(e 'aging su''ort# Controls ha(e e(ent su''orts 4 $ll $SE#%&T !ontrols su''ort e(ents# 4 Load, Cli! and Change e(ents handled )* !ode ma es !oding mu!h sim'ler and mu!h )etter organi7ed# Com'iled Code The "irst re=uest "or an $SE#%&T 'age on the ser(er will !om'ile the $SE#%&T !ode and ee' a !a!hed !o'* in memor*# The result o" this is greatl* in!reased 'er"orman!e# Better $uthenti!ation Su''ort $SE#%&T su''orts "orms-)ased user authenti!ation, in!luding !oo ie management and automati! redire!ting o" unauthori7ed logins# (Kou !an still do *our !ustom login 'age and !ustom user !he! ing)# Gser $!!ounts and +oles $SE#%&T allows "or user a!!ounts and roles, to gi(e ea!h user (with a gi(en role) a!!ess to di""erent ser(er !ode and e-e!uta)les# ?igh S!ala)ilit* 4 Mu!h has )een done with $SE#%&T to 'ro(ide greater s!ala)ilit*# 4 Ser(er to ser(er !ommuni!ation has )een greatl* enhan!ed, ma ing it 'ossi)le to s!ale an a''li!ation o(er se(eral ser(ers# <ne e-am'le o" this is the a)ilit* to run CML 'arsers, CSL trans"ormations and e(en resour!e hungr* session o)6e!ts on other ser(ers# &as* Con"iguration 4 Con"iguration o" $SE#%&T is done with 'lain te-t "iles# 4 Con"iguration "iles !an )e u'loaded or !hanged while the a''li!ation is running# %o need to restart the ser(er# %o more meta)ase or registr* 'u77le# >B@ &as* 2e'lo*ment %o more ser(er restart to de'lo* or re'la!e !om'iled !ode# $SE#%&T sim'l* redire!ts all

new re=uests to the new !ode# ($) What are ma6or e(ents in 5L<B$L#$S$C "ile ? The 5lo)al#asa- "ile, whi!h is deri(ed "rom the ?tt'$''li!ation !lass, maintains a 'ool o" ?tt'$''li!ation o)6e!ts, and assigns them to a''li!ations as needed# The 5lo)al#asa"ile !ontains the "ollowing e(ents: $''li!ationQInit: ,ired when an a''li!ation initiali7es or is "irst !alled# ItFs in(o ed "or all ?tt'$''li!ation o)6e!t instan!es# $''li!ationQ2is'osed: ,ired 6ust )e"ore an a''li!ation is destro*ed# This is the ideal lo!ation "or !leaning u' 're(iousl* used resour!es# $''li!ationQ&rror: ,ired when an unhandled e-!e'tion is en!ountered within the a''li!ation# $''li!ationQStart: ,ired when the "irst instan!e o" the ?tt'$''li!ation !lass is !reated# It allows *ou to !reate o)6e!ts that are a!!essi)le )* all ?tt'$''li!ation instan!es# $''li!ationQ&nd: ,ired when the last instan!e o" an ?tt'$''li!ation !lass is destro*ed# ItFs "ired onl* on!e during an a''li!ationFs li"etime# $''li!ationQBegin+e=uest: ,ired when an a''li!ation re=uest is re!ei(ed# ItFs the "irst e(ent "ired "or a re=uest, whi!h is o"ten a 'age re=uest (G+L) that a user enters# $''li!ationQ&nd+e=uest: The last e(ent "ired "or an a''li!ation re=uest# $''li!ationQEre+e=uest?andler&-e!ute: ,ired )e"ore the $SE#%&T 'age "ramewor )egins e-e!uting an e(ent handler li e a 'age or We) ser(i!e# $''li!ationQEost+e=uest?andler&-e!ute: ,ired when the $SE#%&T 'age "ramewor is "inished e-e!uting an e(ent handler# $''l!ationQEreSend+e=uest?eaders: ,ired )e"ore the $SE#%&T 'age "ramewor sends ?TTE headers to a re=uesting !lient ()rowser)# $''li!ationQEreSendContent: ,ired )e"ore the $SE#%&T 'age "ramewor sends !ontent to a re=uesting !lient ()rowser)# >BD $''li!ationQ$!=uire+e=uestState: ,ired when the $SE#%&T 'age "ramewor gets the !urrent state (Session state) related to the !urrent re=uest# $''li!ationQ+elease+e=uestState: ,ired when the $SE#%&T 'age "ramewor !om'letes e-e!ution o" all e(ent handlers# This results in all state modules to sa(e their !urrent state data# $''li!ationQ+esol(e+e=uestCa!he: ,ired when the $SE#%&T 'age "ramewor !om'letes an authori7ation re=uest# It allows !a!hing modules to ser(e the re=uest "rom the !a!he, thus )*'assing handler e-e!ution# $''li!ationQG'date+e=uestCa!he: ,ired when the $SE#%&T 'age "ramewor !om'letes handler e-e!ution to allow !a!hing modules to store res'onses to )e used to handle su)se=uent re=uests# $''li!ationQ$uthenti!ate+e=uest: ,ired when the se!urit* module has esta)lished the !urrent userFs identit* as (alid# $t this 'oint, the userFs !redentials ha(e )een (alidated# $''li!ationQ$uthori7e+e=uest: ,ired when the se!urit* module has (eri"ied that a user !an a!!ess resour!es# SessionQStart: ,ired when a new user (isits the a''li!ation We) site#

SessionQ&nd: ,ired when a userFs session times out, ends, or the* lea(e the a''li!ation We) site# %ote :- 2uring inter(iew *ou do not ha(e to reall* !ram all these e(ents#But 6ust ee' the )asi! e(ents in mind ($) What order the* are triggered ? The*Fre triggered in the "ollowing order: $''li!ationQBegin+e=uest $''li!ationQ$uthenti!ate+e=uest $''li!ationQ$uthori7e+e=uest $''li!ationQ+esol(e+e=uestCa!he $''li!ationQ$!=uire+e=uestState $''li!ationQEre+e=uest?andler&-e!ute >A1 $''li!ationQEreSend+e=uest?eaders $''li!ationQEreSend+e=uestContent TT!ode is e-e!utedUU $''li!ationQEost+e=uest?andler&-e!ute $''li!ationQ+elease+e=uestState $''li!ationQG'date+e=uestCa!he $''li!ationQ&nd+e=uest# (I) 2o session use !oo ies ? Twist:- ?ow !an we ma e session to not to use !oo ies ? Le"t to the user , *ou will en6o* to "ind this answer# (I)?ow !an we "or!e all the (alidation !ontrol to run ? Eage#.alidate (B)?ow !an we !he! i" all the (alidation !ontrol are (alid and 'ro'er ? Gsing the Eage#Is.alid() 'ro'ert* *ou !an !he! whether all the (alidation are done# ($)I" *ou ha(e !lient side (alidation is ena)led in *our We) 'age , 2oes that mean ser(er side !ode is not run? When !lient side (alidation is ena)led ser(er emit8s Ja(aS!ri't !ode "or the !ustom (alidators# But note that does not mean that ser(er side !he! s on !ustom (alidators do not e-e!ute# It does this two time redundant !he! # $s some o" the (alidators do not su''ort !lient side s!ri'ting# ($)Whi!h Ja(aS!ri't "ile is re"eren!ed "or (alidating the (alidators at the !lient side ? >A> We)GI.alidation#6s 6a(as!ri't "ile installed at 9as'netQ!lient: root IIS dire!tor* is used to (alidate the (alidation !ontrols at the !lient side (B)?ow to disa)le !lient side s!ri't in (alidators? Set &na)leClientS!ri't to "alse# ($)I want to show the entire (alidation error message in a message )o- on the !lient side?

In (alidation summar* set 9ShowMessageBo-: to true# (B)Kou "ind that one o" *our (alidation is (er* !om'li!ated and does not "it in an* o" the (alidators , so what will *ou do ? Best is to go "or Custom.alidators##Below is a sam'le !ode "or a !ustom (alidator whi!h !he! s that a te-t)o- should not ha(e 7ero (alue Tas':Custom.alidator idVHCustom.alidator>H runatVHser(erH &rrorMessageVH%um)er not di(isi)le )* ceroH ControlTo.alidateVHt-t%um)erH <nSer(er.alidateVHSer(er.alidateH Client.alidation,un!tionVHChe! ceroH OUT)rU In'ut: Tas':Te-tBo- idVHt-t%um)erH runatVHser(erH OU Ts!ri't languageVH6a(as!ri'tHU T]-"un!tion Che! cero(sour!e, args) Z int (al V 'arseInt(args#.alue, >1)W i" ((alueVV1) Z args#Is.alid V "alseW >AB [ else Z args#Is.alid V trueW [ [ OO --U TOs!ri'tU ($)What is Tra!ing in $SE#%&T ? Tra!ing allows us to (iew in detail how the !ode was e-e!uted# ($) ?ow do we ena)le tra!ing ? T_` Eage Tra!eVHtrueH _U (I)What e-a!tl* ha''ens when $SEC 'age is re=uested "rom Browser? %ote: - ?ere the inter(iewer is e-'e!ting !om'lete "low o" how an $SEC 'age is 'ro!essed with res'e!t to IIS and $SE#%&T engine# ,ollowing are the ste's whi!h o!!ur when we re=uest a $SEC 'age :4 The )rowser sends the re=uest to the we)ser(er#let8s assume that the we)ser(er at the other end is IIS# 4 <n!e IIS re!ei(es the re=uest he loo s on whi!h engine !an ser(e this re=uest# When I mean engine means the 2LL who !an 'arse this 'age or !om'ile and send a res'onse )a! to )rowser# Whi!h re=uest to ma' to is de!ided )* "ile e-tension o" the 'age re=uested# 2e'ending on "ile e-tension "ollowing are some ma''ing

4 #as'-, "or $SE#%&T We) 'ages, 4 #asm-, "or $SE#%&T We) ser(i!es, 4 #!on"ig, "or $SE#%&T !on"iguration "iles, >AA 4 #ash-, "or !ustom $SE#%&T ?TTE handlers, 4 #rem, "or remoting resour!es 4 &t! Kou !an also !on"igure the e-tension ma''ing to whi!h engine it !an route )* using the IIS engine# ,igure: - M#> ,ollowing s!reen shows some IIS ma''ings >A0 &-am'le a $SE 'age will )e sent to old !lassi! $SE#2LL to !om'ile# While #$SEC 'ages will )e routed to $SE#%&T engine "or !om'ilation# 4 $s this )oo mainl* will target $SE#%&T we will loo in to how $SE#%&T 'ages that is $SEC 'ages generation se=uen!e o!!urs# <n!e IIS 'asses the re=uest to $SE#%&T engine 'age has to go through two se!tion ?TTE module se!tion and ?TTE handler se!tion# Both these se!tion ha(e there own wor to )e done in order that the 'age is 'ro'erl* !om'iled and sent to the IIS# ?TTE modules ins'e!t the in!oming re=uest and de'ending on that the* !an !hange the internal wor "low o" the re=uest# ?TTE handler a!tuall* !om'iles the 'age and generates out'ut# I" *ou see *our ma!hine#!on"ig "ile *ou will see "ollowing se!tion o" ?TTE modules Thtt'ModulesU Tadd nameVH<ut'utCa!heH t*'eVHS*stem#We)#Ca!hing#<ut'utCa!heModuleH OU Tadd nameVHSessionH t*'eVHS*stem#We)#SessionState#SessionStateModuleH OU Tadd nameVHWindows$uthenti!ationH t*'eVHS*stem#We)#Se!urit*#Windows$uthenti!ationModuleH OU Tadd nameVH,orms$uthenti!ationH t*'eVHS*stem#We)#Se!urit*#,orms$uthenti!ationModuleH OU Tadd nameVHEass'ort$uthenti!ationH t*'eVHS*stem#We)#Se!urit*#Eass'ort$uthenti!ationModuleH OU Tadd nameVHGrl$uthori7ationH t*'eVHS*stem#We)#Se!urit*#Grl$uthori7ationModuleH OU Tadd nameVH,ile$uthori7ationH t*'eVHS*stem#We)#Se!urit*#,ile$uthori7ationModuleH OU Tadd nameVH&rror?andlerModuleH t*'eVHS*stem#We)#Mo)ile#&rror?andlerModule, S*stem#We)#Mo)ile, .ersionV>#1#L111#1, CultureVneutral, Eu)li!Je*To enV)1A"L"M">>dL1aAaH O U TOhtt'ModulesU >AL The a)o(e ma''ing shows whi!h "un!tionalit* is handled )* whi!h %ames'a!e# &-am'le ,orms$thuenti!ation is handled )* 9S*stem#We)#Se!urit*#,orms$uthenti!ationModule:#

I" *ou loo at the we)#!on"ig se!tion ?TTE module is where authenti!ation and authori7ation ha''ens# < now the ?TTE handler is where the a!tual !om'ilation ta es 'la!e and the out'ut is generated#,ollowing is a 'aste "rom ?TTE handler se!tion o" W&B#C<%,I5 "ile# Thtt'?andlersU Tadd (er)VH;H 'athVH;#(6s'ro6H t*'eVHS*stem#We)#?tt',or)idden?andlerH OU Tadd (er)VH;H 'athVH;#6a(aH t*'eVHS*stem#We)#?tt',or)idden?andlerH OU Tadd (er)VH;H 'athVH;#6slH t*'eVHS*stem#We)#?tt',or)idden?andlerH OU Tadd (er)VH;H 'athVHtra!e#a-dH t*'eVHS*stem#We)#?andlers#Tra!e?andlerH OU Tadd (er)VH;H 'athVH;#as'-H t*'eVHS*stem#We)#GI#Eage?andler,a!tor*H OU Tadd (er)VH;H 'athVH;#ash-H t*'eVHS*stem#We)#GI#Sim'le?andler,a!tor*H OU ### TOhtt'?andlersU 4 2e'ending on the ,ile e-tension handler de!ides whi!h %ames'a!e will generate the out'ut# &-am'le all #$SEC e-tension "iles will )e !om'iled )* S*stem#We)#GI#Eage?andler,a!tor* 4 <n!e the "ile is !om'iled it send )a! again to the ?TTE modules and "rom there to IIS and then to the )rowser# >A3 ,igure :- M#B IIS "low "rom (arious se!tions# (B)?ow !an we ill a user session ? Session#a)andon >AM (I)?ow do *ou u'load a "ile in $SE#%&T ? I will lea(e this to the readers d Just a hint we ha(e to use S*stem#We)#?tt'Eosted,ile !lass# (I)?ow do I send email message "rom $SE#%&T ? $SE#%&T 'ro(ides two names'a!es S*stem#W&B#mailmessage !lassand S*stem#We)#Mail#Smt'mail !lass# Just a small homewor !reate a $s'#%&T 'ro6e!t and send a email at shi(Q oirala`*ahoo#!om # 2o not S'am# ($)What are di""erent IIS isolation le(els? IIS has three le(el o" isolation:L<W (IIS 'ro!ess):- In this main IIS 'ro!ess and $SE#%&T a''li!ation run in same 'ro!ess# So i" an* one !rashes the other is also a""e!ted# &-am'le let8s sa* (well this is not 'ossi)le) I ha(e hosted *ahoo , hotmail #ama7on and google on a single EC# So all a''li!ation and the IIS 'ro!ess runs on the same 'ro!ess#In !ase an* we)site !rashes it a""e!ts e(er* one# ,igure: - M#A L<W IIS 'ro!ess s!enario Medium (Eooled):- In Medium 'ooled s!enario the IIS and we) a''li!ation run in di""erent 'ro!ess# So in this !ase there are two 'ro!esses 'ro!ess> and 'ro!essB# In 'ro!ess> the IIS 'ro!ess is running and in 'ro!essB we ha(e all We) a''li!ation running# >A@ ,igure: - M#0 Medium 'ooled s!enario ?igh (Isolated):-In high isolated s!enario e(er* 'ro!ess is running is there own 'ro!ess# In

)elow "igure there are "i(e 'ro!esses and e(er* one handling indi(idual a''li!ation# This !onsumes hea(* memor* )ut has highest relia)ilit*# >AD ,igure: - M#L ?igh isolation s!enario ($)$SE used ST$ threading model , whats the threading model used "or $SE#%&T ? $SE#%&T uses MT$ threading model# ($)Whats the use o" T_` 'age as'!om'atVtrue _U attri)ute ? This attri)ute wor s li e a !om'ati)ilit* o'tion# $s said )e"ore $SE wor ed in STS model and $SE#%&T wor s in MT$ model# But what i" *our $SE#%&T a''li!ation is using a .B C<M !om'onent# In order that .B C<M runs 'ro'erl* in $SE#%&T threading model we ha(e to set that attri)ute# $"ter de"ining the $SEC<ME$T dire!ti(e attri)ute $SE#%&T 'ages run in ST$ model thus )uilding the !om'ati)ilit* )etween $SE#%&T and old C<M !om'onents who does not su''ort MT$ model# >01 (B)&-'lain the di""eren!es )etween Ser(er-side and Clientside !ode? Ser(er side !ode is e-e!uted at the ser(er side on IIS in $SE#%&T "ramewor , while !lient side !ode is e-e!uted on the )rowser# (I)Can *ou e-'lain ,orms authenti!ation in detail ? In old $SE i" *ou where said to !reate a login 'age and do authenti!ation *ou ha(e to do hell lot o" !ustom !oding# But now in $SE#%&T that8s made eas* )* introdu!ing ,orms authenti!ation# So let8s see in detail what "orm authenti!ation is# ,orms authenti!ation uses a ti! et !oo ie to see that user is authenti!ated or not# That means when user is authenti!ated "irst time a !oo ie is set to tell that this user is authenti!ated# I" the !oo ies e-'ire then ,orms authenti!ation me!hanism sends the user to the login 'age# ,ollowing are the ste's whi!h de"ines ste's "or ,orms authenti!ation :4 Con"igure We)#!on"ig "ile with "orms authenti!ation#$s shown )elow in the !on"ig "ile *ou !an see we ha(e gi(e the !oo ie name and loginurl 'age# T!on"igurationU Ts*stem#we)U T]-- <ther settings omitted# --U Tauthenti!ation modeVH,ormsHU T"orms nameVHlogin!oo iesH loginGrlVHlogin#as'-H 'rote!tionVH$llH timeoutVHA1H 'athVHOH OU TOauthenti!ationU TOs*stem#we)U TO!on"igurationU

>0> 4 +emo(e anon*mous a!!ess to the IIS we) a''li!ation , "ollowing are !hanges done to we)#!on"ig "ile# T!on"igurationU Ts*stem#we)U T]-- <ther settings omitted# --U Tauthori7ationU Tden* usersVH?H OU TOauthori7ationU TOs*stem#we)U TO!on"igurationU 4 Create the login 'age whi!h will a!!e't user in"ormation#Create *our login 'age that is the Login#as'- whi!h will a!tuall* ta e the user data# 4 ,inall* a Small !oding in the login )utton# LetFs assume that the login 'age has two te-t)o-es T-tname and t-ta'ssword# So im'ort S*stem#We)#Se!urit* and 'ut the "ollowing !ode in login )utton o" the 'age# I" Eage#Is.alid Then I" ,orms$uthenti!ation#$uthenti!ate(t-t%ame#Te-t, t-tEassword#Te-t) Then ,orms$uthenti!ation#+edire!t,romLoginEage(t-t%ame#Te-t, ,alse) &lse l)lStatus#Te-t V H&rror not 'ro'er userH &nd I" &nd I" >0B ($)?ow do I sign out in "orms authenti!ation ? ,orms$uthenti!ation#Signout() ($)I" !oo ies are not ena)led at )rowser end does "orm $uthenti!ation wor ? %o it does not wor # ($)?ow to use a !he! )o- in a datagrid? Twist :- ?ow !an I tra! e(ent in !he! )o- whi!h is one o" the !olumns o" a datagrid ? %ote: - This is normall* as ed when the inter(iewer wants to see that ha(e *ou reall* wor ed 'ra!ti!all* on a 'ro6e!t# ,ollowing are the ste's to )e done :4 In $SEC 'age *ou ha(e to add Itemtem'late tag in datagrid# TItemTem'lateU Tas':Che! Bo- idVHChe! Bo->H runatVHser(erH $utoEostBa! VHTrueH <nChe! edChangedVHChe! QCli! edHUTOas':Che! Bo-U TOItemTem'lateU 4 I" *ou loo at the Itemtem'late we ha(e 9<nChe! Changed: e(ent# This 9<nChe! Changed: e(ent has 9Che! QCli! ed: su)routine is a!tuall* in )ehind !ode#%ote this method whi!h is in )ehind !ode should either )e

9'rote!ted: or 9'u)li!: 4 ,ollowing )elow is the su)routine whi!h de"ines the method Erote!ted Su) Che! QCli! ed(B*.al sender $s <)6e!t, B*.al e $s &(ent$rgs) X do something &nd Su) The a)o(e ste's should )e de"ined in short to the inter(iewer whi!h will gi(e a =ui! "eeling o" *our 'ra!ti!al e-'erien!e with $SE#%&T >0A (I)What are the ste's to !reate a windows ser(i!e in .B#%&T ? Windows Ser(i!es are long-running e-e!uta)le a''li!ations that run in its own Windows session, whi!h then has the a)ilit* to start automati!all* when the !om'uter )oots and also !an )e manuall* 'aused, sto''ed or e(en restarted# ,ollowing are the ste's to !reate a ser(i!e :4 Create a 'ro6e!t o" t*'e 9Windows Ser(i!e:# ,igure M#3 :- Create 'ro6e!t "or Windows Ser(i!e 4 I" *ou see the !lass !reated it is automati!all* inheriting "rom 9S*stem#Ser(i!eEro!ess#Ser(i!eBase:# >00 4 Kou !an o(erride the "ollowing e(ents 'ro(ided )* ser(i!e and write *our !ustom !ode# $ll the three main e(ents !an )e used that is Start , sto' and !ontinue# 'rote!ted o(erride (oid <nStart(stringRS args) Z [ 'rote!ted o(erride (oid <nSto'() Z [ 'rote!ted o(erride (oid <nContinue() Z [ 4 %ow to install the ser(i!e *ou need to do run the install util e-e# InstallGtil TEro6e!t EathUIBI%I"olderSEK#

##%&T $r!hite!ture
(B) What are design 'atterns ? 2esign 'atterns are re!urring solution to re!urring 'ro)lems in so"tware ar!hite!ture# ($) Can *ou list down all 'atterns and there !lassi"i!ation ? %ote :- This is ad(an!ed =uestion )e!ause an* one who sa*s to list down all 'atterns !an onl* )e !ra7* "or what he is as ing#But its alwa*s a win-a-win situation "or the inter(iewer# There are three )asi! !lassi"i!ation o" 'atterns Creational , Stru!tural and Beha(ioral 'atterns#

Creational Eatterns 4 $)stra!t ,a!tor*:- Creates an instan!e o" se(eral "amilies o" !lasses 4 Builder :- Se'arates o)6e!t !onstru!tion "rom its re'resentation 4 ,a!tor* Method:- Creates an instan!e o" se(eral deri(ed !lasses 4 Erotot*'e:- $ "ull* initiali7ed instan!e to )e !o'ied or !loned 4 Singleton:- $ !lass o" whi!h onl* a single instan!e !an e-ist %ote :- The )est wa* to remem)er Creational 'attern is )* $B,ES ($)raham Be!ame ,irst Eresident o" States)# Stru!tural Eatterns 4 $da'ter:-Mat!h inter"a!es o" di""erent !lasses# 4 Bridge:-Se'arates an o)6e!t8s inter"a!e "rom its im'lementation# 4 Com'osite:-$ tree stru!ture o" sim'le and !om'osite o)6e!ts# 4 2e!orator :-$dd res'onsi)ilities to o)6e!ts d*nami!all*# 4 ,aeade:-$ single !lass that re'resents an entire su)s*stem# 4 ,l*weight:-$ "ine-grained instan!e used "or e""i!ient sharing# 4 Ero-*:-$n o)6e!t re'resenting another o)6e!t# @##%&T $r!hite!ture >03 %ote : To remem)er stru!tural 'attern )est is ($BC2,,E) Beha(ioral Eatterns 4 Mediator:-2e"ines sim'li"ied !ommuni!ation )etween !lasses# 4 Memento:-Ca'ture and restore an o)6e!tFs internal state# 4 Inter'reter:-$ wa* to in!lude language elements in a 'rogram# 4 Iterator:-Se=uentiall* a!!ess the elements o" a !olle!tion# 4 Chain o" +es':-$ wa* o" 'assing a re=uest )etween a !hain o" o)6e!ts# 4 Command:-&n!a'sulate a !ommand re=uest as an o)6e!t# 4 State:-$lter an o)6e!tFs )eha(ior when its state !hanges# 4 Strateg*:-&n!a'sulates an algorithm inside a !lass# 4 <)ser(er:-$ wa* o" noti"*ing !hange to a num)er o" !lasses# 4 Tem'late Method:-2e"er the e-a!t ste's o" an algorithm to a su)!lass# 4 .isitor:-2e"ines a new o'eration to a !lass without !hange# %ote :- Just remem)er Musi!####### B MICS <n T. (MMIICCSS<T.)# %ote:- %o sour!e !ode is 'ro(ided "or ar!hite!ture se!tion# $s mu!h o" the things !an )e !lear "rom good GML diagrams# ($)What8s di""eren!e )etween ,a!tor* and $)stra!t ,a!tor* Eattern8s? %ote: - This is =uiet a !on"using ar!hite!t =uestion es'e!iall* in design 'attern se!tion# Inter(iewer !an ta e *ou "or a ni!e ride d# So get the di""eren!e8s in *our heart# ,irst read the de"inition 'ro(ided in the "irst =uestion a)out )oth these 'atterns# The !ommon thing the* ha(e is that the* )elong to !reational 'atterns# In short the* hide the !om'le-it* o" !reating o)6e!ts# The main di""eren!e )etween "a!tor* and $)stra!t "a!tor* is "a!tor* method uses inheritan!e to de!ide whi!h o)6e!t has to )e instantiated# While a)stra!t "a!tor* uses delegation to de!ide instantiation o" o)6e!t# We !an sa* $)stra!t "a!tor* uses "a!tor*

method to !om'lete the ar!hite!ture# $)stra!t ,a!tor* is one le(el higher in a)stra!tion o(er ,a!tor*# >0M The )elow two !lass diagrams will 'ro(ide o(er(iew o" what the a!tual di""eren!e is# ,irst "igure shows a sam'le im'lementation o" ,a!tor* Eatterns# In this "igure there are two )asi! se!tions:4 The a!tual 'rodu!t se!tion i#e# Class 9Erodu!t: it inherits "rom a a)stra!t !lass 9$)stra!tErodu!t:# 4 The !reational as'e!t se!tion that8s 9Con!reteCreator: !lass whi!h inherits "rom !lass 9Creator:# 4 %ow there are some rules the !lient who will need the 9Erodu!t: o)6e!t will "ollow# ?e will ne(er re"er dire!tl* to the a!tual 9Erodu!t: o)6e!t he will re"er the 9Erodu!t: o)6e!t using 9$)stra!tErodu!t:# 4 Se!ond !lient will ne(er use 9%ew: e*word to !reate the 9Erodu!t: o)6e!t )ut will use the 9Creator: !lass whi!h in turn will use the 9Con!reteCreator: !lass to !reate the a!tual 9Erodu!t: o)6e!t# ,igure: - @#> Class diagram o" a "a!tor* Eattern So what are )ene"its "rom this ar!hite!ture? $ll !reational and initiali7ing as'e!ts are now deta!hed "rom the a!tual !lient# $s *our !reational as'e!t is now )een handled in 9Con!reteCreator: and the !lient has re"eren!e to onl* 9Creator:, so an* im'lementation !hange in 9CreateErodu!t: will not a""e!t the !lient !ode# In short now *ou !reational as'e!t o" o)6e!t is !om'letel* en!a'sulated "rom the !lient8s logi!# %ow let8s loo at the se!ond !lass diagram whi!h 'ro(ides an o(er(iew o" what a!tuall* 9$)stra!t "a!tor*: 'attern is# It !reates o)6e!ts "or "amilies o" !lasses# In short it des!ri)es !olle!tion o" "a!tor methods "rom (arious di""erent "amilies# In short it grou's related >0@ "a!tor* methods# &-am'le in this the !lass 9Creator: is im'lemented using the 9$)stra!t: "a!tor* 'attern# It now !reates o)6e!ts "rom multi'le "amilies rather one 'rodu!t# %ote :- Just sti! u' to this de"inition that $)stra!t "a!tor* !lassi"ies "a!tor* methods or grou's logi!all* related "a!tor* method together## ,igure:- @#B Class 2iagram o" $)stra!t ,a!tor* >0D (I)What8s M.C 'attern? Twist: - ?ow !an *ou im'lement M.C 'attern in $SE#%&T? The main 'ur'ose using M.C 'attern is to de!ou'le the 5GI "rom the 2ata# It also gi(es the a)ilit* to 'ro(ide multi'le (iews "or the same 2ata# M.C 'attern se'arates o)6e!ts in to three im'ortant se!tions:4 Model: - This se!tion is s'e!iall* "or maintaining data# It is a!tuall* where *our )usiness logi!, =uer*ing data)ase, data)ase !onne!tion et!# is a!tuall* im'lemented# 4 .iews: - 2is'la*ing all or some 'ortion o" data, or 'ro)a)l* di""erent (iew o" data# .iew is res'onsi)le "or loo and "eel, Sorting, "ormatting et!# 4 Controller: - The* are e(ent handling se!tion whi!h a""e!ts either the model or

the (iew# Controller res'onds to the mouse or e*)oard in'ut to !ommand model and (iew to !hange# Controllers are asso!iated with (iews# Gser intera!tion triggers the e(ents to !hange the model, whi!h in turn !alls some methods o" model to u'date its state to noti"* other registered (iews to re"resh their dis'la*# < now this was all in theor*# Let8s loo at how in a!tuall* $SE#%&T !an we im'lement M.C 'attern# 2uring inter(iew with theor* the* will )e loo ing are more at ha(e *ou reall* im'lemented M.C or its 6ust tal s# ,ollowing are the (arious se!tions o" $SE#%&T whi!h ma's to M.C se!tions:4 Model: - This se!tion is re'resented )* 2ata (iew, 2ataset, T*'ed 2ataset, Business !om'onents, )usiness entit* models et!# %ow this se!tion !an then )e tied u' to either windows a''li!ation or we) GI# 4 .iew: - $SEC, $SCC, or windows a''li!ation GI li e data grid et!# "orm the (iew 'art o" it# 4 Controller: - In $SE#%&T the )ehind !ode is the !ontroller# $s the e(ents are handled )* that 'art# Controller !ommuni!ates )oth with Model as well as (iew# I ho'e I was a)le to ma' *ou imagination o" $SE#%&T with the diagram gi(en )elow# >L1 ,igure: - @# A 2ata "low )etween M.C ar!hite!tures# ($)?ow !an we im'lement singleton 'attern in #%&T? Singleton 'attern mainl* "o!uses on ha(ing one and onl* one instan!e o" the o)6e!t running# &-am'le a windows dire!tor* ser(i!e whi!h has multi'le entries )ut *ou !an onl* ha(e single instan!e o" it through out the networ # %ote:- Ma* o" de(elo'ers would 6um' to a !on!lusion sa*ing using the 9ST$TIC: e*word we !an ha(e a single instan!e o" o)6e!t# But that8s not the real !ase there is something more than to )e done# But 'lease note we !an not de"ine a !lass as ST$TIC, so this will not ser(e our a!tual 'ur'ose o" im'lementing singleton 'attern# ,ollowing are the three ste's needed to im'lement singleton 'attern in #%&T:>L> 4 ,irst !reate *our !lass with stati! mem)ers# Eu)li! !lass ClsStati!Class Eri(ate shared o)6Customer as !lsCustomer &nd !lass This ensures that there is a!tuall* onl* one Customer o)6e!t through out the 'ro6e!t# 4 Se!ond de"ine a 'ri(ate !onstru!tor to *our !lass# %ote: - de"ining a 'ri(ate !onstru!tor to !lass does not allow a !lient to !reate o)6e!ts dire!tl*# 4 ,inall* 'ro(ide a stati! method to get a!!ess to *our singleton o)6e!t# ($)?ow do *ou im'lement 'rotot*'e 'attern in #%&T? Twist: - ?ow to im'lement !loning in #%&T ? , What is shallow !o'* and dee' !o'* ? Cloning is a!hie(ed )* using IClonea)le o" the S*stem names'a!e# It has a 9Clone: method whi!h a!tuall* returns the re"eren!e o" the same !o'*# Clone method allows a Shallow !o'* and not a dee' !o'*# In Shallow !o'* i" *ou ma e !hanges to the !loned o)6e!t it

a!tuall* does !hange on the main o)6e!t itsel"# So how is dee' !o'* a!hie(ed, )* using 9ISeriali7a)le: inter"a!e? So what *ou do is "irst seriali7e the o)6e!t then deseriali7e )a! to a !om'lete new !o'*# %ow an* !hanges to this new !o'* do not re"le!t on the original !o'* o" the o)6e!t, this is !alled as 2ee' !o'*# (I)What are the situations *ou will use a We) Ser(i!e and +emoting in 'ro6e!ts? Well 9We) ser(i!es: uses 9remoting: !on!e'ts internall*# But the ma6or di""eren!e )etween 9we) ser(i!e: and 9remoting: is that 9we) ser(i!e: !an )e !onsumed )* !lients who are not #%&T 'lat"orm# While remoting *ou need the !lient to )e #%&T !om'liant# +egarding the s'eed issue 9+emoting: is "aster than 9We) Ser(i!es:# So I thin when de!iding the ar!hite!ture side o" !hoosing )etween 9We) ser(i!es: and 9+emoting: ee' the !ross 'lat"orm issue and the s'eed issue in mind# ($)Can *ou gi(e a 'ra!ti!al im'lementation o" ,$f$2& 'atterns? >LB ,aeade 'attern sits on the to' o" lot o" su)s*stems and ma es a!!ess eas* to inter"a!es o" these su)s*stems# Basi! 'ur'ose o" ,aeade is to ma e inter"a!ing )etween man* modules and !lasses managea)le# ,igure: - @#0 ,aeade in a!tion $)o(e is a sim'le li(e a''li!ation o" a ,aeade !lass# In this we ha(e "our su)s*stems :4 Customer 4 Erodu!t >LA 4 Ea*ment 4 In(oi!ing $ll the "our modules when )uilt at initial stage where )uilt !om'letel* inde'endent# The main intera!tion )etween all these su)s*stems is !ustomer 'la!ing order# This "un!tionalit* !an )e attained )* using all these su)s*stems, whi!h in(ol(es !om'le- intera!tion )etween them# There8s where ,$f$2& !omes in to a!tion# We ha(e )uilt a ,$f$2& !alled as 9,$C$2&<+2&+: whi!h sits on the to' o" all these su)s*stem and "ul"ills our "un!tionalit*# (I) ?ow !an we im'lement o)ser(er 'attern in #%&T? <)ser(er 'atterns !an )e im'lemented using 92elegates: and 9&(ents:# I lea(e this to the readers to im'lement one sam'le !ode "or o)ser(er 'atterns# (B)What is three tier ar!hite!ture? The three tier so"tware ar!hite!ture emerged in the >DD1s to o(er!ome the limitations o" the two tier ar!hite!ture# There are three la*ers in when we tal a)out three tier ar!hite!ture:Gser Inter"a!e (Client) :- This is mostl* the windows user inter"a!e or the We) inter"a!e# But this has onl* the GI 'art# Mid la*er: - Middle tier 'ro(ides 'ro!ess management where )usiness logi! and rules are e-e!uted and !an a!!ommodate hundreds o" users (as !om'ared to onl* >11 users with the two tier ar!hite!ture) )* 'ro(iding "un!tions su!h as =ueuing, a''li!ation e-e!ution,

and data)ase staging# 2ata $!!ess La*er: - This is also !alled )* the "amous a!ron*m H2$LH !om'onent# It has mainl* the S\L statement whi!h do the data)ase o'eration 'art o" the 6o)# The three tier ar!hite!ture is used when an e""e!ti(e distri)uted !lientOser(er design is needed that 'ro(ides (when !om'ared to the two tier) in!reased 'er"orman!e, "le-i)ilit*, maintaina)ilit*, reusa)ilit*, and s!ala)ilit*, while hiding the !om'le-it* o" distri)uted 'ro!essing "rom the user# >L0 (I)?a(e *ou e(er wor ed with Mi!roso"t $''li!ation Blo! s, i" *es then whi!h? $''li!ation Blo! s are CN and .B#%&T !lasses distri)uted as .isual Studio 'ro6e!ts that !an )e downloaded "rom Mi!roso"tFs We) site and used in an* #%&T a''li!ation, in!luding $SE#%&T We) a''li!ations# The* are use"ul and 'ower"ul tools that !an ma e a''li!ations more maintaina)le, s!ala)le and e""i!ient The se!ond =uestion whi!h o" the a''li!ation )lo! s has )een used de'ends on reall* what *ou ha(e im'lemented# But there are two "amous M$B whi!h is ma ing )u77 around the industr*:4 data a!!ess )lo! The 2ata $!!ess Blo! 'ro(ides stati! methods lo!ated in the S=l?el'er !lass that en!a'sulates the most !ommon data a!!ess tas s 'er"ormed with Mi!roso"t S\L ser(er# I" the term Hstati! methodH is new to *ou, it means that the !lass methods !an )e !alled without instantiating an instan!e o" the !lass# ,or e-am'le, the method &-e!ute+eader () within the S=l?el'er !lass !an )e !alled )* sim'l* using the statement S=l?el'er#&-e!ute+eader () -- no o)6e!t instantiation o" the S=l?el'er !lass is re=uired# 4 &-!e'tion management )lo! # The &-!e'tion Management $''li!ation Blo! 'ro(ides a sim'le *et e-tensi)le "ramewor "or handling e-!e'tions# With a single line o" a''li!ation !ode *ou !an easil* log e-!e'tion in"ormation to the &(ent Log or e-tend it )* !reating *our own !om'onents that log e-!e'tion details to other data sour!es or noti"* o'erators, without a""e!ting *our a''li!ation !ode# The &-!e'tion Management $''li!ation Blo! !an easil* )e used as a )uilding )lo! in *our own #%&T a''li!ation %ote: - It8s )e*ond the s!o'e the )oo to loo in to details o" a''li!ation )lo! # Best is go to www#mi!roso"t#!om and sear!h "or these a''li!ation )lo! # Tr* to !om'ile one or two 'rograms using there gi(en !lasses and do!umentation# ($)What is Ser(i!e <riented ar!hite!ture? 9Ser(i!es: are !om'onents whi!h e-'ose well de"ined inter"a!es and these inter"a!es !ommuni!ate through CML messages# Gsing S<$ *ou !an )uild wor "low, whi!h uses >LL inter"a!es o" these !om'onents# S<$ is t*'i!all* use"ul when *ou are !rossing heterogeneous te!hni!al )oundaries, organi7ations, domain et!# In #%&T S<$ te!hni!all* uses We) ser(i!es to !ommuni!ate with ea!h ser(i!e whi!h is

!rossing )oundaries# Kou !an loo S<$ whi!h sits on T<E o" we) ser(i!es and 'ro(ides a wor "low# S<$ uses ser(i!e !om'onents whi!h o'erate in there own domain )oundar*# Let8s note some 'oints o" ser(i!e :4 The* are inde'endent !om'onents and o'erate in there own )oundar* and own te!hnolog*# 4 The* ha(e well de"ined inter"a!es whi!h use CML and WS2L to des!ri)e themsel(es# 4 Ser(i!es ha(e G+L where an* one !an "ind them and !lients !an )ind to these G+L to a(ail "or the ser(i!e# 4 Ser(i!es ha(e (er* loosel* !ou'led ar!hite!ture# In order to !ommuni!ate to ser(i!e *ou onl* ha(e to now the WS2L# Kour !lient !an then generate 'ro-* "rom the WS2L o" the ser(i!e# >L3 ,igure: - @#L S<$ )asi! ar!hite!ture $)o(e "igure des!ri)es a )roader 'i!ture o" what ser(i!e oriented ar!hite!ture will loo li e# The )asi! "undamental o" S<$ is a we) ser(i!e# In a)o(e diagram *ou !an see there are two ser(i!es a(aila)le# <ne is the 9Credit Card: ser(i!e and other is 9$ddress Che! : >LM we) ser(i!e# Both these ser(i!es are 'ro(ided )* di""erent !om'an*# %ow we want to )uild a "un!tionalit* whi!h needs to (alidate a !redit !ard and also !he! that addresses are 'ro'er# In short we will need "un!tionalities o" )oth the 9CreditCard: and 9$ddressChe! : ser(i!e# $lso note the 9CreditCard: ser(i!e has its own )usiness la*er and 2$L !om'onents, whi!h !an )e in a 'ro'rietar* language# It8s (er* mu!h 'ossi)le that the whole Credit !ard ser(i!e is made in #%&T and the $ddress !he! is S$E im'lementation or J$.$ im'lementation# But )e!ause )oth the s*stems 'ro(ide there "un!tionalit* using We) ser(i!es whi!h is nothing )ut )asi!all* CML message !ommuni!ation# So we ha(e made new ser(i!e whi!h sits li e a ,$f$2& on to' o" )oth the we) ser(i!e and 'er"orms )oth "un!tionalities in one !ommon ser(i!e# Kou will see I ha(e made a third ser(i!e whi!h sits on to' o" )oth the we)ser(i!e and !onsumes them# $lso *ou !an see that the GI 'art o" the s*stems ha(e a!!ess to Buisness la*er and We) ser(i!e o" there s*stem# But the ser(i!e whi!h does )oth these !he! has onl* a!!ess to the We) ser(i!e# (I)What are di""erent wa*s *ou !an 'ass data )etween tiers? There are man* wa*s *ou !an 'ass data )etween tiers :4 2ataset the most 're"erred one as the* maintain data in CML "ormat# 4 2atareader 4 Custom !lasses# 4 CML %ote:- It8s )e*ond the s!o'e o" this )oo to dis!uss a)out S<$# But 6ust to ee' *ou sa"e during inter(iew this )oo has tried to !lear some )asi!s o" S<$# ($)What is Windows 2%$ ar!hite!ture? %ote :- I" *ou ha(e wor ed with !lassi! $SE this =uestion !an !ome to *ou#

The Windows 2istri)uted inter%et $''li!ations $r!hite!ture (2%$) is a Mi!roso"t )lue'rint "or ro)ust, s!ala)le, distri)uted )usiness so"tware# Windows 2%$ has e(ol(ed o(er time and was not 're'lanned# It gi(es all !om)ined ad(antages o" Centrali7ed main"rame, a''li!ation ser(ers, internet te!hnologies and Eersonal !om'uters# Windows 2%$ is a e(olution whi!h started "rom main"rames (Where all logi! was !entrali7ed) , ,o- 'ro ages ( Where we tal ed in terms o" two tier s*stems) , .B3 O S\L S&+.&+ (Three tier where we tal ed in terms o" ha(ing one more tier whi!h was mainl* C<M >L@ where )usiness logi! resided) , C<M/ ( loo ing in terms o" transa!tions and "ul"illing $CI2 rules) and "inall* the 2%$# ,igure :- @#3 Windows 2%$ se!tions $)o(e shown is a Windows 2%$ model whi!h is a )lue 'rint whi!h Mi!roso"t has 'ro'osed# So i" inter(iewer is as ing *ou ha(e *ou wor ed with Windows 2%$ , then answer is *es# Kou will see that *ou alwa*s use this se!tion# 2o not get !on"used with the terminolog* 2%$# >LD ($)What is as'e!t oriented 'rogramming? %ote :- This is something whi!h is !at!hing u' the mar et so inter(iewer !an as *ou to see *ou how *ou are in tou!h with the mar et#So 'ro)a)l* this e-'lanation !an )e =uiet long )ut )ear with me it is worth o" it I will tr* to )e as short as 'ossi)le as this )oo is not a re"eren!e )oo # Just to sa(e *ou "rom inter(iewer I will gi(e a short des!ri'tion o" as'e!t oriented 'rogramming in #%&T# ,irst letFs tr* to de"ine it whi!h !an 'ro)a)l* sa(e *ou during inter(iew $s'e!t-oriented so"tware de(elo'ment is a new te!hnolog* "or se'aration o" !on!erns (S<C) in so"tware de(elo'ment# The te!hni=ues o" $<S2 ma e it 'ossi)le to modulari7e !ross!utting as'e!ts o" a s*stem# < that statement8s !an sa(e *ou "or the "irst stage let8s get down a!tuall* what is it# Let8s re(isit )a! how so"tware de(elo'ment !*!le e(ol(ed# When we loo )a! at times o" Co)ol where we used to )rea the modules in small "un!tionalities and use reusa)ilit* to its ma-imum# Then !ame the time when we tal ed in terms o" <)6e!ts where things where !learer as so"tware was modeled in terms o" real li"e e-am'les# It wor ed "ine and till toda* is the most a!!e'ted wa* o" im'lementing and organi7ing 'ro6e!t# So wh* $<E ? $s'e!t oriented 'rogramming does not o''ose <<E8s )ut rather su''orts it and ma e8s it more maintaina)le# So remo(e the logi! "rom head the $<E is re'la!ement o" <<E# %o its )rother o" <<E hel'ing him to )e )etter# When we tal in terms o" o)6e!t8s it8s an entit* whi!h ma's to real world domain# <)6e!t has attri)utes whi!h re'resent the state o" o)6e!t and also de"ine its )eha(ior# B* rule o" o)6e!t oriented 'rogramming o)6e!t should )e stand alone and !ommuni!ate with other o)6e!t8s using messages or de"ined inter"a!e# <ne o)6e!t should not !ommuni!ate with other o)6e!t dire!tl* rather !ommuni!ate through de"ined inter"a!es# &(er* o)6e!t satis"ies some 9Con!ern: in relation to the s*stem# Twist: - What is Con!ern in $<E?

9$ !on!ern is a 'arti!ular goal, !on!e't, or area o" interest: There are mainl* two t*'es o" !on!ern "rom an o)6e!t 'ers'e!ti(e:4 Core O Main !on!erns whi!h it should satis"* and is his wor # I ho'e in m* se!ond edition i will !ome out with a se'erate !ha'ter on $<E >31 4 S*stem !on!erns whi!h are not related to )usiness "un!tionalities )ut so"tware related !on!erns e-am'le audit trail, &rror handling, Se!urit* et!# < let8s tr* to understand this 'rin!i'le )* some a!tual e-am'le# ,igure :- @#M Customer and $udit trail relationshi's $)o(e is a !lass diagram whi!h shows relationshi')etween two !lasses 9ClsCustomer: and 9Cls$uditTrail:# 9ClsCustomer: !lass does inserting o" new !ustomer8s in to data)ase and 9Cls$uditTrail: does the auditing o" what is !hanged in the !ustomer !lass# %ow there are two !on!erns in this 'ro6e!t :4 Customer !ode should not e-!eed greater than >1 length (Business le(el !on!ern) 4 $ll !ustomer data whi!h is u'dated should )e audited# (S*stem le(el !on!ern) ?ere goes the !lass !ode# I" *ou see the ClsCustomer im'lementation in the u'date method I ha(e !alled the $udit trail im'lementation# I" *ou reall* loo "rom o)6e!t oriented 'oint o" (iew we are doing something in !ustomer !lass whi!h is su''osed to )e not his im'lementation: - $udit Trail logging# Thus we ha(e also )ro en down the rule o" >3> en!a'sulation# In short the !lass not onl* handles his wor )ut also some other wor whi!h is not his !on!ern# < now lets de"ine !ross!utting whi!h is one o" im'ortant as'e!t8s o" $<E# Twist :- What is !ross !utting in $<E ? When one or man* !on!erns s'an a!ross module its !alled as !ross !utting#&-am'le in our audit trail e-am'le we will 'ro)a)l* need to audit trail "or !ustomer as well as su''lier#So $udit trail !an s'an a!ross other o)6e!ts also that is termed as !ross !utting# Below are )oth the !lasses a!tuall* im'lemented as 'er !lass diagram @#M# I" *ou see the 9G'date: method o" the !ustomer !lass , its doing )oth o" the !on!erns that is !he! ing "or !ustomer !ode length and also maintaining the audit trail using the audit trail !lass# Eu)li! Class ClsCustomer Eri(ate 'strCust!ode $s String Eri(ate 'strCust%ame $s String Eu)li! Ero'ert* Code() $s String 5et +eturn 'strCust!ode &nd 5et Set(B*.al .alue $s String) 'strCust!ode V .alue &nd Set &nd Ero'ert* Eu)li! Ero'ert* Customer%ame() $s String

5et +eturn 'strCust%ame &nd 5et Set(B*.al .alue $s String) >3B 'strCust%ame V .alue &nd Set &nd Ero'ert* Eu)li! ,un!tion G'date() $s Boolean X "irst O !ore !on!ern I" 'strCust!ode#Length() U >1 Then Throw %ew &-!e'tion(H.alue !an not )e greater than >1H) &nd I" F usingthe !ustomer audit trail to do auditing X se!ond !on!ern O s*stem !on!ern 2im 'o)6Cls$uditTrail $s %ew Cls$uditTrail With 'o)6Cls$uditTrail #%ew.alue V H>11>H #<ld.alue V H>11AH #Gser%ame V Hshi(H #G'date() &nd With F then inserting the !ustomer in data)ase &nd ,un!tion &nd Class Eu)li! Class Cls$uditTrail Eri(ate 'strGser%ame $s String Eri(ate 'str<ld.alue $s String Eri(ate 'str%ew.alue $s String Eri(ate 'd)lLogTime $s 2ou)le >3A Eu)li! Ero'ert* Gser%ame() $s String 5et +eturn 'strGser%ame &nd 5et Set(B*.al .alue $s String) 'strGser%ame V .alue &nd Set &nd Ero'ert* Eu)li! Ero'ert* <ld.alue() $s String 5et +eturn 'str<ld.alue &nd 5et

Set(B*.al .alue $s String) 'str<ld.alue V .alue &nd Set &nd Ero'ert* Eu)li! Ero'ert* %ew.alue() $s String 5et +eturn 'str%ew.alue &nd 5et Set(B*.al .alue $s String) 'str%ew.alue V .alue &nd Set &nd Ero'ert* Eu)li! Ero'ert* LogTime() $s 2ou)le >30 5et +eturn 'd)lLogTime &nd 5et Set(B*.al .alue $s 2ou)le) 'd)lLogTime V .alue &nd Set &nd Ero'ert* Eu)li! Su) G'date() F do the logging a!ti(it* here &nd Su) &nd Class In short the !ustomer !lass is doing lot o" a!ti(it*# There is lot o" tangling o" !ode# So how do we o(er!ome this 'ro)lemd Sim'le se'arate the S*stem le(el !on!ern ($udit Trail) "rom the !ore le(el !on!ern ( Customer !ode !he! )# This is a!hie(ed at this moment in #%&T using attri)ute 'rogramming# ?ere is the !hange to the !ustomer !lass Im'orts S*stem#+e"le!tion Eu)li! Class ClsCustomer Eri(ate 'strCust!ode $s String Eri(ate 'strCust%ame $s String Eu)li! Ero'ert* Code() $s String 5et +eturn 'strCust!ode &nd 5et Set(B*.al .alue $s String) >3L 'strCust!ode V .alue &nd Set &nd Ero'ert*

Eu)li! Ero'ert* Customer%ame() $s String 5et +eturn 'strCust%ame &nd 5et Set(B*.al .alue $s String) 'strCust%ame V .alue &nd Set &nd Ero'ert* TCls$uditTrail(HShi(H, H>11>H, H>11AH, >B)U Q Eu)li! ,un!tion G'date() $s Boolean I" 'strCust!ode#Length() U >1 Then Throw %ew &-!e'tion(H.alue !an not )e greater than >1H) &nd I" F usingthe !ustomer audit trail to do auditing F then inserting the !ustomer in data)ase &nd ,un!tion &nd Class >33 $nd here is the !hange to the audit trail !lass Im'orts S*stem#+e"le!tion T$ttri)uteGsage($ttri)uteTargets#$ll)U Q Eu)li! Class Cls$uditTrail Inherits $ttri)ute Eri(ate 'strGser%ame $s String Eri(ate 'str<ld.alue $s String Eri(ate 'str%ew.alue $s String Eri(ate 'd)lLogTime $s 2ou)le Eu)li! Ero'ert* Gser%ame() $s String 5et +eturn 'strGser%ame &nd 5et Set(B*.al .alue $s String) 'strGser%ame V .alue &nd Set &nd Ero'ert* Eu)li! Ero'ert* <ld.alue() $s String 5et +eturn 'str<ld.alue &nd 5et Set(B*.al .alue $s String) 'str<ld.alue V .alue &nd Set >3M

&nd Ero'ert* Eu)li! Ero'ert* %ew.alue() $s String 5et +eturn 'str%ew.alue &nd 5et Set(B*.al .alue $s String) 'str%ew.alue V .alue &nd Set &nd Ero'ert* Eu)li! Ero'ert* LogTime() $s 2ou)le 5et +eturn 'd)lLogTime &nd 5et Set(B*.al .alue $s 2ou)le) 'd)lLogTime V .alue &nd Set &nd Ero'ert* Eu)li! Su) %ew(B*.al 'strGser%ame $s String, Q B*.al 'str<ld.alue $s String, Q B*.al 'strnew.alue $s String, Q B*.al 'lng $s Long) G'date() &nd Su) Eu)li! Su) G'date() F do the logging a!ti(it* here >3@ &nd Su) &nd Class The "un 'art o" the !ode is )elow , *ou !an see that the !ode audit trail is now se'erate and the !ode !he! )elongs to the !ustomer !ode# TCls$uditTrail(HShi(H, H>11>H, H>11AH, >B)U Q Eu)li! ,un!tion G'date() $s Boolean I" 'strCust!ode#Length() U >1 Then Throw %ew &-!e'tion(H.alue !an not )e greater than >1H) &nd I" F usingthe !ustomer audit trail to do auditing F then inserting the !ustomer in data)ase &nd ,un!tion %ote:- $r!hite!ture is e(er*)od*s "a(orite and the wide !om)ination is di""i!ult to )e !o(ered in this )oo # Man* o" the things !an onl* !ome )* li(e e-'erien!e#

$2<#%&T

(B)What is the names'a!e in whi!h #%&T has the data "un!tionalit* !lasses ? ,ollowing are the names'a!es 'ro(ided )* #%&T "or data management :S*stem#data This !ontains the )asi! o)6e!ts used "or a!!essing and storing relational data, su!h as 2ataSet,2ataTa)le, and 2ata+elation# &a!h o" these is inde'endent o" the t*'e o" data sour!e and the wa* we !onne!t to it# S*stem#2ata#<le2B Contains the o)6e!ts that we use to !onne!t to a data sour!e (ia an <L&-2B 'ro(ider, su!h as <le2)Conne!tion, <le2)Command, et!# These o)6e!ts inherit "rom the !ommon )ase !lasses, and so ha(e the same 'ro'erties, methods, and e(ents as the S=lClient e=ui(alents# S*stem#2ata#S=lClient: This Contains the o)6e!ts that we use to !onne!t to a data sour!e (ia the Ta)ular 2ata Stream (T2S) inter"a!e o" Mi!roso"t S\L Ser(er (onl*)# This !an generall* 'ro(ide )etter 'er"orman!e as it remo(es some o" the intermediate la*ers re=uired )* an <L&-2B !onne!tion# S*stem#CML This Contains the )asi! o)6e!ts re=uired to !reate, read, store, write, and mani'ulate CML do!uments a!!ording to WAC re!ommendations# (B) Can *ou gi(e a o(er(iew o" $2<#%&T ar!hite!ture ? The most im'ortant se!tion in $2<#%&T ar!hite!ture is 92ata Ero(ider:#2ata Ero(ider 'ro(ides a!!ess to datasour!e (S\L S&+.&+ , $CC&SS ,<+$CL&)#In short it 'ro(ides o)6e!t to a!hie(e "un!tionalities li e o'ening and !losing !onne!tion , retrie(e data and u'date data#In )elow "igure *ou !an see that data 'ro(ider "our main se!tions :4 Conne!tion# D# $2<#%&T ; M1 'er!ent o" IT 'ro6e!ts are data)ase 'ro6e!ts,so $2<#%&T "orms the heart o" ma6or #%&T inter(iews# >M1 4 Command o)6e!t (This is the res'onsi)le o)6e!t to use stored 'ro!edures) 4 2ata $da'ter (This o)6e!t a!ts as a )ridge )etween datastore and dataset)# 4 2atareader (This o)6e!t reads data "rom data store in "orward onl* mode)# 2ataset o)6e!t re'resents dis!onne!ted and !a!hed data#I" *ou see the diagram it is not in dire!t !onne!tion with the data store (S\L S&+.&+ , <+$CL& et!) rather it tal s with 2ata ada'ter , who is res'onsi)le "or "illing the dataset#2ataset !an ha(e one or more 2atata)le and relations# ,igure :- D#> $2<#%&T $r!hite!ture ; %ot answering sim'le $2<#%&T =uestions !an lead to negati(e results# >M> 92ata.iew: o)6e!t is used to sort and "ilter data in 2atata)le# %ote:- This is one o" the "a(orite =uestion in #%&T#Just 'aste the 'i!ture in *our mind and during inter(iew tr* to re"er that image#

(B)What are the two "undamental o)6e!ts in $2<#%&T ? 2atareader and 2ataset are the two "undamental o)6e!ts in $2<#%&T# (B)What is di""eren!e )etween dataset and datareader ? ,ollowing are some ma6or di""eren!es )etween dataset and datareader :4 2ata+eader 'ro(ides "orward-onl* and read-onl* a!!ess to data , while the 2ataSet o)6e!t !an hold more than one ta)le (in other words more than one rowset) "rom the same data sour!e as well as the relationshi's )etween them# 4 2ataset is a dis!onne!ted ar!hite!ture while datareader is !onne!ted ar!hite!ture# 4 2ataset !an 'ersists !ontents while datareader !an not 'ersist !ontents , the* are "orward onl*# (I)What are ma6or di""eren!e )etween !lassi! $2< and $2<#%&T ? ,ollowing are some ma6or di""eren!es )etween )oth 4 $s in !lassi! $2< we had !lient and ser(er side !ursors the* are no more 'resent in $2<#%&T#%ote itFs a dis!onne!ted model so the* are no more a''li!a)le# 4 Lo! ing is not su''orted due to dis!onne!ted model# 4 $ll data is 'ersisted in CML as !om'ared to !lassi! $2< there where data whi!h was 'ersisted in Binar* "ormat also# (B)What is the use o" !onne!tion o)6e!t ? The* are used to !onne!t a data to a Command o)6e!t# 4 $n <le2)Conne!tion o)6e!t is used with an <L&-2B 'ro(ider ; Wh* do *ou want to lea(e this !om'an* ? (%e(er sa* an*thing negati(e a)out *our 'ast !om'an*) >MB 4 $ S=lConne!tion o)6e!t uses Ta)ular 2ata Ser(i!es (T2S) with MS S\L Ser(er (B)What is the use o" !ommand o)6e!ts and what are the methods 'ro(ided )* the !ommand o)6e!t ? The* are used to !onne!t !onne!tion o)6e!t to 2atareader or dataset#,ollowing are the methods 'ro(ided )* !ommand o)6e!t :4 &-e!ute%on\uer* :- &-e!utes the !ommand de"ined in the CommandTe-t 'ro'ert* against the !onne!tion de"ined in the Conne!tion 'ro'ert* "or a =uer* that does not return an* rows (an GE2$T&, 2&L&T& or I%S&+T)#+eturns an Integer indi!ating the num)er o" rows a""e!ted )* the =uer*# 4 &-e!ute+eader :- &-e!utes the !ommand de"ined in the CommandTe-t 'ro'ert* against the !onne!tion de"ined in the Conne!tion 'ro'ert*# +eturns a HreaderH o)6e!t that is !onne!ted to the resulting rowset within the data)ase, allowing the rows to )e retrie(ed# 4 &-e!uteS!alar :- &-e!utes the !ommand de"ined in the CommandTe-t 'ro'ert* against the !onne!tion de"ined in the Conne!tion 'ro'ert*# +eturns onl* a single (alue (e""e!ti(el* the "irst !olumn o" the "irst row o" the resulting rowset)# $n* other returned !olumns and rows are dis!arded# ,ast and e""i!ient when

onl* a HsingletonH (alue is re=uired (B)What is the use o" dataada'ter ? These are o)6e!ts that !onne!t one or more Command o)6e!ts to a 2ataset o)6e!t##The* 'ro(ide logi! that gets the data "rom the data store and 'o'ulates the ta)les in the 2ataSet, or 'ushes the !hanges in the 2ataSet )a! into the data store# 4 $n <le2)2ata$da'ter o)6e!t is used with an <L&-2B 'ro(ider 4 $ S=l2ata$da'ter o)6e!t uses Ta)ular 2ata Ser(i!es with MS S\L Ser(er# (B)What are )asi! methods o" 2ataada'ter ? There are three most !ommonl* used methods o" 2ataada'ter :,ill :- &-e!utes the Sele!tCommand to "ill the 2ataSet o)6e!t with data "rom the data sour!e# Can also )e used to u'date (re"resh) an e-isting ta)le in a 2ataSet with !hanges ; $uthor has Intentionall* mar ed all 2ata)ase =uestions as Basi! )eli(e me not answering them will not gi(e a good im'ression during inter(iews# >MA made to the data in the original datasour!e i" there is a 'rimar* e* in the ta)le in the 2ataSet# ,illS!hema :- Gses the Sele!tCommand to e-tra!t 6ust the s!hema "or a ta)le "rom the data sour!e, and !reates an em't* ta)le in the 2ataSet o)6e!t with all the !orres'onding !onstraints# G'date:- Calls the res'e!ti(e InsertCommand, G'dateCommand, or 2eleteCommand "or ea!h inserted, u'dated,or deleted row in the 2ataSet so as to u'date the original data sour!e with the !hanges made to the !ontent o" the 2ataSet# This is a little li e the G'dateBat!h method 'ro(ided )* the $2< +e!ordset o)6e!t, )ut in the 2ataSet it !an )e used to u'date more than one ta)le# (B)What is 2ataset o)6e!t? The 2ataSet 'ro(ides the )asis "or dis!onne!ted storage and mani'ulation o" relational data# We "ill it "rom a data store,wor with it while dis!onne!ted "rom that data store, then re!onne!t and "lush !hanges )a! to the data store i" re=uired# (B)What are the (arious o)6e!ts in 2ataset ? 2ataset has a !olle!tion o" 2ataTa)le o)6e!t within the Ta)les !olle!tion# &a!h 2ataTa)le o)6e!t !ontains a !olle!tion o" 2ata+ow o)6e!ts and a !olle!tion o" 2ataColumn o)6e!ts# There are also !olle!tions "or the 'rimar* e*s,!onstraints, and de"ault (alues used in this ta)le whi!h is !alled as !onstraint !olle!tion, and the 'arent and !hild relationshi's )etween the ta)les#,inall*, there is a 2e"ault.iew o)6e!t "or ea!h ta)le# This is used to !reate a 2ata.iew o)6e!t )ased on the ta)le, so that the data !an )e sear!hed, "iltered or otherwise mani'ulated while dis'la*ing the data# %ote :- Loo )a! again to the main diagram "or $2<#%&T ar!hite!ture "or (isuali7ing this answer in 'i!torial "orm (B) ?ow !an we !onne!t to Mi!roso"t $!!ess , ,o-'ro , <ra!le et! ? Mi!roso"t 'ro(ides S*stem#2ata#<le2) names'a!e to !ommuni!ate with data)ases li e $!!ess , ora!le et!#In short an* <L& 2B-Com'liant data)ase !an )e !onne!ted using S*stem#2ata#<ld2) names'a!e#

; %o one !an )e 'er"e!t in #%&T as whole , so when *ou thin *ou do not now the answer admit it , it 'ut8s lot o" / e""e!t# >M0 %ote :- Small sam'le o" <L&2B is 'ro(ided in 9Windows$''<le2): whi!h uses 9%wind#md): in )in dire!tor* to dis'la* data in List)o-# Eri(ate Su) load2ata() 2im strEath $s String strEath V $''2omain#Current2omain#Base2ire!tor* 2im o)6<L&2BCon $s %ew <le2)Conne!tion(9Ero(iderVMi!roso"t#Jet#<L&2B#0#1W2ata Sour!e V: ^ strEath ^ 9%wind#md):) 2im o)6<L&2BCommand $s <le2)Command 2im o)6<L&2B+eader $s <le2)2ata+eader Tr* o)6<L&2BCommand V %ew <le2)Command(9Sele!t ,irst%ame "rom &m'lo*ees:) o)6<L&2BCon#<'en() o)6<L&2BCommand#Conne!tion V o)6<L&2BCon o)6<L&2B+eader V o)6<L&2BCommand#&-e!ute+eader() 2o While o)6<L&2B+eader#+ead() lst%orthwinds#Items#$dd(o)6<L&2B+eader#5etString(1)) Loo' Cat!h e- $s &-!e'tion Throw e,inall* o)6<L&2BCon#Close() &nd Tr* &nd Su) The main heart is the 9Loaddata(): method whi!h a!tuall* loads the data in list)o-# %ote:- This sour!e !ode has the !onne!tionstring har !oded in the 'rogram itsel" whi!h is not a good 'rogramming 'ra!ti!e#,or windows a''li!ation the )est 'la!e to store !onne!tionstring is 9$''#!on"ig:#$lso note 9$''2omain#Current2omain#Base2ire!tor*: "un!tion this gi(es the !urrent 'ath o" the running e-e whi!h is 9BI%: and the M2B "ile is in that dire!tor*#$lso note the "inall* )lo! whi!h e-e!utes irres'e!ti(e that there is error or not#Thus ensuring that all the !onne!tion to the datastore is "reed#It8s )est 'ra!ti!e to 'ut all !lean u' statements in "inall* )lo! thus ensuring that the resour!es are deallo!ated 'ro'erl*# (B) ?ow do we !onne!t to S\L S&+.&+ , whi!h names'a!e do we use ? ; Where do *ou see *oursel" a"ter three *ears ? >ML Eri(ate Su) Load2ata() X note :- with and end with ma es *our !ode more reada)le 2im strConne!tionString $s String

2im o)6Conne!tion $s %ew S=lConne!tion 2im o)6Command $s %ew S=lCommand 2im o)6+eader $s S=l2ata+eader Tr* X this gets the !onne!tionstring "rom the a''#!on"ig "ile# X note i" this gi(es error see where the M2B "ile is stored in *our '! and 'oint to that strConne!tionString V $''Settings#Item(9Conne!tionString:) X ta e the !onne!tiostring and initiali7e the !onne!tion o)6e!t With o)6Conne!tion #Conne!tionString V strConne!tionString #<'en() &nd With o)6Command V %ew S=lCommand(9Sele!t ,irst%ame "rom &m'lo*ees:) With o)6Command #Conne!tion V o)6Conne!tion o)6+eader V #&-e!ute+eader() &nd With X loo'ing through the reader to "ill the list )o2o While o)6+eader#+ead() lst2ata#Items#$dd(o)6+eader#Item(9,irst%ame:)) Loo' Cat!h e- $s &-!e'tion Throw e,inall* o)6Conne!tion#Close() &nd Tr* Ta''SettingsU Tadd e*V:Conne!tionstring: (alueV:Ser(erV&+MB<M>-ITBWGser I2VsaW2ata)aseV&m'lo*ees:OU TOa''SettingsU %ote:- The a)o(e !ode is 'ro(ided in C2 in "older Windows$''S=lClient:#Comments in the !ode do e-'lain a lot )ut we will again iterate through the whole !ode later##:Load2ata: is the main method whi!h loads the data "rom S\L S&+.&+#Be"ore running this !ode *ou ha(e to install S\L S&+.&+ in *our ma!hine#$s we are dealing ; What are *our negati(e 'oints ? (Care"ul gu*8s) >M3 with S\LCLI&%T we need to setu' data)ase in S\L S&+.&+#,or this sam'le i ha(e im'orted a!!ess 9%wind#md): in 9Sam'le$!!ess2ata)ase: "older in C2 in to

S\lS&+.&+#2e'ending on !om'uter *ou will also ha(e to !hange the !onne!tionstring in We)#!on"ig "ile# We !an use the 2TS im'ort wi7ard to im'ort#See the )elow "igure whi!h is using data sour!e as Mi!roso"t $!!ess#While im'orting the data)ase author had gi(e the data)ase name as 9&m'lo*ees:# ,igure:- D#B Loading 9%wind#md): in S\L S&+.&+ "or the sam'le ; $re *ou !om"orta)le with lo!ation shi"t ? I" *ou ha(e 'ersonal 'ro)lems sa* no right at the "irst stage#### or else a"ter 6oining surel* *ou will re'ent# >MM ,igure :- D#A Load onl* the &m'lo*ee ta)le# ,or sim'li!it* sa e we will onl* im'ort the em'lo*ee ta)le as thats the onl* thing needed in our sam'le !ode# ; 2o *ou wor during late night8s ?#Best answer i" there is 'ro6e!t deadline *es#2o not show that it8s *our !ulture to wor during nights# >M@ ,igure :- D#0 .iew o" loaded &m'lo*ee ta)le %ow "rom inter(iew 'oint o" (iew de"initel* *ou are not going to sa* the whole sour!e !ode whi!h is gi(en in )oo #Inter(iewer e-'e!ts onl* the )roader answer o" what are the ste's needed to !onne!t to S\L S&+.&+#,or "undamental sa e author has e-'lained the whole sour!e !ode#In short *ou ha(e to e-'lain the 9Load2ata: method in )roader wa*#,ollowing are the ste's to !onne!t to S\L S&+.&+ :4 ,irst is im'ort the names'a!e 9S*stem#2ata#S=lClient:# 4 Create a !onne!tion o)6e!t as shown in 9Load2ata: method# With o)6Conne!tion #Conne!tionString V strConne!tionString #<'en() &nd With 4 Create the !ommand o)6e!t with the S\L#$lso assign the !reated !onne!tion o)6e!t to !ommand o)6e!t# and e-e!ute the reader# ; $n* s'e!ial a!hei(ements in *our li"e till now###tell *our )est 'ro6e!t whi!h *ou ha(e done )est in *our !areer # >MD o)6Command V %ew S=lCommand(9Sele!t ,irst%ame "rom &m'lo*ees:) With o)6Command #Conne!tion V o)6Conne!tion o)6+eader V #&-e!ute+eader() &nd With 4 ,inall* loo' through the reader and "ill the list )o-#I" old .B 'rogrammers are e-'e!ting the mo(ene-t !ommand it8s re'la!ed )* +ead() whi!h returns true i" there is an* data to )e read#I" the #+ead() return8s "alse that means that it8s end o" datareader and there is no more data to )e read# 2o While o)6+eader#+ead() lst2ata#Items#$dd(o)6+eader#Item(9,irst%ame:))

Loo' 4 ,inall* do not "orget to !lose the !onne!tion o)6e!t# %ote:- In 9Load2ata: *ou will see that !onne!tionstring is stored in We)#!on"ig "ile and is loaded using 9$''Settings#Item(9Conne!tionString:):#While running this sam'le li(e on *our data)ase do not "orget to !hange this !onne!tionstring a!!ordingl* or else the sour!e !ode will not run# (B) ?ow do we use stored 'ro!edure in $2<#%&T and how do we 'ro(ide 'arameters to the stored 'ro!edures? $2<#%&T 'ro(ides the S=lCommand o)6e!t whi!h 'ro(ides the "un!tionalit* o" e-e!uting stored 'ro!edures# %ote :- Sam'le !ode is 'ro(ided in "older 9WindowsS=lClientCommand:#There are two stored 'ro!edures !reated in same data)ase 9&m'lo*ees: whi!h was !reated "or the 're(ious =uestion# C+&$T& E+<C&2G+& Sele!tB*&m'lo*ee `,irst%ame n(ar!har(B11) $S Sele!t ,irst%ame "rom &m'lo*ees where ,irst%ame li e `,irst%ame / F_F C+&$T& E+<C&2G+& Sele!t&m'lo*ee $S Sele!t ,irst%ame "rom &m'lo*ees I" t-t&m'lo*ee%ame#Te-t#Length V 1 Then o)6Command V %ew S=lCommand(9Sele!t&m'lo*ee:) &lse ; $re *ou loo ing "or onsite o''urtunites ? (Be !are"ul do not show *our des'eration o" a)road 6ourne*s) >@1 o)6Command V %ew S=lCommand(9Sele!tB*&m'lo*ee:) o)6Command#Earameters#$dd(9`,irst%ame:, 2ata#S=l2)T*'e#%.arChar, B11) o)6Command#Earameters#Item(9`,irst%ame:)#.alue V t-t&m'lo*ee%ame#Te-t#Trim() &nd I" In the a)o(e sam'le not lot has )een !hanged onl* that the S\L is mo(ed to the stored 'ro!edures#There are two stored 'ro!edures one os 9Sele!t&m'lo*ee: whi!h sele!ts all the em'lo*ees and the other is 9Sele!tB*&m'lo*ee: whi!h returns em'lo*ee name starting with a s'e!i"i! !hara!ter#$s *ou !an see to 'ro(ide 'arameters to the stored 'ro!edures we are using the 'arameter o)6e!t o" the !ommand o)6e!t#In su!h =uestion inter(iewer e-'e!ts two sim'le answers one is that we use !ommand o)6e!t to e-e!ute stored 'ro!edures and the 'arameter o)6e!t to 'ro(ide 'arameter to the stored 'ro!edure#$)o(e sam'le is 'ro(ided onl* "or getting the a!tual "eel o" it# (B) ?ow !an we "or!e the !onne!tion o)6e!t to !lose a"ter m* datareader is !losed ? Command method &-e!utereader ta es a 'arameter !alled as CommandBeha(ior where in we !an s'e!i"* sa*ing !lose !onne!tion automati!all* a"ter the 2atareader is !lose# 'o)62ata+eader V 'o)6Command#&-e!ute+eader(CommandBeha(ior#CloseConne!tion)

(B) I want to "or!e the datareader to return onl* s!hema o" the datastore rather than data ? 'o)62ata+eader V 'o)6Command#&-e!ute+eader(CommandBeha(ior#S!hema<nl*) (B) ?ow !an we "ine tune the !ommand o)6e!t when we are e-'e!ting a single row or a single (alue ? $gain CommandBeha(iour enumeration 'ro(ides two (alues Single+esult and Single+ow#I" *ou are e-'e!ting a single (alue then 'ass 9CommandBeha(iour#Single+esult: and the =uer* is o'timi7ed a!!ordingl* , i" *ou are e-'e!ting single row then 'ass 9CommandBeha(iour#Single+ow: and =uer* is o'timi7ed a!!ording to single row# (B) Whi!h is the )est 'la!e to store !onne!tionstring in #%&T 'ro6e!ts ? ; Wh* ha(e *ou !hanged so man* 6o)s ? (Ere'are a de!ent answer do not )lame !om'anies and indi(idiuals "or *our "re=uent !hange) >@> Con"ig "iles are the )est 'la!e to store !onne!tion strings#I" it8s a we)-)ased a''li!ation 9We)#!on"ig: "ile will )e used and i" it8s a windows a''li!ation 9$''#!on"ig: "iles will )e used# (B) What are ste's in(ol(ed to "ill a dataset ? Twist :- ?ow !an we use dataada'ter to "ill a dataset ? Sam'le !ode is 'ro(ided in 9Windows2ataSetSam'le: "older in C2#:Load2ata: has all the im'lementation o" !onne!ting and loading to dataset#This dataset is "inall* )inded to a ListBo-#Below is the sam'le !ode# Eri(ate Su) Load2ata() 2im strConne!tionString $s String strConne!tionString V $''Settings#Item(9Conne!tionString:) 2im o)6Conn $s %ew S=lConne!tion(strConne!tionString) o)6Conn#<'en() 2im o)6Command $s %ew S=lCommand(9Sele!t ,irst%ame "rom &m'lo*ees:) o)6Command#Conne!tion V o)6Conn 2im o)62ata$da'ter $s %ew S=l2ata$da'ter() o)62ata$da'ter#Sele!tCommand V o)6Command 2im o)62ataSet $s %ew 2ataSet &nd Su) In su!h t*'e o" =uestion8s inter(iewer is loo ing "rom 'ra!ti!al angle , that ha(e *ou wor ed with dataset and datada'ters#Let me tr* to e-'lain the a)o(e !ode "irst and then we mo(e to what ste's to sa* suring inter(iew# 2im o)6Conn $s %ew S=lConne!tion(strConne!tionString) o)6Conn#<'en() ,irst ste' is to o'en the !onne!tion#$gain note the !onne!tion string is loaded "rom !on"ig "ile# 2im o)6Command $s %ew S=lCommand(9Sele!t ,irst%ame "rom &m'lo*ees:) o)6Command#Conne!tion V o)6Conn

Se!ond ste' is to !reate a !ommand o)6e!t with a''ro'riate S\L and set the !onne!tion o)6e!t to this !ommand# 2im o)62ata$da'ter $s %ew S=l2ata$da'ter() ; $n* 'lans o" o'ening *our own so"tware !om'an*###Beware do not start 'ouring *our )illgate8s dream to him#####!an lead to a serious situation# >@B o)62ata$da'ter#Sele!tCommand V o)6Command Third ste's is to !reate the $da'ter o)6e!t and 'ass the !ommand o)6e!t to the ada'ter o)6e!t# o)62ata$da'ter#,ill(o)62ataSet) ,ourth ste' is to load the dataset using the 9,ill: method o" the dataada'ter# lst2ata#2ataSour!e V o)62ataSet#Ta)les(1)#2e"ault.iew lst2ata#2is'la*Mem)er V 9,irst%ame: lst2ata#.alueMem)er V 9,irst%ame: ,i"th ste' is to )ind to the loaded dataset with the 5GI#$t this moment sam'le has list)o- as the GI#Binding o" the GI is done )* using 2e"ault.iew o" the dataset#Just to re(ise e(er* dataset has ta)les and e(er* ta)le has (iews#In this sam'le we ha(e onl* loaded one ta)le i#e# &m'lo*ees ta)le so we are re"erring that with a inde- o" 7ero# Just sa* all the "i(e ste's during inter(iew and *ou will see the smile in the inter(iewer8s "a!e# (B)What are the (arious methods 'ro(ided )* the dataset o)6e!t to generate CML? %ote:- CML is one o" the most im'ortant lea' )etween !lassi! $2< and $2<#%&T#So this =uestion is normall* as ed more generall* how !an we !on(ert an* data to CML "ormat#Best answer is !on(ert in to dataset and use the )elow methods# 4 +eadCML +ead8s a CML do!ument in to 2ataset# 4 5etCML This is "un!tion8s whi!h return8s a string !ontaining CML do!ument# 4 WriteCML This write8s a CML data to dis # (B) ?ow !an we sa(e all data "rom dataset ? >@A 2ataset has 9$!!e'tChanges: method whi!h !ommits all the !hanges sin!e last time 9$!!e't!hanges: has )een e-e!uted# %ote :- This )oo does not ha(e an* sam'le o" $!!e't!hanges#I lea(e that to reader8s as homewor sam'le#But *es "rom inter(iew as'e!t that will )e enough# (B) ?ow !an we !he! that some !hanges ha(e )een made to dataset sin!e it was loaded ? Twist :- ?ow !an !an!el all !hanges done in dataset ? , ?ow do we get !hanged (alue dataset ? ,or tra! ing down !hanges 2ataset has two methods whi!h !omes as res!ue 95etChanges 9and 9?asChanges:#

5etChanges +eturn8s dataset whi!h are !hanged sin!e it was loaded or sin!e $!!e't!hanges was e-e!uted# ?asChanges This 'ro'ert* indi!ate8s has an* !hange8s )een made sin!e the dataset was loaded or a!!e't!hanges method was e-e!uted# I" we want to re(ert or a)andon all !hange8s sin!e the dataset was loaded use 9+e6e!tChanges:# %ote:- <ne o" the most misunderstood things a)out these 'ro'erties is that it tra! s the !hanges o" a!tual data)ase#That8s a "undamental mista e , a!tuall* the !hanges are related to onl* !hanges with dataset and has nothing to with !hanges ha''ening in a!tual data)ase#$s dataset are dis!onne!ted and do not now an*thing a)out the !hanges ha''ening in a!tual data)ase# (B) ?ow addOremo(e row8s in 92ataTa)le: o)6e!t o" 92ataSet: ? 92atata)le: 'ro(ides 9%ew+ow: method to add new row to 92ataTa)le:#:2ataTa)le: has 92ata+owColle!tion: o)6e!t whi!h has all rows in a 92ataTa)le: o)6e!t#,ollowing are the methods 'ro(ided )* 92ata+owColle!tion: o)6e!t :>@0 $dd $dd8s a new row in 2ataTa)le +emo(e +emo(e8s a 92ata+ow: o)6e!t "rom 92ataTa)le: +emo(e$t +emo(e8s a 92ata+ow: o)6e!t "rom 92ataTa)le: de'ending on inde- 'osition o" the 92ataTa)le:# (B) What8s )asi! use o" 92ata.iew: ? 92ata.iew: re'resent8s a !om'lete ta)le or !an )e small se!tion o" row8s de'ending on some !riteria#It8s )est used "or sorting and "inding data with in 9datata)le:# 2ata(iew has the "ollowing method8s :,ind Ta e8s a arra* o" (alue8s and return8s the inde- o" the row# ,ind+ow This also ta es arra* o" (alues )ut returns a !olle!tion o" 92ata+ow:# I" we want to mani'ulate data o" 92ataTa)le: o)6e!t !reate 92ata.iew: (Gsing the 92e"ault.iew: we !an !reate 92ata.iew: o)6e!t) o" the 92ataTa)le: o)6e!t# and use the "ollowing "un!tionalities :$dd%ew $dd8s a new row to the 92ata.iew: o)6e!t# >@L 2elete 2eletes the s'e!i"ied row "rom 92ata.iew: o)6e!t# (B) What8s di""eren!e )etween 92ataSet: and

92ata+eader: ? %ote:- This is m* )est =uestion and i e-'e!t e(er*one to answer it# ,ollowing are the ma6or di""eren!e )etween 92ataSet: and 92ata+eader: :4 92ataSet: is a dis!onne!ted ar!hite!ture , while 92ata+eader: has li(e !onne!tion while reading data#So i" we want to !a!he data and 'ass to a di""erent tier 92ataSet: "orms the )est !hoi!e and it has de!ent CML su''ort# 4 When a''li!ation needs to a!!ess data "rom more than one ta)le 92ataSet: "orms the )est !hoi!e# 4 I" we need to mo(e )a! while reading re!ord8s , 9datareader: does not su''ort this "un!tionalit*# 4 But one o" the )iggest draw)a! s o" 2ataSet is s'eed#$s 92ataSet: !arr* !onsidera)le o(erhead )e!ause o" relations,multi'le ta)les et! s'eed is slower than 92ata+eader:#$lwa*s tr* to use 92ata+eader: wheree(er 'ossi)le# , as it8s meant s'e!iall* "or s'eed 'er"orman!e# (B) ?ow !an we load multi'le ta)les in a 2ataSet ? o)6Command#CommandTe-t V HTa)le>H o)62ata$da'ter#,ill(o)62ataSet, HTa)le>H) o)6Command#CommandTe-t V HTa)leBH o)62ata$da'ter#,ill(o)62ataSet, HTa)leBH) $)o(e is a sam'le !ode whi!h shows how to load multi'le 92ataTa)le: o)6e!t8s in one 92ataSet: o)6e!t#Sam'le !ode shows two ta)les 9Ta)le>: and 9Ta)leB: in o)6e!t <)62ataSet# lstdata#2ataSour!e V o)62ataSet#Ta)les(HTa)le>H)#2e"ault.iew In order to re"er 9Ta)le>: 2ataTa)le , use Ta)les !olle!tion o" 2ataSet and the 2e"ault(iew o)6e!t will gi(e *ou the ne!essar* out'ut# >@3 (B) ?ow !an we add relation8s )etween ta)le in a 2ataSet ? 2im o)6+elation $s 2ata+elation o)6+elationV%ew 2ata+elation(HCustomer$ddressesH,o)62ataSet#Ta)les(HCustomerH)#Columns(HCustidH) ,o)62ataSet#Ta)les(H$ddressesH)#Columns(HCustidQ" H)) o)62ataSet#+elations#$dd(o)6+elation) +elation8s !an )e added )etween 92ataTa)le: o)6e!t8s using the 92ata+elation: o)6e!t#$)o(e sam'le !ode is tr*ing to )uild a relationshi' )etween 9Customer: and 9$ddresses: 92atata)le: using 9Customer$ddresses: 92ata+elation: o)6e!t# (B) What8s the use o" CommandBuilder ? CommandBuilder )uilds 9Earameter: o)6e!ts automati!all*#Below is a sim'le !ode whi!h uses !ommand)uilder to load its 'arameter o)6e!t8s# 2im 'o)6CommandBuilder $s %ew <le2)CommandBuilder('o)62ata$da'ter) 'o)6CommandBuilder#2eri(eEarameters('o)6Command) Be !are"ul while using 92eri(eEarameters: method as it needs a e-tra tri' to the 2atastore whi!h !an )e (er* ine""i!ient#

(B) What8s di""eren!e )etween 9<'timisti!: and 9Eessimisti!: lo! ing ? In 'essimisti! lo! ing when user wants to u'date data it lo! s the re!ord and till then no one !an u'date data#<ther user8s !an onl* (iew the data when there is 'essimisti! lo! ing# In o'timisti! lo! ing multi'le user8s !an o'en the same re!ord "or u'dating , thus in!rease ma-imum !on!urren!*#This is the most 're"erred wa* o" lo! ing 'ra!ti!all*#%ow a da*s )rowser )ased a''li!ation are (er* !ommon and ha(ing 'essimisti! lo! ing is not a 'ra!ti!al solution# >@M ($) ?ow man* wa*8s are there to im'lement lo! ing in $2<#%&T ? ,ollowing are the wa*s to im'lement lo! ing using $2<#%&T :4 When we !all 9G'date: method o" 2ata$da'ter it handles lo! ing internall*#I" the 2ataSet (alues are mot mat!hing with !urrent data in 2ata)ase it raises Con!urren!* e-!e'tion error#We !an easil* tra' this error using Tr*##Cat!h )lo! and raise a''ro'riate error message to the user# 4 2e"ine a 2atetime stam' "ield in the ta)le#When a!tuall* *ou are "iring the GE2$T& S\L statements !om'are the !urrent timestam' with one e-isting in the data)ase#Below is a sam'le S\L whi!h !he! s "or timestam' )e"ore u'dating and an* mismat!h in timestam' it will not u'date the re!ords#This is the )est 'ra!ti!e used )* industries "or lo! ing# G'date ta)le> set "ield>V`test where LastTimeStam'V`CurrentTimeStam' 4 Che! "or original (alues stored in S\L S&+.&+ and a!tual !hanged (alues#In stored 'ro!edure !he! )e"ore u'dating that the old data is same as the !urrent#&-am'le in the )elow shown S\L )e"ore u'dating "ield> we !he! that is the old "ield> (alue same#I" not then some one else has u'dated and ne!essar* a!tion has to )e ta en# G'date ta)le> set "ield>V`test where "ield> V `old"ield>(alue Lo! ing !an )e handled at $2<#%&T side or at S\L S&+.&+ side i#e# in stored 'ro!edures#"or more details o" how to im'lementing lo! ing in S\L S&+.&+ read 9What are di""erent lo! s in S\L S&+.&+ ?: in S\L S&+.&+ !ha'ter# %ote:- This is one o" the "a(orite =uestion8s o" inter(iewer , so !ram it####When i sa* !ram it i do not mean it#### i mean understand it#This )oo has tried to !o(er $2<#%&T as mu!h as 'ossi)le , )ut indeterminist nature o" $2<#%&T inter(iew =uestion8s ma es it di""i!ult to ma e "ull 6usti!e#But ho'e so that the a)o(e =uestion8s will ma e *ou =uiet !on"ident during inter(iews# ($)?ow !an we 'er"orm transa!tions in #%&T? The most !ommon se=uen!e o" ste's that would )e 'er"ormed while de(elo'ing a transa!tional a''li!ation is as "ollows: >@@ 4 <'en a data)ase !onne!tion using the <'en method o" the !onne!tion o)6e!t# 4 Begin a transa!tion using the Begin Transa!tion method o" the !onne!tion o)6e!t# This method 'ro(ides us with a transa!tion o)6e!t that we will use

later to !ommit or roll)a! the transa!tion# %ote that !hanges !aused )* an* =ueries e-e!uted )e"ore !alling the Begin Transa!tion method will )e !ommitted to the data)ase immediatel* a"ter the* e-e!ute#Set the Transa!tion 'ro'ert* o" the !ommand o)6e!t to the a)o(e mentioned transa!tion o)6e!t# 4 &-e!ute the S\L !ommands using the !ommand o)6e!t# We ma* use one or more !ommand o)6e!ts "or this 'ur'ose, as long as the Transa!tion 'ro'ert* o" all the o)6e!ts is set to a (alid transa!tion o)6e!t# 4 Commit or roll )a! the transa!tion using the Commit or +oll)a! method o" the transa!tion o)6e!t# 4 Close the data)ase !onne!tion# (I)What8s di""eren!e )etween 2ataset# !lone and 2ataset# !o'* ? Clone: - It onl* !o'ies stru!ture, does not !o'* data# Co'*: - Co'ies )oth stru!ture and data# ($)Can *ou e-'lain the di""eren!e )etween an $2<#%&T 2ataset and an $2< +e!ordset? There two main )asi! di""eren!es )etween re!ordset and dataset :4 With dataset *ou an retrie(e data "rom two data)ases li e ora!le and s=l ser(er and merge them in one dataset , with re!ordset this is not 'ossi)le 4 $ll re'resentation o" 2ataset is using CML while re!ordset uses C<M# 4 +e!ordset !an not )e transmitted on ?TTE while 2ataset !an )e#

S\L S&+.&+
(B) What is normali7ation? What are di""erent t*'e o" normali7ation? %ote :- $ regular #%&T 'rogrammer wor ing on 'ro6e!ts o"ten stum)les in this =uestion ,whi!h is )ut o)(ious#Bad 'art is sometimes inter(iewer !an ta e this as a (er* )asi! =uestion to )e answered and it !an )e a turning 'oint "or the inter(iew#So letFs !ram it# It is set o" rules that has )een esta)lished to aid in the design o" ta)les that are meant to )e !onne!ted through relationshi's# This set o" rules is nown as %ormali7ation# Bene"its o" %ormali7ing *our data)ase in!lude: 4 $(oiding re'etiti(e entries 4 +edu!ing re=uired storage s'a!e 4 Ere(enting the need to restru!ture e-isting ta)les to a!!ommodate new data# 4 In!reased s'eed and "le-i)ilit* o" =ueries, sorts, and summaries# %ote :- 2uring inter(iew 'eo'le e-'e!t to answer ma-imum o" three normal "orms and thats what is e-'e!ted 'ra!ti!all*#$!tuall* *ou !an normali7e data)ase to "i"th normal "orm#But )elie(e this )oo answering three normal "orms will 'ut *ou in de!ent sha'e during inter(iew# ,ollowing are the three normal "orms :,irst %ormal ,orm

,or a ta)le to )e in "irst normal "orm, data must )e )ro en u' into the smallest units 'ossi)le#In addition to )rea ing data u' into the smallest meaning"ul (alues, ta)les in "irst normal "orm should not !ontain re'etitions grou's o" "ields# >1# S\L S&+.&+ >D1 ,igure :- >1#> +e'eating grou's e-am'le ,or in the a)o(e e-am'le !it*> and !it*B are re'eating#In order this ta)le to )e in ,irst normal "orm *ou ha(e to modi"* the ta)le stru!ture as "ollows#$lso not that the Customer %ame is now )ro en down to "irst name and last name (,irst normal "orm data should )e )ro en down to smallest unit)# ,igure :- >1#B Customer ta)le normali7ed to "irst normal "orm Se!ond %ormal "orm The se!ond normal "orm states that ea!h "ield in a multi'le "ield 'rimar* e*ta)le must )e dire!tl* related to the entire 'rimar* e*# <r in other words,ea!h non- e* "ield should )e a "a!t a)out all the "ields in the 'rimar* e*# In the a)o(e ta)le o" !ustomer , !it* is not lin ed to an* 'rimar* "ield# ,igure :- >1#A %ormali7ed !ustomer ta)le# >D> ,igure :- >1#0 Cit* is now shi"ted to a di""erent master ta)le# That ta es our data)ase to a se!ond normal "orm# Third normal "orm $ non- e* "ield should not de'end on other %on- e* "ield#The "ield HTotalH is de'endent on HGnit 'ri!eH and H=t*H# ,igure :- >1#L ,ill third normal "orm So now the HTotalH "ield is remo(ed and is multi'li!ation o" Gnit 'ri!e ; \t*# %ote :- ,ourth and ,i"th normal "orm is le"t as a home wor to users# (B)What is denormali7ation ? 2enormali7ation is the 'ro!ess o" 'utting one "a!t in numerous 'la!es (its (i!e-(ersa o" normali7ation)#<nl* one (alid reason e-ists "or denormali7ing a relational design - to enhan!e 'er"orman!e#The sa!ri"i!e to 'er"orman!e is that *ou in!rease redundan!* in data)ase# (B)What is a !andidate e* ? $ ta)le ma* ha(e more than one !om)ination o" !olumns that !ould uni=uel* identi"* the rows in a ta)leW ea!h !om)ination is a !andidate e*# 2uring data)ase design *ou !an 'i! u' one o" the !andidate e*s to )e the 'rimar* e*# ,or e-am'le, in the su''lier ta)le >DB su''lierid and su''liername !an )e !andidate e* )ut *ou will onl* 'i! u' su''lierid as the 'rimar* e*# (B) What are di""erent t*'es o" 6oins and whats the di""eren!e )etween them ? I%%&+ J<I% Inner 6oin shows mat!hes onl* when the* e-ist in )oth ta)les#&-am'le in the )elow S\L there are two ta)les Customers and <rders and the inner 6oin in made on Customers

Customerid and <rders Customerid#So this S\L will onl* gi(e *ou result with !ustomers who ha(e orders#I" the !ustomer does not ha(e order it will not dis'la* that re!ord# S&L&CT Customers#;, <rders#; ,+<M Customers I%%&+ J<I% <rders <% Customers#CustomerI2 V<rders#CustomerI2 L&,T <GT&+ J<I% Le"t 6oin will dis'la* all re!ords in le"t ta)le o" the S\L statement#In S\L )elow !ustomers with or without orders will )e dis'la*ed# <rder data "or !ustomers without orders a''ears as %GLL (alues# ,or e-am'le, *ou want to determine the amount ordered )* ea!h !ustomer and *ou need to see who has not ordered an*thing as well# Kou !an also see the L&,T <GT&+ J<I% as a mirror image o" the +I5?T <GT&+ J<I% (Is !o(ered in the ne-t se!tion) i" *ou swit!h the side o" ea!h ta)le# S&L&CT Customers#;, <rders#; ,+<M Customers L&,T <GT&+ J<I% <rders <% Customers#CustomerI2 V<rders#CustomerI2 +I5?T <GT&+ J<I% +ight 6oin will dis'la* all re!ords in right ta)le o" the S\L statement#In S\L )elow all orders with or without mat!hing !ustomer re!ords will )e dis'la*ed# Customer data "or orders without !ustomers a''ears as %GLL (alues# ,or e-am'le, *ou want to determine i" there are an* orders in the data with unde"ined CustomerI2 (alues (sa*, a"ter a !on(ersion or something li e it)# Kou !an also see the +I5?T <GT&+ J<I% as a mirror image o" the L&,T <GT&+ J<I% i" *ou swit!h the side o" ea!h ta)le# S&L&CT Customers#;, <rders#; ,+<M Customers +I5?T <GT&+ J<I% <rders <% Customers#CustomerI2 V<rders#CustomerI2 >DA (I)What are inde-es and What is the di""eren!e )etween !lustered and non!lustered inde-es? Inde-es in S\L Ser(er are similar to the inde-es in )oo s# The* hel' S\L Ser(er retrie(e the data =ui! er There are !lustered and non!lustered inde-es# $ !lustered inde- is a s'e!ial t*'e o" indethat reorders the wa* re!ords in the ta)le are 'h*si!all* stored# There"ore ta)le !an ha(e onl* one !lustered inde-# The lea" nodes o" a !lustered inde- !ontain the data 'ages# $ non!lustered inde- is a s'e!ial t*'e o" inde- in whi!h the logi!al order o" the indedoes not mat!h the 'h*si!al stored order o" the rows on dis # The lea" node o" a non!lustered inde- does not !onsist o" the data 'ages# Instead, the lea" nodes !ontain inde- rows# ($)?ow !an *ou in!rease S\L 'er"orman!e ? ,ollowing are ti's whi!h will in!rease *our S\l 'er"orman!e :4 &(er* inde- in!reases the time in ta es to 'er"orm I%S&+TS, GE2$T&S and 2&L&T&S, so the num)er o" inde-es should not )e (er* mu!h# Tr* to use ma-imum 0-L inde-es on one ta)le, not more# I" *ou ha(e read-onl* ta)le, then the num)er o" inde-es ma* )e in!reased# 4 Jee' *our inde-es as narrow as 'ossi)le# This redu!es the si7e o" the indeand redu!es the num)er o" reads re=uired to read the inde-# 4 Tr* to !reate inde-es on !olumns that ha(e integer (alues rather than !hara!ter

(alues# 4 I" *ou !reate a !om'osite (multi-!olumn) inde-, the order o" the !olumns in the e* are (er* im'ortant# Tr* to order the !olumns in the e* as to enhan!e sele!ti(it*, with the most sele!ti(e !olumns to the le"tmost o" the e*# 4 I" *ou want to 6oin se(eral ta)les, tr* to !reate surrogate integer e*s "or this 'ur'ose and !reate inde-es on their !olumns# >D0 4 Create surrogate integer 'rimar* e* (identit* "or e-am'le) i" *our ta)le will not ha(e man* insert o'erations# 4 Clustered inde-es are more 're"era)le than non!lustered, i" *ou need to sele!t )* a range o" (alues or *ou need to sort results set with 5+<GE BK or <+2&+ BK# 4 I" *our a''li!ation will )e 'er"orming the same =uer* o(er and o(er on the same ta)le, !onsider !reating a !o(ering inde- on the ta)le# 4 Kou !an use the S\L Ser(er Ero"iler Create Tra!e Wi7ard with HIdenti"* S!ans o" Large Ta)lesH tra!e to determine whi!h ta)les in *our data)ase ma* need inde-es# This tra!e will show whi!h ta)les are )eing s!anned )* =ueries instead o" using an inde-# ($)What is the use o" <L$E ? <L$E is use"ul )e!ause it 'ro(ides "ast and intera!ti(e a!!ess to aggregated data and the a)ilit* to drill down to detail# ($)WhatFs a measure in <L$E ? Measures are the e* 'er"orman!e indi!ators that *ou want to e(aluate# To determine whi!h o" the num)ers in the data might )e measures, a rule o" thum) is: I" a num)er ma es sense when it is aggregated, then it is a measure# ($)What are dimensions in <L$E ? 2imensions are the !ategories o" data anal*sis#,or e-am'le, in a re(enue re'ort )* month )* sales region, the two dimensions needed are time and sales region#T*'i!al dimensions in!lude 'rodu!t, time, and region# ($)What are le(els in dimensions ? 2imensions are arranged in hierar!hi!al le(els, with uni=ue 'ositions within ea!h le(el# ,or e-am'le, a time dimension ma* ha(e "our le(els, su!h as Kear, \uarter, Month, and 2a*# <r the dimension might ha(e onl* three le(els, "or e-am'le, Kear, Wee , and 2a*# The (alues within the le(els are !alled mem)ers# ,or e-am'le, the *ears B11B and B11A are mem)ers o" the le(el Kear in the Time dimension# >DL ($)What are "a!t ta)les and dimension ta)les in <L$E ? Twist :- !an *ou e-'lain the star s!hema "or <L$E ? The dimensions and measures are 'h*si!all* re'resented )* a star s!hema#2imension ta)les re(ol(e around "a!t ta)le# $ "a!t ta)le !ontains a !olumn "or ea!h measure as well as a !olumn "or ea!h dimension# &a!h dimension !olumn has a "oreign- e* relationshi' to the related dimension ta)le, and the dimension !olumns ta en together are the e* to the "a!t ta)le#

($)What is 2TS? 2TS is used to 'ull data "rom (arious sour!es into the star s!hema# ($)What is "ill"a!tor ? Twist :- When does 'lage s'lit o!!urs ? The F"ill "a!torF o'tion s'e!i"ies how "ull S\L Ser(er will ma e ea!h inde- 'age# When there is no "ree s'a!e to insert new row on the inde- 'age, S\L Ser(er will !reate new inde- 'age and trans"er some rows "rom the 're(ious 'age to the new one# This o'eration is !alled 'age s'lits# Kou !an redu!e the num)er o" 'age s'lits )* setting the a''ro'riate "ill "a!tor o'tion to reser(e "ree s'a!e on ea!h inde- 'age# The "ill "a!tor is a (alue "rom > through >11 that s'e!i"ies the 'er!entage o" the inde- 'age to )e le"t em't*# The de"ault (alue "or "ill "a!tor is 1# It is treated similarl* to a "ill "a!tor (alue o" >11, the di""eren!e in that S\L Ser(er lea(es some s'a!e within the u''er le(el o" the inde- tree "or ,ILL,$CT<+ V 1# The "ill "a!tor 'er!entage is used onl* at the time the inde- is !reated# I" the ta)le !ontains read-onl* data (or data that (er* rarel* !hanged), *ou !an set the F"ill "a!torF o'tion to >11# When the ta)leFs data modi"ied (er* o"ten, *ou !an de!rease the "ill "a!tor to M1_ or whate(er *ou thin is )est# ($)What is +$I2 and how does it wor ? +edundant $rra* o" Inde'endent 2is s (+$I2) is a term used to des!ri)e the te!hni=ue o" im'ro(ing data a(aila)ilit* through the use o" arra*s o" dis s and (arious data-stri'ing methodologies# 2is arra*s are grou's o" dis dri(es that wor together to a!hie(e higher data-trans"er and IO< rates than those 'ro(ided )* single large dri(es# $n arra* is a set o" multi'le dis dri(es 'lus a s'e!iali7ed !ontroller (an arra* !ontroller) that ee's tra! o" how data is distri)uted a!ross the dri(es# 2ata "or a 'arti!ular "ile is written in segments to the di""erent dri(es in the arra* rather than )eing written to a single dri(e# >D3 ,or s'eed and relia)ilit*, itFs )etter to ha(e more dis s# When these dis s are arranged in !ertain 'atterns and use a s'e!i"i! !ontroller, the* are !alled a +edundant $rra* o" Ine-'ensi(e 2is s (+$I2) set# There are se(eral num)ers asso!iated with +$I2, )ut the most !ommon are >, L and >1# +$I2 > wor s )* du'li!ating the same writes on two hard dri(es# LetFs assume *ou ha(e two B1 5iga)*te dri(es# In +$I2 >, data is written at the same time to )oth dri(es# +$I2> is o'timi7ed "or "ast writes# +$I2 L wor s )* writing 'arts o" data a!ross all dri(es in the set (it re=uires at least three dri(es)# I" a dri(e "ailed, the entire set would )e worthless# To !om)at this 'ro)lem, one o" the dri(es stores a H'arit*H )it# Thin o" a math 'ro)lem, su!h as A / M V >1# Kou !an thin o" the dri(es as storing one o" the num)ers, and the >1 is the 'arit* 'art# B* remo(ing an* one o" the num)ers, *ou !an get it )a! )* re"erring to the other two, li e this: A / C V >1# <" !ourse, losing more than one !ould )e e(il# +$I2 L is o'timi7ed "or reads# +$I2 >1 is a )it o" a !om)ination o" )oth t*'es# It doesnFt store a 'arit* )it, so itFs "ast, )ut it du'li!ates the data on two dri(es to )e sa"e# Kou need at least "our dri(es "or +$I2 >1# This t*'e o" +$I2 is 'ro)a)l* the )est !om'romise "or a data)ase ser(er# %ote :- ItFs di""i!ult to !o(er !om'lete as'e!t o" +$I2 in this )oo #ItFs )etter to ta e some de!ent S\L S&+.&+ )oo "or in detail nowledge , )ut *es "rom inter(iew as'e!t *ou !an

'ro)a)l* es!a'e with this answer# (B)WhatFs the di""eren!e )etween 2&L&T& T$BL& and T+G%C$T& T$BL& !ommands? ,ollowing are di""eren!e )etween them :4 2&L&T& T$BL& s*nta- logs the deletes thus ma ing the delete o'eration slow#T+G%C$T& ta)le does not log an* in"ormation )ut it logs in"ormation a)out deallo!ation o" data 'age o" the ta)le#So T+G%C$T& ta)le is "aster as !om'ared to delete ta)le# 4 2&L&T& ta)le !an )e rolled )a! while T+G%C$T& !an not )e# 4 2&L&T& ta)le !an ha(e !riteria while T+G%C$T& !an not# 4 T+G%C$T& ta)le !an not triggers# >DM (B)What are the 'ro)lems that !an o!!ur i" *ou do not im'lement lo! ing 'ro'erl* in S\L S&+.&+ ? ,ollowing are the 'ro)lems that o!!ur i" *ou do not im'lement lo! ing 'ro'erl* in S\L S&+.&+# Lost G'dates Lost u'dates o!!ur i" *ou let two transa!tions modi"* the same data at the same time, and the transa!tion that !om'letes "irst is lost# Kou need to wat!h out "or lost u'dates with the +&$2 G%C<MMITT&2 isolation le(el# This isolation le(el disregards an* t*'e o" lo! s, so two simultaneous data modi"i!ations are not aware o" ea!h other# Su''ose that a !ustomer has due o" B111g to )e 'aid#?e 'a*s >111g and again )u*s a 'rodu!t o" L11g#Lets sa* that these two transa!tions are now )een entered "rom two di""erent !ounters o" the !om'an*#%ow )oth the !ounter user start ma ing entr* at the same time >1:11 $M#$!tuall* s'ea ing at >1:1> $M the !ustomer should ha(e B111g->111g/L11 V >L11g 'ending to )e 'aid#But as said in lost u'dates the "irst transa!tion is not !onsidered and the se!ond transa!tion o(errides it#So the "inal 'ending is B111g/L11g V BL11g#####I ho'e the !om'an* does not loose the !ustomer# %on-+e'eata)le +ead %on-re'eata)le reads o!!ur i" a transa!tion is a)le to read the same row multi'le times and gets a di""erent (alue ea!h time#$gain, this 'ro)lem is most li el* to o!!ur with the +&$2 G%C<MMITT&2 isolation le(el# Be!ause *ou let two transa!tions modi"* data at the same time, *ou !an get some une-'e!ted results# ,or instan!e, a !ustomer wants to )oo "light , so the tra(el agent !he! s "or the "lights a(aila)ilit*#Tra(el agent "inds a seat and goes ahead to )oo the seat#While the tra(el agent is )oo ing the seat , some other tra(el agent )oo s the seat#When this tra(el agent goes to u'date the re!ord , he gets error sa*ing that 9Seat is alread* )oo ed:#In short the tra(el agent gets di""erent status at di""erent times "or the seat# 2irt* +eads 2irt* reads are a s'e!ial !ase o" non-re'eata)le read# This ha''ens i" *ou run a re'ort while transa!tions are modi"*ing the data that *ouFre re'orting on# ,or e-am'le there is a !ustomer in(oi!e re'ort whi!h runs on >:11 $M in a"ternoon and a"ter that all in(oi!es are sent to the res'e!ti(e !ustomer "or 'a*ments#Lets sa* one o" the !ustomer has >111g

>D@ to )e 'aid#Customer 'a*s >111g at >:11 $M and at the same time re'ort is run#$!tuall* !ustomer has no mone* 'ending )ut is still issued a in(oi!e# Ehantom +eads Ehantom reads o!!ur due to a transa!tion )eing a)le to read a row on the "irst read, )ut not )eing a)le to modi"* the same row due to another transa!tion deleting rows "rom the same ta)le# Lets sa* *ou edit a re!ord in the mean time some)od* !omes and deletes the re!ord , *ou then go "or u'dating the re!ord whi!h does not e-ist####Eani!# Interestingl*, the 'hantom reads !an o!!ur e(en with the de"ault isolation le(el su''orted )* S\L Ser(er: +&$2 C<MMITT&2# The onl* isolation le(el that doesnFt allow 'hantoms is S&+I$LIc$BL&, whi!h ensures that ea!h transa!tion is !om'letel* isolated "rom others# In other words, no one !an a!=uire an* t*'e o" lo! s on the a""e!ted row while it is )eing modi"ied# (B)What are di""erent transa!tion le(els in S\L S&+.&+ ? Twist :- what are di""erent t*'es o" lo! s in S\L S&+.&+ ? Transa!tion Isolation le(el de!ides how is one 'ro!ess isolated "rom other 'ro!ess#Gsing transa!tion le(els *ou !an im'lement lo! ing in S\L S&+.&+# There are "our transa!tion le(els in S\L S&+.&+ :+&$2 C<MMITT&2 The shared lo! is held "or the duration o" the transa!tion, meaning that no other transa!tions !an !hange the data at the same time# <ther transa!tions !an insert and modi"* data in the same ta)le, howe(er, as long as it is not lo! ed )* the "irst transa!tion# +&$2 G%C<MMITT&2 %o shared lo! s and no e-!lusi(e lo! s are honored# This is the least restri!ti(e isolation le(el resulting in the )est !on!urren!* )ut the least data integrit*# >DD +&E&$T$BL& +&$2 This setting disallows dirt* and non-re'eata)le reads# ?owe(er, e(en though the lo! s are held on read data, new rows !an still )e inserted in the ta)le, and will su)se=uentl* )e read )* the transa!tion# S&+I$LIc$BL& This is the most restri!ti(e setting holding shared lo! s on the range o" data# This setting does not allow the insertion o" new rows in the range that is lo! edW there"ore, no 'hantoms are allowed# ,ollowing is the s*nta- "or setting transa!tion le(el in S\L S&+.&+# S&T T+$%S$CTI<% IS<L$TI<% L&.&L S&+I$LIc$BL& (I)What are di""erent lo! s in S\L S&+.&+ ? 2e'ending on the transa!tion le(el si- t*'es o" lo! !an )e a!=uired on data :Intent The intent lo! shows the "uture intention o" S\L Ser(erFs lo! manager to a!=uire lo! s on a s'e!i"i! unit o" data "or a 'arti!ular transa!tion# S\L Ser(er uses intent lo! s to =ueue e-!lusi(e lo! s, there)* ensuring that these lo! s will )e 'la!ed on the data elements

in the order the transa!tions were initiated# Intent lo! s !ome in three "la(ors: intent shared (IS), intent e-!lusi(e (IC), and shared with intent e-!lusi(e (SIC)# IS lo! s indi!ate that the transa!tion will read some ()ut not all) the resour!es in the ta)le or 'age )* 'la!ing shared lo! s# IC lo! s indi!ate that the transa!tion will modi"* some ()ut not all) resour!es in the ta)le or 'age )* 'la!ing e-!lusi(e lo! s# SIC lo! s indi!ate that the transa!tion will read all resour!es, and modi"* some()ut not all) o" them# This will )e a!!om'lished )* 'la!ing the shared lo! s on the resour!es read and e-!lusi(e lo! s on the rows modi"ied# <nl* one SIC lo! is allowed 'er resour!e at one timeW there"ore, SIC lo! s 're(ent other !onne!tions "rom modi"*ing an* data in the resour!e ('age or ta)le), although the* do allow reading the data in the same resour!e# B11 Shared Shared lo! s (S) allow transa!tions to read data with S&L&CT statements# <ther !onne!tions are allowed to read the data at the same timeW howe(er, no transa!tions are allowed to modi"* data until the shared lo! s are released# G'date G'date lo! s (G) are a!=uired 6ust 'rior to modi"*ing the data# I" a transa!tion modi"ies a row, then the u'date lo! is es!alated to an e-!lusi(e lo! W otherwise, it is !on(erted to a shared lo! # <nl* one transa!tion !an a!=uire u'date lo! s to a resour!e at one time# Gsing u'date lo! s 're(ents multi'le !onne!tions "rom ha(ing a shared lo! that want to e(entuall* modi"* a resour!e using an e-!lusi(e lo! # Shared lo! s are !om'ati)le with other shared lo! s, )ut are not !om'ati)le with G'date lo! s# &-!lusi(e &-!lusi(e lo! s (C) !om'letel* lo! the resour!e "rom an* t*'e o" a!!ess in!luding reads# The* are issued when data is )eing modi"ied through I%S&+T, GE2$T& and 2&L&T& statements# S!hema S!hema modi"i!ation lo! s (S!h-M) are a!=uired when data de"inition language statements, su!h as C+&$T& T$BL&, C+&$T& I%2&C, $LT&+ T$BL&, and so on are )eing e-e!uted# S!hema sta)ilit* lo! s (S!h-S) are a!=uired when store 'ro!edures are )eing !om'iled# Bul G'date Bul u'date lo! s (BG) are used when 'er"orming a )ul -!o'* o" data into a ta)le with T$BL<CJ hint# These lo! s im'ro(e 'er"orman!e while )ul !o'*ing data into a ta)leW howe(er, the* redu!e !on!urren!* )* e""e!ti(el* disa)ling an* other !onne!tions to read or modi"* data in the ta)le# (I)Can we suggest lo! ing hints to S\L S&+.&+ ? We !an gi(e lo! ing hints that hel'Fs *ou o(erride de"ault de!isions made )* S\L Ser(er# ,or instan!e, *ou !an s'e!i"* the +<WL<CJ hint with *our GE2$T& statement to !on(in!e S\L Ser(er to lo! ea!h row a""e!ted )* that data modi"i!ation# Whether itFs B1> 'rudent to do so is another stor*W what will ha''en i" *our GE2$T& a""e!ts DL_ o" rows

in the a""e!ted ta)le? I" the ta)le !ontains >111 rows, then S\L Ser(er will ha(e to a!=uire DL1 indi(idual lo! s, whi!h is li el* to !ost a lot more in terms o" memor* than a!=uiring a single ta)le lo! # So thin twi!e )e"ore *ou )om)ard *our !ode with +<WL<CJS# (I)What is L<CJ es!alation? Lo! es!alation is the 'ro!ess o" !on(erting a lot o" low le(el lo! s (li e row lo! s, 'age lo! s) into higher le(el lo! s (li e ta)le lo! s)# &(er* lo! is a memor* stru!ture too man* lo! s would mean, more memor* )eing o!!u'ied )* lo! s# To 're(ent this "rom ha''ening, S\L Ser(er es!alates the man* "ine-grain lo! s to "ewer !oarse-grain lo! s# Lo! es!alation threshold was de"ina)le in S\L Ser(er 3#L, )ut "rom S\L Ser(er M#1 onwards itFs d*nami!all* managed )* S\L Ser(er# (B)What are the di""erent wa*s o" mo(ing dataO data)ases )etween ser(ers and data)ases in S\L Ser(er? There are lots o" o'tions a(aila)le, *ou ha(e to !hoose *our o'tion de'ending u'on *our re=uirements# Some o" the o'tions *ou ha(e are: B$CJGEO+&ST<+&, deta!hing and atta!hing data)ases, re'li!ation, 2TS, BCE, logshi''ing, I%S&+T###S&L&CT, S&L&CT###I%T<, !reating I%S&+T s!ri'ts to generate data# (I)What are ad(antages o" S\L B111 o(er S\l M#1 ? 4 Gser-2e"ined ,un!tions: Gser-2e"ined ,un!tions (G2,s) -- one or more Transa!t-S\L statements !an )e used to en!a'sulate !ode "or reuse# Gserde"ined "un!tions !annot ma e a 'ermanent !hanges to the data or modi"* data)ase ta)les# G2, !an !hange onl* lo!al o)6e!ts "or a G2,, su!h as lo!al !ursors or (aria)les# 4 2istri)uted Eartitioned .iews: 2istri)uted 'artitioned (iews allow *ou to 'artition ta)les hori7ontall* a!ross multi'le ser(ers# So, *ou !an s!ale out one data)ase ser(er to a grou' o" data)ase ser(ers that !oo'erate to 'ro(ide the same 'er"orman!e le(els as a !luster o" data)ase ser(ers# 2ue to distri)uted 'artitioned (iews, S\L Ser(er B111 now on the "irst 'la!e in the t'!-! tests# B1B 4 %ew 2ata T*'es: These in!lude: )igint, an @-)*te integer t*'eW s=lQ(ariant, a data t*'e that allows the storage o" data o" di""erent data t*'esW and the ta)le data t*'e, whi!h allows a''li!ations to store results tem'oraril* "or later use# 4 I%ST&$2 <, and $,T&+ Triggers: There are I%ST&$2 <, and $,T&+ Triggers in S\L Ser(er B111# I%ST&$2 <, triggers are e-e!uted instead o" the I%S&+T, GE2$T& or 2&L&T& triggering a!tion# $,T&+ triggers are e-e!uted a"ter the triggering a!tion# 4 Cas!ading +e"erential Integrit* Constraints: There are new <% 2&L&T& and <% GE2$T& !lauses in the +&,&+&%C&S !lause o" the C+&$T& T$BL& and $LT&+ T$BL& statements#The <% 2&L&T& !lause !ontrols what a!tions are ta en i" *ou attem't to delete a row to whi!h e-isting "oreign e*s 'oint# The <% GE2$T& !lause de"ines the a!tions that are ta en i" *ou attem't to u'date a !andidate e* (alue to whi!h e-isting "oreign e*s 'oint#

4 The <% 2&L&T& and <% GE2$T& !lauses ha(e two o'tions: %< $CTI<% :-%< $CTI<% s'e!i"ies that the deletionOu'date "ail with an error# C$SC$2& :-C$SC$2& s'e!i"ies that all the rows with "oreign e*s 'ointing to the deletedOu'dated row are also deletedOu'dated# 4 AB CEG and 305B Memor* Su''ort: S\L Ser(er B111 &nter'rise &dition running under Windows B111 2ataCenter !an su''ort u' to AB CEGs and u' to 305B o" 'h*si!al memor* (+$M) on a !om'uter# 4 CML Su''ort: S\L Ser(er B111 !an use CML to insert, u'date, and delete (alues in the data)ase, and the data)ase engine !an return data as &-tensi)le Mar u' Language (CML) do!uments (B)What is the di""eren!e )etween a ?$.I%5 CL$GS& and a W?&+& CL$GS&? Kou !an use ?a(ing Clause with the 5+<GE BK "un!tion in a =uer* and W?&+& Clause is a''lied to ea!h row )e"ore the* are 'art o" the 5+<GE BK "un!tion in a =uer*# (B) What is di""eren!e )etween G%I<% and G%I<% $LL S\L s*nta- ? B1A G%I<% S\L s*nta- is used to sele!t in"ormation "rom two ta)les#But it sele!ts onl* distin!t re!ords "rom )oth the ta)le# , while G%I<% $LL sele!ts all re!ords "rom )oth the ta)les# %ote :- Sele!ted re!ords should ha(e same datat*'e or else the s*nta- will not wor # (I)?ow !an *ou raise !ustom errors "rom stored 'ro!edure ? The +$IS&++<+ statement is used to 'rodu!e an ad ho! error message or to retrie(e a !ustom message that is stored in the s*smessages ta)le# Kou !an use this statement with the error handling !ode 'resented in the 're(ious se!tion to im'lement !ustom error messages in *our a''li!ations# The s*nta- o" the statement is shown here# +$IS&++<+ (ZmsgQid YmsgQstr [Z,se(erit* ,state [ R ,argument R ,,###n S S )) R WIT? o'tion R ,,###n S S $ des!ri'tion o" the !om'onents o" the statement "ollows# msgQid :-The I2 "or an error message, whi!h is stored in the error !olumn in s*smessages# msgQstr :-$ !ustom message that is not !ontained in s*smessages# se(erit* :- The se(erit* le(el asso!iated with the error# The (alid (alues are 1PBL# Se(erit* le(els 1P>@ !an )e used )* an* user, )ut >DPBL are onl* a(aila)le to mem)ers o" the "i-ed-ser(er role s*sadmin# When le(els >DPBL are used, the WIT? L<5 o'tion is re=uired# state $ (alue that indi!ates the in(o!ation state o" the error# The (alid (alues are 1P>BM# This (alue is not used )* S\L Ser(er# $rgument, # # # <ne or more (aria)les that are used to !ustomi7e the message# ,or e-am'le, *ou !ould 'ass the !urrent 'ro!ess I2 (``SEI2) so it !ould )e dis'la*ed in the message# WIT? o'tion, # # #

The three (alues that !an )e used with this o'tional argument are des!ri)ed here# L<5 - ,or!es the error to logged in the S\L Ser(er error log and the %T a''li!ation log# %<W$IT - Sends the message immediatel* to the !lient# B10 S&T&++<+ - Sets ``&++<+ to the uni=ue I2 "or the message or L1,111# The num)er o" o'tions a(aila)le "or the statement ma e it seem !om'li!ated, )ut it is a!tuall* eas* to use# The "ollowing shows how to !reate an ad ho! message with a se(erit* o" >1 and a state o" ># +$IS&++<+ (F$n error o!!ured u'dating the %on,atal ta)leF,>1,>) --+esults-$n error o!!ured u'dating the %on,atal ta)le The statement does not ha(e to )e used in !on6un!tion with an* other !ode, )ut "or our 'ur'oses it will )e used with the error handling !ode 'resented earlier# The "ollowing alters the 'sQ%on,atalQI%S&+T 'ro!edure to use +$IS&++<+# GS& tem'd) go $LT&+ E+<C&2G+& 'sQ%on,atalQI%S&+T `ColumnB int V%GLL $S 2&CL$+& `&rrorMsgI2 int I%S&+T %on,atal .$LG&S (`ColumnB) S&T `&rrorMsgI2 V``&++<+ I, `&rrorMsgI2 TU1 B&5I% +$IS&++<+ (F$n error o!!ured u'dating the %on,atal ta)leF,>1,>) &%2 When an error-'rodu!ing !all is made to the 'ro!edure, the !ustom message is 'assed to the !lient# The "ollowing shows the out'ut generated )* \uer* $nal*7er# B1L (I) What is $CI2 "undamental and what are transa!tions in S\L S&+.&+ ? $ transa!tion is a se=uen!e o" o'erations 'er"ormed as a single logi!al unit o" wor # $ logi!al unit o" wor must e-hi)it "our 'ro'erties, !alled the $CI2 ($tomi!it*, Consisten!*, Isolation, and 2ura)ilit*) 'ro'erties, to =uali"* as a transa!tion: $tomi!it* 4 $ transa!tion must )e an atomi! unit o" wor W either all o" its data modi"i!ations are 'er"ormed or none o" them is 'er"ormed# Consisten!* 4 When !om'leted, a transa!tion must lea(e all data in a !onsistent state# In a relational data)ase, all rules must )e a''lied to the transa!tionFs modi"i!ations to maintain all data integrit*# $ll internal data stru!tures, su!h as B-tree inde-es or dou)l*-lin ed lists, must )e !orre!t at the end o" the transa!tion#

Isolation 4 Modi"i!ations made )* !on!urrent transa!tions must )e isolated "rom the modi"i!ations made )* an* other !on!urrent transa!tions# $ transa!tion either sees data in the state it was in )e"ore another !on!urrent transa!tion modi"ied it, or it sees the data a"ter the se!ond transa!tion has !om'leted, )ut it does not see an intermediate state# This is re"erred to as seriali7a)ilit* )e!ause it results in the a)ilit* to reload the starting data and re'la* a series o" transa!tions to end u' with the data in the same state it was in a"ter the original transa!tions were 'er"ormed# 2ura)ilit* 4 $"ter a transa!tion has !om'leted, its e""e!ts are 'ermanentl* in 'la!e in the s*stem# The modi"i!ations 'ersist e(en in the e(ent o" a s*stem "ailure# ($) What is 2BCC? B13 2BCC (2ata)ase Consisten!* Che! er Commands) is used to !he! logi!al and 'h*si!al !onsisten!* o" data)ase stru!ture#2BCC statements !an "i- and dete!t 'ro)lems#The* are grou'ed in to "our !ategories :4 Maintenan!e !ommands li e 2BCC 2B+&I%2&C , 2BCC 2B+&E$I+ et! , the* are mainl* used "or maintenan!e tas s in S\L S&+.&+# 4 Mis!ellaneous !ommands li e 2BCC +<WL<CJ , 2BCC T+$C&<,, et! , the* are mainl* used "or ena)ling row-le(el lo! ing or remo(ing 2LL "rom memor*# 4 Status Commands li e 2BCC <E&%T+$% , 2BCC S?<WC<%TI5 et! , the* are mainl* used "or !he! ing status o" the data)ase# 4 .alidation Commands li e 2BCC C?&CJ$LL<C,2BCC C?&CJC$T$L<5 et! , the* 'er"orm (alidation o'erations on data)ase# %ote :- Che! MS2% "or list o" all 2BCC !ommands , its (er* mu!h 'ossi)le s'e!iall* during 2B$ inter(iews the* !an as in de'th indi(idual !ommands# Below is a sam'le s!reen in whi!h 2BCC S?<WC<%TI5 !ommand is run#2BCC S?<WC<%TI5 is used to dis'la* "ragmentation in"ormation "or the data and inde-es o" the s'e!i"ied ta)le#In the sam'le s!reen 9Customer: ta)le is !he! ed "or "ragmentation in"ormation#I" *ou loo at the "igure 9S!an densit*: is >11 i" e(er*thing is !ontigious in this image it is DL#A3_ whi!h is de!ent 'er!entage#So su!h t*'e o" use"ul in"ormation !an )e !olle!ted )* 2BCC !ommand and data)ase 'er"orman!e and maintenan!e !an )e im'ro(ed# B1M ,igure :- >1#3 2BCC S?<WC<%TI5 !ommand in a!tion# B1@ ($) What is 'ur'ose o" +e'li!ation ? +e'li!ation is wa* o" ee'ing data s*n!hroni7ed in multi'le data)ases#S\L ser(er re'li!ation has two im'ortant as'e!ts 'u)lisher and su)s!ri)er# Eu)lisher

2ata)ase ser(er that ma es data a(aila)le "or re'li!ation is !alled as Eu)lisher# Su)s!ri)er 2ata)ase Ser(ers that get data "rom the 'u)lishers is !alled as Su)s!ri)ers# ($) What are di""erent t*'e o" re'li!ation su''orted )* S\L S&+.&+ ? There are three t*'es o" re'li!ation su''orted )* S\L S&+.&+:Sna'shot +e'li!ation# Sna'shot +e'li!ation ta es sna'shot o" one data)ase and mo(es it to the other data)ase#$"ter initial load data !an )e re"reshed 'eriodi!all*#The onl* disad(antage o" this t*'e o" re'li!ation is that all data has to !o'ied ea!h time the ta)le is re"reshed# Transa!tional +e'li!ation In transa!tional re'li!ation data is !o'ied "irst time as in sna'shot re'li!ation , )ut later onl* the transa!tions are s*n!hroni7ed rather than re'li!ating the whole data)ase#Kou !an either s'e!i"* to run !ontinuousl* or on 'eriodi! )asis# Merge +e'li!ation# Merge re'li!ation !om)ines data "rom multi'le sour!es into a single !entral data)ase#$gain as usual the initial load is li e sna'shot )ut later it allows !hange o" data )oth on su)s!ri)er and 'u)lisher , later when the* !ome on-line it dete!ts and !om)ines them and u'dates a!!ordingl*# (I) What is BCE utilit* in S\L S&+.&+ ? B1D BCE (Bul Co'* Erogram) is a !ommand line utilit* )* whi!h *ou !an im'ort and e-'ort large amounts o" data in and out o" S\L S&+.&+ data)ase# Below is a sam'le whi!h shows BCE in a!tion# ,igure :- >1#M &-'ort BCE utilit* in a!tion B>1 ,igure :- >1#@ Im'ort BCE utilit* in a!tion (I)What are di""erent t*'es o" triggers in S\l S&+.&+ B111 ? There are two t*'es o" triggers :4 I%ST&$2 <, triggers I%ST&$2 <, triggers "ire in 'la!e o" the triggering a!tion# ,or e-am'le, i" an I%ST&$2 <, GE2$T& trigger e-ists on the Sales ta)le and an GE2$T& statement is e-e!uted against the Salesta)le, the GE2$T& statement will not !hange a row in the sales ta)le# Instead, the GE2$T& statement !auses the I%ST&$2 <, GE2$T& trigger to )e e-e!uted, whi!h ma* or ma* not modi"* data in the Sales ta)le# B>> 4 $,T&+ triggers $,T&+ triggers e-e!ute "ollowing the S\L a!tion, su!h as an insert, u'date, or delete#This is the traditional trigger whi!h e-isted in S\L S&+.&+# I%ST&$2 <, triggers gets e-e!uted automati!all* )e"ore the Erimar* Je* and the ,oreign Je* !onstraints are !he! ed, whereas the traditional $,T&+ triggers gets e-e!uted a"ter these !onstraints are !he! ed#

Gnli e $,T&+ triggers, I%ST&$2 <, triggers !an )e !reated on (iews# ($)I" we ha(e multi'le $,T&+ Triggers on ta)le how !an we de"ine the se=uen!e o" the triggers ? I" a ta)le has multi'le $,T&+ triggers, then *ou !an s'e!i"* whi!h trigger should )e e-e!uted "irst and whi!h trigger should )e e-e!uted last using the stored 'ro!edure s'Qsettriggerorder# $ll the other triggers are in an unde"ined order whi!h *ou !annot !ontrol# ($)What is S\l in6e!tion ? It is a ,orm o" atta! on a data)ase-dri(en We) site in whi!h the atta! er e-e!utes unauthori7ed S\L !ommands )* ta ing ad(antage o" inse!ure !ode on a s*stem !onne!ted to the Internet, )*'assing the "irewall# S\L in6e!tion atta! s are used to steal in"ormation "rom a data)ase "rom whi!h the data would normall* not )e a(aila)le andOor to gain a!!ess to an organi7ation8s host !om'uters through the !om'uter that is hosting the data)ase# S\L in6e!tion atta! s t*'i!all* are eas* to a(oid )* ensuring that a s*stem has strong in'ut (alidation# $s name suggest we in6e!t S\L whi!h !an )e relati(el* dangerous "or the data)ase# &-am'le this is a sim'le S\L S&L&CT email, 'asswd, loginQid, "ullQname ,+<M mem)ers W?&+& email V F-F %ow some)od* does not 'ut 9-: as the in'ut )ut 'uts 9- W 2+<E T$BL& mem)ersW:# So the a!tual S\L whi!h will e-e!ute is :B>B S&L&CT email, 'asswd, loginQid, "ullQname ,+<M mem)ers W?&+& email V F-F W 2+<E T$BL& mem)ersW Thin what will ha''en to *our data)ase

S=l ser(er Cursors


5eneral !on!e'ts In this arti!le, I want to tell *ou how to !reate and use ser(er side !ursors and how *ou !an o'timi7e a !ursor 'er"orman!e# Cursor is a data)ase o)6e!t used )* a''li!ations to mani'ulate data in a set on a row-)*-row )asis, instead o" the t*'i!al S\L !ommands that o'erate on all the rows in the set at one time# ,or e-am'le, *ou !an use !ursor to in!lude a list o" all user data)ases and ma e multi'le o'erations against ea!h data)ase )* 'assing ea!h data)ase name as a (aria)le# The ser(er side !ursors were "irst added in S\L Ser(er 3#1 release and now su''orted in all editions o" S\L Ser(er M#1 and S\L Ser(er B111#

Be"ore using !ursor, *ou "irst must de!lare the !ursor# <n!e a !ursor has )een de!lared, *ou !an o'en it and "et!h "rom it# Kou !an "et!h row )* row and ma e multi'le o'erations on the !urrentl* a!ti(e row in the !ursor# When *ou ha(e "inished wor ing with a !ursor, *ou should !lose !ursor and deallo!ate it to release S\L Ser(er resour!es# 2e!laring a Cursor Be"ore using !ursor, *ou "irst must de!lare the !ursor, i#e# de"ine its s!rolling )eha(ior and the =uer* used to )uild the result set on whi!h the !ursor o'erates# To de!lare !ursor, *ou !an use a s*nta- )ased on the S\L-DB standard and a s*nta- using a set o" Transa!t-S\L e-tensions# S\L-DB S*ntaThis is S\L-DB S*nta-: 2&CL$+& !ursorQname RI%S&%SITI.&S RSC+<LLS CG+S<+ ,<+ sele!tQstatement R,<+ Z+&$2 <%LK Y GE2$T& R<, !olumnQname R,###nSS[S where !ursorQname - the name o" the ser(er side !ursor, must !ontain "rom > to >B@ !hara!ters# I%S&%SITI.& - s'e!i"ies that !ursor will use a tem'orar* !o'* o" the data instead o" )ase ta)les# This !ursor does not allow modi"i!ations and modi"i!ations made to )ase ta)les are not re"le!ted in the data returned )* "et!hes made to this !ursor# SC+<LL - s'e!i"ies that !ursor !an "et!h data in all dire!tions, not onl* se=uentiall* until the end o" the result set# I" this argument is not s'e!i"ied, ,&TC? %&CT is the onl* "et!h o'tion su''orted# sele!tQstatement - the standard sele!t statement, !annot !ontain C<MEGT&, C<MEGT& BK, ,<+ B+<WS&, and I%T< e*words# +&$2 <%LK - s'e!i"ies that !ursor !annot )e u'dated# GE2$T& R<, !olumnQname R,###nSS - s'e!i"ies that all !ursorFs !olumns !an )e u'dated (i" <, !olumnQname R,###nS is not s'e!i"ied), or onl* the !olumns listed in the <, !olumnQname R,###nS list allow modi"i!ations# Transa!t-S\L &-tended S*ntaThis is Transa!t-S\L &-tended S*nta-: 2&CL$+& !ursorQname CG+S<+ RL<C$L Y 5L<B$LS R,<+W$+2Q<%LK Y SC+<LLS RST$TIC Y J&KS&T Y 2K%$MIC Y ,$STQ,<+W$+2S

R+&$2Q<%LK Y SC+<LLQL<CJS Y <ETIMISTICS RTKE&QW$+%I%5S ,<+ sele!tQstatement R,<+ GE2$T& R<, !olumnQname R,###nSSS where !ursorQname - the name o" the ser(er side !ursor, must !ontain "rom > to >B@ !hara!ters# L<C$L - s'e!i"ies that !ursor !an )e a(aila)le onl* in the )at!h, stored 'ro!edure, or trigger in whi!h the !ursor was !reated# The L<C$L !ursor will )e im'li!itl* deallo!ated when the )at!h, stored 'ro!edure, or trigger terminates# 5L<B$L - s'e!i"ies that !ursor is glo)al to the !onne!tion# The 5L<B$L !ursor will )e im'li!itl* deallo!ated at dis!onne!t# ,<+W$+2Q<%LK - s'e!i"ies that !ursor !an onl* "et!h data se=uentiall* "rom the "irst to the last row# ,&TC? %&CT is the onl* "et!h o'tion su''orted# ST$TIC - s'e!i"ies that !ursor will use a tem'orar* !o'* o" the data instead o" )ase ta)les# This !ursor does not allow modi"i!ations and modi"i!ations made to )ase ta)les are not re"le!ted in the data returned )* "et!hes made to this !ursor# J&KS&T - s'e!i"ies that !ursor uses the set o" e*s that uni=uel* identi"* the !ursorFs rows ( e*set), so that the mem)ershi' and order o" rows in the !ursor are "i-ed when the !ursor is o'ened# S\L Ser(er uses a ta)le in tem'd) to store e*set# The J&KS&T !ursor allows u'dates non e* (alues "rom )eing made through this !ursor, )ut inserts made )* other users are not (isi)le# G'dates non e* (alues made )* other users are (isi)le as the owner s!rolls around the !ursor, )ut u'dates e* (alues made )* other users are not (isi)le# I" a row is deleted, an attem't to "et!h the row returns an ``,&TC?QST$TGS o" -B# 2K%$MIC - s'e!i"ies that !ursor re"le!ts all data !hanges made to the )ase ta)les as *ou s!roll around the !ursor# ,&TC? $BS<LGT& o'tion is not su''orted with 2K%$MIC !ursor# ,$STQ,<+W$+2 - s'e!i"ies that !ursor will )e ,<+W$+2Q<%LK and +&$2Q<%LK !ursor# The ,$STQ,<+W$+2 !ursors 'rodu!e the least amount o" o(erhead on S\L Ser(er# +&$2 <%LK - s'e!i"ies that !ursor !annot )e u'dated# SC+<LLQL<CJS - s'e!i"ies that !ursor will lo! the rows as the* are read into the !ursor to ensure that 'ositioned u'dates or deletes made through the !ursor will )e su!!eed# <ETIMISTIC - s'e!i"ies that !ursor does not lo! rows as the* are read into the !ursor# So, the 'ositioned u'dates or deletes made through the !ursor will not su!!eed i" the row has )een

u'dated outside the !ursor sin!e this row was read into the !ursor# TKE&QW$+%I%5 - s'e!i"ies that i" the !ursor will )e im'li!itl* !on(erted "rom the re=uested t*'e to another, a warning message will )e sent to the !lient# sele!tQstatement - the standard sele!t statement, !annot !ontain C<MEGT&, C<MEGT& BK, ,<+ B+<WS&, and I%T< e*words# GE2$T& R<, !olumnQname R,###nSS - s'e!i"ies that all !ursorFs !olumns !an )e u'dated (i" <, !olumnQname R,###nS is not s'e!i"ied), or onl* the !olumns listed in the <, !olumnQname R,###nS list allow modi"i!ations#

<'ening a Cursor <n!e a !ursor has )een de!lared, *ou must o'en it to "et!h data "rom it# To o'en a !ursor, *ou !an use the "ollowing s*nta-: <E&% Z Z R5L<B$LS !ursorQname [ Y !ursorQ(aria)leQname[ where 5L<B$L - i" this argument was not s'e!i"ied and )oth a glo)al and a lo!al !ursor e-ist with the same name, the lo!al !ursor will )e o'enedW otherwise, the glo)al !ursor will )e o'ened# !ursorQname - the name o" the ser(er side !ursor, must !ontain "rom > to >B@ !hara!ters# !ursorQ(aria)leQname - the name o" a !ursor (aria)le that re"eren!es a !ursor# $"ter a !ursor is o'ening, *ou !an determine the num)er o" rows that were "ound )* the !ursor# To get this num)er, *ou !an use ``CG+S<+Q+<WS s!alar "un!tion# ,et!hing a Cursor <n!e a !ursor has )een o'ened, *ou !an "et!h "rom it row )* row and ma e multi'le o'erations on the !urrentl* a!ti(e row in the !ursor# To "et!h "rom a !ursor, *ou !an use the "ollowing s*nta-: ,&TC? R R %&CT Y E+I<+ Y ,I+ST Y L$ST Y $BS<LGT& Zn Y `n(ar[ Y +&L$TI.& Zn Y `n(ar[

S ,+<M S Z Z R5L<B$LS !ursorQname [ Y `!ursorQ(aria)leQname[ RI%T< `(aria)leQnameR,###nS S

where %&CT - the de"ault !ursor "et!h o'tion# ,&TC? %&CT returns the ne-t row a"ter the !urrent row# E+I<+ - returns the 'rior row )e"ore the !urrent row# ,I+ST - returns the "irst row in the !ursor# L$ST - returns the last row in the !ursor# $BS<LGT& Zn Y `n(ar[ - returns the nth row in the !ursor# I" a 'ositi(e num)er was s'e!i"ied, the rows are !ounted "rom the to' o" the data setW i" 1 was s'e!i"ied, no rows are returnedW i" a negati(e num)er was s'e!i"ied, the num)er o" rows will )e !ounted "rom the )ottom o" the data set# +&L$TI.& Zn Y `n(ar[ - returns the nth row in the !ursor relati(e to the !urrent row# I" a 'ositi(e num)er was s'e!i"ied, returns the nth row )e*ond the !urrent rowW i" a negati(e num)er was s'e!i"ied, returns the nth row 'rior the !urrent rowW i" 1 was s'e!i"ied, returns the !urrent row# 5L<B$L - i" this argument was not s'e!i"ied and )oth a glo)al and a lo!al !ursor e-ist with the same name, the lo!al !ursor will )e "et!hedW otherwise, the glo)al !ursor will )e "et!hed# !ursorQname - the name o" the ser(er side !ursor, must !ontain "rom > to >B@ !hara!ters# !ursorQ(aria)leQname - the name o" a !ursor (aria)le that re"eren!es a !ursor# I%T< `(aria)leQnameR,###nS - allows data returned "rom the !ursor to )e held in tem'orar* (aria)les# The t*'e o" (aria)les must mat!h the t*'e o" !olumns in the !ursor sele!t list or su''ort im'li!it !on(ersion# The num)er o" (aria)les must mat!h the num)er o" !olumns in the !ursor sele!t list#

Closing a Cursor When *ou ha(e "inished wor ing with a !ursor, *ou !an !lose it to release an* resour!es and lo! s that S\L Ser(er ma* ha(e used while the !ursor was o'en# To !lose a !ursor, *ou !an use the "ollowing s*nta-: CL<S& Z Z R5L<B$LS !ursorQname [ Y !ursorQ(aria)leQname [ where

5L<B$L - i" this argument was not s'e!i"ied and )oth a glo)al and a lo!al !ursor e-ist with the same name, the lo!al !ursor will )e !losedW otherwise, the glo)al !ursor will )e !losed# !ursorQname - the name o" the ser(er side !ursor, must !ontain "rom > to >B@ !hara!ters# !ursorQ(aria)leQname - the name o" a !ursor (aria)le that re"eren!es a !ursor# %ote# I" *ou ha(e !losed a !ursor, )ut ha(e not deallo!ated it, *ou !an o'en it again when needed# 2eallo!ating a Cursor When *ou ha(e "inished wor ing with a !ursor and want to !om'letel* release S\L Ser(er resour!es that were used )* a !ursor, *ou !an deallo!ate a !ursor# To deallo!ate a !ursor, *ou !an use the "ollowing s*nta-: 2&$LL<C$T& Z Z R5L<B$LS !ursorQname [ Y `!ursorQ(aria)leQname[ where 5L<B$L - i" this argument was not s'e!i"ied and )oth a glo)al and a lo!al !ursor e-ist with the same name, the lo!al !ursor will )e deallo!atedW otherwise, the glo)al !ursor will )e deallo!ated# !ursorQname - the name o" the ser(er side !ursor, must !ontain "rom > to >B@ !hara!ters# !ursorQ(aria)leQname - the name o" a !ursor (aria)le that re"eren!es a !ursor#

&-am'le: 2&CL$+& `name .$+C?$+(L1) -- data)ase name 2&CL$+& `'ath .$+C?$+(BL3) -- 'ath "or )a! u' "iles 2&CL$+& `"ile%ame .$+C?$+(BL3) -- "ilename "or )a! u' 2&CL$+& `"ile2ate .$+C?$+(B1) -- used "or "ile name S&T `'ath V F2:IBa! u'IF S&L&CT `"ile2ate V C<%.&+T(.$+C?$+(B1),5&T2$T&(),>>B) 2&CL$+& d)Q!ursor CG+S<+ ,<+ S&L&CT name ,+<M master#d)o#s*sdata)ases W?&+& name %<T I% (FmasterF,FmodelF,Fmsd)F,Ftem'd)F) <E&% d)Q!ursor ,&TC? %&CT ,+<M d)Q!ursor I%T< `name

W?IL& ``,&TC?QST$TGS V 1 B&5I% S&T `"ile%ame V `'ath / `name / FQF / `"ile2ate / F#B$JF B$CJGE 2$T$B$S& `name T< 2ISJ V `"ile%ame ,&TC? %&CT ,+<M d)Q!ursor I%T< `name &%2 CL<S& d)Q!ursor 2&$LL<C$T& d)Q!ursor

GML
(B) What is UML? The Unified Modeling Language (UML) is a graphical language for visualizing,specifying, constructing, and documenting the artifacts of a soft are!intensive system"UML provides #lue prints for #usiness process,$ystem function,programming language statements,data#ase schemas and reusa#le components" (%) &o many types of diagrams are there in UML ? T ist '! ()plain in short all types of diagrams in UML ? There are nine types of diagrams in UML '! Use case diagram' They descri#e *W&+T* of a system rather than *&,W* the system does it"They are used to identify the primary elements and processes that form the system" The primary elements are termed as *actors* and the processes are called *use cases"* Use -ase diagrams sho s *actors* and there *roles*" -lass diagram' .rom the use case diagram e can no go to detail design of system , for hich the primary step is class diagram"The #est ay to identify classes is to consider all */,U/$* in use cases as classes , *0(1B$* as methods of classes, relation #et een actors can then #e used to define relation #et een classes"The relationship or association

#et een the classes can #e either an *is!a* or *has!a* relationship hich can easily #e identified from use cases" ,#2ect diagram' +n o#2ect is an instance of a class",#2ect diagram captures the state of classes in the system and their relationships or associations at a specific point of time" $tate diagram' + state diagram, as the name suggests, represents the different states that o#2ects in the system undergo during their life cycle",#2ect change in response to certain simulation so 33" UML 435 this simulation effect is captured in state diagram"$o #asically it has a initial state and final state and events that happen in #et een them"Whenever you thin6 that some simulations are complicated you can go for this diagram" $e7uence diagram' $e7uence diagrams can #e used to e)plore the logic of a comple) operation, function, or procedure"They are called se7uence diagrams #ecause se7uential nature is sho n via ordering of messages".irst message starts at the top and the last message ends at #ottom"The important aspect of a se7uence diagram is that it is time!ordered" This means that the e)act se7uence of the interactions #et een the o#2ects is represented step #y step" 8ifferent o#2ects in the se7uence diagram interact ith each other #y passing *messages*" -olla#oration diagram' + colla#oration diagram groups together the interactions #et een different o#2ects to fulfill a common purpose" +ctivity diagram' +ctivity diagram is typically used for #usiness process modeling, for modeling the logic captured #y a single use case , or for visualizing the detailed logic of a #usiness rule"-omplicated process flo s in the system are captured in the activity

diagram"$imilar to a state diagram, an activity diagram also consists of activities, actions, transitions, initial and final states, and guard conditions"But difference is state diagrams are in conte)t of simulation hile activity gives detail vie of a #usiness logic" 8eployment diagram' 8eployment diagrams sho the hard are for your system, the soft are that is installed on that hard are, and the middle are used to connect the disparate machines to one another"%t sho s ho the hard are and soft are or6 together to run a system"%n one line its sho s the deployment vie of the system" -omponent diagram' The component diagram represents the high!level parts that ma6e up the system".rom "/(T angle point of vie they form the */+M($9+-($*"This diagram depicts, at a 43: high level, hat components form part of the system and ho they are interrelated"%ts sho s the logical grouping of classes or group of other components" /ote '! The #est ay to remem#er all the #loc6s of UML is ;$erve cool $,U9 during church ceremony; that covers $tate chart,-lass diagrams,$e7uence diagram,,#2ect diagram,Use -ase diagram,9ac6age diagram,8eployment diagram,-olla#oration diagram,-omponent diagram'" (B) What are advantages of using UML? T ist' ! What is Modeling and hy UML ? +s the name suggest U/%.%(8 M,8(L%/< L+/<U+<("Modelling has #een around for years, not only in soft are field #ut also in other trades li6e civil, mechanical etc" ()ample in civil engineering dra ing the main architecture #uilt of diagram is a model #y itself"Modelling ma6es comple) and huge system to #rea6 up in to simple and discrete pieces that can #e individually understood" ()ample simple flo chart dra ing is modeling" There are t o main advantages of modeling'! = 1eada#ility' ! 1epresenting your hole architecture in flo chart, class diagrams, (1 diagrams etc ma6es your pro2ect more reada#le" (specially hen

programmer>s change 2o#s handover #ecomes easier" More the pro2ect is not reada#le more the dependencies" = 1eusa#ility' ! +fter the system is more reada#le and #ro6en do n to pieces, it #ecomes easier to identify redundant and similar modules" Thus increasing reusa#ility" $o hy UML, ell different language>s have different ays of coding and synta)es" %n order to #ring all languages in one roof UML is in to picture" +s the term comes in U/%.%(8, it unifies all disparate languages in one roof so that can #e understood #y people ho are or6ing on some other platforms" (+)What>s the se7uence of UML diagrams in pro2ect? T ist' ! &o did you implement UML in your pro2ect? .irst let me say some fact a#out this 7uestion, you can not implement all the nine diagrams given #y UML in one pro2ect? you can #ut can #e very rare scenario" The ay UML is implemented in pro2ect varies from pro2ect to pro2ect and company to company" 43@ $econd very important point to remem#er is normally all diagrams are not implemented in pro2ect , #ut some #asic diagrams are important to have in order that pro2ect is reada#le" When e tal6 a#out pro2ect>s every pro2ect have phases e)ample (1e7uirement>s phase, design phase, coding phase etc etc)"+s every phase of the soft are cycle proceeds these diagrams come in picture" $ome diagrams span across multiple phases" /ote' ! %f you ant to have a detail a#out soft are life cycle loo6 out for chapter A9ro2ect Management;" /ormally follo ing are different #asic phases'! 1e7uirement phase (Use -ase 8iagrams , +ctivity diagrams) 1e7uirement phase is the phase here you normally gather re7uirement and Use -ases are the #est things to ma6e e)planation of the system" %n re7uirement phase you can further ma6e complicated Use -ases more simple and easy to understand #y using

activity diagrams, #ut % do not see it as must in every pro2ect" %f the Use cases are really complicated go for a +ctivity diagram" ()ample -1U8 (creates, read, update and delete) operation use cases have no significance for ma6ing activity diagrams" $o in short the outcome UML documents from re7uirement phase ill #e Use -ase and +ctivity diagram documents (+ctivity diagram documents ill only #e there if there are complicated Use -ases to #e simplified)" Bust a small T ist' ! 8o % need all UML diagrams in a pro2ect? /ote' ! This 7uestion is specially as6ed to 6no have you actually used UML" % have seen many guys trying to give some 2ac6 of all ans er>s saying AC($;" Be are it>s a trap" /ot all diagrams are needed in pro2ect e)ample' ! +ctivity diagrams ill only #e needed hen you ant some simplified loo6 of a complicated use case" 8esign phase (-lass diagrams , o#2ect diagrams , -omponent diagrams , -olla#oration diagrams , 8eployment diagrams, $e7uence diagrams) 8esign phase is the phase here you design your technical architecture of your pro2ect" /o again in this you do not use all UML documents of a pro2ect" But the ne)t document after the Use -ase document ill #e the -omponent diagram" -omponent diagrams form a high level classification of the system" $o after AUse -ases; 2ust try to come out ith a high level classification D grouping of related functionalities" 43E This should #e compulsory diagram as outcome of this document ill form A/+M($9+-($; structure of "/(T pro2ect" ,6 no once your high level grouping is done you can go ahead ith class diagrams" (specially from Use -ase you get the A/,U/$; and A0(1B$; hich can form the class name and the method name respectively" .rom my point of vie class diagrams should #e compulsory in pro2ects" ,#2ect diagrams are not compulsory it depends on ho complicated your pro2ect" ,#2ect

diagrams sho >s the relation #et een instances of class at runtime" %n short it captures the state and relation of classes at any given moment of time" ()ample you have class hich creates o#2ects of different classes, it>s li6e a factory" %n class diagram you ill only sho that it as a simple class ith a method called as A-reate,#2ect;"But in o#2ect diagrams actually you ill sho the types of instances creates from that o#2ect" -olla#oration diagrams mainly depict interaction #et een o#2ect to depict a some purpose" % find this diagram to #e more useful than ,#2ect diagrams as they are addressed for some purpose" ()ample ALogin 9rocess; hich ill use ALogin o#2ect;, AUser ,#2ect; etc to fulfill the login purpose" $o if you find the process very complicated go for this diagram" % see as a thum# rule if there is a activity diagram hich sho s some serious complicated scenarios % ill li6e to go for this diagram inorder to simplify the e)planation" $tate chart diagram is again created if your pro2ect re7uires it" %f your pro2ect has some complicated start and end states to sho then this diagram is most useful" 1ecently % as ma6ing a call center pro2ect here the agent phone pic6up and hang state has to #e depicted" $o my first state as hen agent pic6s up the phone and the final stage as hen agent hangs the phone, in #et een process as very complicated, hich can only #e sho n #y using state chart diagrams" $e7uence diagrams are needed if some se7uence is complicated" 8o not confuse se7uence diagrams ith +ctivity diagram, +ctivity diagram>s map to a Use -ase hile se7uence diagrams sho o#2ect interaction in se7uence" 8eployment diagrams are again not a compulsory re7uirement" %t sho s the hard are and soft are deployment of your system" %f you really have leisure in your pro2ect go for it or if you ant to ma6e the client smile seeing some diagrams" %mplementation phase D -oding phase (-lass diagrams for reverse 43F

engineering , ,ther diagrams for validity chec6) %n this phase mostly class diagrams are re!engineered ith the source code" But other diagrams are also present for validity chec6 e)ample state chart diagrams ill #e used in case to chec6 that the #oth activity #et een those states are follo ing the proper logic" %f some things have to #e changed then again there is iteration #ac6 ard to the 1e7uirement phase" Testing phase This phase mostly goes for the testing department" % am not tal6ing a#out preparing UT9 plans #ut $%T9 plans" Where the testing department ill loo6 at all diagrams to prepare a test plan and e)ecute it" ()ample it ill see the Use -ase document to see the #usiness rules, it ill see the activity diagram and se7uence diagrams to see the proper flo of modules" %f some things are not proper there is iteration #ac6 to the 8esign phase" 1oll out and close over phases" +ll document 2ust to rechec6 the things are proper e)ample are all modules deployed according to the deployment diagrams, are all #usiness rules in Use -ases satisfied" Let>s revise follo ing are the points'! = /ot all diagrams are compulsory" = The minimum diagrams according to soft are life cycle phases are '! 1e7uirement phase' ! Use -ase 8iagrams 8esign 9hase' ! -omponent diagrams, -lass diagrams %mplementation phase' ! +ll diagrams derived from pervious phases specially class diagram for reverse engineering" Testing phase' ! +ll diagrams derived from re7uirement and design phases for verification and preparing test plans" 1oll out and close over phase' ! +ll document derived from 8esign phase and re7uirement phases" Belo is a sample figure hich sho s all the documents in relevant phases" 43G

.igure '!33"3 9hase mapping ith UML documents 44H /ote'! This #oo6 ill no attempt to descri#e every element of a UML diagram"But it>s advisa#le that install any decent UML tool and do a small practice of one or t o diagrams hich ill ma6e you comforta#le during intervie " (+)<ive a small #rief e)planation of all (lements in activity diagrams? .igure '! 33"4 (lements of +ctivity 8iagram +ction $tate '! %t is a type of state that has an internal action and one outgoing event that completes the internal action" $tate '! %t>s a condition hen follo ing events occur'! 443 = ,#2ect satisfies a condition" = ,r performs a action" = ,r aits for a event to happen" %nitial $tate'! %t represents a state #efore any event occurs" .inal $tate'! 1epresents completion of an activity" Transition .or6''! 8enotes #eginning of parallel path activities" Transition Boin' ! 8enotes merging of parallel path activities" -ontrol .lo ' ! 1epresents relationship #et een t o states and actions" %n short it indicates that an o#2ect in one state is entering some other state" ,#2ect .lo ' ! -onnects an o#2ect flo state to control flo or action state" ,#2ect in $tate' ! %ndicates an o#2ect state after manipulation #y multiple activities" 8ecisions' ! 8efines if there are any condition>s in the path" $ im Lanes' ! +ssigns responsi#ility to action states" $ignal receipt $hape' ! Used to replace an event la#el on a transition" $ignal $end $hape' ! Used to replace an event la#el on a transition" -onstraint' ! -ondition>s that must #e maintained true in order the system is valid" 444 4!(lement -onstraint' ! %t sho s a constraint on t o classes or associations" ,1 constraint' ! %t sho s an ,1 constraint on t o classes or associations"

(+) ()plain 8ifferent elements of a colla#oration diagram ? .igure '! 33"I (lements of -olla#oration 8iagrams -lassifier 1ole '! %t classifies a role" +ssociation 1ole '! %t sho s relation #et een t o classifier roles" Multi!,#2ect '! %t used to sho operation related to entire set of o#2ects rather than on a single o#2ect" -onstraint '! -ondition>s hich must #e maintained as true in order that system is valid" 44I 4!(lement -onstraint' ! %t sho s a constraint on t o classes or associations" ,1 constraint' ! %t sho s an ,1 constraint on t o classes or associations" (+) ()plain -omponent diagrams ? .igure '! 33"5 (lements of component diagrams 9ac6age' ! %t logically groups element of a UML model" -omponent' ! %t>s the actual implementation or physical module of a UML system" 445 /ode' ! + physical system hich represents a processing resource"()ample 9- or a host machine" %nter.ace '! %t specifies the e)ternally operations of a class, component, pac6age, or other element ithout specifying internal structure" 8ependency '! $ho s relationship #et een t o elements" 4!(lement -onstraint' ! %t sho s a constraint on t o classes or associations" ,1 constraint' ! %t sho s an ,1 constraint on t o classes or associations" 44: (+) ()plain all parts of a deployment diagram? .igure ' ! 33": (lements of 8eployment 8iagram 9ac6age' ! %t logically groups element of a UML model" /ode' ! + physical system hich represents a processing resource" ()ample 9- or a host machine"

-omponent' ! %t>s the actual implementation or physical module of a UML system" /ode instance' ! %t>s a runtime physical instance of a processing resource" 44@ -omponent %nstance' ! %t represents an implementation unit that has identity at run time and can contain o#2ects" + component could #e contained ithin a node instance" %nter.ace '! %t specifies the e)ternally operations of a class, component, pac6age, or other element ithout specifying internal structure" ,#2ect' ! %nstance of a class" -omposition shape' ! %t is a form of aggregation that indicates that a part may #elong to only one element or life time of the element" -ommunication' ! &o an actor 8ependency' ! $ho s relationship #et een t o elements" 4!(lement -onstraint' ! %t sho s a constraint on t o classes or associations" ,1 constraint' ! %t sho s an ,1 constraint on t o classes or associations" 44E (+) 8escri#e various components in se7uence diagrams? .igure '!33"@ (lements of $e7uence diagrams ,#2ect lifeline' ! %t represents the lifetime of o#2ect creation and its destruction" %f the o#2ect is created or destroyed during the time period the diagram represents, then the lifeline stops or starts at the appropriate point" +n o#2ectJs destruction is mar6ed ith a large K" +ctivation' ! %t>s time period during hich actor is performing a action" Lifeline '! This say>s that there e)ist some condition on the o#2ect lifetime" 44F Message' ! %t sho s communication #et een o#2ects that conveys information and results in an action" Message (call)'! %ts same li6e message #ut also conveys some information and results in

action" +ll messages have same definition as the Message (-all) given a#ove" 4!(lement -onstraint' ! %t sho s a constraint on t o classes or associations" ,1 constraint' ! %t sho s an ,1 constraint on t o classes or associations" 44G (+) What are the element in $tate -hart diagrams ? .igure '! 33"E (lements of $tate -hart 8iagrams $tate' ! %t>s a condition hen follo ing events occur'! = ,#2ect satisfies a condition" = ,r performs a action" = ,r aits for a event to happen" 4IH -omposite $tate '! %t has one or more su#states" %nitial $tate' ! %t represents a state #efore any event occurs" .inal $tate' ! 1epresents completion of an activity" Transition '! $ho s the change of one state to other" Transition .or6' ! 8enotes #eginning of parallel path activities" Transition Boin' ! 8enotes merging of parallel path activities" 8ecision' ! %ndicates condition to move to different states" $hallo &istory' ! 1epresents the state last visited" When a transition to the indicator fires, an o#2ect resumes the state it last had at the same level as the history indicator" 8eep history' + deep history allo s you to return from hatever su#!state, hereas a shallo one only remem#ers the initial state of a composite state" 4!(lement -onstraint' ! %t sho s a constraint on t o classes or associations" ,1 constraint' ! %t sho s an ,1 constraint on t o classes or associations" 4I3 (+)8escri#e different elements in $tatic -hart diagrams ? .igure '! 33"F (lements of $tatic diagrams 9ac6age' ! %t logically groups element of a UML model" -lass' ! They descri#e set of o#2ects ith similar structure, #ehavior, and relationships" 8ata Type '! + data type is an instance of the 8ataType metaclass defined in the UML metamodel" + data type declares a type of class attri#ute" That type is availa#le as a string you can include hen you define attri#utes for other elements in a model"

4I4 %nterface '! %t specifies the e)ternally operations of a class, component, pac6age, or other element ithout specifying internal structure" <eneralization' ! generalization is a relationship #et een a specific element and a general element, such that the specific element is fully consistent ith the general element and includes additional information (such as attri#utes and associations)" .or e)ample, the classes -ar, Bi6e, -ycle can all #e specific elements of a more general a#stract class element named vehicle" Binary +ssociation' ! %t>s a relationship #et een t o classes" -omposition' ! + composition is a form of aggregation that indicates that a part may #elong to only one hole and that the lifetime of the hole determines the lifetime of the part" 8ependency' ! $ho s relationship #et een t o elements" Utility ' ! Whatever +ttri#utes and operations you define for a utility #ecome glo#al varia#les and procedures" $u#system' ! %t is a pac6age that contains the contents of the entire system or an entire model ithin the system" 9arameterized class' ! %t is a template that descri#es a class ith one or more un#ound formal parameters" Binding' ! Binding is a 6ind of dependency that indicates a #inding of parameterized class, or template, parameters to actual values to create a #ound, or no parameterized, element" Bound element ' ! 9arameters of the parameterized class are #ound to actual values" ,#2ect' ! 1epresents instance of a class" Lin6' ! 1epresents Lin6s #et een o#2ects" /!ary Lin6' ! represents lin6 #et een n o#2ects" Meta!-lass' ! Whose instances are classes" $ignal' ! $pecifies stimulus #et een classes for hich there is no reply" %t is a generaliza#le element defined independently of the classes handling the signal" ()ception' ! $ignal raised #ecause of #ad e)ecution"

4II Trace' ! %ndicates historical relationship #et een t o elements" 1efinement' ! 1efinement is a 6ind of dependency that indicates a historical or derivation relationship #et een t o elements ith a mapping #et een them" Usage ' ! Usage is a 6ind of dependency that indicates that one element re7uires the presence of another element for its correct implementation or functioning" 4!(lement -onstraint' ! %t sho s a constraint on t o classes or associations" ,1 constraint' ! %t sho s an ,1 constraint on t o classes or associations" 4I5 (+)()plain different elements of a Use -ase ? .igure '!33"G 8ifferent (lements of Use -ase 9ac6age' ! %t logically groups element of a UML model" Use -ase '! %t represents a set of events" +ctor ' ! 1ole played #y an outside o#2ect" %nterface '! %t specifies the e)ternally operations of a class, component, pac6age, or other element ithout specifying internal structure" -ommunication' ! &o an actor 8ependency sho s relationship #et een t o elements" 4I: ()tends' ! %ndicates that the elements come in parent child relationship here one element inherits other elements #ehavior" Uses' ! &ere one element uses the other elements #ehavior"The main difference #et een ()tends and Uses is a A%s a; and A&as a; relationship"; %s a Arelationship defines a child parent relationship" ()ample AKCL; is a child of A9M1;";&as a; relationship defines an aggregation relationship that AKCL; has a ABLU( $&%1T;" $ystem #oundary' ! %ndicates the system #oundary of a Use case" 4!(lement -onstraint' ! %t sho s a constraint on t o classes or associations" ,1 constraint' ! %t sho s an ,1 constraint on t o classes or associations" T ist' ! What>s difference #et een +ctivity and se7uence diagrams?(% leave this to the

readers) 4I@

You might also like