Posts

  • Coffeescript Model class with attr_accessor rails alike

    Nowadays I’ve been toying around with the fabolous coffeescript language and I’ve created a basic model class.
    This class allow you to use attr_accessor method as you can do in Ruby. If you don’t know what attr_accessor is you can take a look here: Ruby attr_accessor.
    Briefly what attr_accessor does is to let you access object attributes in ā€œobject.attributeā€ form (which in javascript is built in) but more importantly let you add a constrain on read/write permission of that attribute! In fact if you want the attribute to be readonly you need to use the ā€œattr_readerā€ method, in the opposite case you need to use the ā€œattr_writerā€ method. If you don’t want to add any constraint you can use the ā€œattr_accessorā€.

  • Strong Typing vs Duck Typing PHP, C#, Ruby

    If you have heard of strong and weak typing but doesn’t know the main difference and advantages/disadvantages of both the paradigms in this article I’ll try to help you having a better undestanding of the overall concept. The first thing you need to understand is what types are. When you save some data in the memory you can associate to that space of memory a data-type, by associating a type you can have different behavior when manipulating that piece of data. In an object orientet language generally there are two main categories of data:

  • 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:

subscribe via RSS