Posts

Showing posts from October, 2013

The Type Hint Tight Couple

Anybody who does object oriented development quickly learns about type hinting - the process by which you can indicate to one object another object it should expect. Remember this example from the last post? <?php class MyClass() {   public function __construct(MyObject $mobj) {     $this->myObject = $mobj;   } } But type hinting alone is not sufficient to loosely couple our objects. In fact, even though we are injecting our dependency in the initial example, we're type hinting on a concrete object, meaning that we are tied to that specific object for all future iterations. Sure, we can mock it for testing (which is an advantage), but we can't easily subclass it and use it elsewhere. Fixing the Type Hint Tight Couple It's easy to fix this particular tight coupling problem. To do so, we can draw back on our knowledge of SOLID principles, namely the Dependency Inversion Principle, which states: Objects should rely upon abstractions, not concretions. F

Tight coupling in OOP

What Is Tight Coupling? It would help to define exactly what the problem is, in order to solve it. Tight coupling, in object oriented application, is an abnormal dependency between two unrelated objects. This usually manifests itself in a few different ways; today we're going to talk about the first type: the object creation tight couple. The Object Creation Tight Couple Have you ever seen or written code like this? <?php class MyClass(){   public function __construct(){     $this->myObject = new MyObject();   } } We've all probably observed this. Even if it's in another method besides the constructor, we've all seen code that creates other objects. The culprit here is the new keyword. This keyword creates an object, but the creation of an object tightly couples one object to another. It's impossible to easily swap one object for another. Solving The Object Creation Tight Couple There are a few easy ways to solve this particular type of problem. The first is w

5 Ecommerce Metrics You Should Be Tracking

When it comes to ecommerce analytics, business owners and marketing managers typically focus on metrics like conversion rates, number of transactions, and average order value. These are valuable, and should be monitored. After all, measuring such outcomes is what directly impacts revenue and the bottom line. Thanks to Google Analytics as well as Mixpanel, Flurry, Site Catalyst, and other analytics platforms, these ecommerce metrics are readily available to site owners. While focusing on the outcomes is key, close attention to tracking user behavior and interaction with the site or mobile app will also yield significant incremental improvements. Here are five interactions you don’t see a lot of people measuring, when they really should be. Product Categories You can easily report on top products, what’s selling, and what’s not selling on your website. However, go beyond that and consider rolling up your reports to the product category level. Some categories can be driving more