• Home
  • Resume
  • CV PDF
  • Portfolio
    • PHP Factory Pattern | PHP/OOP/Design Patterns
    • User validation form | PHP/OOP/HTML
    • Pizza Fanatic App | PHP/MySQL
    • Raspberry Pi Robot | RaspberryPi/Python
    • Commercial in Confidence | MySQL/PHP/AJAX
    • Gazetteer Geolocation | APIs/cURL/PHP/AJAX
    • Wasteman Clearance | Bootstrap/JS
    • Paddy Boyle Photos | Node.js
    • Paddy Boyle Photography | Node.js
    • Jackie Ceramics Site | Bootstrap
    • My Website | Node.js/Express/HBS
    • Phoenix Beading Site | Bootstrap
    • Neighbourhood Site | Bootstrap
    • GitHub Profiler API | AJAX/jQuery
    • AJAX CRUD Requests | AJAX/jQuery/Node.js
    • Geolocation App/API | AJAX/PHP/CURL/JSON
    • Json Generator App | AJAX
    • Musicon Site | Handlebars
    • Rock Paper Scissors App | JS
    • PHP Calculator App | PHP
    • Race Registration App | JS
    • Magic Eight Ball App | JS
    • Games of Chance App | JS
    • Tasty Treats Form | Node.js
    • React Exercise | Node.js/React
    • Bitesize API | AJAX
    • Wordsmith API | AJAX
    • Piano Keys App | jQuery
    • Gameboard App | jQuery
    • Web Safe Font App | jQuery
    • Feedster App | PHP
    • Madison Site | jQuery
    • Task List | Python/Flask
    • Trivia Card | jQuery
    • Academia Stats | DC.js/Crossfilter
    • Connect Four Game | jQuery
    • DRY App | Bootstrap
    • Silent Signs | JS/Bootstrap
    • Tic Tac Toe Game | JS
    • Stopwatch App | JS
    • CSS Poster | HTML5/CSS3
  • Git Hub
  • Contact
Jed Boyle logo

Jed Boyle

Full Stack Developer

Jed Boyle logo

Jed Boyle

Full Stack Developer

  • Home
  • Resume
  • CV PDF
  • Portfolio
  • GIT HUB
  • Contact
Jed Boyle logo

Jed Boyle

Full Stack Developer

  • Home
  • Resume
  • CV PDF
  • Portfolio
  • GIT HUB
  • Contact

PHP Design Patterns - Factory Pattern

    XAMPP

    HTML5

    CSS3

    PHP

    Heroku

PHP Design Patterns - Factory Pattern

https://php-design-patterns-001-factor.herokuapp.com/
https://php-design-patterns-001-factor.herokuapp.com/
https://php-design-patterns-001-factor.herokuapp.com/
Previous Next

Project Description


Here I have created one of the most popular design patterns called the Factory Pattern. Design patterns use OOP and make code easier to maintain and organise. With a factory pattern a class simply creates the object that you want to use. So I have developed two classes; one is the actual object created, and the other is the class that creates the object.

The book class has the constructor function that creates the instance of each book. It also holds the method that gets the name and the author. These functions are both public as they need to be accessed by the static book factory class.

As the book name and author variables are both private the book factory class must have a public and static function to create and return the name and author of each instantiated book. Each book instance's data is hard coded as this is a simple project on factory patterns for PHP design patterns, it has no need for a database.

After pushing each book instance to an array I can then loop through it in the HTML and display each book card with the interpolated data.

Click here for GitHub repository




Project Description


Here I have created one of the most popular design patterns called the Factory Pattern. Design patterns use OOP and make code easier to maintain and organise. With a factory pattern a class simply creates the object that you want to use. So I have developed two classes; one is the actual object created, and the other is the class that creates the object.

The book class has the constructor function that creates the instance of each book. It also holds the method that gets the name and the author. These functions are both public as they need to be accessed by the static book factory class.

As the book name and author variables are both private the book factory class must have a public and static function to create and return the name and author of each instantiated book. Each book instance's data is hard coded as this is a simple project on factory patterns for PHP design patterns, it has no need for a database.

After pushing each book instance to an array I can then loop through it in the HTML and display each book card with the interpolated data.

Click here for GitHub repository



My Social