Mobile and Wireless Systems Programming - Youssef RIDENE

Introduction. Tips and Tricks. Tools. Conclusion. Mobile and Wireless Systems Programming. Programming methodology. Youssef RIDENE ...
580KB taille 5 téléchargements 316 vues
Introduction Tips and Tricks Tools Conclusion

Mobile and Wireless Systems Programming Programming methodology

Youssef RIDENE : [email protected]

Mobile and Wireless Systems Programming

Introduction Tips and Tricks Tools Conclusion

Why a methodology ? Mobile properties

Small embedded systems Low effort for maintability Low memory and performance Power consumption Small screens

Mobile not Desktop !

Youssef RIDENE : [email protected]

Mobile and Wireless Systems Programming

Introduction Tips and Tricks Tools Conclusion

Why a methodology ? Mobile properties

Profile Configuration Screen size Available Memory Available APIs Available media formats

Youssef RIDENE : [email protected]

Mobile and Wireless Systems Programming

Introduction Tips and Tricks Tools Conclusion

Do it once Loops Variables Strings Arrays Input/Output UI Exceptions General

NOK double x = d ∗ ( l i m / max ) ∗ s x ; double y = d ∗ ( l i m / max ) ∗ s y ;

Youssef RIDENE : [email protected]

Mobile and Wireless Systems Programming

Introduction Tips and Tricks Tools Conclusion

Do it once Loops Variables Strings Arrays Input/Output UI Exceptions General

NOK double x = d ∗ ( l i m / max ) ∗ s x ; double y = d ∗ ( l i m / max ) ∗ s y ; OK double xy = d ∗ ( l i m / max ) ; double x = xy ∗ s x ; double y = xy ∗ s y ;

Youssef RIDENE : [email protected]

Mobile and Wireless Systems Programming

Introduction Tips and Tricks Tools Conclusion

Do it once Loops Variables Strings Arrays Input/Output UI Exceptions General

NOK double x = d ∗ ( l i m / max ) ∗ s x ; double y = d ∗ ( l i m / max ) ∗ s y ; OK double xy = d ∗ ( l i m / max ) ; double x = xy ∗ s x ; double y = xy ∗ s y ;

Youssef RIDENE : [email protected]

Mobile and Wireless Systems Programming

Introduction Tips and Tricks Tools Conclusion

Do it once Loops Variables Strings Arrays Input/Output UI Exceptions General

NOK i n t MAX = 1 0 0 0 0 0 0 ; i n t [ ] Tab = new i n t [ 1 0 0 0 ] ; for

( i n t i = 0 ; i < Tab . l e n g t h ; Tab [ 0 ] = MAX; ...

i ++){

}

Youssef RIDENE : [email protected]

Mobile and Wireless Systems Programming

Introduction Tips and Tricks Tools Conclusion

Do it once Loops Variables Strings Arrays Input/Output UI Exceptions General

NOK i n t MAX = 1 0 0 0 0 0 0 ; i n t [ ] Tab = new i n t [ 1 0 0 0 ] ; ( i n t i = 0 ; i < Tab . l e n g t h ; Tab [ 0 ] = MAX; ...

for

i ++){

}

OK i n t MAX = 1 0 0 0 0 0 0 ; i n t [ ] Tab = new i n t [ 1 0 0 0 ] ; for

( i n t i = 0 ; i < Tab . l e n g t h ; i f ( i ==0) Tab [ 0 ] = MAX; ...

i ++){

}

Youssef RIDENE : [email protected]

Mobile and Wireless Systems Programming

Introduction Tips and Tricks Tools Conclusion

Do it once Loops Variables Strings Arrays Input/Output UI Exceptions General

NOK i n t MAX = 1 0 0 0 0 0 0 ; i n t [ ] Tab = new i n t [ 1 0 0 0 ] ; ( i n t i = 0 ; i < Tab . l e n g t h ; Tab [ 0 ] = MAX; ...

for

i ++){

}

OK i n t MAX = 1 0 0 0 0 0 0 ; i n t [ ] Tab = new i n t [ 1 0 0 0 ] ; for

( i n t i = 0 ; i < Tab . l e n g t h ; i f ( i ==0) Tab [ 0 ] = MAX; ...

i ++){

}

Youssef RIDENE : [email protected]

Mobile and Wireless Systems Programming

Introduction Tips and Tricks Tools Conclusion

Do it once Loops Variables Strings Arrays Input/Output UI Exceptions General

NOK f o r ( i n t i = 0 ; i < x . l e n g t h ; i ++) x [ i ] ∗= Math . PI ∗ Math . c o s ( y ) ;

Youssef RIDENE : [email protected]

Mobile and Wireless Systems Programming

Introduction Tips and Tricks Tools Conclusion

Do it once Loops Variables Strings Arrays Input/Output UI Exceptions General

