Escrito por estudiantes que aprobaron Inmediatamente disponible después del pago Leer en línea o como PDF ¿Documento equivocado? Cámbialo gratis 4,6 TrustPilot
logo-home
Notas de lectura

Patterns 1 - Advanced Software Engineering

Puntuación
-
Vendido
-
Páginas
22
Subido en
04-02-2023
Escrito en
2022/2023

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

Institución
Grado

Vista previa del contenido

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

Escuela, estudio y materia

Institución
Estudio
Desconocido
Grado

Información del documento

Subido en
4 de febrero de 2023
Número de páginas
22
Escrito en
2022/2023
Tipo
NOTAS DE LECTURA
Profesor(es)
Dr kevan buckley
Contiene
Todas las clases

Temas

$8.49
Accede al documento completo:

¿Documento equivocado? Cámbialo gratis Dentro de los 14 días posteriores a la compra y antes de descargarlo, puedes elegir otro documento. Puedes gastar el importe de nuevo.
Escrito por estudiantes que aprobaron
Inmediatamente disponible después del pago
Leer en línea o como PDF

Conoce al vendedor
Seller avatar
Nawoda
5.0
(2)

Conoce al vendedor

Seller avatar
Nawoda University of Wolverhampton (West Midlands)
Seguir Necesitas iniciar sesión para seguir a otros usuarios o asignaturas
Vendido
2
Miembro desde
3 año
Número de seguidores
2
Documentos
15
Última venta
3 año hace
Nawoda Balasooriya

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

5.0

2 reseñas

5
2
4
0
3
0
2
0
1
0

Documentos populares

Recientemente visto por ti

Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes