Home arrow PHP arrow Checking Integers with the Strategy Design Pattern

Checking Integers with the Strategy Design Pattern

If youíre a PHP developer who wants to learn how to implement the Strategy design pattern in a real-world project, then you might want to take a look at this article series. Over the course of its six tutorials, youíll walk through the development of a modular and flexible application, which will use this powerful pattern to validate different types of data, including integer and float numbers, email addresses and URLs.

TABLE OF CONTENTS:
  1. Checking Integers with the Strategy Design Pattern
  2. Review: implementing the Strategy design pattern to validate input data
  3. Creating an abstract validation class
  4. Validating integer numbers
By: Alejandro Gervasio
Rating: starstarstarstarstar / 1
April 20, 2010

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

And now that you've been introduced to the subject covered by this series, itís time to review the topics covered in the first tutorial, in case you havenít read it yet. In that part I explained in depth the logic that stands behind the Strategy pattern, as well as how to use it for checking the validity of incoming data at a very basic level.

In that first example, I created a simple form helper class which was capable of taking different validator objects, or ďstrategies,Ē via one of its core methods, not surprisingly called ďaddValidator().Ē This flexible schema permits it to assemble multiple validation strategies at run time, in order to check distinct kinds of data without having to define a monolithic class that attempts to validate everything.

With the helper class ready to be used at will, the next step that needs to be taken to implement the Strategy pattern is to begin defining the isolated classes responsible for checking input data. Therefore, in this second part of the series Iím going to create a brand new strategy class that will be tasked with validating integer numbers. According to the model imposed by the pattern, instances of this class and other classes will be injected afterward into the helper, thus setting up a specific validation strategy.

Now, itís time to leave the preliminaries behind and learn more on how to implement the Strategy design pattern in PHP. Letís get going!



 
 
>>> More PHP Articles          >>> More By Alejandro Gervasio
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: