Zandstra | PHP Objects, Patterns and Practice | E-Book | www.sack.de
E-Book

E-Book, Englisch, 536 Seiten

Zandstra PHP Objects, Patterns and Practice


3rd ed
ISBN: 978-1-4302-2926-1
Verlag: Apress
Format: PDF
Kopierschutz: 1 - PDF Watermark

E-Book, Englisch, 536 Seiten

ISBN: 978-1-4302-2926-1
Verlag: Apress
Format: PDF
Kopierschutz: 1 - PDF Watermark



This book takes you beyond the PHP basics to the enterprise development practices used by professional programmers. Updated for PHP 5.3 with new sections on closures, namespaces, and continuous integration, this edition will teach you about object features such as abstract classes, reflection, interfaces, and error handling. You'll also discover object tools to help you learn more about your classes, objects, and methods. Then you'll move into design patterns and the principles that make patterns powerful. You'll learn both classic design patterns and enterprise and database patterns with easy-to-follow examples. Finally, you'll discover how to put it all into practice to help turn great code into successful projects. You'll learn how to manage multiple developers with Subversion, and how to build and install using Phing and PEAR. You'll also learn strategies for automated testing and building, including continuous integration. Taken together, these three elements-object fundamentals, design principles, and best practices-will help you develop elegant and rock-solid systems.

Matt Zandstra has worked as a web programmer, consultant, and writer for nearly two decades. He is the author of SAMS Teach Yourself PHP in 24 Hours (three editions) and a contributor to DHTML Unleashed. He has written articles for Linux Magazine, Zend.com, IBM DeveloperWorks, and php|architect Magazine, among others. Matt works as a consultant advising companies on their architectures and system management, and also develops systems primarily with PHP, and Java. Matt also writes fiction.

Zandstra PHP Objects, Patterns and Practice jetzt bestellen!

Autoren/Hrsg.


Weitere Infos & Material


