/usr/portage

Software representing structure 3

The current discussion about whether or not to use Smarty nowadays misses the point as it may simply depend on the environment. In a small development team, up to five people or so, you could just use the template-alike PHP syntax as all parts of the application are written by the same people with more or less equally shared responsibilities. This is what I would call a “single hands” process. Everything is done by everyone (that’s a bit oversimplified as in such environments intuitive structures emerging but let’s take it for now). This kind oft environment can often be found in startups and the like. This is were the process is really hands-on, the development process is often relatively agile as everyone is the others neighbour and there is often no explicit design stage. This is were you just ask your mate “hey, what’s the name of this template variable”. Such an environment has a lot of advantages but for sure a lot of disadvantages, often in terms of quality.

In other environments where responsibilities are much finer grained and balanced, a template engine might become a structural element of the development process as it represents a responsibility split between collegues. A template language is in fact an API for the user interaction/frontend developer. An API is a small subset of the factual possibilities, and this is where a template language might represents organisation prinicples. We as software developers define our API to encapsulate richer functionality and provide access to a well-thought (yeah, hopefully) subset of modification paths we want to allow on purpose. Just because the other guy does not need to know about the ugly internals. A good template language is a small subset of the language environment and exposes only functions which are really needed for view generation.

Beneath that, a template engine can structure the adoption of a pattern. Think about the MVC pattern, which is nowadays halfway common in web development environments. A template language in an MVC-alike environment enforces the usage of the view as “just a view”. While you would need to establish rules and procedures which subset of PHP is allowed correct for templating, a template engine establishs this rules and procedures implicitly. The other side of “do not try to solve social problems technically” is “do not try to solve technical problems socially”.

Filed on 14-01-2008, 13:01 under , , , , , & three comments & no trackbacks

Relational data 0

I concede that the relational model is the worst form of DBMS except for all those other forms that have been tried from time to time.
Bill Karvin – In Support of the Relational Model

I can’t agree more with that statement. Also I find software like CouchDb really interesting, it will not be the way to go. Beneath modeling, the main advantage of relational models is the flexible question startpoint (in terms of SQL it means the basic information you have beforehand to get the rest of what you need). If you know just a little about tree structure, the start point problem will be self-explaining. Accessing an upper node from a sub node just can’t be implemented as fast as accessing a flat structure and there relations.

Filed on 30-11-2007, 07:07 under , , & no comments & no trackbacks

The worker design pattern 1

I want to provide you a pattern I which I thought about a lot in the last days. Comments are appreciated.

Problem



  1. You have a small object which is data and large set of operations which could be performed to that object

  2. You want to keep the object’s method list small

  3. The operations can be done in different ways, including different implementations

  4. Your small object only knows how to read and save itself from the data abstraction layer

  5. You want to batch process a number of small objects

Solution

  1. You have a worker interface which defines the accessor API for the worker and how to add subjects
  2. You can have multiple workers per subject
  3. Your worker does the transformation, your subject is transformed
  4. Your subject is kept light weight

Example


Your ImageBinary object represents the image binary including height and width (metadata is decoupled). You perform various operations on this object like resizing, cropping, scaling.
$image1 = new ImageBinary(array(‘id’ => 1));
$image2 = new ImageBinary(array(‘id’ => 2));
$image3 = new ImageBinary(array(‘id’ => 3));

$worker = new ImageWorker;
$worker->add($image1);
$worker->add($image2);
$worker->add($image3);
$worker->rotate(90);

Related patterns


Manager, Adapter

Filed on 06-06-2007, 01:01 under , , & one comment & no trackbacks

Die Welt ist schlecht 1

... und erst ihr Code:

    /* WAS IST DAS ???
    //ich weiss es auchnicht aber es ist schon lange auskommentiert glaube ich
    $db->Execute("UPDATE weblogs SET title='$_POST[blog_title]', info='$_POST[blog_desc]',name='$_POST[blog_name]',template='$_POST[blog_template]' WHERE id = ".$_SESSION['weblog']['id']);
    $db->Execute("UPDATE weblogs SET aktiv='$_POST[blog_aktiv]' WHERE id = ".$_SESSION['weblog']['id']);
    */

Filed on 22-08-2006, 16:04 under , , , & one comment & no trackbacks