64
COMP61511 (Fall 2018) Software Engineering Concepts In Practice Week 3 Bijan Parsia & Christos Kotselidis < , @manchester.ac.uk> (bug reports welcome!) bijan.parsia christos.kotselidis

COMP61511 (Fall 2018) Software Engineering Concepts In ...syllabus.cs.manchester.ac.uk/pgt/2018/COMP61511/... · A Bit On Git Slides. Technical Debt. Technical Debt is "the obligations

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Page 1: COMP61511 (Fall 2018) Software Engineering Concepts In ...syllabus.cs.manchester.ac.uk/pgt/2018/COMP61511/... · A Bit On Git Slides. Technical Debt. Technical Debt is "the obligations

COMP61511(Fall2018)SoftwareEngineeringConcepts

InPracticeWeek3

BijanParsia&ChristosKotselidis< , @manchester.ac.uk>

(bugreportswelcome!)bijan.parsia christos.kotselidis

Page 2: COMP61511 (Fall 2018) Software Engineering Concepts In ...syllabus.cs.manchester.ac.uk/pgt/2018/COMP61511/... · A Bit On Git Slides. Technical Debt. Technical Debt is "the obligations

ReflectingOnPersonalQualities

Page 3: COMP61511 (Fall 2018) Software Engineering Concepts In ...syllabus.cs.manchester.ac.uk/pgt/2018/COMP61511/... · A Bit On Git Slides. Technical Debt. Technical Debt is "the obligations

3Of5We'reatWeek3!

3/5sdoneaftertoday!Whereareyou?

Andwhereareyougoing?Whatarethenextsteps?

Thisisagoodtimetoreflect

Page 4: COMP61511 (Fall 2018) Software Engineering Concepts In ...syllabus.cs.manchester.ac.uk/pgt/2018/COMP61511/... · A Bit On Git Slides. Technical Debt. Technical Debt is "the obligations

ReflectionReflection is the process of examining one own thoughts,beliefs, experiences, concepts, etc. in order to gain self-knowledgeandinsight

Refectiondoesn'tneedtobejudgementalYouaren'tlookingforflawsYouaretryingtounderstandyourselfThisincludesgoodthings!

Maybetheycangetbetter

Page 5: COMP61511 (Fall 2018) Software Engineering Concepts In ...syllabus.cs.manchester.ac.uk/pgt/2018/COMP61511/... · A Bit On Git Slides. Technical Debt. Technical Debt is "the obligations

ReflectionExample1ForCW1somepeoplehandedin

arararchive(e.g.,mbassbp2_cw1.rar)Thisisinspite

mymentioningitinlectureitbeingdescribedintheassignmentLab0andLab1havingthesamerequirment

AndbeinggradedandreturnedbeforeCW1wasdue!Whatwentwrongwiththeirprocess?Howtofixit?

Page 6: COMP61511 (Fall 2018) Software Engineering Concepts In ...syllabus.cs.manchester.ac.uk/pgt/2018/COMP61511/... · A Bit On Git Slides. Technical Debt. Technical Debt is "the obligations

ReflectionExample2LastThursafternoon

severalpeopleassertedthattheircode100%shouldpasssomesimpletestsandthattheircodereviewfound"nobugs"

Forsome,IfoundtheycouldnotpassanytestForothers,Ilookedatthesourcecodeandimmediatelyspied2-3"obvious"bugsWhatwentwrong?

Andhowdowefixit

Page 7: COMP61511 (Fall 2018) Software Engineering Concepts In ...syllabus.cs.manchester.ac.uk/pgt/2018/COMP61511/... · A Bit On Git Slides. Technical Debt. Technical Debt is "the obligations

ReflectionExample3Lookonthediscussionboard!

Alotofmyrepliesarealongthelines:"Ontheonehand,youhavewhatwcdoes.Ontheother,youhaveaideaofhowtodoitdifferently.Whichdoyouthinkshouldwin?"

Andthatwasenough!Howtogetthatwithoutanexternalprompt?

Page 8: COMP61511 (Fall 2018) Software Engineering Concepts In ...syllabus.cs.manchester.ac.uk/pgt/2018/COMP61511/... · A Bit On Git Slides. Technical Debt. Technical Debt is "the obligations

ReflectionExample4Peopleasked:

Ifixedmyminiwc.pywillyouretestittocheckthatit'srightIwanttoknowthatmyinterpretationisrightIjustwanttoconfirmmyunderstandingsoIdon'tlosepoints