1;Title Page ;1
2;Copyright Page;2
3;Contents at a Glance;3
4;Table of Contents;4
5;About the Author;16
6;About the Technical Reviewer;17
7;Acknowledgments;18
8;Introduction to the Third Edition;19
9;Part 1: Introduction;20
10;Chapter 1 PHP: Design and Management;21
10.1;The Problem;21
10.2;PHP and Other Languages;22
10.3;About This Book;23
10.3.1;Objects;24
10.3.2;Patterns;24
10.3.3;Practice;24
10.3.4;What’s New in the Third Edition;25
10.4;Summary;25
11;Part 2: Objects;27
12;Chapter 2 PHP and Objects;28
12.1;The Accidental Success of PHP Objects;28
12.1.1;In the Beginning: PHP/FI;28
12.1.2;Syntactic Sugar: PHP 3;28
12.1.3;PHP 4 and the Quiet Revolution;29
12.1.4;Change Embraced: PHP 5;30
12.2;Into the Future;31
12.3;Advocacy and Agnosticism: The Object Debate;31
12.4;Summary;31
13;Chapter 3: Object Basics;32
13.1;Classes and Objects;32
13.1.1;A First Class;32
13.1.2;A First Object (or Two);33
13.2;Setting Properties in a Class;34
13.3;Working with Methods;36
13.3.1;Creating a Constructor Method;38
13.4;Arguments and Types;39
13.4.1;Primitive Types;39
13.4.1.1;Primitive Types Matter: An Example;40
13.4.2;Taking the Hint: Object Types;42
13.5;Inheritance;44
13.5.1;The Inheritance Problem;44
13.5.2;Working with Inheritance;48
13.5.2.1;Constructors and Inheritance;50
13.5.2.2;Invoking an Overridden Method;52
13.5.3;Public, Private, and Protected: Managing Access to Your Classes;52
13.5.3.1;Accessor Methods;54
13.5.3.2;The ShopProduct Classes;54
13.6;Summary;56
14;Chapter 4 Advanced Features;57
14.1;Static Methods and Properties;57
14.2;Constant Properties;60
14.3;Abstract Classes;61
14.4;Interfaces;63
14.5;Late Static Bindings: The static Keyword;64
14.6;Handling Errors;67
14.6.1;Exceptions;68
14.6.1.1;Throwing an Exception;69
14.6.1.2;Subclassing Exception;70
14.7;Final Classes and Methods;73
14.8;Working with Interceptors;74
14.9;Defining Destructor Methods;78
14.10;Copying Objects with __clone();79
14.11;Defining String Values for Your Objects;81
14.12;Callbacks, Anonymous Functions and Closures;82
14.13;Summary;86
15;Chapter 5 Object Tools;87
15.1;PHP and Packages;87
15.1.1;PHP Packages and Namespaces;87
15.1.1.1;Namespaces to the Rescue;88
15.1.1.2;Using the File System to Simulate Packages;92
15.1.1.3;Naming the PEAR Way;94
15.1.1.4;Include Paths;94
15.1.2;Autoload;96
15.2;The Class and Object Functions;97
15.2.1;Looking for Classes;98
15.2.2;Learning About an Object or Class;99
15.2.3;Learning About Methods;100
15.2.4;Learning About Properties;101
15.2.5;Learning About Inheritance;101
15.2.6;Method Invocation;102
15.3;The Reflection API;103
15.3.1;Getting Started;103
15.3.2;Time to Roll Up Your Sleeves;104
15.3.3;Examining a Class;106
15.3.4;Examining Methods;107
15.3.5;Examining Method Arguments;109
15.3.6;Using the Reflection API;110
15.4;Summary;113
16;Chapter 6 Objects and Design;114
16.1;Defining Code Design;114
16.2;Object-Oriented and Procedural Programming;115
16.2.1;Responsibility;118
16.2.2;Cohesion;119
16.2.3;Coupling;119
16.2.4;Orthogonality;119
16.3;Choosing Your Classes;120
16.4;Polymorphism;121
16.5;Encapsulation;122
16.6;Forget How to Do It;123
16.7;Four Signposts;124
16.7.1;Code Duplication;124
16.7.2;The Class Who Knew Too Much;124
16.7.3;The Jack of All Trades;124
16.7.4;Conditional Statements;125
16.8;The UML;125
16.8.1;Class Diagrams;125
16.8.1.1;Representing Classes;125
16.8.1.2;Attributes;126
16.8.1.3;Operations;127
16.8.1.4;Describing Inheritance and Implementation;127
16.8.1.5;Associations;128
16.8.1.6;Aggregation and Composition;129
16.8.1.7;Describing Use;130
16.8.1.8;Using Notes;131
16.8.2;Sequence Diagrams;132
16.9;Summary;134
17;Part 3: Patterns;135
18;Chapter 7 What Are Design Patterns? Why Use Them?;136
18.1;What Are Design Patterns?;136
18.2;A Design Pattern Overview;138
18.2.1;Name;138
18.2.2;The Problem;138
18.2.3;The Solution;139
18.2.4;Consequences;139
18.3;The Gang of Four Format;139
18.4;Why Use Design Patterns?;140
18.4.1;A Design Pattern Defines a Problem;140
18.4.2;A Design Pattern Defines a Solution;140
18.4.3;Design Patterns Are Language Independent;140
18.4.4;Patterns Define a Vocabulary;140
18.4.5;Patterns Are Tried and Tested;141
18.4.6;Patterns Are Designed for Collaboration;141
18.4.7;Design Patterns Promote Good Design;141
18.5;PHP and Design Patterns;142
18.6;Summary;142
19;Chapter 8 Some Pattern Principles;143
19.1;The Pattern Revelation;143
19.2;Composition and Inheritance;144
19.2.1;The Problem;144
19.2.2;Using Composition;147
19.3;Decoupling;149
19.3.1;The Problem;149
19.3.2;Loosening Your Coupling;151
19.4;Code to an Interface, Not to an Implementation;153
19.5;The Concept That Varies;154
19.6;Patternitis;155
19.7;The Patterns;155
19.7.1;Patterns for Generating Objects;155
19.7.2;Patterns for Organizing Objects and Classes;155
19.7.3;Task-Oriented Patterns;155
19.7.4;Enterprise Patterns;156
19.7.5;Database Patterns;156
19.8;Summary;156
20;Chapter 9 Generating Objects;157
20.1;Problems and Solutions in Generating Objects;157
20.2;The Singleton Pattern;161
20.2.1;The Problem;161
20.2.2;Implementation;162
20.2.3;Consequences;164
20.3;Factory Method Pattern;164
20.3.1;The Problem;165
20.3.2;Implementation;167
20.3.3;Consequences;169
20.4;Abstract Factory Pattern;169
20.4.1;The Problem;170
20.4.2;Implementation;171
20.4.3;Consequences;173
20.4.4;Prototype;174
20.4.5;The Problem;175
20.4.6;Implementation;175
20.5;But That’s Cheating!;178
20.6;Summary;179
21;Chapter 10 Patterns for Flexible Object Programming;180
21.1;Structuring Classes to Allow Flexible Objects;180
21.2;The Composite Pattern;180
21.2.1;The Problem;181
21.2.2;Implementation;183
21.2.3;Consequences;186
21.2.4;Composite in Summary;189
21.3;The Decorator Pattern;190
21.3.1;The Problem;190
21.3.2;Implementation;192
21.3.3;Consequences;196
21.4;The Facade Pattern;196
21.4.1;The Problem;196
21.4.2;Implementation;197
21.4.3;Consequences;198
21.5;Summary;198
22;Chapter 11 Performing and Representing Tasks;199
22.1;The Interpreter Pattern;199
22.1.1;The Problem;199
22.1.2;Implementation;200
22.1.3;Interpreter Issues;207
22.2;The Strategy Pattern;208
22.2.1;The Problem;208
22.2.2;Implementation;209
22.3;The Observer Pattern;212
22.3.1;Implementation;214
22.4;The Visitor Pattern;220
22.4.1;The Problem;220
22.4.2;Implementation;221
22.4.3;Visitor Issues;225
22.5;The Command Pattern;226
22.5.1;The Problem;226
22.5.2;Implementation;226
22.6;Summary;230
23;Chapter 12 Enterprise Patterns;231
23.1;Architecture Overview;231
23.1.1;The Patterns;232
23.1.2;Applications and Layers;232
23.2;Cheating Before We Start;235
23.2.1;Registry;235
23.2.1.1;The Problem;235
23.2.2;Implementation;236
23.2.2.1;Registry, Scope, and PHP;239
23.2.2.2;Consequences;244
23.3;The Presentation Layer;245
23.3.1;Front Controller;245
23.3.1.1;The Problem;245
23.3.1.2;Implementation;246
23.3.1.3;Consequences;254
23.3.2;Application Controller;255
23.3.2.1;The Problem;255
23.3.2.2;Implementation;256
23.3.2.3;Consequences;266
23.3.3;Page Controller;267
23.3.3.1;The Problem;267
23.3.3.2;Implementation;267
23.3.3.3;Consequences;271
23.3.4;Template View and View Helper;272
23.3.4.1;The Problem;272
23.3.4.2;Implementation;272
23.3.4.3;Consequences;274
23.4;The Business Logic Layer;274
23.4.1;Transaction Script;275
23.4.1.1;The Problem;275
23.4.1.2;Implementation;275
23.4.1.3;Consequences;279
23.4.2;Domain Model;279
23.4.2.1;The Problem;279
23.4.2.2;Implementation;280
23.4.2.3;Consequences;282
23.5;Summary;283
24;Chapter 13 Database Patterns;284
24.1;The Data Layer;284
24.2;Data Mapper;284
24.2.1;The Problem;285
24.2.2;Implementation;285
24.2.2.1;Handling Multiple Rows;289
24.2.3;Consequences;296
24.3;Identity Map;297
24.3.1;The Problem;297
24.3.2;Implementation;298
24.3.3;Consequences;300
24.4;Unit of Work;300
24.4.1;The Problem;301
24.4.2;Implementation;301
24.4.3;Consequences;305
24.4.4;Lazy Load;305
24.4.5;The Problem;305
24.4.6;Implementation;306
24.4.7;Consequences;307
24.5;Domain Object Factory;307
24.5.1;The Problem;307
24.5.2;Implementation;308
24.5.3;Consequences;309
24.6;The Identity Object;310
24.6.1;The Problem;310
24.6.2;Implementation;311
24.6.3;Consequences;316
24.7;The Selection Factory and Update Factory Patterns;316
24.7.1;The Problem;316
24.7.2;Implementation;316
24.7.3;Consequences;320
24.8;What’s Left of Data Mapper Now?;320
24.9;Summary;322
25;Part 4: Practice;324
26;Chapter 14 Good (and Bad) Practice;325
26.1;Beyond Code;325
26.2;Borrowing a Wheel;325
26.3;Playing Nice;327
26.4;Giving Your Code Wings;327
26.5;Documentation;328
26.6;Testing;329
26.7;Continuous Integration;330
26.8;Summary;330
27;Chapter 15 An Introduction to PEAR and Pyrus;331
27.1;What Is PEAR?;331
27.2;Phar Out with Pyrus;332
27.3;Installing a Package;334
27.3.1;PEAR Channels;335
27.4;Using a PEAR Package;337
27.4.1;Handling PEAR Errors;339
27.5;Creating Your Own PEAR Package;342
27.5.1;package.xml;342
27.5.2;Package Elements;342
27.5.3;The contents Element;344
27.5.4;Dependencies;347
27.5.5;Tweaking Installation with phprelease;348
27.5.6;Preparing a Package for Shipment;349
27.5.7;Setting Up Your Own Channel;349
27.5.7.1;Defining a Channel with PEAR2_SimpleChannelServer;350
27.5.7.2;Managing a PEAR Channel with PEAR2_SimpleChannelFrontend;351
27.5.7.3;Managing a Package;352
27.6;Summary;354
28;Chapter 16 Generating Documentation with phpDocumentor;355
28.1;Why Document?;355
28.2;Installation;356
28.3;Generating Documentation;357
28.4;DocBlock Comments;358
28.5;Documenting Classes;360
28.6;File-Level Documentation;361
28.7;Documenting Properties;361
28.8;Documenting Methods;363
28.9;Creating Links in Documentation;364
28.10;Summary;367
29;Chapter 17 Version Control with Subversion;368
29.1;Why Use Version Control?;368
29.2;Getting Subversion;369
29.3;Configuring a Subversion Repository;370
29.3.1;Creating a Repository;370
29.4;Beginning a Project;371
29.5;Updating and Committing;375
29.6;Adding and Removing Files and Directories;378
29.6.1;Adding a File;378
29.6.2;Removing a File;379
29.6.3;Adding a Directory;379
29.6.4;Removing Directories;380
29.7;Tagging and Exporting a Release;380
29.7.1;Tagging a Project;380
29.7.2;Exporting a Project;381
29.8;Branching a Project;381
29.9;Summary;385
30;Chapter 18 Testing with PHPUnit;386
30.1;Functional Tests and Unit Tests;386
30.2;Testing by Hand;387
30.3;Introducing PHPUnit;389
30.3.1;Creating a Test Case;389
30.3.2;Assertion Methods;390
30.3.3;Testing Exceptions;391
30.3.4;Running Test Suites;392
30.3.5;Constraints;393
30.3.6;Mocks and Stubs;395
30.3.7;Tests Succeed When They Fail;398
30.4;Writing Web Tests;401
30.4.1;Refactoring a Web Application for Testing;401
30.4.2;Simple Web Testing;404
30.4.3;Introducing Selenium;405
30.4.3.1;Getting Selenium;405
30.4.3.2;Creating a Test;406
30.5;A Note of Caution;410
30.6;Summary;412
31;Chapter 19 Automated Build with Phing;413
31.1;What Is Phing?;413
31.2;Getting and Installing Phing;414
31.3;Composing the Build Document;414
31.3.1;Targets;416
31.3.2;Properties;418
31.3.3;Types;422
31.3.3.1;FileSet;423
31.3.3.2;PatternSet;424
31.3.3.3;FilterChain;425
31.3.4;Tasks;427
31.3.4.1;Echo;427
31.3.4.2;Copy;427
31.3.4.3;Input;429
31.3.4.4;Delete;431
31.4;Summary;431
32;Chapter 20 Continuous Integration;432
32.1;What Is Continuous Integration?;432
32.1.1;Preparing a Project for CI;433
32.1.1.1;CI and Version Control;434
32.1.1.2;Unit Tests;435
32.1.1.3;Documentation;436
32.1.1.4;Code Coverage;436
32.1.1.5;Coding Standards;438
32.1.1.6;PHP Code Browser;438
32.1.1.7;Build;440
32.2;CruiseControl and phpUnderControl;441
32.2.1;Installing CruiseControl;441
32.2.2;Installing phpUnderControl;443
32.2.3;Installing Your Project;445
32.2.3.1;Running phpUnderControl / CruiseControl;448
32.2.3.2;Test Failures;450
32.2.3.3;Failure Notification;451
32.2.3.4;Adding Your Own Build Targets;452
32.3;Summary;455
33;Part 5: Conclusion;456
34;Chapter 21 Objects, Patterns, Practice;457
34.1;Objects;457
34.1.1;Choice;458
34.1.2;Encapsulation and Delegation;458
34.1.3;Decoupling;458
34.1.4;Reusability;459
34.1.5;Aesthetics;459
34.2;Patterns;459
34.2.1;What Patterns Buy Us;460
34.2.1.1;Tried and Tested;460
34.2.1.2;Patterns Suggest Other Patterns;460
34.2.1.3;A Common Vocabulary;460
34.2.1.4;Patterns Promote Design;460
34.2.2;Patterns and Principles of Design;460
34.2.2.1;Favor Composition over Inheritance;461
34.2.2.2;Avoid Tight Coupling;461
34.2.2.3;Code to an Interface, Not an Implementation;461
34.2.2.4;Encapsulate the Concept That Varies;462
34.3;Practice;462
34.3.1;Testing;463
34.3.2;Documentation;463
34.3.3;Version Control;463
34.3.4;Automated Build;463
34.3.5;Continuous Integration;464
34.3.6;What I Missed;464
34.4;Summary;464
35;Appendix A Bibliography;466
35.1;Books;466
35.2;Articles;467
35.3;Sites;467
36;Appendix B A Simple Parser;469
36.1;The Scanner;469
36.2;The Parser;476
37;Index;489



Ihre Fragen, Wünsche oder Anmerkungen
Vorname*
Nachname*
Ihre E-Mail-Adresse*
Kundennr.
Ihre Nachricht*
Lediglich mit * gekennzeichnete Felder sind Pflichtfelder.
Wenn Sie die im Kontaktformular eingegebenen Daten durch Klick auf den nachfolgenden Button übersenden, erklären Sie sich damit einverstanden, dass wir Ihr Angaben für die Beantwortung Ihrer Anfrage verwenden. Selbstverständlich werden Ihre Daten vertraulich behandelt und nicht an Dritte weitergegeben. Sie können der Verwendung Ihrer Daten jederzeit widersprechen. Das Datenhandling bei Sack Fachmedien erklären wir Ihnen in unserer Datenschutzerklärung.