Tải bản đầy đủ (.pdf) (80 trang)

Living with The Legacy Code: A very Short Guide

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (3.07 MB, 80 trang )


with
L
e
g
a
c
y

C
o
d
e
L
i
v
i
n
g

@rowan_m

@rowan_m
Ibuildings
Plusnet

What is
“Legacy Code”?

Code without
tests


Code you've
“inherited”
Code no-one
understands
Technical debt
What is
“Legacy Code”?

Who has
never
created
Legacy Code?

M
y

o
w
n
s
t
o
r
y
l
i
t
t
l
e


M
y

o
w
n
s
t
o
r
y
l
i
t
t
l
e
P
r
a
g
m
a
t
i
c
,

n

o
t

i
d
e
a
l
i
s
t
i
c

Starting a project

Aim to understand
the concepts
and motivations

Try using
the application

Find and then read
any / all
documentation

C
h
e

c
k
l
i
s
t
Official:
Project brief ( )
Requirements ( )
Tech. Spec. ( )
Actual:
Emails ( )
Meeting notes ( )
Progress:
Gant charts ( )
Burndowns ( )
Overtime logs ( )
Quality:
Bug tracker ( )
Complaints ( )
User Forums ( )

Talk to the
original developers

Talk to the users
… especially the
“different” ones

Approaching

the code

Catalogue the
live platform
& environment

Recreate it!

Deploy the code

C
h
e
c
k
l
i
s
t
PHP:
php.ini ( )
PEAR / PECL modules ( )
Compile options ( )
Patches ( )
The Rest:
OS ( )
Package manager ( )
Web server ( )
Web server modules ( )
Site config. ( )

Database ( )
Cache ( )
JS libraries ( )
Firewall rules ( )
Proxies ( )
Services running ( )

Time to enter
The Code

Reading
Static analysis
Dynamic analysis
Time to enter
The Code

p
h
p
d
o
c
phpdoc -ti 'Sweet Application' \
-pp -o HTML:Smarty:PHP \
-d Libraries \
-t Docs
/>Title
Style
Code in here
Docs out here!


Beware of type-hiding!
Type-hinting
Type-hiding
/**
* @param array $opts
Current options
* @return array
Options with flag set
*/
function setFlag(array $opts) {
$opts['flag'] = true;
return $opts;
}
/**
* @param int $fullPence
Full price in pence
* @return float Discounted
price in pence
*/
function applyDiscount($fullPence) {
return ($fullPence * 0.8);
}

d
o
x
y
g
e

n
/>doxygen -s -g ~/doxy.conf
vim ~/doxy.conf
# edit at least this
OUPUT_DIRECTORY
# play with the rest
cd ~/dev/project
doxygen ~/doxy.conf
Docs out here
Code in here

×