[go: up one dir, main page]

0% found this document useful (0 votes)
48 views14 pages

Aoop Ha-2

1) Test driven development is a software development process that involves writing tests before writing application code to guide the development. 2) The process involves including a test, running tests to see if any fail, writing code to pass the test, refactoring code if needed, and repeating the process. 3) Clean code makes code more readable and maintainable through practices like using simple and descriptive names, proper indentation and whitespace, and avoiding code smells.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views14 pages

Aoop Ha-2

1) Test driven development is a software development process that involves writing tests before writing application code to guide the development. 2) The process involves including a test, running tests to see if any fail, writing code to pass the test, refactoring code if needed, and repeating the process. 3) Clean code makes code more readable and maintainable through practices like using simple and descriptive names, proper indentation and whitespace, and avoiding code smells.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

sDetome Asstynmeat 2200D33040

LA.Dference betuoeen Aktiact clan and Dtoface.MDevaStosthReddy


Abstnct cly Tntenface
O Atstract clan Can have akskroet hae the
) Dnteyface Can only haue
&non-absract methodu abetract mehod
Tt doesn't suppot multiple RE Suppody muttiple trhettance.
fnhettoan ce
cthi Abstact elan ann favefral, non- ü) nteface has
ony static
finalstate § non-Stafic voiables fral aoiables. i
eV) The atstact keyoood is wed to dv) The inteface keypoond is wed
declaxe abstract clas to dec lare
cv An abstract elas Can be extend v)Arn inteaee Can be implermeits
ustng "keyuoxd extend'. by ustng vegoond implemeits".
E
pulic abstract elan shape f putl'e intoface oauoable
puie abstract void doa);
3 void da)();

Abstract factory Design Pattoun


"Abstraet factory Destgn patton osiks undr Super foctoriey
cohich ereates anothe factorg
f factoies .ohich compiles under ereationa Design Jacony
patteun.
Squane"); Sytem-outpaintn
nide
sapetrnglement Reetangle clam
doao
; void publie
Shape*intedace
i
orie Factory nplemeotatton
its eal Eo,uoe factaies
upufactoïes
chieh . anothen or oejects
under' oLke, patun design actony fAbsact
pattua. Deseriptiorn
Desig foctory ra
Abstct
():void td tdouol).
oid tdaano:void tdaoc)void
targe Raundeduane |3uone
Ractangle
implen
end
tdaa):void
Shape
1getShape):shape *gtSope():shope
shopeFactoy Pourdad Fattory Srape
Eztendy
main + factory shape
hgetshapel):
+ytFactory):Absrat
Derno actory nbstvat paducen Factoy factony Abstnet
dagrar Block_
0
92000 33010
clan Squone tmplemeuh sape f
publie vod drau {
Systen out 'pinln l"Smide Squone ");
clan Roundod Rectargle tonplened shape f
puble void doaus )f
Sykem ot pinten Daide aundedReetange ))
elau PoundSauare
publie void tmplernendty
doauo dhage
Ssterm out pirtiDnide RoundedSquore ");
absttact clan tbstoct Factory
putle chope gtshage (stiny shopeTyR))
cla shopefackory enterds AtstLeactory
puble shape getshape (Shing shape Tre)
i4(Saretye equalslgrone Case ("SQUARE")
elnn neuo Suae )}
else if(ShapeTgpe equalilqrore Cae C"RECTANGlE")
neunn ne Rectarqle ;
xe nn null)

clan Rounded choge fackory ekerdy


Ahetnct Fatony
utsie Srope ehoe (Sitrg shayatyp
L$ (shapeype. eqy1al Iaqone Cae ('saUARE ))
seusn neo audadquae(}
ele if(StaeType eaualh Igneoe osecEeTANG LED)
atn
elnn neo.dd
Rec tanqe);
nulli
22000330+0
ttan Tactoryfoducen
publee static Atstractfactory get Factory Cboolean
ifC6)
tetuun neuo
else shapeFactoy)}
setun neuw sLoundedshopel);
clau Abstrat Factory fattn Derno f
publc statie vod main(Stitrg axql3)

stactfactory af=fpttory poroduce.getfastory (tae);


Shofe si = af geshape ("Rectange );
Sdao)}
Shape S2r oj gtshape
S2-Joauol)) Cquae")')
Abstract Factony afi =fctonypradueer qetfactoy (Fale);
Shape s3 =of- gotthape C ectangle")}
S3dawl))
shape Sy =afgetshape (" Squaoe ") ;
Sdoool);

Conclusion Jn this
pattn se take shape as inerace By ustng
inteace we irplenented 4 clan by ustng trnplemerda and
we oveiden bne mesthod drwer()
Output
Dnatde Reckange
Tuyide Sauane
Gnstle Pourdad etorele
Trsde Poundedquoe
920003010

)
Adaglen dean patton
Descxiption!
In this patlenn t o ungeloted objecty woars togehen.
""The obje tha can loin tuoo unselated object, is called as
Feapler design paton and tt cormes urden structnal desin paten
"Th tits attro of paokern ue need to implement înthe 2 oa
WVolt clan ohich is used to meose vot.
ii SocKet is wse to contant is pooduced 20v.
Rlock diogram
Volt

volt
getvotl)
getvdt)

Eatend Secket
tget VotC

Socket Adapter
get i2ovotsC)
Sockt elo Adaghe get (2volts)
Jet 3 vot)
3et 12v
gef Bv/convendvolt Main
Tmplemets
Maint)
2200033070
nplernerkation
clax Vo tt
prtvte tnt vo tt;
publie vod (intv)
thes. volt =Vj
publie int get volts C)
{.
netoun vots;
pubte void setvolt Cint olt)
this.votto vottj

clan Socket

publte volt gelVote


setsun neovoltL a0);
3

intoface sockat Adapten


volt qet(20 voltC );
olt get 2volt );
volt get 3volt();
clas Soesetclas Adaten entends sockat
Cnplaneda Soket Adapken
puble volt get Dovote)

publte volt gt votC)


sétwn Convert vot CV, to);
pubie volt qat vott)
Lvolt v= Convetvolt
get voltl} CVi yO)}
2200o32070
povot volt convet volt( vott v, trt i:)
aetusun new volt (voget volts () /)3

publle clan main


puble stotic void main CSting Yonqs)
SocketAdagey Socket ada pten neuo SoeetAdapten();
volt 120 = sOCket Hdapten
Ket Adapter. qeti20volt
it 2 Soc
Volt SocketAdapte C)
lt v3 -Stcket
qet i2volt03
Adaptenget3volt C),
Lystemoul"pontln(The output (20v" t Vi20:get volts ();
System -out poünt Xn (" the output 2u"+ vntqet volts C));
Systern out poünttn The btput zu" tv9:qetvolts ();

outputy
The output o Dov 120
the outpt 2v 12
the atput 3v:3
22000230t0

Test Daven Deve lopment (TDD)


