• Nenhum resultado encontrado

Software and systems engineering

N/A
N/A
Protected

Academic year: 2022

Share "Software and systems engineering"

Copied!
52
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 opportunities

(3)

Different devices, 15 to 60 different applications…

Different clients, different products

http://www.androidauthority.com

(4)

Little reuse and agility, high costs

Even with Android!

(5)

Problem might also appear in the

context of a single

product...

(6)

How to

detect it?

(7)

Code cloning tool, file

(8)

Code cloning tool, packages

(9)

But what

is a clone?

(10)

Clones? Strings? Tokens?

if (first == null && second != null) { return -1;

} if (first == null && second != null) { return -1;

}

if (f == null && s != null) { return -1;

}

if (f == null && s != null) { return 0;

}

(11)

Clones? Reuse opportunities?

int getDay() { return day;

}

int getMonth() { return month;

}

int getDay() {

return day+1;

}

(12)

int sum(int x,int y){return x+y;}

int sumInt(int a,int b){return a+b;}

(13)

Changing clone notion, small

(14)

Changing clone notion, large

(15)

Minimum clone length (tokens)

if (o.toString().equals("/")) {

div = new DivExp(null, null));

}

if (o.toString().equals("*")) {

mult = new MultExp(null, null));

}

notified by the first setting but not by

the second

(16)

P-match...

maps different variables and function names to

different tokens

if (x>0)

{y=1; x=2; x=w;}

else

{y=1; x=2; x=z;}

(17)

Minimum TKS (kinds of tokens)

int x = 0;

int y = 0;

int z = 0;

int a = 0;

int b = 0;

int c = 0;

(18)

Shaper level, hard and

soft

(19)

Shaper level, easy and

none

(20)

Different tools,

different approaches

(21)

Strategy

Start with stronger constraints

Analyze clones

Reduce constraints

Cycle until no more significant clones (or few significant and too many non significant ones, but be careful!)

(22)

Significant clones...

can be avoided

it is worth avoiding them

in terms of abstraction

in terms of conciseness

in terms of consistency

in terms of legibility

(23)

Code reviews should

complement all that!

(24)

Code anomalies

beyond cloning, not necessarily affecting

reuse...

(25)
(26)
(27)

or code size, but other

quality factors

(28)

Again, code reviews

should complement all

that!

(29)

Modularity

opportunities

(30)

Little modularity and agility, more deffects,   high costs

{GameMenu.MENU_OPTION_ID_PLAY,GameMenu.ME NU_OPTION_ID_C

ONFIG_SOUND,GameMenu.MENU_OPTION_ID_ARENA _SHOW_RANKING,GameMenu.MENU_OPTION_ID_HELP };

//#else

//#public final int[] mainMenuCommands = {GameMenu.MENU_OPTION_ID_PLAY,GameMenu.MENU _OPTION_ID_CONFIG_SOUND,GameMenu.MENU_OPTI ON_ID_HELP};

//#endif

/** Main pause menu options. Shown in the menu when game is paused */

private final int[] mainPauseMenuCommands = { GameMenu.MENU_OPTION_ID_RESUME,GameMenu.ME NU_OPTION_ID_TRACK_11,GameMenu.MENU_OPTIO N_ID_TRACK_12

}private final int[] helpCommands = {

GameMenu.MENU_OPTION_ID_HELP_GOAL, GameMenu.MENU_OPTION_ID_HELP_STRAIGHTS, GameMenu.MENU_OPTION_ID_HELP_CURVES, GameMenu.MENU_OPTION_ID_HELP_ABOUT };

/** Pause exit menu options */

private final int[] pauseMenuRestartCommands = {

GameMenu.MENU_OPTION_ID_PAUSE_RESTART_YES ,

GameMenu.MENU_OPTION_ID_PAUSE_RESTART_NO }; private final int[] endRaceMenuCommands = {

GameMenu.MENU_OPTION_ID_ARENA_POST_SCOR E,

GameMenu.MENU_OPTION_ID_END_RACE_RETRY,

GameMenu.MENU_OPTION_ID_END_RACE_SELECT_

TRACK,

GameMenu.MENU_OPTION_ID_BACK_MAIN_MENU };\

//# private final int[] endRaceMenuCommands = { //#

GameMenu.MENU_OPTION_ID_END_RACE_RETRY, //#

GameMenu.MENU_OPTION_ID_END_RACE_SELECT_TR ACK,

//#

GameMenu.MENU_OPTION_ID_BACK_MAIN_MENU //# }; */

private int PREVIOUS_KEY_CODE = MainCanvas.UP_PRESSED;

private int NEXT_KEY_CODE = MainCanvas.DOWN_PRESSED;

/** Title of the menu*/

private String menuTitle;

private Image rewardUserImageMainMenu;public static final int TRACK_SELECTION_MENU = 5;

//#if feature_arena_enabled /**

* Post ranking menu */

public static final int POST_SCORE_MENU = 10;

//#endif

package com.meantime.j2me.gui;

import java.util.Vector;

import com.meantime.j2me.util.Screen;

import com.meantime.j2me.util.bvg.BVGAnimator;

