100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
Patterns 1 - Advanced Software Engineering $7.99   Add to cart

Class notes

Patterns 1 - Advanced Software Engineering

 6 views  0 purchase
  • Course
  • Institution

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

Preview 3 out of 22  pages

  • February 4, 2023
  • 22
  • 2022/2023
  • Class notes
  • Dr kevan buckley
  • All classes
  • Unknown
avatar-seller
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

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller Nawoda. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $7.99. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

64438 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
$7.99
  • (0)
  Add to cart