Index

ImageA

accessor methods, 11, 152

add parameter technique, 189190

add() method, 286287, 291

algorithm, substituting, 104105

AND logical operator, 172

architectural design patterns, 277278

architecture, 26

arrays

associative, 17

replacing with objects, 140143

associative arrays, 17

attribute groups, rewriting, 16

attributes

accessing directly, 127130

classes with too many, 10

context of, 20

Autoload Package, 74

AutoloaderTest class, 74

automated tests, 5861, 266

ImageB

Back, Kent, 5

bar() method, 76

behavior design patterns, 278

bidirectional association

changing to unidirectional, 146148

changing unidirectional to, 143146

big refactoring, 24

breaks, replacing control flags with, 176177

business logic, separating from view, 308318

ImageC

change bidirectional association to unidirectional technique, 146148

change reference to value technique, 140

change unidirectional association to bidirectional technique, 143145

change value to referencen technique, 137140

class hierarchy, collapsing, 235238

class responsibilities, changing, 107132

extract class technique, 115120

hide delegate technique, 124127

inline class technique, 121123

introduce foreign method technique, 130132

move method technique, 107112

move property technique, 112115

remove the middle man technique, 127130

classes

data, 21

extracting, 1011, 1316, 37, 115120

extracting subclasses from, 226231

extracting super class, 231234

inline class, 15, 1920, 121123

large, 1011

modifying many, for single change, 15

removing unnecessary, 19

small, 115

two-way references between, 143148

CLI environment, 288

code

conditional, 41, 152

debugging, 4952, 57, 289

legacy, 251264

object-oriented, 279298

problems in, 56

procedural, 24, 279298

readability of, 48

speculative, 20

type. See type code

value of workig, 23

code comments, 7, 2224, 3334, 98

code duplication, 67, 17, 3436, 51, 194, 213

collapse hierarchy technique, 20, 235238

collection, encapsulation of, 21

comments, 7, 2224, 3334, 98

communication, automated tests and, 5961

competition design patterns, 278

complexity, 26

complicatedness, 26

ComponentSuite class, 73

conditional code, 41, 152

conditional expressions, 31

consolidating, 170175

duplicate, 173175

nested, replacing with guard clauses, 179182

conditional logic, 1820, 37

decomposing, 167170

replacing with polymorphism, 182186

simplifying, 167186

conditional logical operators, 172

consolidate conditional expression technique, 170175

consolidate duplicate conditional fragments, 173174

constant methods, 161, 164

constants, replacing magic numbers with, 149150

constructors

replacing with factory methods, 206207

super class, 216219

Continuous Integration Systems, 82

control flags, removing, 175179

creational design patterns, 278

cross-platform open-source IDEs, 64

customer requirements, 251

customer-developer relationship, 60

ImageD

data classes, 21

@dataProvider, 69

data rationalization, 133166

change bidirectional association to unidirectional, 146148

change reference objects to value objects, 140

change unidirectional association to bidirectional, 143146

change value to reference, 137140

encapsulate field, 150151

replace arrays with objects, 140,–143

replace data value with object, 135137

replace magic numbers with constants, 149150

replace subclasses with fields, 161165

replace type code with state/strategy, 156161

replace type code with subclasses, 151155

self-encapsulate field, 133134

data types, 17

data value, replacing with object, 17, 135137

database portability, 262

debugging, 492, 57

while refactoring, 289

decompose conditional technique, 167170

decomposition conditional, 7

Decorator Design pattern, 278, 308315

delegates

calling directly, 127130

delegation

change to reference, 137140

replace with inheritance, 243249

depended-on components (DOCs), 74

design overhead, 15

design patterns, 277327

about, 277278

architectural, 277

Decorator, 308315

MVC, 319327

object-oriented, 277

reasons to use, 278

refactoring with, 278

Template View, 308, 315,–318

when to use, 278

development speed, 5051

dispatch() method, 324327

divergent changes, 1315

Doctrine ORM library, 299307

documentation, 60

don't repeat yourself (DRY), 49

duplicated code, 6, 7, 17, 3436, 194, 213

dynamic layouts, 262263

ImageE

edit.php script, 292, 296

edit() method, 291296, 307

EditTest, 294

encapsulate field technique, 21, 64, 150151

encapsulation, 124

error code, replacing with exception, 208210

exceptions

replacing error code with, 208210

replacing with test, 210

testing, 70

ExceptionTest class, 74

exit point, replacing control flag with, 177179

@expectedException, 70

explicit methods, replacing parameters with, 196199

external methods, 15

extract class technique, 1011, 1316, 115120

extract method technique, 610, 1516, 8592

extract subclass technique, 1011, 226231

extract super class technique, 231234, 275

ImageF

Façade class, 280, 319, 320

Façade pattern, 278299

factory method, 139, 206207

feature creep, 1

feature envy, 1516

feedback, 60

fields

moving to subclasses, 223226

moving to super class, 211213

replacing subclasses with, 161165

files, safely removing, 64

fixtures, working with, 281

flow conditionals, 7

footer() method, 309310, 314

foreign methods, introducing, 130132

form template method, 238243

Fowler, Martin, 5

functional tests, 5861

automated, 82

organizing, 81

with PHPUnit Selenium, 8284

recording and running, 7981

with Selenium, 7782

functionalities, 52, 54

functions, 192

ImageG

getContent() method, 320325

getMock() method, 7576

getter classes, 21

getter methods, 64, 133137, 146149, 151, 325

getTotal() method, 7677

global variables, 12

graphical user interface (GUI), separating from business logic, 308318

guard clauses, replacing nested conditionals with, 179182

ImageH

header() function, 290, 309310, 314

hide delegate technique, 124127

hide method technique, 206

hierarchy, collapsing, 19, 235238

HP4 language, 1

ImageI

index.php script, 282, 310, 326

index() method, 282, 284, 286, 296, 300, 303, 305, 314, 316, 321

inheritance, 211, 231

collapse hierarchy, 19

replace delegation with, 247249

replace with delegation, 243247

inline class technique, 15, 1920, 121123

inline method, 9293

inline temp, 9495

integrated development environments (IDEs), 6364

automation of refactoring activities using, 6364

cross-platform open-source, 64

Selenium, 7881

integration tests, 40

internationalization, 263

introduce explaining variable technique, 9899

introduce foreign method technique, 130132

introduce NullObject technique, 1820

introduce parameter object technique, 203204

Iterator interface, 69

ImageJ

JUnit 3.8.1, 64

ImageK

keep it simple stupid (KISS), 48

ImageL

large classes, 1011

legacy application (example), 251254

_form.php, 260

config.php, 255

database portability, 262

edit.php, 258260

footer.php, 257

functions.php, 255256

header.php, 256257

index.php, 254255

maintenance, 261262

new features, 262263

new.php, 257258

regression testing, 267274

remove.php, 260261

legacy code, 251264

list() construct, 90

local variables, 86

extract method and, 8892

reassigning, 8891

logical operators, 172

long methods, 710

long parameter lists, 1213

loops, 7

ImageM

magic numbers, replacing with constants, 149150

method calls, simplifying, 187210

add parameter, 189191

hide method, 206

introduce parameter object, 203204

parameterize method, 194196

preserve whole object, 199201

replace constructor with factory method, 206208

replace error code with exception, 208210

replace exception with test, 210

remove parameter, 191192

remove setting method, 204205

rename method, 187189

replace parameter with explicit method, 196198

replace parameter with method, 201203

separate query from modifier, 192194

method objects, replacing methods with, 102104

methodology design patterns, 278

methods

accessor, 11, 152

external, 15

extracting, 610, 1516, 8592

factory, 139, 206207

foreign, 130132

form template, 238243

hiding, 206

length of, 85

long, 710

moving to subclass, 220222

moving to super class, 213216

parameterize, 194196

polymorphic, 191

renaming, 20, 187189

replacing parameters with explicit, 12, 196199, 201

replacing with method object, 102104

short, 85

Mock Object, 7577

Model View Controller (MVC) architecture, 277278, 319327

modifiers, separating query from, 192193

move, 64

move method technique, 6, 9, 1516, 107112

move property (field) technique, 15, 112115

ImageN

nested conditionals, replacing with guard clauses, 179182

NetBeans, 64

NullObject, introducing, 1820

ImageO

object relational mapping (ORM), 298307

