Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Ramon Kleiss:
Introduction to Aspect-Oriented Programming
Aug 07, 2014 @ 16:09:10

Ramon Kleiss has posted a tutorial to his site recently introducing you to the concept of AOP in PHP (Aspect Oriented Programming). In it he provides an overview of some of be basic AOP concepts and code examples showing them in action.

For my first blog post, I'm going to take you on a little trip into a really cool programming paradigm: aspect-oriented programming, which is a little known style of programming while it can come in really useful. It is common knowledge that in software development you should have a Separation of Concerns (the first letter in SOLID). Although it is accepted that the Single Responsibility Principle is hard to design, it is still valued as one of the top best practices one can use.

He starts with a base class (ArticleManager) and how it's easy for it to grow when more dependencies are needed. He then evolves this example to use a more AOP approach, resolving the scope creep in the main class using cross-cutting concerns, advice, pointcut and aspects. He moves away from his basic example and uses a Symfony-based example to show how to implement a LoggingPointcut, inject it into the class and set up an "intercept" method to handle the notification of which method was called.

You will have to be careful to remember that you are using AOP as the application development continues, since it is very easy to forget about if you're happily developing away. Just take this rule of thumb: does the class I'm modifying care about the extra functionality? If it doesn't see if you can use inheritance or see if you can use AOP.
tagged: aspect oriented programming aop introduction example

Link: http://ramonkleiss.nl/intro-to-aop/

NetTuts.com:
Aspect-Oriented Programming in PHP with Go!
Apr 10, 2013 @ 15:56:41

In this new tutorial on NetTuts.com today they introduce you to aspect-oriented programming (AOP) in PHP through the use of the Go! PHP library.

The concept of Aspect-Oriented Programming (AOP) is fairly new to PHP. There's currently no official AOP support in PHP, but there are some extensions and libraries which implement this feature. In this lesson, we'll use the Go! PHP library to learn AOP in PHP, and review when it can be helpful.

They start with a brief history of AOP in general and a basic vocabulary of some of the common terms like "point-cut", "aspect" and "cross-concern." They briefly look at some of the other PHP tools for AOP, but then help you get Go! up and running. Sample code is included showing how to integrate it into your project and, more practically, create a logging system that can be used as an aspect.

tagged: aspect oriented programming tutorial go library introduction

Link: http://net.tutsplus.com/tutorials/php/aspect-oriented-programming-in-php-with-go

TechFlirt:
Object Oriented Programming in PHP
Apr 02, 2013 @ 18:05:23

If you've been writing mostly procedural PHP code and are looking to make that "next step" up to working with objects and classes (OOP), you should check out this detailed tutorial introducing you to some of the primary OOP-in-PHP concepts.

Object oriented programming (OOP) was first introduced in php4. Area for oop in php version 4 was not very vast. There were only few features available in php4. Major concept of the object oriented programming in PHP is introduced from version 5(we commonly known as php5). [...] But still in php5 object model is designed nicely. If you have good understanding of OOP then you can create very good architecture of your php application. You only need to know some of the basic principles of object oriented programming and how to implement that concept of oop in php.

While the wording is slightly odd in some spots (English doesn't seem to be the author's first language), it's' a great introduction to the major OOP-related topics including:

Each section also has downloadable code to go along with the examples, making it easier to follow and test out the actual scripts.

tagged: object oriented programming tutorial introduction series beginner

Link: http://www.techflirt.com/tutorials/oop-in-php/index.html

PHPEasy.co.uk:
Object Orientation Basics part 4 – Implementing CRUD methods
Aug 07, 2012 @ 17:23:36

PHPEasy.co.uk continues their series looking at some of the basics of Object-Oriented Programming (OOP) in PHP with part four showing how to implement CRUD methods (Create/Read/Update/Delete) on a database connection.

In the last tutorial in this beginners series we discussed using PDO to connect to a MySQL database. Following on from that tutorial we are going to improve the Guitar class we made by adding some basic CRUD methods so that our class can interact with our database using PDO.

He brings back the same class structure and shows how to take a "Guitar" object, create a connection via a "conn()" method and use the getters/setters to assign values for saving, selecting, deleting and updating the database's records.

tagged: oop object oriented introduction pdo crud

Link:

NetTuts.com:
Aspect-Oriented Programming in PHP
May 11, 2012 @ 14:34:18

On the NetTuts.com (Plus) site there's a new tutorial focusing on aspect-oriented programming in PHP, a shift from the usual methods of development with the goal of "crosscutting" your classes/objects by weaving in extra functionality. Their examples of this method use the FLOW3 framework.

All modern frameworks (including FLOW3) push a lot of patterns into the software stack that do a great job at separating the concerns of your business logic; among them the famous MVC that is separating your logic into different layers. However, an application is not only built on business logic alone. As it grows, you may want to implement additional services, features, plugins or plugins of plugins. You surely don’t want this stuff in your business logic! But what are your options?

For their example, they show how to implement a logger across your classes, taking it out of the actual code and implementing it in an aspect (at the "pointcut") by "weaving" it into a DocBlock comment with special annotations. They help you get the FLOW3 framework set up and show you how to "kickstart" a new project and work with its controllers and resources. They show you how to implement the Logging aspect and how to define it in your code (and where it caches the requests).

tagged: aspect oriented programming tutorial typo3 flow3

Link:

Dennis Hotson's Blog:
PHP Object Oriented Programming Reinvented
Sep 23, 2010 @ 17:43:39

Dennis Hotson has a new post to his Tumblr blog about what he calls PHP object-oriented programming reinvented - a chunk of code he's created that lets you build classes out of objects.

It’s tentatively called "PHP Object Oriented Programming Reinvented". Although it turns out the acronym is kind of unfortunate. I'm still working on that... The main idea is that classes aren't really very special at all, they're just objects like everything else. They don't even have names.. you give your class a name by giving the variable it's assigned to a name.

He includes a code snippet that shows the creation of a sample class (the "class" class) and extend it with a new class of "animal"....and then extend that with a class for a "dog". You can take a look at the full code for the method here.

tagged: object oriented programming reinvented

Link:

Brandon Savage's Blog:
5 (Good) Lessons The Government Teaches Us About Object-Oriented Programming
Dec 02, 2009 @ 18:11:55

Brandon Savage has taken some of the good practices in object oriented application development and related them to some of the things that the government can teach you about them:

However, the ubiquity of governments around the world also gives us a unique opportunity to learn some lessons from them as developers, particularly about principles of object oriented programming. Governments serve as perfet object lessons (pun intended), demonstrating some of the good, the bad, and the ugly object-oriented practices we see.

He looks at five topics - abstraction, encapsulation, implementation of dumb objects, decoupling and the concept of "one class, one responsibility".

tagged: government opinion object oriented

Link:

Brandon Savage's Blog:
Q&A: Answering Some Questions About Object-Oriented Programming
Oct 30, 2009 @ 14:20:52

Brandon Savage has posted the answers to some questions that were raised by a previous post of his on object-oriented development and some best practices. In this new post, he answers the questions:

  • "Often times when a developer gives each object only one responsibility, they tightly couple objects together." Can you explain?
  • I do not know about dependency injection – do you have any links that do not require subscription?
  • Can you please explain 'one object – one job' concept?

Each question is answered, sometimes with code included, to help resolve any confusion about how to correct use object oriented practices in your applications.

tagged: oop object oriented programming questions

Link:

Ibuildings Blog:
Migrating a dev team to an OO team (Part 1)
Sep 07, 2009 @ 18:28:12

On the Ibuildings blog today Dennis-Jan Broerse has posted the first part of a series he's doing on moving a development team up into the world of object oriented programming.

Being a trainer for Ibuildings, I noticed that the main topic of almost every course plan for customers is object oriented programming. So OO is popular and demand for it is rising. However, while PHP support for OO has been present for a couple of years still many companies that I visit are maintaining and developing procedural applications.

He talks some about how he tries to promote the OOP way of doing things and defines one of the major hindrances for companies to try to move their development towards it - time. The next part of his series will look at ways to help with this.

tagged: migrate development oop object oriented

Link:

Blue Parabola Blog:
Objectively Oriented
Feb 18, 2009 @ 15:31:30

On the Blue Parabola blog, Matthew Turland takes a look at object-oriented programming and what core concepts lie at its heart.

What is object-oriented programming? The acronym OOP has become a bit of a buzzword in the current age of programming, to the point where the waters of its definition have become rather murky. [...] PHP may not be object-oriented, but from a purist perspective, neither is Java. What do I mean by "purist perspective?" Plain and simple: everything is either an object or a message being passed between objects (where message parameters are also objects).

He mentions one of the first languages to support objects (Simula) and the four fundamental concepts that would make a language truly OOP - abstraction, inheritance, encapsulation, polymorphism. Its his opinion, though, that while its good for languages to adhere to these four principles as much as they can, discussions about how well they adhere to them is usually just "spinning your wheels" and don't have much use.

tagged: object oriented definition abstraction inheritance encapsulation ploymorphism

Link:


Trending Topics: