This is the Aggressione Web Development Studio Weblog, where we write about things you might want to read about ... and anything else that we happen to be interested in sharing. For more information on us and what we do,
visit our main site.
RSS feeds. / ADD to Google Reader

Archive for the ‘Web development’ Category

Object Data Modeling with PHP 5
by evgeni on May 11th, 2011

Hey there,

We all love arrays, and we all use them all the time, especially in PHP world filling up an empty associative array with data is one of the most mundane tasks.
I must say due to the convenience of it and the habit I was on the same train for quite some time.

There is nothing wrong with arrays, besides the fact that they can get slow, and I mean slow on big objects as well as get really slow when you are filling them up with data.

I am going to share an idea that is kinda ORM and ActiveRecord related, but in the same time I feel flexible enough to let me write SQL queries freely.

  /**
   * Basic Data Representation 
   * Represents the db table structure. 
  */
  class dataModel { 
 
       //set the properties that match the DB table you are representing
       protected $id; 
       protected $first_name; 
       protected $last_name;
 
       // implement setter and getters 
       // add logic if you want to
       public function __set( $key, $value ) {
             if ( ) { ... } 
       }
 }
 
/**
 * The actual model 
 * Extends the representation layer and makes operations
 *
**/
class myModel extends dataModel {
 
   public function __construct() {
 
   $sSQL = " ....my sql ... "; 
 
   while(  <db_fetched_data> ) {
 
           $this->id = $myresult->id;
   }
   ... more code ... 
}
 
$oModel = new myModel(); 
 
echo $oModel->id;

Ok , here is what this does – you have a basic class that represents your table via it’s properties, and an actual class that extends it and makes the SQL calls.
For the purposes of the example – it will load the values of course every time you instantiate it via it’s constructor, but of course it doesn’t have to be this way.
The loading and instancing can be implemented with singleton pattern in mind, or whatever else needs you might have.

On one hand we have the data we are working on represented in a object and on the other hand we are skipping the “extra” layer that the actual ORM libraries add. I am not claiming that this is better or worse than ORM, but rather a different take on it.

Cons:
– harder to maintain
– working with related tables things can get messy ( this is where ORM is better ) .
– when altering the table , one must alter the representation class as well

Pros:
– really , really fast – no key seek while filling up arrays, no nothing.
– smart data manipulation on “load” time – meaning logic can be implemented on setters and getters
– no extra layer of logic just to issue queries
– really flexible to be modeled per your needs – no ties with a framework
– setters can explicitly define what data can be loaded into the object

I have managed to shave off about 0.5MB memory usage when I implemented this into my projects, but I would love to hear from fellow developers if anybody is willing to give it a shot.

-Evgeni

The UI of tomorrow devices
by chris on July 28th, 2010

For so many years in web development I have been watching with interest where the UI design is heading to and how it is evolving. These days it looks that the hardware limitations have been overcome – the CPUs are getting faster and faster, the video cards are getting some crazy FPS even in heavy graphic applications, the memory and storage capacity has jumped hundreds of times compared to what we had 10yrs ago, monitors and device displays are getting bigger and with better resolution, and finally touch displays are becoming common….So now when hardware so powerful that you can only struggle when using some really complex software, for UI designers sky is the limit. (more…)

Transparent Object Storage in PHP 5
by evgeni on July 15th, 2010

Hey there !

If you are like me and do a lot of PHP OO sooner or later you are going to come to the need of something that transparently stores data between your objects. Something that is easy to use and access and is more or less transparent to your application.

So today I am going to show you with some code how to achieve that and what are the benefits of it. Of course like many more things there is always more than one way of doing it, but I will show you mine. Let’s get started with some code. (more…)

Out of the topic: I love Google and laughing with them is great…
by chris on May 25th, 2010

I love Google so far ( I really hope the are not goin to turn into a Big Bad monster somewhere in the future ) and i like to watch some of those funny videos that google labs and some random guys are making for their technologies.

Heres one[http://www.collegehumor.com/video:1922981] for Google Street View, that I confess, I dropped on the floor laughing when I first watched it ( Thank you guys from Collegehumor.com )

Have you ever thought about HTML5/CSS3 site soon ?
by chris on May 25th, 2010

I had one of those thoughts few weeks ago when I was checking whats around those HTML5/CSS3 web sites. I feel really tempted to go and make my next project based on those two technologies but…. Unfortunately its still a dream as I will have to fight with buncha angry calls from my clients that “a lot of our users can’t see this page” and by a lot they would probably meant all those lazy people that are still using IE6 (there are still 50% of IE total mass of users that use this 9 years ofd browser….WHAT???? ) or FF2 or even some other more exotic old-fashioned browsers from the last century.

But anyway, its good to think about all those nice web sites that are around the corner and that we will be designing in near future. While we are waiting on this to become reality and HTML5/CSS3 to become standard you can check some nice examples of what can be done here ( http://html5gallery.com/ )