News Feed
Sections




News Archive
feed this:

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

Reddit.com:
Is there anything wrong with using functions?
August 07, 2013 @ 11:39:47

In a largely object-oriented world, one Redditer asks if it's still okay to just use functions, the more procedural method of PHP development:

Is there anything wrong with using an include file of functions instead of using full code in a file? [...] Obviously you wouldn't write functions for one off tiny things, but I think it would help to read files altogether especially if the functions file was alphabetically listed.

There's several suggestions in the comments including things like:

  • You should also look into using a templating engine, so you can separate your html from your php code.
  • One thing you could always ask yourself is "Do I will ever need to write that part a second time somewhere else ?" If "yes", that means you should put that part in a function.
  • Before you go writing a load of functions and putting them all in a file, which can get quite unmanageable, consider grouping them logically and placing them in classes.
  • Function names should start with a verb though (except for trivial getters whose meaning is clear by context, which can be named after the thing they get).
  • Do group them logically, but it's not necessary to place them in a class unless they share data or state.
0 comments voice your opinion now!
oop functions procedural opinion file group

Link: http://www.reddit.com/r/PHP/comments/1jss6q/is_there_anything_wrong_with_using_functions

NetTuts.com:
From Procedural to Object Oriented PHP
June 24, 2013 @ 12:17:36

In this new tutorial from NetTuts.com, they want to help you make the move from procedural PHP to the world of Object-Oriented PHP. They opt for the mini-project approach and show you how to make a simple Google API client.

This tutorial was inspired by a speech given by Robert C. Martin that I watched a year or so ago. The main subject of his talk is about the possibility of picking The Last Programming Language. He addresses topics such as why should such a language exist? And what it should look like? However, if you read between the lines, there was another interesting idea that caught my attention: the limitations that each programming paradigm imposes upon on us programmers. So before we get into how we could go about converting a procedural based PHP app into an object oriented one, I want to cover a little bit of theory beforehand.

They start their example with a procedural approach, showing how to make the client and make a request for calendar information. They then work through the refactoring of the example, breaking it up into logical chunks (objects) and separating out some of the logic (like view versus logic). They talk about everything from basic OOP terms out to more complex ideas like SOLID.

0 comments voice your opinion now!
procedural objectoriented oop programming tutorial introduction google api client

Link: http://net.tutsplus.com/tutorials/php/from-procedural-to-object-oriented-php

Reddit.com:
Good guidance for shifting to OO from Procedural coding
March 19, 2013 @ 12:33:29

On Reddit.com there's a conversation kicked off by user swiftpants about making the move from procedural PHP programming to the world of object-oriented programming. They ask for advice from the community for the next steps to take to make the jump.

One thing I always have in the back of my head is that all my code is procedural and I should be making use of classes and ?? more. I have a very basic understanding of OO programming but I rarely implement it. Is there a good book or online guide that can get me on my way to OO programming in php. I am especially looking for feed back from self taught programmers.

There's lots of comments on the post talking about everything from:

  • Introductory videos from KillerPHP
  • Reading lots of other people's (OOP) code
  • That OOP is more about code reusing and simplicity (DRY) than abstraction.
  • You can learn a lot by working with one of the MVC/OO frameworks. Download one and build something.
  • The suggestion of phptherightway.com

Have any other thoughts on the best ways to learn OOP in PHP? Share them here!

0 comments voice your opinion now!
reddit opinion oop procedural programming guide suggestion


Anthony Ferrara:
Programming With Anthony - Paradigm Soup
November 22, 2012 @ 09:50:23

Anthony Ferrara has posted about his first video in a series he's creating about programming and related topics. In this first one he talks about "Paradigm Soup".

So, for the past few days I've been talking about a secret project that I've been working on. Well, today I'm pleased to announce the project. I've been working on starting a series of YouTube videos about programming. The first of these videos is about Paradigms (Procedural, OOP, Functional). Plenty of future ones are planned, but the topics, order and even if they happen is completely up to you!

He goes through some common practices in things like OOP, functional and procedural programming as well as how they relate to each other. You can view the video in the post or you can watch it over on Youtube. If you want to keep up with the series, you can follow this playlist.

0 comments voice your opinion now!
video tutorial series paradigm oop functional programming procedural


Slawek Lukasiewicz's Blog:
Working with date and time in object oriented way
June 10, 2011 @ 08:13:14

Slawek Lukasiewicz has a new post today about working with dates and times in PHP on a more object-oriented fashion than in the more traditionally procedural way of just calling PHP date/time functions on the string values.

Date and time manipulation in PHP is mostly connected with functions like: date, time or strtotime. They can be sufficient, but if we want to deal with dates like with objects - we can use DateTime class. DateTime class is not only straightforward wrapper for standard functions, it has a lot of additional features - for example timezones.