object-oriented code, transforming procedural code into, 279298

object-oriented patterns, 277

object-oriented programming, conditional logic and, 167

objects

passing whole, as parameter, 199203

preserving whole, 22, 199203

reference, 137, 140

replacing arrays with, 140143

value, 137, 140

opportunity cost, 2

OR logical operator, 172

override methods, 64

ImageP

page controller pattern, 254

parameter objects, 1213, 16, 22, 203204

parameterize method technique, 194196

parameters

adding, 189190

long lists of, 1213

passing whole object as, 199203

removing, 20, 191192

replacing with explicit methods, 196199

replacing with methods, 12, 201

patterns. See design patterns

PEAR distribution system, 65

PHP 5, migration from PHP 4 to, 279

PHP Development Tools (PDT), 64

PHP IDE, 6364

PHPDocumentor, 32

PHPUnit, 58

installation, 6566

integrated with Selenium, 8284

overview, 6465

test doubles, 75

Mock Object, 7677

Stub Object, 7576

unit tests with, 6477

organizing, 7174

running, 7071

writing, 6670

PHPUnit_Extensions_SeleniumTestCase class, 82

PHPUnit_Framework_TestCase class, 66, 7475

PHPUnit_Framework_TestSuite class, 72

polymorphic methods, 191

polymorphism, 1819, 4142, 167, 182186

preserve whole object technique, 22, 199201

primitive data types, 1718

private access modifer, 95

procedural applications, regression testing, 266274

procedural code, 24

transforming into object-oriented code, 279298

procedural programming, conditional logic and, 167

pull up constructor body technique, 216219

pull up field technique, 211213

pull up method technique, 213216

push down field technique, 223226

push down method technique, 220222

ImageQ

quality assurance teams, 61

queries, separating from modifiers, 192193

ImageR

refactoring

concept of, 25

with design patterns, 277327

example, 2747

goal of, 2526

reasons for, 47

debugging, 4950

design improvement, 47

increased productivity, 5051

software understandability, 4849

risks of, 60

rules for, 5155

steps in process of, 54

testing before, 53

when debugging, 52

when not to do, 53

when to do, 5153

Refactoring (Fowler), 5

refactoring techniques, 67, 55

add parameter, 189190

automation of, 6364

big refactoring, 24

change bidirectional association to unidirectional, 146146

replace conditional with polymorphism, 182186

change reference to value, 140

change unidirectional association to bidirectional, 143145

change value to reference, 137140

collapse hierarchy, 1920, 235238

for comments, 2224

consolidate conditional expression, 170175

for data classes, 21

decompose conditional, 7, 167170

for divergent changes, 1315

for duplicate switches, 1819

encapsulate collection, 21

encapsulate field, 21, 64, 150151

extract class, 1011, 1316, 115120

extract method, 610, 1516, 8592

extract subclass, 1011, 2021, 226231

extract super class, 231234, 275

form template method, 238243

hide delegate, 124127

hide method, 206

implementing MVC architecture, 319327

Inline class, 15, 1920, 121123

inline method, 9293

inline temp, 9495

introduce explaining variable, 9899

introduce foreign method, 130132

introduce NullObject, 1820

introduce parameter object, 16, 203204

for large classes, 1011

for long methods, 710

for long parameter lists, 1213

move method, 6, 9, 1516, 107112

move property (field), 15, 112115

parameterize method, 194196

preserve whole object, 16, 22, 199201

for procedural code, 24

pull up constructor body, 216219

pull up field, 211213

pull up method, 213216

push down field, 223226

push down method, 220222

remove control flag, 175179

remove parameter, 20, 191192

remove setting method, 21, 204205

remove the middle man, 127130

for removing speculative code, 20

rename method, 20, 187189

replace arrays with objects, 140143

replace constructor with factory method, 206207

replace data value with object, 135137

replace delegation with inheritance, 247249

replace error code with exception, 208210

replace exception with test, 210

replace inheritance with delegation, 243247

replace magic number with constant, 149150

replace method with method object, 102104

replace parameter with explicit method, 196199

replace parameter with method, 201

replace SQL with ORM, 298307

replace subclass with fields, 161166

replace temp with query, 9598

replace type code with state/strategy, 156160

replace type code with subclasses, 151155

