Posts

  • The best shell for progamming: oh my zsh

    Hello guys, it’s been years that i’m using bash as my preferred shell. Recently i’ve found a cool tool that you should try, it’s called: oh my zsh. What’s that? It’s zsh: basically bash with some more features and also have cool plugins made by develpers that you can enable to have easier time progamming in your preferred language. There are more then 150 plugins and you should definatelly take a look at that! the install is also really easy, for example here’s the command to run on MacOSX ‘curl -L http://install.ohmyz.sh | sh’ and you’re done!

  • Test double php introduction

    When you start unit testing your code you don’t want to test a full behavior of your code but just a little part in isolation to the rest. In order do do that you need to isolate your class from the other context, test doubles are tools (aka patterns) that allow you to do that. There are five common test double:

  • PHP: why and when static is evil

    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. Before explaining you when and when not to use static you need to know the difference between static and istance variables. The difference is that with a static variable his value will remain the same for the full execution of the process, anytime you access it. With an instance variable instead that values is binded to the instance of the class (the object!) and can be different for every new istance of the class. Let’s make and example:

  • Laravel Testing Redirect::back()

    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. But keep in mind that in general the best approach is to don’t use many Redirect::back() and instead use the redirect to a certain route, in fact is much more clearer from the test perspective to assert a redirect to a given route instead of a fake one. Anyways here’s the solution:

  • PHP Value Object

    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:

subscribe via RSS