He shows how to use the DateTime functionality to return an object you can call several different methods on. He gives examples of the formatting call, comparing one DateTime object to another, how to update the date after the object's created, calculating the difference between two dates and iterating through a certain time period.

1 comment voice your opinion now!
time date datetime objectoriented procedural tutorial


Aleksey Martynov's Blog:
Getting started with lexa-tools Blog in 15 Minutes
May 25, 2011 @ 11:10:58

Aleksey Martynov has submitted a new tutorial showing you how to (create a) "blog in 15 minutes" with the help of the lexa-tools framework, a set of utilities that gives you a procedural API to some handy tools.

The tutorial walks you through all the steps you'll need:

  • setting up the environment
  • creating a site skeleton
  • making the blog posts model (with the CRUD generator)
  • make the main page to display the latest posts
  • adding comments
  • creating a page for each posts's detail
  • and the comments view

If you'd like to just skip to the end, you can download the source here.

0 comments voice your opinion now!
lexatools blog tutorial framework procedural


James Cohen's Blog:
Working with Date and Time in PHP
May 04, 2011 @ 08:59:23

James Cohen has a new post to his blog today looking at some of the built-in functionality that PHP has to work with dates and times including simple things like strtotime and the DateTime feature.

A lot of people ask questions relating to date and time in PHP. Here are some answers to the most commonly asked questions and common mistakes.

He covers the differences between working with dates in strtotime, worrying about timezone settings and compares the strtotime/DateTime methods for formatting and returning dates, modifying dates, converting between timezones as well as finding the difference between two timezones.

0 comments voice your opinion now!
date time datetime strtotime timezone tutorial procedural oop


Web Builder Zone:
The PHP paradigms poll results OOP wins
October 05, 2010 @ 11:21:17

According to this new post on the Web Builder Zone, the results of a poll taken about the best programming method for PHP these days is - by far - object-oriented programming.

After two weeks of gathering votes, the PHP paradigms poll is now closed. With 216 votes (73%), the winner paradigm in popularity is Object-Oriented Programming. The old procedural approach to PHP, which has given fame to Wordpress and Drupal, is coming to an end. Even Drupal 7 has an object-oriented database layer as a primary component, and this paradigm is by far the most diffused in the world for web sites and applications written in high level languages (different from C).

While the overwhelming amount of votes went to OOP, there were still a few for some of the other options including the second place winner - procedural programming. He also talks a bit about OOP's current place in the PHP ecosystem and how it has allowed for certain great tools to be developed, but how it also has a good ways to go in functionality.

0 comments voice your opinion now!
poll paradigm results oop objectoriented procedural


NETTUTS.com:
Object-Oriented PHP for Beginners
July 09, 2010 @ 08:56:25

If you're just making the move from procedural PHP development into the next level - object oriented programming - and are having a bit of trouble getting the hang of it, you might want to read this new tutorial from NETTUS.com introducing the topic.

For many PHP programmers, object-oriented programming is a frightening concept, full of complicated syntax and other roadblocks. As detailed in my book, Pro PHP and jQuery, you'll learn the concepts behind object-oriented programming (OOP), a style of coding in which related actions are grouped into classes to aid in creating more-compact, effective code.

He introduces the concepts behind objects and working with them in your code first then moves into how they relate to classes (with a housing metaphor). He talks about class structure, properties, methods (both magic and user-defined) as well as using __toString, visibility and using DocBlock comments in your code. They also have a comparison between procedural code and object-oriented code in the form of a few reasons to lean towards OOP.

0 comments voice your opinion now!
procedural development oop objectoriented tutorial introduction


Giorgio Sironi's Blog:
The dangers of Late Static Bindings
April 14, 2010 @ 07:06:41

Giorgio Sironi has a new post that warns you of the dangers that could come from the use of a technology just recently introduced to PHP - late static binding.

There's a lot of (justified) excitement about PHP 5.3 new features, such as the support of namespaces and anonymous functions. Though, some glittering capabilities of the language are definitely not gold: the goto statement is probably the most debated example, but also the long-awaited Late Static Bindings support is an hammer which may hurt your fingers...

He talks about how two of the characteristics of late static binding - the fact that it involves something being static and that there's a sort of hierarchy involved. He gives a code example of how it could be used and notes that static functions should be used sparingly since they are a more procedural way of doing things.

The post also includes a good example - an abstract Factory method - and a bad example - Active Record that doesn't evolve towards a Repository pattern being used.

0 comments voice your opinion now!
latestaticbinding danger procedural static hierarchy



Community Events





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


language interview series laravel wordpress configure framework list refactor threedevsandamaybe community developer code unittest podcast release opinion introduction testing install

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