Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4,6 TrustPilot
logo-home
Class notes

Patterns 1 - Advanced Software Engineering

Rating
-
Sold
-
Pages
22
Uploaded on
04-02-2023
Written in
2022/2023

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

Institution
Course

Content preview

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

Written for

Institution
Study
Unknown
Course

Document information

Uploaded on
February 4, 2023
Number of pages
22
Written in
2022/2023
Type
Class notes
Professor(s)
Dr kevan buckley
Contains
All classes

Subjects

R150,13
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
Nawoda
5,0
(2)

Get to know the seller

Seller avatar
Nawoda University of Wolverhampton (West Midlands)
Follow You need to be logged in order to follow users or courses
Sold
2
Member since
3 year
Number of followers
2
Documents
15
Last sold
3 year ago
Nawoda Balasooriya

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

5,0

2 reviews

5
2
4
0
3
0
2
0
1
0

Trending documents

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their exams and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can immediately select a different document that better matches what you need.

Pay how you prefer, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card or EFT and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions