News Feed
Jobs Feed
Sections




News Archive
feed this:

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

Anthony Ferrara:
Beyond Design Patterns
September 19, 2013 @ 10:43:11

Anthony Ferrara has written up a new post that looks beyond design patterns. He suggests that more emphasis should be put on learning proper methods for abstraction and communication between objects and structures.

Many people teach design patterns as a fundamental step to Object Oriented Programming. They are so universally seen as important that almost every single conference that I have been to has had at least one talk about them. They are quite often used as interview questions to test a candidate's OOP knowledge. However, just like inheritance, they are not needed for OOP. And just like inheritance, they are a distraction rather than a foundation. Instead of focusing on patterns, I suggest focusing on learning about abstraction and communication.

He briefly covers the three types of patterns most people are introduced to - creational, structural and behavioral - and his suggestions of other patterns that answer more of the "what the problem is" question:

  • Shim patterns (Flyweight, Iterator, etc)
  • Compositional patterns (Adapter, Builder, Facade, etc)
  • Decompositional patterns (Bridge, Command, Mediator, etc)

He spends some time later in the post looking a bit more closely at four specific patterns, Adapter, Bridge, Facade and Proxy. He points out that they (essentially) do the same kind of thing and boils it down to a more refined set of implementation patterns and the problems they help solve.

0 comments voice your opinion now!
designpattern communication abstraction implementation problem

Link: http://blog.ircmaxell.com/2013/09/beyond-design-patterns.html

PHPMaster.com:
Avoid the Original MySQL Extension, Part 2
February 25, 2013 @ 13:40:09

PHPMaster.com has posted the second part of their "avoid the original MySQL extension" tutorial series (part one is here). In this new part, they share more about another alternative - the PDO extension.

The PDO extension supports twelve drivers, enabling it to connect to a variety of relational databases without the developer having to learn a number of different APIs. It does this by abstracting the database interaction calls behind a common interface, enabling the developer to utilize a consistent interface for different databases. This of course gives it a major advantage over both the MySQL and MySQLi extensions who are limited to only one database.

Included in the post are examples of some of the basics - connecting, executing queries, getting the results - as well as more compelx things like binding parameters and transaction support. There's also a bit about changing the default behavior of the PDO object through config options. He finishes off the article talking some about some of the issues that could come from using an abstraction layer like this and the need to still write good, compatible SQL depending on the database.

0 comments voice your opinion now!
mysql extension avoid pdo tutorial abstraction


Matthew Weier O'Phinney's Blog:
View Layers, Database Abstraction, Configuration, Oh, My!
March 06, 2012 @ 13:18:14

Matthew Weier O'Phinney (of the Zend Framework project) has posted an introduction to some new ZF2 features - view layers, abstraction and configuration updates.

Late last week, the Zend Framework community 2.0.0beta3, the latest iteration of the v2 framework. What have we been busy doing the last couple months? In a nutshell, getting dirty with view layers, database abstraction, and configuration.

He covers each topic well, providing code examples for all three - a simple view layer (more here), database abstraction functionality (inserting, selecting and TableGateway) and the configuration changes that allow for things like key translation, section inheritance and constant substitution.

0 comments voice your opinion now!
zendframework2 view layer database abstraction configuration beta3


Gonzalo Ayuso's Blog:
Database Abstraction Layers in PHP. PDO versus DBAL
July 12, 2011 @ 10:14:29

In this new post to his blog, Gonzalo Ayuso compares two technologies that can make working with databases in your applications simpler - PDO and the Doctrine2 DBAL layer.

In fact DBAL isn't a pure database abstraction layer. It's built over PDO. It's a set of PHP classes we can use that gives us features not available with 'pure' PDO. If we use Doctrine2 we're using DBAL behind the scene, but we don't need to use Doctrine2 to use DBAL. We can use DBAL as a database abstraction layer without any ORM. Obiously this extra PHP layer over our PDO extension needs to pay a fee. I will have a look to this fee in this post.

He includes a few simple benchmarking scripts that compare similar operations done by either, including memory usage and execution time. PDO comes out on top, obviously, because it's an extension versus a set of PHP libraries that need to be included in the application. He does include examples of a few things he likes that DBAL does that PDO doesn't by default - a transactional mode, type conversion, a simpler binding interface and the ability to nest transactions.

0 comments voice your opinion now!
database abstraction doctrine2 dbal pdo layer benchmark feature


Volker Dusch's Blog:
References suck! - Let's fix MySqli prepared statements!
June 14, 2011 @ 11:46:55

Volker Dusch has a new post to his blog looking at the use of references in PHP (or lack there of) and what we, as end users of the language, can do about it. His example looks at mysqli prepared statements.

Even so not every PHP Developers knows WHY we don't use references pretty much every core function and every somewhat modern framework avoids them so people adapted this best practice. The leftovers in the PHP core, like sort() or str_replace(), are exceptions to the rule. So if the common consensus is, or at least 'should be', that we should not use references then maybe we should start looking for places where they hurt and how we could fix them?

He talks about prepared statements and one thing he sees that makes it a "hard sell" to developers needing a good way to query their databases. He points out the difference in code required between the normal MySQL calls and mysqli (hint: it's more) and shows how to use an abstraction layer to make things a bit easier. He points out the downfalls of using this approach, mainly the performance hit you get (from using his fetchAll method).

0 comments voice your opinion now!
references mysqli prepared statement performance abstraction


Sameer Borate's Blog:
Templating with Haml
September 09, 2010 @ 12:51:40

Sameer Borate has posted about an alternative templating system that's currently being used in multiple languages - Haml (HTML Abstraction Markup Language). As Sameer points out, there's also a PHP port of it.

It has been a while since I've used a template engine during development, the last one I used was Smarty. Now there are a plethora of template systems, but most are a rehash of Smarty. Readers may beg to differ, but Smarty gets the work done, which is all that matters. The one that I found really interesting is Haml.

He includes some markup examples of how it's structured - the main structure of the site, tables, divs, etc - and what it comes out like on the other side of the parser. The phphaml and phamlp libraries let you run the template through with variable values set and display it. There are some downsides he mentions, though, like the rules on indentation and that the markup has to be all in one file (or combined before sending to be rendered).

0 comments voice your opinion now!
template haml markup abstraction tutorial phphaml phamlp


php|architect:
Crystal Starting to Form
August 19, 2010 @ 08:46:00

On the php|architect blog today Bill Karwin looks at a new library - Crystal - a database library to help make it simpler to work with SQL (and make it more human-readable).

Martin [Rusev]'s project is called Crystal. It's an object-oriented wrapper for the venerable mysql and pg extensions, with the goals of making SQL more human-readable, and providing a library that is lightweight and easy to learn.

There's code examples on the site of how to use the library. Bill also mentions some of the things the project does well and a few things it doesn't - like leaving out some of the advanced SQL functionality in favor of simplicity. He also mentions concerns about SQL injection handling, code not shared between database handlers and the unfinished nature of some features.

0 comments voice your opinion now!
crystal database abstraction layer simple opinion


Jani Hartikainen's Blog:
Exceptions and abstraction
August 16, 2010 @ 09:59:45

Jani Hartikainen has a few suggestions on how to handle exceptions in your application - more specifically how to handle them in your classes and still keep proper abstraction.

So you already know how to handle your errors properly. Even if you're already using exceptions, there are some nuances to the use of exceptions that are important to know and understand in order to write code that is easier to reuse and more decoupled. Let's talk about exceptions and how they relate to your classes and abstraction.

He looks at classes/abstraction, how they relate to normal and custom exceptions and how to design your code better to wrap exceptions in custom handlers to make maintainability even easier. He also suggests catching everything in more general exceptions as well, giving you an overall way to handle abstracted exceptions.

0 comments voice your opinion now!
exception abstraction class tutorial


Brandon Savage's Blog:
Peer Review Looking At Abstraction - Redux
September 02, 2009 @ 11:46:24

Brandon Savage has posted his latest part of his "Peer Review" series. He takesa step back and looks at abstraction again, this time incorporating some of the suggestions other members of the PHP community gave based on the previous version.

This entry will focus on our use of the database, and specifically on the already_tweeted() method. This method has a number of problems, and while we're focusing on the implementation of the database, it's important to note that we will also need to address some of the logic (which will be the next part of the series).

He looks at assumptions (how they can be bad), the use of an ORM layer to help negate some of the problems surrounding them and adding in some exceptions to properly handle issues that might come up.

0 comments voice your opinion now!
review abstraction orm assumption


Brandon Savage's Blog:
Peer Review Looking Into Abstraction
August 26, 2009 @ 09:47:31

Brandon Savage has posted his latest article in his series looking at refactoring a piece of code (starting here) focusing in on the abstraction already in the code and how it can be made better.

This article will focus on the constructor method. There are a couple of problems, namely that the constructor itself does a lot of actual work. Also, we have the cURL setup done in the constructor. This object is a Twitter object, not a cURL object; this means that we should decouple the cURL functionality and abstract it into a separate object of its own.

He recommends splitting out the current method the class uses to create the cURL connection (setting it up in the constructor) and making a separate HTTP class that can be pulled in as an object and used as a sort of API. The full code of the new class is also included.

0 comments voice your opinion now!
abstraction review curl refactor



Community Events











Don't see your event here?
Let us know!


introduction performance unittest install opinion framework security database application podcast hack overview component language release symfony2 package facebook hhvm composer

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework