Posted by

PHP Interfaces vs. Abstact classes

I’ve been reading a lot about OOP in PHP, and I’ve noticed that these concepts may be confusing since they seem to work the same way.

 

Interfaces

Interfaces allow you to define methods a class implementing the interface and how to handle them.
All the methods specified in an interface must be implemented in a class.

interface GeometricShape {
    public function getArea();
    public function draw();
    // ...
}

Features of an Interface:

  • A class can implement several interfaces.
  • Interface constant cannot be overridden.
  • Methods cannot contain code/logic.
  • Methods must be public.
  • Slower than abstract classes

Abstract Classes

Abstract classes look like interfaces but, this abstract classes can define methods, in other words, you can put a “default” logic to the abstract class methods.

 

abstract class GeometricShape {
    abstract protected function getArea() {
        // You can add some "default" code here
        return 0;
    }
}

Features of Abstract Classes

  • A class can only extend one abstract class.
  • Constrants can be overridden.
  • Methods can contain logic (i.e. default code which can be overridden).
  • Shared code can be in abstract classes.
  • Fast.

 

There are more features you can find in an interface or an abstract class, however I don’t recall them right now :P

 

 

Tagged , , , ,

Game Design

This post was inspired by a JDGamer, in his post titled “Design Before Development – An Important Lesson“, I read the post and it says: nothing but the truth!.

There is this, group of friends I have (including me) with a common goal: we want to make a videogame, but, we have tried to do this for a long, long time now, looks like whatever we plan, it always get stucked. I’ve been asking me “why we can’t make a videogame?”.

Well, it seems like we always say we want to make a videogame and immediately after we start to code / draw, so, we are meeting again, and I’ll ask a lot of questions, like:

  • What kind of videogame are we developing?
  • What is the fun factor of it?
  • How complex do we intend to do this game? Is it casual? is it hardcore?
  • What can I do for the project to succeed?

These questions, and probably many more will come to my head, but perhaps, this time, we can do something, with a well-thought base idea.

Tagged , , , ,

Unity3D + ex2D

Hey I’m back!, today, I’m testing this extension for Unity3D called ex2D which (as its website says) is a highly integrated 2D-sprite-related development extension for Unity. It aims at providing high performance 2D sprite/UI solution inside Unity, with a specific focus on creating tons of cutting-edge sprite animations and other content in complicated Unity scenes, while still maintaining great performance on mobile devices.

I really like this tool and it’s really worth the price ($25 USD). If you are using Unity and you want to make a 2D game, try ex2D you wont be dissapointed.

When you are in Unity, it looks something like this (depending on your projects art :P ):

I’m starting this project, it is a 2D side scroller, and the 2D/3D mixing looks really nice:

Official ex2D website: http://www.ex-dev.com/ex2d/

Tagged , , , , ,

Videos when I played with Unity3D

These are some videos I recorded when I was playing with Unity3D and followed a tutorial:

 

Continue reading

Tagged , , , , , ,

Hello world!

Welcome to my personal blog, where I’ll be posting, mostly, about software development, let’s see how it goes :)

Tagged ,