Archive for May 2011

Week 20, year 2011

  • Lazy Loading in PHP with Closures - Closures are a great way to do all kinds of neat tricks in PHP, and they’re particularly useful for Lazy Loading. I’m currently involved in a +200k SLoC legacy project, and the challenge is moving it to a Domain Driven implementation (while improving the performance), with the ultimate goal of making it more testable. The problem We want to find a Customer, and ask it for a list of Orders: <?php// client code$customer=$customerRepository->find($id);$orders=$customer->getOrders(); With the ActiveRecord pattern, this is simple. The Customer object holds an instance of the database adapter, and queries it for related Orders: <?phpclassCustomer{publicfunctiongetOrders(){$ordersData=$this->db->query(/* select orders. . . [Mathias Verraes]
Permalink | From 16 May 2011 to 22 May 2011 | Last updated on: Mon, 7 Jun 2021 09:18:52 GMT

Week 19, year 2011

  • Ubiquitous Language - Customers usually have never been forced to really think about their domain in a structured way – let alone explain it in detail to a developer, who doesn’t know anything about that domain. Often the customer doesn’t have a set of clear definitions for the concepts his business uses daily, or has multiple terms for the same concepts. Developers are even worse. They also tend to have vague concepts and lots of ways to name the same thing. Depending on where you look in the code or the documentation (if any), you might see: “bank account”, “account”, “bank_account”, “bankAccount”, “BankAccount”. And worse: “BA”, “bank_acc”, “acnt”. [Mathias Verraes]
Permalink | From 09 May 2011 to 15 May 2011 | Last updated on: Mon, 7 Jun 2021 09:18:52 GMT