Geschreven door studenten die geslaagd zijn Direct beschikbaar na je betaling Online lezen of als PDF Verkeerd document? Gratis ruilen 4,6 TrustPilot
logo-home
College aantekeningen

Patterns 1 - Advanced Software Engineering

Beoordeling
-
Verkocht
-
Pagina's
22
Geüpload op
04-02-2023
Geschreven in
2022/2023

Lecture notes of 22 pages for the course Advanced Software Engineering at University of Wolverhampton (Test)

Instelling
Vak

Voorbeeld van de inhoud

Last Time – This time
! Program refactoring ! Design patterns basics
Advanced Software Engineering Topics




Design Patterns - 1




Dr John Kanyaru 1 2




Refactoring

Program Refactoring  Refactoring
 Program transformation that preserves semantics
 Improves software qualities
 Understandability, extensibility, reusability


Introduction  Why is refactoring important?
 Keep up with software evolution
 It may be necessary to improve design to support further
functionality


Dr JM Kanyaru 3 4

, Simple Refactoring So What?
for ( int radius=1, radius < 10; radius++ ) {
area = 3.1416 * radius * radius;  What was gained?
System.out.printf(“area radius %d= %f“,radius,area);
}  Understandability
 By looking at the code you can tell better what the
computation is doing
for ( int radius=1,radius< 10; radius++ )
area = computeArea(radius);  Anything lost?
System.out.printf(“area radius %d= %f“,radius,area);
}
 May be some performance
double computeArea(int radius) {  Short loop and compilers are smart (inlining)
return 3.1416 * radius * radius;
}

5 6




Another Simple Refactoring So What? (Again)
double computeArea(int radius) {
return 3.1416 * radius * radius;
 What was gained?
}  Understandability
 By looking at the code you can tell better what the
computation is doing
 Performance
static final double PI = 3.1416;  Maybe – possible compiler optimization, specially if
double computeArea(int radius) { variable is used in several places
return PI * radius * radius;
}  Anything lost?
 …

7 8

, Insights (1) Insights (2)
 Refactorings are relatively small changes
 A refactoring focus on one change at a time  To apply a refactoring certain conditions should hold
 Several refactorings can be applied to a program incrementally  Example: There should be a magic number in a
computation

program program’ program’’
 Each refactoring is an algorithm that consists of
several steps
refactoring refactoring
 Example:
 Declare a static final field with a meaningful name
 Initialize the field with the magic number
 Substitute the magic number in the original computation with
the new field


9 10




Insights – Recap Why Refactoring?

 Refactorings are relatively small changes  Improve design of software
 A refactoring focus on one change at a time
 Improve understandability
 Several refactorings can be applied to a program
incrementally
 Bug finding
 To apply a refactoring certain conditions should hold

 Each refactoring is an algorithm that consists of  Improve programming productivity
several steps  Code faster – because all of the above

11 12

Geschreven voor

Instelling
Studie
Onbekend
Vak

Documentinformatie

Geüpload op
4 februari 2023
Aantal pagina's
22
Geschreven in
2022/2023
Type
College aantekeningen
Docent(en)
Dr kevan buckley
Bevat
Alle colleges

Onderwerpen

€7,59
Krijg toegang tot het volledige document:

Verkeerd document? Gratis ruilen Binnen 14 dagen na aankoop en voor het downloaden kan je een ander document kiezen. Je kan het bedrag gewoon opnieuw besteden.
Geschreven door studenten die geslaagd zijn
Direct beschikbaar na je betaling
Online lezen of als PDF

Maak kennis met de verkoper
Seller avatar
Nawoda
5,0
(2)

Maak kennis met de verkoper

Seller avatar
Nawoda University of Wolverhampton (West Midlands)
Volgen Je moet ingelogd zijn om studenten of vakken te kunnen volgen
Verkocht
2
Lid sinds
3 jaar
Aantal volgers
2
Documenten
15
Laatst verkocht
3 jaar geleden
Nawoda Balasooriya

BSc (Hons) in Computer Networks (First class) from the University of Wolverhampton.

5,0

2 beoordelingen

5
2
4
0
3
0
2
0
1
0

Populaire documenten

Recent door jou bekeken

Waarom studenten kiezen voor Stuvia

Gemaakt door medestudenten, geverifieerd door reviews

Kwaliteit die je kunt vertrouwen: geschreven door studenten die slaagden en beoordeeld door anderen die dit document gebruikten.

Niet tevreden? Kies een ander document

Geen zorgen! Je kunt voor hetzelfde geld direct een ander document kiezen dat beter past bij wat je zoekt.

Betaal zoals je wilt, start meteen met leren

Geen abonnement, geen verplichtingen. Betaal zoals je gewend bent via Bancontact, iDeal of creditcard en download je PDF-document meteen.

Student with book image

“Gekocht, gedownload en geslaagd. Zo eenvoudig kan het zijn.”

Alisha Student

Veelgestelde vragen