03.09.2015 Views

Design Patterns

Download - Assembla

Download - Assembla

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

■INDEX 265<br />

deliver method, 219<br />

dependencies, hard-coded, 249<br />

dequeue, 114<br />

design patterns. See patterns<br />

DHTML, 144–145<br />

dialog boxes, flyweight pattern for, 190–192<br />

directory lookup (example), 206–210<br />

display method, 27–29<br />

DOM elements, reducing needed, 186–190<br />

duck typing, emulating interfaces with,<br />

17–18<br />

dynamic implementations, 99<br />

dynamic user interface, 225–226<br />

dynamic virtual proxy, creating, 210–213<br />

E<br />

edit-in-place field (example), 52<br />

using classical inheritance, 52–55<br />

using mixin classes, 59–62<br />

using prototypal inheritance, 55–58<br />

efficiency, of virtual proxies, 213<br />

email API, adapter pattern with, 152–158<br />

encapsulation<br />

benefits of, 39<br />

defined, 26<br />

drawbacks of, 39–40<br />

vs. information hiding, 26<br />

inheritance and, 49–50<br />

encapsulation functions, 226–227, 243<br />

ensureImplements function, 18<br />

event bubbling, 255<br />

event capturing, 255<br />

event delegation, 122, 255<br />

event listeners<br />

with bridge pattern, 109–110<br />

as observers, 222<br />

use of, in JavaScript, 142<br />

event objects, 255<br />

event utility, creating with facade pattern,<br />

146–147<br />

event-driven environments, 215<br />

execute method, 226, 229, 235–239<br />

extend function, 43–45, 55, 62<br />

extend keyword, 42<br />

externally hosted libraries, 20<br />

extrinsic data, 179, 192<br />

encapsulation of, 182–183<br />

removing from class, 188–189<br />

storage of, 186, 193<br />

extrinsic state, 180–186<br />

F<br />

facades/facade pattern, 201<br />

vs. adapter pattern, 144, 149<br />

addEvent function, 142, 146–147<br />

benefits of, 148<br />

vs. bridges, 111<br />

common examples of, 141–142<br />

as convenient methods, 143–144<br />

creating event utility (example), 146–147<br />

drawbacks of, 148<br />

introduction to, 141<br />

JavaScript libraries as, 142<br />

setting styles on HTML elements<br />

(example), 144–145<br />

steps for implementing, 147<br />

uses of, 141, 148<br />

factory method, changing function into, 84<br />

factory pattern, 23, 38, 83<br />

benefits of, 107<br />

creating decorator objects with, 169–172<br />

creating, for flyweight pattern, 193<br />

drawbacks of, 108<br />

example, 99–104<br />

instantiation using, 181<br />

RSS reader (example), 104–107<br />

simple, 93–96<br />

true, 96–98<br />

uses of, 99<br />

fieldsets, 128<br />

findProduct function, 67<br />

flyweight manager, 193<br />

flyweight pattern<br />

calendar (example), 185–186<br />

car registrations (example), 179–183<br />

composite pattern with, 183–186<br />

converting objects to, 185<br />

drawbacks of, 194<br />

encapsulation of extrinsic data, 182–183<br />

extrinsic state and, 180–186<br />

for dialog boxes, 190–192<br />

instantiation using a factory, 181<br />

intrinsic state and, 180–181<br />

introduction to, 179<br />

steps for implementing, 193<br />

storing instances for reuse, 190–192<br />

structure of, 179<br />

tooltip objects (example), 186–190<br />

web calendar (example), 183–185<br />

when to use, 192<br />

fooMail, migrating to dedMail from, 157–158<br />

form elements, 127–128<br />

form validation, using composite pattern,<br />

127–136<br />

FormItem interface, 128, 133<br />

fully exposed objects, 27–30<br />

functions<br />

combining, with facades, 143–144<br />

convenience, 143–144<br />

decorator pattern for, 172–173<br />

as first-class objects, 6–8<br />

in JavaScript, 6–8<br />

modifying into factory method, 84<br />

nested, 32–33, 36

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!