Reflect!Doweunderstandwhypeopleaskedthese?What'stherightresponse?What'swouldbeaproblemwithansweringthesedirectly?

Arepointsthepointofthecoursework?

Page 9: COMP61511 (Fall 2018) Software Engineering Concepts In ...syllabus.cs.manchester.ac.uk/pgt/2018/COMP61511/... · A Bit On Git Slides. Technical Debt. Technical Debt is "the obligations

ReflectionExample4Lookonthediscussionboard!

AlotofpeoplegotstuckHowandwhy?Didyougetstuck?Didyougetunstuck?

How?

Page 11: COMP61511 (Fall 2018) Software Engineering Concepts In ...syllabus.cs.manchester.ac.uk/pgt/2018/COMP61511/... · A Bit On Git Slides. Technical Debt. Technical Debt is "the obligations

BijanicReflection!Notsobad,actually!

Aremygoalscorrect?Aremymethodseffective?

Whatwouldprovemewrong?Isitworththeeffort?

I'mprettytired!

How'dIdo?

Page 12: COMP61511 (Fall 2018) Software Engineering Concepts In ...syllabus.cs.manchester.ac.uk/pgt/2018/COMP61511/... · A Bit On Git Slides. Technical Debt. Technical Debt is "the obligations

MetacognitionMetacognitionisthinkingaboutthinking

ReflectionisoneexampleIngeneral,animportantskill

Forexample,whenyouarestuckonaproblemithelpstocheckwhetheryouareinarutthatis,justtryingthesamethingoverandover

Beingawarethatyougotstuckcanhelpyougetunstuck!

Page 13: COMP61511 (Fall 2018) Software Engineering Concepts In ...syllabus.cs.manchester.ac.uk/pgt/2018/COMP61511/... · A Bit On Git Slides. Technical Debt. Technical Debt is "the obligations

CognitiveBiasesAcognitivebiasisasystematicdeparturefromrationality.

Weallhavethem,and ofthem:lots

Page 15: COMP61511 (Fall 2018) Software Engineering Concepts In ...syllabus.cs.manchester.ac.uk/pgt/2018/COMP61511/... · A Bit On Git Slides. Technical Debt. Technical Debt is "the obligations

Self-EfficacyPerceivedself-efficacyisdefinedaspeople'sbeliefsabouttheircapabilities to produce designated levels of performance thatexerciseinfluenceovereventsthataffecttheirlives.

Toomuchself-efficacyisoverconfidenceisrelatedtoDunning-Krugar

Toolittleself-efficacyparalysesyouleadstounderachievement

Page 16: COMP61511 (Fall 2018) Software Engineering Concepts In ...syllabus.cs.manchester.ac.uk/pgt/2018/COMP61511/... · A Bit On Git Slides. Technical Debt. Technical Debt is "the obligations

TwoKeyBiases"Thetendencytoseeoneselfaslessbiasedthanotherpeople,ortobeabletoidentifymorecognitivebiasesinothersthaninoneself."

"Thetendencyforunskilledindividualstooverestimatetheirownabilityandthetendencyforexpertstounderestimatetheirownability."

Bias-BlindSpot

Dunning-KrugarEffect

Beverycarefulhere!

Page 17: COMP61511 (Fall 2018) Software Engineering Concepts In ...syllabus.cs.manchester.ac.uk/pgt/2018/COMP61511/... · A Bit On Git Slides. Technical Debt. Technical Debt is "the obligations

GoldilocksSelf-EfficacyBothtoomuchandtoolittlearebad!

Toomuch==boredToolittle==dauntedanduninterested

Aimforthesweetspot!

Page 18: COMP61511 (Fall 2018) Software Engineering Concepts In ...syllabus.cs.manchester.ac.uk/pgt/2018/COMP61511/... · A Bit On Git Slides. Technical Debt. Technical Debt is "the obligations

GoldilocksScience!

Awesomestpapertitle:"Self-efficacyandinterest:Experimentalstudiesofoptimalincompetence"

Page 19: COMP61511 (Fall 2018) Software Engineering Concepts In ...syllabus.cs.manchester.ac.uk/pgt/2018/COMP61511/... · A Bit On Git Slides. Technical Debt. Technical Debt is "the obligations

Trajectory!Trajectoryovercurrentlevel

CurrentlevelisstaticItinformstrajectory

Butdoesn'tdetermineitReflection!

AreyoulearningquicklyorslowlyAreyoulearninghowtolearn

Page 20: COMP61511 (Fall 2018) Software Engineering Concepts In ...syllabus.cs.manchester.ac.uk/pgt/2018/COMP61511/... · A Bit On Git Slides. Technical Debt. Technical Debt is "the obligations

AGoalA student who has mastered the [Core Body of Knowledge(CBOK) will be able to develop a modest-sized softwaresystemofafewthousandlinesofcodefromscratch,beabletomodify a pre-existing large-scale software systemexceeding 1,000,000 lines of code, and be able to integratethird-partycomponentsthatarethemselvesthousandsof lines of code. Development and modification includeanalysis,design,andverification,andshouldyieldhigh-qualityartefacts,includingthefinalsoftwareproduct.

IEEE&ACMACM2009.

SoftwareEngineeringCurriculumRecommendations

Page 21: COMP61511 (Fall 2018) Software Engineering Concepts In ...syllabus.cs.manchester.ac.uk/pgt/2018/COMP61511/... · A Bit On Git Slides. Technical Debt. Technical Debt is "the obligations

AStudentWill...beabletodevelop

amodest-sizedsoftwaresystemofafewthousandlinesofcodefromscratch,

beabletomodifya...large-scalesoftwaresystemexceeding1,000,000linesofcode,andbeabletointegrate(1000sLOC)third-partycomponents

Developmentandmodificationincludeanalysis,design,andverification,andshouldyieldhigh-qualityartefacts,includingthefinalsoftwareproduct.

Page 22: COMP61511 (Fall 2018) Software Engineering Concepts In ...syllabus.cs.manchester.ac.uk/pgt/2018/COMP61511/... · A Bit On Git Slides. Technical Debt. Technical Debt is "the obligations

Wc?Wheredoeswc.pygetus?

Foraproperclone≈hundredsofLOCOTOH,maybeunder100!wcgolf?

Withextensionsmaybe1000s?

NotcountinginfrastructureTests,etc.

Does100spredict1000s?Goodquestion!

Page 23: COMP61511 (Fall 2018) Software Engineering Concepts In ...syllabus.cs.manchester.ac.uk/pgt/2018/COMP61511/... · A Bit On Git Slides. Technical Debt. Technical Debt is "the obligations

LookAround!Modestsizesoftwaresystems?

Whatdotheylooklike?Whatdotheydo?Collectsomeexamples!

RememberreverseengineeringPortfromadifferentlanguage!Rewritefromscratch

Createsomethingnew!

Page 26: COMP61511 (Fall 2018) Software Engineering Concepts In ...syllabus.cs.manchester.ac.uk/pgt/2018/COMP61511/... · A Bit On Git Slides. Technical Debt. Technical Debt is "the obligations

ThusFarWeLookedAt...External

FunctionalCorrectness(thefunctionalquality)

Non-functional(abit)Efficiency(thenon-functionalquality)

Now,someinternalTestabilityForModification

Maintainability

Page 27: COMP61511 (Fall 2018) Software Engineering Concepts In ...syllabus.cs.manchester.ac.uk/pgt/2018/COMP61511/... · A Bit On Git Slides. Technical Debt. Technical Debt is "the obligations

Internal:ForModificationMaintainability

easeto"changeoraddcapabilities,improveperformance,orcorrectdefects"

Flexibilityeasetomodifyfornewsituations("internal"versionofadaptability)

Portabilityeasetomodifyfornewenvironments

Reusabilityeasetoextractpartsforuseinothersystems

Page 28: COMP61511 (Fall 2018) Software Engineering Concepts In ...syllabus.cs.manchester.ac.uk/pgt/2018/COMP61511/... · A Bit On Git Slides. Technical Debt. Technical Debt is "the obligations

Internal:ForComprehensionReadability

easeofcomprehendingthesourcecode,espatthestatementlevelUnderstandability

easeofcomprehendingthesoftwaresystemasawholefromthesynoptic("bird'seye")viewtothemyopic("worm'seye")view

Readabilityispartofunderstandability.Butyoucanhavereadablemethodsorfunctionsandanimpossibletograsparchitecture.

Page 29: COMP61511 (Fall 2018) Software Engineering Concepts In ...syllabus.cs.manchester.ac.uk/pgt/2018/COMP61511/... · A Bit On Git Slides. Technical Debt. Technical Debt is "the obligations

Internal:TestabilityAcriticalproperty!

RelativetoatargetqualityAsystemcouldbe

highlytestableforcorrectensslowlytestableforefficiency

PartlydeterminedbytestinfrastructureHavinggreathooksfortestspointlesswithouttests

PracticallyspeakingLowtestabilityblocksknowingqualitiesTest-basedevidenceisessential

Page 30: COMP61511 (Fall 2018) Software Engineering Concepts In ...syllabus.cs.manchester.ac.uk/pgt/2018/COMP61511/... · A Bit On Git Slides. Technical Debt. Technical Debt is "the obligations

ProblemIndicators"asurfaceindicationthatusuallycorrespondstoadeeperproblem"(KentBeckvia )Quicktospot(ifyouhaveexperience)Doesn'talwayscorrespondtoaproblemSomewhatsubjectiveThe

PainPointsApartofthesystemthatrecurrentlycausesproblems

HardtouseRevistoften

CodeSmell

MartinFowler

"WTFtest"

Page 31: COMP61511 (Fall 2018) Software Engineering Concepts In ...syllabus.cs.manchester.ac.uk/pgt/2018/COMP61511/... · A Bit On Git Slides. Technical Debt. Technical Debt is "the obligations

TestabilitySmell def get_file_list(): # Get list of arguments from the command line, minus "wc.py" args_list = sys.argv[1:] ...

or def get_max_width(): max_val_list = []

for rec in file_log: max_val_list.append(rec.get_max_value())

return max(max_val_list)

Thankstothebravestudentwhovolunteeredtheircode!

Page 32: COMP61511 (Fall 2018) Software Engineering Concepts In ...syllabus.cs.manchester.ac.uk/pgt/2018/COMP61511/... · A Bit On Git Slides. Technical Debt. Technical Debt is "the obligations

TestabilitySmellFIXED def get_file_list(**args**): # Get list of arguments from the command line, minus "wc.py" args_list = args[1:] ...

sowecantestby: >>> import wc >>> wc.get_file_list(['wc.py', '-l', 'filename.txt'])

Thankstothebravestudentwhovolunteeredtheircode!

Page 33: COMP61511 (Fall 2018) Software Engineering Concepts In ...syllabus.cs.manchester.ac.uk/pgt/2018/COMP61511/... · A Bit On Git Slides. Technical Debt. Technical Debt is "the obligations

TestabilitySmell2Whatabout:

#all the module's code wc()

Thankstothebravestudentwhovolunteeredtheircode!

Page 34: COMP61511 (Fall 2018) Software Engineering Concepts In ...syllabus.cs.manchester.ac.uk/pgt/2018/COMP61511/... · A Bit On Git Slides. Technical Debt. Technical Debt is "the obligations

TestabilitySmell2FIXEDWewanttoimportthemodulewithoutrunninganything!

#all the module's code if __name__ = "__main__": wc()

Now,import wcdoesn'trunwc()

Thankstothebravestudentwhovolunteeredtheircode!

Page 35: COMP61511 (Fall 2018) Software Engineering Concepts In ...syllabus.cs.manchester.ac.uk/pgt/2018/COMP61511/... · A Bit On Git Slides. Technical Debt. Technical Debt is "the obligations

RefactoringNotice

NoneofthesemoveschangedfunctionalityOrprettymuchanyexternalquality

Butweimprovedtestabilitymaybereadabilityandmaintainabilityreusability!

Werefactoredthecode

Page 36: COMP61511 (Fall 2018) Software Engineering Concepts In ...syllabus.cs.manchester.ac.uk/pgt/2018/COMP61511/... · A Bit On Git Slides. Technical Debt. Technical Debt is "the obligations

WhyDidTheseThingsHappen?HasteLackofunderstanding

OftheproblemOfthetools

E.g.,PythonSomeoneElse'sCodeJustanaccident!

Seemedlikeagoodideaatthetime!

Page 37: COMP61511 (Fall 2018) Software Engineering Concepts In ...syllabus.cs.manchester.ac.uk/pgt/2018/COMP61511/... · A Bit On Git Slides. Technical Debt. Technical Debt is "the obligations

AConsequenceRemembertheTestableFunction'stests

Whatdotestslooklikefor:

>>> import wc>>> wc.get_file_list(['wc.py', '-l', 'filename.txt'])

def get_file_list(): # Get list of arguments from the command line, minus "wc.py" args_list = sys.argv[1:] ...

Page 38: COMP61511 (Fall 2018) Software Engineering Concepts In ...syllabus.cs.manchester.ac.uk/pgt/2018/COMP61511/... · A Bit On Git Slides. Technical Debt. Technical Debt is "the obligations

TestConsequencesMaybe

or

Aretheseeasytomaintain?

>>> import subprocess>>> subprocess.check_output('python wc -l filename.txt')

>>> import sys, wc>>> sys.argv = ['wc.py', '-l', 'filename.txt']>>> wc.get_file_list()

Page 39: COMP61511 (Fall 2018) Software Engineering Concepts In ...syllabus.cs.manchester.ac.uk/pgt/2018/COMP61511/... · A Bit On Git Slides. Technical Debt. Technical Debt is "the obligations

TechnicalDebtOurlackoftestabilityislikeadebt

WemighthavetopayitoffinthefutureByrefactoring

IfwewaititincursinterestThemoretestswewrite,themoretestswehavetochangelaterOurcurrenttestsare

HardtowriteHardtoreadMaybebuggy!

Debtbreedsmoredebt!

Page 40: COMP61511 (Fall 2018) Software Engineering Concepts In ...syllabus.cs.manchester.ac.uk/pgt/2018/COMP61511/... · A Bit On Git Slides. Technical Debt. Technical Debt is "the obligations

ABitOnGitSlides

Page 41: COMP61511 (Fall 2018) Software Engineering Concepts In ...syllabus.cs.manchester.ac.uk/pgt/2018/COMP61511/... · A Bit On Git Slides. Technical Debt. Technical Debt is "the obligations

TechnicalDebt

Page 42: COMP61511 (Fall 2018) Software Engineering Concepts In ...syllabus.cs.manchester.ac.uk/pgt/2018/COMP61511/... · A Bit On Git Slides. Technical Debt. Technical Debt is "the obligations

TechnicalDebt is "the obligations incurred by a software

organization when it chooses an expedient design orconstruction approach that increases complexity and is morecostlyinthelongterm."

Technical debt

Typically,lower(internal)qualitylevelItmaybuyanexternalqualityeffect

Morefunctionality(correctness)Moreefficiency

ItmayhavenegativeexternaleffectsItmayjustbuyprojecteffects

E.g.,developereffort

Page 44: COMP61511 (Fall 2018) Software Engineering Concepts In ...syllabus.cs.manchester.ac.uk/pgt/2018/COMP61511/... · A Bit On Git Slides. Technical Debt. Technical Debt is "the obligations

IntentionalVsUnintentionalDebtUnintentionaldebt==accidentalorincidental

Wemightnotknowweincurredit!Wemightnotknowtheinterest!Resultsofpoorpractice

Seethetestabilityissuesfromthismorning!Intentionaldebt==deliberate,knowinglyincurred

NeedsanidentifiablerationaleWithascope

Ifyoudon'tknowthescope,it'sprobablynot(fully)intentional

Page 45: COMP61511 (Fall 2018) Software Engineering Concepts In ...syllabus.cs.manchester.ac.uk/pgt/2018/COMP61511/... · A Bit On Git Slides. Technical Debt. Technical Debt is "the obligations

WhyGoIntoDebt?2.AShort-TermDebt

Tacticalreasons2.A.1"Big"Debt

Significantshortcuts2.A.2"Little"(individual)Debt

Tinyshortcuts2.BLong-TermDebt

Strategicreasons

Page 46: COMP61511 (Fall 2018) Software Engineering Concepts In ...syllabus.cs.manchester.ac.uk/pgt/2018/COMP61511/... · A Bit On Git Slides. Technical Debt. Technical Debt is "the obligations

PayingDownDebtDebtcanbecomeunmanageable

EvenmanageabledebtcanbecostlyPayingdowndebtcosts

Debtshiftscoststothefuture(Butmightaddsomecostsnow)

RefactoringistheusualapproachButalsothingslikeaddingtests

Doyoualwayshavetopaydownyourdebt?

Page 47: COMP61511 (Fall 2018) Software Engineering Concepts In ...syllabus.cs.manchester.ac.uk/pgt/2018/COMP61511/... · A Bit On Git Slides. Technical Debt. Technical Debt is "the obligations

GoodDebtVs.BadDebtGooddebt

HasaclearbenefitIsworththecostIsmanageable

BaddebtSkewedcost/benefitratioLessorun-manageable

Debtcan"spoil"Toomuchgooddebtcanbecomebad

Page 49: COMP61511 (Fall 2018) Software Engineering Concepts In ...syllabus.cs.manchester.ac.uk/pgt/2018/COMP61511/... · A Bit On Git Slides. Technical Debt. Technical Debt is "the obligations

ManyEquivalencesSourcecodeequivalent

CharacterequivalentASTequivalentNon-comment/namesASTequivalent

TranslationequivalentE.g.,aftercompilation

All-behaviorequivalentBisimilarFunctionallyequivalent

Page 50: COMP61511 (Fall 2018) Software Engineering Concepts In ...syllabus.cs.manchester.ac.uk/pgt/2018/COMP61511/... · A Bit On Git Slides. Technical Debt. Technical Debt is "the obligations

FunctionallyEquivalentTwoprogramsarefunctionallyequivalent just incase theyimplementexactlythesamefunctionality.

Functionalityistypicallycharacterisedby"Input-Output"behaviourInternalstructuredoesn'tmatter

Programminglanguage,algorithm,etc.FEPscandiffer"solely"inexecutionpaths

Therecanbebehaviourdifferences(e.g.,performance!)Strongbutnotmaximallystrong!

Page 51: COMP61511 (Fall 2018) Software Engineering Concepts In ...syllabus.cs.manchester.ac.uk/pgt/2018/COMP61511/... · A Bit On Git Slides. Technical Debt. Technical Debt is "the obligations

WhatBehaviourIs"Functionality"?The functionality of a software system is the requiredbehaviourofthesystem

Notideal,asnon-functionalbehaviourmayberequired

Thefunctionalityofasoftwaresystemisthebehaviourofthesystemthatperformssomeusertask

Ineithercause,thefunctionalityisasubsetofallbehaviour

Page 52: COMP61511 (Fall 2018) Software Engineering Concepts In ...syllabus.cs.manchester.ac.uk/pgt/2018/COMP61511/... · A Bit On Git Slides. Technical Debt. Technical Debt is "the obligations

FunctionalityEquivalent(Reprise)Twoprogramsarefunctionallyequivalent just incase theyimplementexactlythesamefunctionality

The functionality of a program are those behaviours whichperformsausertask

Functionalitymaybechanging,unknown,ormisunderstood

Thesetoffunctionallyequivalentprogramsdependsonthefunctionalityparameter

Page 53: COMP61511 (Fall 2018) Software Engineering Concepts In ...syllabus.cs.manchester.ac.uk/pgt/2018/COMP61511/... · A Bit On Git Slides. Technical Debt. Technical Debt is "the obligations

FizzBuzzExampleComparea"normal"FizzBuzzsolutionwithagolfversion:

Page 54: COMP61511 (Fall 2018) Software Engineering Concepts In ...syllabus.cs.manchester.ac.uk/pgt/2018/COMP61511/... · A Bit On Git Slides. Technical Debt. Technical Debt is "the obligations

FunctionallyEquivalentGivenasetofrequiredfunctionalitiesF,andtwosystems,S1&S2,S1isfunctionalityequivalent(withrespecttoF)toS2ifS1andS2enactF.

So,iftwoprogramsarebehaviourlyequivalentthentheyarefunctionallyequivalent.

WhathappensifS1andS2don'tquiteenactthesameF?

Page 55: COMP61511 (Fall 2018) Software Engineering Concepts In ...syllabus.cs.manchester.ac.uk/pgt/2018/COMP61511/... · A Bit On Git Slides. Technical Debt. Technical Debt is "the obligations

"Sufficiently"FunctionallyEquivalentGivenasetofrequiredfunctionalitiesF,andtwosystems,S1 & S2, which enact functionality sets F1 & F2 (respectively),where, F1 ≠ F2 ≠ F, S1 is sufficiently functionallyequivalent to S2 wrt F if F1 and F2 share "enough" of anoverlapwithF.

Obviously,"enough"isaparameter!

Page 56: COMP61511 (Fall 2018) Software Engineering Concepts In ...syllabus.cs.manchester.ac.uk/pgt/2018/COMP61511/... · A Bit On Git Slides. Technical Debt. Technical Debt is "the obligations

WcExample!GNUwchasmorefunctionality(anduser-notablebehaviour)thanminiwc.py

Orotherwcs!Differentflagoptions,findlongestline,etc.

Somebehaviourisuservisiblebutnot"functional"(orinteresting)wc --help --versionvs.wc --version --help

Non-equivalentinGNUwcDowecaretopreservethis?!

Howaboutspacing?!

Page 58: COMP61511 (Fall 2018) Software Engineering Concepts In ...syllabus.cs.manchester.ac.uk/pgt/2018/COMP61511/... · A Bit On Git Slides. Technical Debt. Technical Debt is "the obligations

WhatIsRefactoringRefactoring is a transformation of code into sufficientlyfunctionally equivalent code that has "better" internalproperties.

"MartinFowlerdefinesas"achangemadetotheinternalstructureofthesoftwaretomakeiteasiertounderstandandcheapertomodifywithoutchangingitsobservablebehavior"(Fowler1999)"—McConnell,24.2

"Sufficientlyfunctionallyequivalent"Userobservable/desirablebehaviourispreservedUptosomepoint

Page 59: COMP61511 (Fall 2018) Software Engineering Concepts In ...syllabus.cs.manchester.ac.uk/pgt/2018/COMP61511/... · A Bit On Git Slides. Technical Debt. Technical Debt is "the obligations

ExamplesForexample,amonolithicscript

haslowtestability(onlysystemtests!)replaceitwithasetoffunctions

e.g.,forarghandling,counting,andprintingresultsresult:easytotestscript

Forexample,hardcodedvaluesgreatforgettinggoing(techdebt!)refactorbymakingthemconfigurable

easiertotweakoreventuallymakeaparameterresult:moreflexibility!

Page 60: COMP61511 (Fall 2018) Software Engineering Concepts In ...syllabus.cs.manchester.ac.uk/pgt/2018/COMP61511/... · A Bit On Git Slides. Technical Debt. Technical Debt is "the obligations

CodeSmellsProblemsigns(selectsample,McConnell )

Codeisduplicated.Aroutineistoolong.Aloopistoolongortoodeeplynested.Inheritancehierarchieshavetobemodifiedinparallel.Aclassdoesn'tdoverymuch.Aroutinehasapoorname.Commentsareusedtoexplaindifficultcode.Aprogramcontainscodethatseemslikeitmightbeneededsomeday.

24.2

Page 61: COMP61511 (Fall 2018) Software Engineering Concepts In ...syllabus.cs.manchester.ac.uk/pgt/2018/COMP61511/... · A Bit On Git Slides. Technical Debt. Technical Debt is "the obligations

KnownDebtCodesmellsindicate(potentially)unknowndebtButthere'sexplicit,knowndebt

HacksdonefortimepressureIncompletetransitionsfromearlierdesignsLearningcodeTechnologyworkaroundsCodefordiscardedfeaturesOverengineeredcode

Page 62: COMP61511 (Fall 2018) Software Engineering Concepts In ...syllabus.cs.manchester.ac.uk/pgt/2018/COMP61511/... · A Bit On Git Slides. Technical Debt. Technical Debt is "the obligations

WhatRefactoringIsNotCodecreation

RefactoringmightenableorfacilitatenewfunctionalityButyoushouldn'taddwhilerefactoring

Bugfixing!Again,mayfacilitateRefactoringmayrevealor"fix"bugs

PerformancetuningSeeaboveCleancodemaybefaster...ornot!

DesignchangesorrearchitectingPrescursoractivity!

Page 63: COMP61511 (Fall 2018) Software Engineering Concepts In ...syllabus.cs.manchester.ac.uk/pgt/2018/COMP61511/... · A Bit On Git Slides. Technical Debt. Technical Debt is "the obligations

RefactoringPreconditionsTests,tests,tests

Evenwhenapplying"automatic"refactoringsRemember,nochangeinbehavior

Uptoapointatleast!Forsimplerefactorings

useatool!e.g.,renamingaroutine

Forcomplexrefactoringshaveaplan!

andtest!

Page 64: COMP61511 (Fall 2018) Software Engineering Concepts In ...syllabus.cs.manchester.ac.uk/pgt/2018/COMP61511/... · A Bit On Git Slides. Technical Debt. Technical Debt is "the obligations

TechnicalDebtCaseStudySlides