Test doiven developrnerd is a Softwane developmert proceh.
As the me
name rnpltes,ivolves tilizing tets to guide aplicotion
developrert rexuttng n sinple , tortiue, tnpkmertotion
oitth goad test covenage sigt fiom the stent
the instructiors below ae hoo to Conduet a TDD tet
i) Onclude a test
Ko Run though al af the test and See f any neo.one fails
atiy chate
Pogam.
¿) Test yon code and sefactor it
cV) epeat
hdd a tetk
pas
Erecute the text
(Refoetony
Make chongey to code
Lfart JErecALte dhe tetfas
fon Development stops
cleon code
clean code makes the code moe eoda be ord hence eaiby maintainab
inshoat cleancoding s the uoay ef oriting thecede Such-that
it ists eaily eadable estable and les pone to ew
chonacteryties ! clean code
"Stmple
"Mointainable
"Tetatde
" Readable
2200032030
To orite clean cede in java
Sructne

matn
FJava
9teowCe
-test
-java

opernaing
Sn puo ue h e to name voable clowses, methody et
hence shoud aoay geve them a name thot they an belath to
whitespace, and îndentatiorn
cohitespace can help you make pun cade vey seodabe that is
ohy it adised to add ohtespaces toheneve
you can odd tham.
Code Smelu
Code Smel ne not the kas tte
proganoth code Smell
to0 youn pxcpam mtdht, coonk juut finehey do not prevent
dhe proqam fiom funettontn or are fneomect They jut
or
Sgnity hke oeaknes n detqn and miqkt inçreales dhe sK
or buqs and pxoamfarlre on the felune.
"Types ef code Srnelly
(nuoithin clams
Sy ketuoeen claes
úy code amelt idhin clanes
Cormment yes, cornmert one Code Srnell too B like deodat
to the code J! emmerde eiglan feso ines ef complkx code Cony
compex euenion
qmhod Along methad tontatny too many ltoes o! code.Any
Code uotth moge han l8 iney shDud make you Quest (on
2200032040
ACode smel betoeen clael
Oata elames A clan hat jut stPed da and no methods.These
elanes don t contain any dunction aty
Data cumps-Data that lo ky Sini l aybe belorgs 4o dhe Sne
clan.

Dadoctorirng technigu
Qefactoinq encompases a number of specifte code hygiene
paartices " when it comes to eliminatig code Smelly haoever,
there ae thuree patiulanly etfectie technia!
Composiog Methady
"The tecntque ,cornposing aims to eliminate sedutat methedy
"here re two distinct ooys developes Coan do fis
Srplefing methody cal
"The next techni¡e s to mpf mesthod calethat ovetime
have becorne busied io Jage amous ef code that ore
daunting to uok oith pOamey have Seveolnys to
Ermey melhod caly.
2200o 330o
tlahset
Hahset s a lolernentotion canu. of set
" Set act os aran set 8tore gHoup f objeey
No dupltctt values ve allouoed
" Oden caunot be paredicted.
method e! hashset:
boolean add Cobj E)
,) vod clean c
N) boolean Cortainn (obi)
ivy boslean sErnpy U
cM) tnt sne)
iplementation
clats ash getDemo
publte statte void main String ags)
Hashset sting hs=neuo tashset<string))
hs add LTndio);,
hg. add Canca)'"
ha. add mni ea ");
hso addDndia);
terator.ite hs iteraton 0;
ohle Cit hotext){
&gtero out. pritla (itarnext L1);

india
Caradda
set)) printn break;
shet<string>c); keugetC)) out h3ytm. arn set
neu
Set<strtng
set > Cose3'r
phno); not ('ph S-opln kjbrea
Cname)) get <hn Phno
&netC)}
name"
; ("entes nome
So-p Coel
hnput(ome
no); iph k;
brea
next);longt phng-[c.
phno"); enten -outpsnt
lnc Syutero
SConet( name
=
")nane (enter otpsitl tem 1-eade
Cchoice) Switch
))
Systermoutapüntn("erter
choic)e SConeytnt choice= int
Et"); putprintln Systern-
kayset"9Stem-outpintent'
dlal eplay 4.
upolnn.
key")) from vale tetrieve &sten-o
pai")n keyalue phoneSpkenoutpsüntlnt
erten l-
CStermin) 7 Cannen (rue)i
neuo uohile
=Stsc
onnen
phno Lorg
C); lonqStiing, tauhtap< neo
Hasapesthing,
Lorg
=hn
CI) ags Csting in void stotie publie
tashapDerno cln
.ttlbttasbta
ble javatrnpont,
*ulil ipoxt
a
Hahma
32040
2200033040
Rinked list

clas lLTerno
publle static votd roln (siing ogs t3)
Linkedlist <string> u- neo LinkodList cgAring? );
liadd l'aica")}
li add'canado");

l. add('china)s
Sytem.outpoüntla;
Scanner sc neoSanne (syten.in);
String elenert ;
fnt position , choice =0;
ohile choice )
S"oplaC l- add elernent)s
J.opaC nemove an element ");
S-oplnt 3- change an elemet ");
So-psn 4. exit")3
S"opnlenter w choiee");
choice SC next Lntl)
&uoitch Cchote)
Coes: Siopln( ente an element ");
alemet senert())
S-opluleulen positio))
position sc nextSnt ()}
ladd lpositlon , element )?
break;
postlon= nerte)
l.nemave (posttton\5
kaeak.
22000330+0

Cav 3. Sygtem ouf ntrta (' enden potiton";


position= ScnextlutC);
Bytem.out pointla ( enten now elemeut)
element -scnext (1)
l set (post tion, element);
brea h

ystemot po~ntla List);


Dtoraton it-l. itentorS
while (t-hasent J)
Systernout paintln lit- Next()):

You might also like