 | News Feed |
 | Jobs Feed |
Sections
|
| feed this: |  |
Lorna Mitchell's Blog: PHP and JSON
by Chris Cornutt February 11, 2010 @ 10:55:06
Lorna Mitchell has taken a look at using JSON in PHP applications in a new post to her blog. More specifically, she looks at how to get it working and a downfall or two that comes with it.
This is a quick outline on working with JSON from PHP, which is actually pretty simple to do. This post has some examples on how to do it and what the results should look like. JSON stands for JavaScript Object Notation, and is widely used in many languages (not just JavaScript) for serialisation. It is particularly popular for use in web services.
She gives an example of the translation between a PHP array (of subarrays) out into a JSON message complete with grouping. She does mention one problem that using this data format has, though - the lack of typing information that comes along with the message details. That can mean the difference between an array being pushed in on the sending side and an object (from json_decode) coming out the other side. As noted in the comments, though, there's a second parameter for json_decode that tells it to force the output as an array instead (along with a mention of another helpful constant in PHP 5.3 - JSON_FORCE_OBJECT).
voice your opinion now!
json example object array webservice
Brandon Savage's Blog: 5 (Good) Lessons The Government Teaches Us About Object-Oriented Programming
by Chris Cornutt December 02, 2009 @ 12: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".
voice your opinion now!
government opinion object oriented
Adam Gotterer's Blog: Building an Object Collection Manager with the Standard PHP Library (SPL)
by Chris Cornutt November 02, 2009 @ 09:17:14
Adam Gotterer has written up a tutorial with his process behind creating an object collection manager with PHP's built-in SPL functionality.
The purpose of a collection is to store objects in an organized manner with specific access rules. We are going to build a collection class using the Standard PHP Library (SPL). Our final product will be capable of iterating, counting and access to objects via array. If you are not familiar with SPL you can find some additional information on the PHP SPL manual site. Unfortunately the manual is somewhat lacking.
He creates an object that implements the ArrayAccess, Countable and Iterator objects to create a "Collection" class to hold his multiple objects inside an"objects" array. He includes some code to test the class and the output as a result.
voice your opinion now!
object collection manager spl tutorial
Federico Cargnelutti's Blog: Testing Zend Framework Action Controllers With Mocks
by Chris Cornutt November 02, 2009 @ 07:58:44
In this new post to his blog today Federico Cargnelutti shows you how to use mock objects to unit test controllers in your Zend Framework application.
In this post I'll demonstrate a unit test technique for testing Zend Framework Action Controllers using Mock Objects. Unit testing controllers independently has a number of advantages: you can develop controllers test-first (TDD), develop and test all of your controller code before developing any of the view scripts and helps you quickly identify problems in the controller, rather than problems in one of the combination of Model, View and Controller.
He sets up a sample user controller and a test case to go along with it. Drop in a test for the user controller class that uses a "getMock" method to define a mock controller object for the "render" method. He also points out a few issues with this sort of testing in the Zend Framework - the return value of the Zend_Test_PHPUnit_ControllerTestCase, issues throwing exceptions with the Front Controller and a problem with the dispatcher's storage of the Action Controller.
voice your opinion now!
action controller zendframework test mock object
Brandon Savage's Blog: Five Tips To Make Good Object-Oriented Code Better
by Chris Cornutt October 28, 2009 @ 07:58:45
Brandon Savage has posted a set of five tips on how you can make your object-oriented code work better and be easier to maintain in the long run.
Last week, I did a talk at the Frederick Web meetup about tips and tricks for improving your object-oriented code. A lot of these tips were adapted from a fabulous presentation by Stefan Priebsch but the ideas are by no means original to him, and they're exceptionally good ideas when you're talking about object-oriented code. Slides are at the end of this blog post, and I'm happy to do this talk over again for local groups.
His list of five is:
- Use Objects. Lots of Objects
- Use Interfaces To Make APIs Predictable
- Use Dependency Injection
- Composition Over Inheritance
- Create Loosely Coupled Classes
voice your opinion now!
oop object tip
WebReference.com: Object Orientated Programming - The beginning
by Chris Cornutt October 14, 2009 @ 07:58:42
New from WebReference.com there's the first part of a tutorial series looking at working with object-oriented programming in PHP:
It is essentially a different way of constructing your applications. Instead of having loose procedures and functions that are meant to serve one purpose, Object Orientated Programming enables you to put data and functions in one container. This container is referred to as an object. An object enables you to model your application as closely as possible to the real world.
They introduce the object - what it is, some of its properties - and include some example code to show how it works. Their sample defines a class and shows how to call methods and set properties on it. They also touch on some of the OOP basics like constructors and inheritance,
voice your opinion now!
oop object introduction tutorial
Jani Hartikainen's Blog: What is a null object, and when are they useful?
by Chris Cornutt September 14, 2009 @ 12:46:10
In this latest post to his blog Jani Hartikainen looks at creating "null objects" for your applications - a simple tool that lets you replace multiple evaluation checks with a simple object.
How many times have you written code, which checks if a value is null, and then displays something special because of that? Have you written the very same check in more than one place in your code? A null object is an elegant solution to this.
His example shows how to replace a standard User class to grab the user's name with an anonymous user that extends it to return the string "Anonymous User" instead. By creating an intermediate class like this, you can simple call a "getName" and know that there will be some sort of value as the result.
voice your opinion now!
null object anonymous tutorial
Ibuildings Blog: Migrating a dev team to an OO team (Part 1)
by Chris Cornutt September 07, 2009 @ 13: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.
voice your opinion now!
migrate development oop object oriented
Chris Jones' Blog: Upgrading PHP Web Applications with Minimum Downtime using Oracle Editioning
by Chris Cornutt September 02, 2009 @ 12:03:47
Chris Jones has posted a guide to upgrading you PHP apps with as little downtime as possible via the new Editioning feature the 11gR2 version of the database.
The Editioning feature of Oracle Database 11gR2 is ideal for web sites that aim for no downtime when releasing application enhancements. Editioning allows certain database objects to have multiple versions all available at the same time. Applications can decide at runtime which version of the objects should be used.
He gives an example of a simple PHP application - an hours tracking app. He creates a stored function that calculates the number of days of vacation an employee can have and shows how to create a new "edition" of it with updated calculations. Your script then runs an alter on the session to point the edition to this new version.
voice your opinion now!
oracle editioning version object
|
Community Events
Don't see your event here? Let us know!
|