• Nenhum resultado encontrado

Software and systems engineering

N/A
N/A
Protected

Academic year: 2022

Share "Software and systems engineering"

Copied!
31
0
0

Texto

(1)

Software and systems engineering

Paulo Borba

Informatics Center

Federal University of Pernambuco

phmb@cin.ufpe.br ◈ twitter.com/pauloborba

(2)

Reuse problems

(3)

Modularity problems

(4)

How and when to

solve them?

(5)

Technical debt

component problematic

component

improved component

Debt

new features,

dirty way restructuring

(6)

Maintenance costs more

Practical Analysis for Refactoring, Don Roberts, 1999.

(7)

Lehman’s first law

“A large program that is used undergoes

continuing change or becomes progressively less useful”

“The change process continues until it is judged more cost effective to replace the system with

a recreated version

(8)

Lehman’s second law

“As a large program is continuously changed, its complexity, which reflects deteriorating

structure, increases unless work is done to maintain or reduce it”

(9)

Technical debt quadrant

http://martinfowler.com/bliki/TechnicalDebtQuadrant.html

(10)

How to solve

them?

(11)

Preserving behavior

problematic component

improved component maintenance

Test 1 Test 2

Test n

...

Test 1 Test 2

Test n

...

(12)

Tests  

(be aware of terminology)

Acceptance, whole system, GUI

Integration, controllers and subsystems, web service interface

Unit, domain and auxiliary classes, OO interface

Regression

(13)

Refactorings are...

behavior-preserving source-to-source

transformations that

improve some quality factors

(14)

Reuse and modularity problem

if(objeto.getNome() == null ||

objeto.getNome().equals("") ||

objeto.getSobrenome() == null ||

objeto.getSobrenome().equals("") ||

objeto.getTipo() == null ||

objeto.getTipo().equals("") ||

...

(15)

Extract method refactoring

boolean nullOrEmpty(Membro s) { return s.getNome() == null ||

s.getNome().equals("");

}

boolean nullOrEmpty(String s) { return s == null ||

s.equals("");

}

(16)

Debt reduced

if(nullOrEmpty(objeto.getNome()) ||

nullOrEmpty(objeto.getSobrenome()) ||

nullOrEmpty(objeto.getTipo()) ||

...

if(objeto.getNome() == null ||

objeto.getNome().equals("") ||

objeto.getSobrenome() == null ||

objeto.getSobrenome().equals("") ||

objeto.getTipo() == null ||

objeto.getTipo().equals("") ||

...

(17)

Debt eliminated

if(invalidStringFields(objeto) ...

if(nullOrEmpty(objeto.getNome()) ||

nullOrEmpty(objeto.getSobrenome()) ||

nullOrEmpty(objeto.getTipo()) ||

...

(18)

Automatic  refactorings 

(19)

Tools give no behavior preservation guarantee

problematic component

improved component maintenance

Test 1 Test 2

Test n

...

Test 1 Test 2

Test n

...

(20)

Refactoring catalogue

http://www.refactoring.com/catalog/index.html

(21)

Black belt

parametrization!

(22)

Smells good?

artigos.each{|a|

map = {}

a.elements.each("DADOS-BASICOS-DO-ARTIGO"){|d|

atts = d.attributes

map["TITULO-DO-ARTIGO"] = atts["TITULO-DO-ARTIGO"]

map["ANO-DO-ARTIGO"] = atts["ANO-DO-ARTIGO"]

}

a.elements.each("DETALHAMENTO-DO-ARTIGO"){|d|

atts = d.attributes

map["TITULO-DO-MEIO"] = atts["TITULO-DO-MEIO"]

map["VOLUME"] = atts["VOLUME"]

map["FASCICULO"] = atts["FASCICULO"]

map["PAGINA-INICIAL"] = atts["PAGINA-INICIAL"]

map["PAGINA-FINAL"] = atts["PAGINA-FINAL"]

} ...

functions as parameters

(23)

Not only for articles...

...

a.elements.each("AUTORES"){|author|

map["AUTORES"] = (if map["AUTORES"] then map["AUTORES"]

else [] end) +

[author.attributes["NOME-PARA-CITACAO"]]

} }

(24)

XML structure as parameter

structure = {

"DADOS-BASICOS-DO-ARTIGO" =>

["TITULO-DO-ARTIGO", "ANO-DO-ARTIGO"], "DETALHAMENTO-DO-ARTIGO" =>

["TITULO-DO-MEIO", "VOLUME", "FASCICULO", "PAGINA-INICIAL", "PAGINA-FINAL"],

"AUTORES" =>

["*", "NOME-PARA-CITACAO"]}

}

(25)

Abstracting structure details

structure.keys.each {|e|

a.elements.each(e) {|d|

atts = d.attributes

if structure[e].include?("*") then

(structure[e] - ["*"]).each {|att|

map[e] = (if map[e] then map[e] else [] end) + [atts[att]]

} else

structure[e].each {|att|

map[att] = atts[att]

} end }

}

(26)

Improvement is more often needed than not,

so abstract to see it! 

(27)

How to choose refactoring

targets?

(28)

Values

Principles

Patterns

Bad smells based on...

(29)

Strategy

Identify problem

Any pattern for problem in the given context?

New solution based on values and principles?

Apply appropriate refactorings

Test

(30)

Take notes,

now!

(31)

Software and systems engineering

Paulo Borba

Informatics Center

Federal University of Pernambuco

phmb@cin.ufpe.br ◈ twitter.com/pauloborba

Referências

Documentos relacionados

Patch theory can be used to evaluate complexity in ecological systems (Pickett et al., 2000), and suggests that understanding complexity in spatial structure is a powerful approach

Little reuse and agility, high costs.. Even

• “…Se puder verificar equipes incompletas no início da próxima aula seria uma mão

To control scope, we need to manage a list of tasks... To control time, we need to manage

In order to examine the standing balance under dual-task conditions, the participants were asked to maintain an upright standing position while performing two different

► Financiamento base aos centros interface com € 80M para 6 anos LANÇADO – 1º aviso € 12M para 2018 ► Reforço do equipamento dos centros interface; Vales. Economia

a) realizar anualmente uma reunião, na forma de seminário ou congresso, onde os bolsistas deverão apresentar sua produção científica sob a forma de pôsteres,

Portanto, a avaliagao doperfil e da importancia do Controle Periddico de Satde dos militares do Hospital de Guarnigao de Maraba no ano de 2019, torna-se relevante, tendo como