" , .2013
.
.
, , , , ,
) "" ,(Java ) XP ,Scrum ,Agile(
.Kernel Mode VS User Mode VS User Mode
,:
) . ""?(
1 .
.C++
Debugging.
.
, "" "":
"" , Linkage : .
"" .
M ISRA C
M ISRA Motor Industry Software Reliability Association :
.
MISRA C ) ( .C
, .
142 122 ,2004 20 .
100%
.
. , .
" "
1
, .
C , , =0
,0 ==0 0 ;0 0 if 0'.
:
; )i f ( x==0
; )( doHorribleThings
" "
:C ?
? :
23
0
3
0
12
=
=
=
=
=
5 4 + 3
i =! i > 14
1 << 2 + 4
a & 0x0F <= 0 x07
; a =5; b = a+ ++a
" "
C , .
, int , IN T 16 16.
, :
; ) void f ( i n t a , i n t b
; int i = 1
; ) f ( i ++, i / 2
C . C"
) ( .
C ,stack overflow ,0
.
" , .
, :
,
,CONSTANT_VALUES_IN_UPPERCASE
,ClassN amesStartsW ithCapitals
,variableN amesStartsW ithLowercase
m_memberVariables
s_staticVariables
"" :Scope
g_globalVariables
)(methodName
MethodName() :
)(method_name
, , , .
, IN OU T .
, :
WRONG:
{ ) i n t Sample ( i n t i n p u t V a l
; ) i n p u t V a l += C u r r e n t F a c t o r ( i n p u t V a l
; ) i n p u t V a l = M u l t i p l i e r ( i n p u t V a l
...
; return i n p u t V a l
}
RIGHT :
i n t Sample ( i n t i n p u t V a l ) {
int l o c a l V a l = inputVal ;
l o c a l V a l += C u r r e n t F a c t o r ( l o c a l V a l ) ;
l o c a l V a l = M u l t i p l i e r ( l o c a l V a l ) ;
...
return l o c a l V a l ;
}
ulAccountNum
szName
bBuzy
cApples
iSize
! ,
: 3.14159265 r r : , ," "
const int PI = 3.14159265 : ,P I r r
Defensive Programming
, . ,
. .
.Proactive Debugging
: !
, , , . ,
: ? ? ?
, , :
integer : 8, 16, 32 64 , )?.(embedded? 64 bit desktop
sizeof limit.h .
/* Minimum and maximum values a signed char can hold. */
)# define SCHAR_MIN (-128
# define SCHAR_MAX 127 /* Maximum value an unsigned char can hold. (Minimum is 0.) */
)# define UCHAR_MAX 255 # define SHRT_MIN (-32768
)# define SHRT_MAX 32767 /* Maximum value an unsigned short int can hold. (Minimum is 0.
*/
# define USHRT_MAX 65535 /* Minimum and maximum values a signed int can hold. */
# define INT_MIN (-INT_MAX - 1) # define INT_MAX 2147483647 /* Maximum value an
unsigned int can hold. (Minimum is 0.) */
# define UINT_MAX 4294967295U ...
: !
. ,
, , '.
.
: !
. .
.
, .
, :
,
.
, :
? ? ? ,?
? ? ?
:Google . :
!
http://googlestyleguide.googlecode.com/svn/trunk/cppguide.xml :
HandleStuff() :
) (
by ref erence
) (http://www-cs-students.stanford.edu/~sjac/c-to-cpp-info/references :
0
" " ) , e'(
by ref erence ) ! (?by value
) ,(status !
.
, .N ull
.
.malloc,realloc or free
D0 tors .
) (.
: , A || B A .
2
Defensive Programming
, : ,Debugging
. .
: , ' . .
,
.
: !
3
4
5
6
7
8
9
10
Android Programming
) .(Linux Kernel
" ,Google ) Open Handset Alliance 65
(.
' , .Dalvik
' .
JV M ,Native Development Kit, NDK .c/c + +
) (2013
Android Architecture
:
, Kernel , ) .(Drivers etc. ,
, .C/C + + , Dalvik ,
.Dalvik code
.Java Java Byte Code
.Dalvik Code Dalvik ,F ramework Java
.
, .
, :
Native Libraries
,C/C + + .Java
: Surface Manager .
10
:openGL/SGL 2D 3D .GP U
:Media framework (coder decoder) codec
:W ebkit Chrome Saf ari .
11
Application Framework
Java .Android
:Activity Manager .
:Package Manger .
:Content providers .
12
Applications
, : .
, ) Home ,Contacts , P hone Browser , (Launcher' .
, ,Java ) (.
13
14
MVVM Model-View-ViewModel
Design Patten GUI Business
Logic Back end logic .
V iew Data objects .
, V iew M odel .
M F C ,Swing GU I
GU I.
" :
GU I " GU I , .XM L
GU I " V iewM odel " ."V iew "
) (Binding A )( . onButtonAClick
"".
: ,
5 ,
) ,(manif est :
.
Android 101
:Activity . ) (U I .Activity .Activity
, Activity . Activity
, , .
:ActivityManager Activities .
Activities .
: Intent .
.
:
, " Intent Activity.
.Activities
, , .
' .
Broadcast.
15
:Intent .
) ,(Explicit .
) , (Implicit , " Intent Filter
. , .
: Service , .U I
,Activity ,U I ,Service Intent ,
, , '.
: Content Providers .
: , (DB) SQLite ,' . content provider
. .ContentP rovider
:Broadcast receivers .system-wide , :
, ' . BroadcastReceiver
.Intent
.
. .
, .
16
17
ActivityService
,Activities , ,Services ,
.
Service lifecycle
Activity lifecycle
, " .Override
.
onResume :onStart onResume Activity
.onStart Activity ,
.onStart Activity , .onResume
onStop , onP ause :onResume Activity ,
Activity .onP ause Activity , .onStop
onResume " Activity .
back Activity , Activity
. Activity ,onP ause onResume
. Activity onP ause onStop
, Activity onCreate onStart.onResume
onStop :onDestroy onStop Activity .
onDestroy , .Activity
Activity , .
18
:onCreate .
,2 .
Activity ,
19
:state Browser
Activity Browser :
: state Browser .
M aps !
,Home .
Browser , M ail :
20
21
22
:Android
23
24
Android Manifest
XM L :
Java Package . )(Unique ID
:Services, Activities, ContentP roviders, BroadcastRecievers
' ," .
.
AP I .
Android API ) (.
.
Resources
, XM L ,GU I XM L
.
' resouces " . ,
resource . , package ,resources
.R ) f inal ( .
.
Files
: ,DB (Opaque Binary Blob) OBB
file systems , .cached files AP Is , "
) Context Service.(Activity
11
12
13
25