//#if device_graphics_transform_midp2 //# import javax.microedition.lcdui.game.Sprite;

//#else

import com.meantime.j2me.util.game.Sprite;

private static final int

PRESENTATION_BACKGROUND_COLOR = 0x000000;

//#if device_screen_128x128

/** Initial car animation position x */

private static final int CAR_LEFT_INITIAL_POS_X = -78;

/** Initial car animation position y */

private static final int CAR_LEFT_POS_Y = 31;

/** Initial tire animation position y */

//#

//#endif

/** Used to left tire animatiom position x */

private int currentTireleftPosX; private BVGAnimator presentation_second_bvg;

private BVGAnimator arena_bvg;

gff //#

Dffdsffffffffffffffffffffffffffffff Ghrwds {

/** Constants to paint the scroll bar */

private static final int ARENA_SCROLL_HEIGHT

= 92;

private static final int ARENA_SCROLL_POS_Y = 17;

//#elif device_screen_128x117 //#

//# /** Constants to paint the scroll bar */

//# private static final int ARENA_SCROLL_HEIGHT = 81;

//# private static final int ARENA_SCROLL_POS_Y = 16;

//#if sku_id_se1 //#

//#g = originalG;

//#g.drawImage(bufferImg, 0, 0, 0);

//#

//#endif} catch(Exception e){

e.printStackTrace();

} }

public void changeScreen (innewScreenIndex;

this.nextScreenMode = newScreenMode;

this.nextScreenParam = param; /**

* Shows the last screen shown.

* If there's not a last screen (i.e., the screen index in * the stack is public void goBack() { int[] screenData = this.popSc

// avoid mainCanvas to go back to a waiting server screen

if (screenData[STACK_SCREEN_MODE_INDEX] ==

Resources.MAIN_SCREEN_MODE_ARENA_WAITING_

SERVER) { this.goBack();

return;this.changeScreen(screenData[STACK_SCREEN_

INDEX],

screenData[STACK_SCREEN_MODE_INDEX], screenData[STACK_PARAM_INDEX]);

} this.goBack = true;

}//#public void commandAction(Command c, Displayable d) { //#if (c == this.leftCommand) {

//#this.keyPressed(LEFT_SOFT_KEY);

//#} else if (c == this.rightCommand) { //#this.keyPressed(RIGHT_SOFT_KEY);

//#}

//#}

//#

//#endif

(31)

But what is modularity?

Good Bad

Much Little

(32)

A modular system is...

split into separate units, language elements, modules

developed by separate work assignments, design elements, modules

(33)

with the aim of

achieving modularity benefits...

Independent development

Independent maintenance

Independent understanding

(34)

Bad modularity?

... void cadastrar(Conta conta) { if (conta != null &&

conta.valida() &&

!this.existe(conta.getNumero())) { if (proxima <= maximo-1) {

contas[proxima] = conta;

proxima = proxima + 1;

} else {...Espaço insuficiente...}

} else {...Conta inválida...}

} ...

(35)

Good modularity?

Graphical User Interface (GUI)

Communication Business

Data

(36)

Depends on what you intend to

independently

develop, maintain,

and understand!

(37)

Depends on what

more likely changes

or varies!

(38)

How to detect

modularity

problems?

(39)

Few or big modules

(40)

Complex modules

(41)

Visualizations of

specific metrics

(42)

Big, deep, shallow

modules

(43)

Unwanted module

dependencies

(44)

Metrics behind all that

Depth of inheritance tree

SLOC

Coupling, code level

method and constructor call

extends and implements declarations

field access

(45)

Coupling and

dependencies

(46)

Design structure

matrixes

(47)

Cycles, aferent and

eferent dependencies

(48)

Relative

modularity

analysis!

(49)

GUI

Business

Data

GUI

Business

Data UC

aspect

crosscuts

OK with GUI,

Business and Data concerns

but tangling and scattering when we also consider

Update complaint...

OK with Update

complaint and other use case concerns

but tangling and

scattering when we also consider GUI, Data...

(50)

Strategy

First at the architecture level, then at the code level:

Start with more selective filters and metrics

Analyze smells

Reduce filter and metrics constraints

Cycle until no more interesting smells

(51)

Code and design

reviews complement all

that

(52)

Software and systems engineering

Paulo Borba

Informatics Center

Federal University of Pernambuco

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

Referências

Documentos relacionados

Congestão nasal e coriza PGs e Leucotrienos Secreção glandular Colinérgico e Histaminérgico Resposta Sistema Rinite alérgica • Sintomas - Rinorréia - Congestão nasal -

a) No Brasil, o arrasto é tido como uma das modalidades mais rentáveis, visto que suas redes são capazes de capturar milhares de toneladas de pescado ao ano. b) Não existe

Mobiliário, papel e celulose - Portugal será um bom local como porta de entrada na Europa para estes tipos de mercadorias provenientes do Brasil, sendo o porto de Sines

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

“As a large program is continuously changed, its complexity, which reflects deteriorating. structure, increases unless work is done to maintain or

Scenario: export multiple members link not enabled when there are no member selected Given I am at the member list page. And the system has no