self-encapsulate field, 133134

separate business logic from view, 308318

separate query from modifier, 192193

split temporary variable, 99102

substitute algorithm, 6, 104105

refactoring tools, 6384

IDEs, 6364

PHPUnit, 6477

Selenium, 7782

reference objects, 137

changing value objects to, 137140

changing to value objects, 140

regression tests, 264276

remove control flag technique, 175179

remove parameter technique, 20, 191192

remove setting method technique, 21, 204205

remove the middle man technique, 127130

remove() method, 296298

rename, 63

rename method technique, 20, 187189

render() method, 13, 312314, 323324

replace conditional with polymorphism technique, 182185

replace constructor with factory method technique, 139, 206207

replace data value with object technique, 135137

replace delegation with inheritance technique, 247248

replace error code with exception technique, 208209

replace exception with test technique, 210

replace inheritance with delegation technique, 243246

replace nested conditional with guard clause technique, 179181

replace parameter with explicit method technique, 196198

replace parameter with method technique, 201202

replace SQL with ORM technqiues, 298307

replace subclass with fields technique, 161166

replace temp with query method technique, 9598

REQUEST_METHOD, 288

return exit point, replacing control flag with, 177179

return on investment (ROI), 2

rule of three, 5152

ImageS

Savant3 template engine library, 315

second law of thermodynamics, 26

Selenium

functional testing using, 7782

installation, 7879

integration with PHPUnit, 8284

organizing tests, 81

overview, 7778

recording and running functional tests, 7981

Selenium Grid, 78

Selenium IDE, 7881

Selenium Remote Control (RC), 78, 82

self-encapsulate field technique, 133134

separate business logic from view technique, 308318

separate query from modifer technique, 192193

$_SERVER variable, 288

setter classes, 21

setter methods, 64, 133, 151

removing, 21, 204205

setUp() method, 69, 83, 288

single responsibility principle, 99

small classes, 115

Smarty template engine, 308

software

adding functionality to, 52

divergent changes in, 1315

functionality of, 54

rewriting, 5

techniques for making changes to, 60

improvement of design, with refactoring, 47

software development

after initial release, 60

automatic tests and process of, 5860

productivity in, 5051

software development teams, 61

software value, 23, 266

speculative code, 20

split temporary variable technique, 99102

SQL, replace with ORM, 298307

SQL injection, 261

state object, replacing type code with, 156161

structural design patterns, 278

structure, 26

structured data type, 17

Stub Object, 7576

subclasses

extracting, 1011, 2021, 226231

moving fields to, 223226

moving methods to, 220222

replacing type code with, 151155

replacing with fields, 161165

substitute algorithm technique, 6, 104105

suite tests, 275276

super class constructors, 216219

super classes

extracting, 231234, 275

moving attributes to, 211213

moving methods to, 213216

switch statements, 1819

system under test (SUT), 74

ImageT

tearDown() method, 69

template engine, 308

template pattern, 238

Template View design pattern, 278, 308, 315318

temporary fields, 20

temporary variables, 86, 90

inline, 9495

introducing, as explaining variable, 9899

replacing with query, 9598

splitting, 99102

@test annotation, 66

test doubles, 7477

test-driven development (TDD), 49, 6162

test-first development, 5762

tets/testing

automated, 5861, 266

before refactoring, 53

functional tests, 5861, 7784

integration tests, 40

with PHPUnit, 6477

regression tests, 264276

replacing exceptions with, 210

suite tests, 275276

unit tests, 39, 5859, 6477, 267, 282

__toString() method, 120, 246

trust, 61

two-way references, 143148

type code

replacing with class, 17

replacing with state/strategy pattern, 17, 156161

replacing with subclasses, 17, 151155

ImageU

unidirectional association

changing bidirectional to, 146148

changing to bidirectional, 143146

unit tests, 39, 5859, 267, 282

organizing, 7174

running, 7071

test doubles, 7477

with PHPUnit, 6477

writing, 6670

ImageV

value objects, 137

changing reference values to, 140

changing to reference values, 137140

variables

global, 12

local, 86, 8892

temporary, 86, 90, 94102

viewIndex() method, 316318

ImageW

whole object, preservation of, 199201

working code, value of, 23

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.181.66