NOK f o r ( i n t i = 0 ; i < x . l e n g t h ; i ++) x [ i ] ∗= Math . PI ∗ Math . c o s ( y ) ; OK double p i c o s y = Math . PI ∗ Math . c o s ( y ) ; f o r ( i n t i = 0 ; i < x . l e n g t h ; i ++) x [ i ] ∗= p i c o s y ;

Youssef RIDENE : [email protected]

Mobile and Wireless Systems Programming

Introduction Tips and Tricks Tools Conclusion

Do it once Loops Variables Strings Arrays Input/Output UI Exceptions General

NOK f o r ( i n t i = 0 ; i < x . l e n g t h ; i ++) x [ i ] ∗= Math . PI ∗ Math . c o s ( y ) ; OK double p i c o s y = Math . PI ∗ Math . c o s ( y ) ; f o r ( i n t i = 0 ; i < x . l e n g t h ; i ++) x [ i ] ∗= p i c o s y ;

Youssef RIDENE : [email protected]

Mobile and Wireless Systems Programming

Introduction Tips and Tricks Tools Conclusion

Do it once Loops Variables Strings Arrays Input/Output UI Exceptions General

NOK S t r i n g B u f f e r s t r B u f = new S t r i n g B u f f e r ( ) ; f o r ( i n t i = 0 ; i < t a i l l e ; i ++) { i f ( t [ i ] >= ’ 0 ’ && t [ i ] < ’ 5 ’ ) { s t r B u f += t [ i ] ; } }

Youssef RIDENE : [email protected]

Mobile and Wireless Systems Programming

Introduction Tips and Tricks Tools Conclusion

Do it once Loops Variables Strings Arrays Input/Output UI Exceptions General

NOK S t r i n g B u f f e r s t r B u f = new S t r i n g B u f f e r ( ) ; f o r ( i n t i = 0 ; i < t a i l l e ; i ++) { i f ( t [ i ] >= ’ 0 ’ && t [ i ] < ’ 5 ’ ) { s t r B u f += t [ i ] ; } }

OK S t r i n g B u f f e r s t r B u f = new S t r i n g B u f f e r ( ) ; c h a r cBuf ; f o r ( i n t i = 0 ; i < t a i l l e ; i ++) { cBuf = t [ i ] ; i f ( c B u f >= ’ 0 ’ && c B u f < ’ 5 ’ ) { s t r B u f += c B u f ; } }

Youssef RIDENE : [email protected]

Mobile and Wireless Systems Programming

Introduction Tips and Tricks Tools Conclusion

Do it once Loops Variables Strings Arrays Input/Output UI Exceptions General

NOK S t r i n g B u f f e r s t r B u f = new S t r i n g B u f f e r ( ) ; f o r ( i n t i = 0 ; i < t a i l l e ; i ++) { i f ( t [ i ] >= ’ 0 ’ && t [ i ] < ’ 5 ’ ) { s t r B u f += t [ i ] ; } }

OK S t r i n g B u f f e r s t r B u f = new S t r i n g B u f f e r ( ) ; c h a r cBuf ; f o r ( i n t i = 0 ; i < t a i l l e ; i ++) { cBuf = t [ i ] ; i f ( c B u f >= ’ 0 ’ && c B u f < ’ 5 ’ ) { s t r B u f += c B u f ; } }

Youssef RIDENE : [email protected]

Mobile and Wireless Systems Programming

Introduction Tips and Tricks Tools Conclusion

Do it once Loops Variables Strings Arrays Input/Output UI Exceptions General

NOK i n t sum = 0 ; for ( int i = 0; i < v . size ( ) ; sum += v . e l e m e n t A t ( i ) ; }

i ++) {

Youssef RIDENE : [email protected]

Mobile and Wireless Systems Programming

Introduction Tips and Tricks Tools Conclusion

Do it once Loops Variables Strings Arrays Input/Output UI Exceptions General

NOK i n t sum = 0 ; for ( int i = 0; i < v . size ( ) ; sum += v . e l e m e n t A t ( i ) ; }

i ++) {

OK i n t sum = 0 ; int size = v. size (); f o r ( i n t i = 0 ; i < s i z e ; i ++) { sum += v . e l e m e n t A t ( i ) ; }

Youssef RIDENE : [email protected]

Mobile and Wireless Systems Programming

Introduction Tips and Tricks Tools Conclusion

Do it once Loops Variables Strings Arrays Input/Output UI Exceptions General

NOK i n t sum = 0 ; for ( int i = 0; i < v . size ( ) ; sum += v . e l e m e n t A t ( i ) ; }

i ++) {

OK i n t sum = 0 ; int size = v. size (); f o r ( i n t i = 0 ; i < s i z e ; i ++) { sum += v . e l e m e n t A t ( i ) ; }

Youssef RIDENE : [email protected]

Mobile and Wireless Systems Programming

Introduction Tips and Tricks Tools Conclusion

Do it once Loops Variables Strings Arrays Input/Output UI Exceptions General

Forward loop l o n g s t a r t 1 = Sy s t em . c u r r e n t T i m e M i l l i s ( ) ; f o r ( i = 0 ; i