jacopo beschi: yet another web guy

Posts Archive

PHP: why and when static is evil

Created at: Nov/09/2014 jacopo beschi

Hello guys, many pepole asked me in various situation if they should use static in their code, for this reason i decided to briefly explain why static is generally a bad choiceh and in which cases you can use it.

Read on

Laravel Testing Redirect::back()

Created at: Oct/22/2014 jacopo beschi

Hello guys, sometimes in your functional test you need to test a redirect, this is pretty easy to test except for the Laravel Redirect::back() method. I've found out that this is hard to test and the only solution to solve the problem is to fake a HTTP_REFERRER value.

Read on

PHP Value Object

Created at: Oct/13/2014 jacopo beschi

Let's talk about, Value objects. The first thing to undersdand is why and when they are needed. Generally when you save some data you pair with a variable/attribute a value. In every programming language there are many type of values, for example strings,numbers and so on; imagine now that you need to save the number of apples and user have bought:

<?php 
$total_apples = 20;
Read on

PHP and lazy loading

Created at: Sep/29/2014 jacopo beschi

Any if you ever heard of lazy loading? Lazy loading is a tecnique used for data caching in software engineering. The concept of lazy loading is really simple: if you already have loaded a resource one time, then you will not load a new one but instead just return the one you have already loaded.

Read on

Testing in Laravel framework: step2 TDD calculator

Created at: Aug/21/2014 jacopo beschi

Hello again, in the previous article i've explained how to run your first test. Now we go a little more in detail and we tackle a real example.What we are going to do is write the calculator in TDD (test first). We incrementally build the calculator step after step. The step will be the following:

  1. Create a simple String calculator with a method int Add(string numbers)
  2. The method can take 0, 1 or 2 numbers, and will return their sum (for an empty string it will return 0) for example “” or “1” or “1,2”
  3. Allow the Add method to handle an unknown amount of numbers
Read on