I have mixed feelings about ORMs, and prefer to err on the side of the more lightweight solution when I’m not sure which tool will be most appropriate to the problem I’m trying to solve. I recently found myself re-inventing the CRUD wheel once again for a node app I’m writing, and tried to find a library with a little more abstraction than the basic MySQL library without going full ORM – but turned up nothing that was appealing.
I have to say that I’m pretty happy with the result. I’ve been using the Q Promise Library, but I’ve heard good things about some other libraries so I wrote this to support a range of promise libraries so that you can use your preferred library natively with this library. Its methods return promises so they can be easily chained with other promises. The library exposes methods which correspond to HTTP methods for GET, POST, PUT and DELETE so that you can spend more time on your app instead of writing yet another set of CRUD methods.
You can find the docs on the project’s github page. I’d appreciate all constructive feedback whether it is positive or negative.
Last night I gave a talk about building websites with Knockout.JS, which I’ve been happily using for a long time. I demonstrated using Slim as an application framework, and RedBeanPHP as an ORM on the back-end. I’ve used Slim on a few projects in the past, but this was my first time playing with RedBeanPHP. I’m looking forward to learning more about this cool little ORM.
The main message of the talk was that choosing simple frameworks can mean writing and maintaining less code, and can help to overcome obstacles to adopting TDD.
At the same time, I’m a big fan of Angular, Symfony and Doctrine. For projects that can benefit from those more elaborate architectures they should be used. For smaller projects, or to make getting traction with TDD easier you should consider smaller frameworks like those touched on here.
If I were doing this talk again I would break it into three parts to that I could spend more time on each library, and on the unit testing. I was barely able to finish in an hour and a half, and I feel terrible for putting the group through such a long and code-heavy talk (again).
The slides are posted on slideshare, and the code is posted on github.
Today I released a very simple role-playing game which I developed for use at Scout camps. It is ideal for playing around a camp fire, but works just fine around a table too. The rule book is only 12 pages long, and only 2 of them are really about the rules. Most of it is help for the person who’s running the game such as story ideas.
I hope that it will be approachable by non-nerds since the rules are so simple. I’ve only played it with youth aged about 10 – 14 but I expect adults would have fun with it too.
Check it out at http://intenserpg.vicmetcalfe.com/.
Here are the slides from the SOLID wrap-up I presented at GTA-PHP last night (Google Docs, PPTX, PDF). I’ve also made a gist for the LSP example referenced on slide 8 that I couldn’t find at the time. I covered the Liskov Substitution Principal (LSP), the Dependency Inversion Principal (DIP) and the Interface Segregation Principal (ISP) in PHP. I’ve covered SRP and OCP in earlier posts. I mentioned that I wasn’t particularly fond of applying the ISP in PHP, and Ilia Alshanetsky pointed out that PHP’s performance can suffer if you use too many small interfaces in your PHP. We discussed the notion of putting constructors in interfaces, and Guilherme Blanco pointed out that since you can’t instantiate an interface an abstract class would be a more appropriate way to require a specific constructor. Peter Meth and Dan (sorry Dan, I don’t know your last name!) asked where to find a good summary of the SOLID principals, and I suggested the Wikipedia entry, which has a nice table for jogging your memory on the acronym’s meaning. Thanks to everyone who showed up!