Archive for March, 2009

Preface

This is an introductory post to the series, where I’ll cover all design patterns, their usage, diagrams. Besides patterns, I am going to guide you through the principles of the high-quality application design. We’ll start from these principles (GRASP), and then advance to patterns, see how they use these principles and develop several systems (architecture only). The whole series will take 10-15 posts. However, I don’t have exact plan yet :) So, let’s go!

So what we’re talking about?

Actually, design pattern is no more, than a proven solution to some common problem. When saying “problem” I mean things you face with when developing the application architecture. These solutions are intended to make you application better – more extensible, flexible, simple.

Common examples of design problems (Let’s agree that in this series “design” means application, not graphics or DB design) are:
Continue reading ‘Creator and Information Expert principles – GRASP (Design patterns series)’ »

I bet you didn’t know, that switch can be used to answer the question: “Which of the N following statements is true?” Continue reading ‘Trick with php switch()’ »

As you know, PHP can return only one value from the function. However, there is a simple workaround – we return an indexed array from function and immediately split it into variables using list():

  1.  
  2. function ret()
  3. {
  4. //something useful here
  5. return array($varA, $varB);
  6. }
  7. list($a, $b) = ret();//we’ll have $varA in $a and $varB in $b after this
  8.  

Yesterday I’ve read a post on The Developer’s Day blog. Then tested this thing in Yii. There is a jQuery in my application, so I created test controller and test action, that only outputted “Hello, world” and called it from the firebug console Continue reading ‘Speeding up Yii or why should you use DB sessions’ »

The problem

Nearly every large application has some configuration parameters – site admin email, cache time for different blocks, number of latest news, number of items per search or catalogue page etc.

Continue reading ‘Handling Application Parameters in Yii – Using the Database’ »

The problem…

In Yii you can have all your JS and CSS files together with your PHP. For example, you have some view in /views/user/create.php and you can have your css & js in /views/user/assets/css/ and /views/user/assets/js/. That’s quite convenient when you reuse your views/controllers/components from application to application. But these directories are not accessible from the web, so there is publishing mechanism there. Continue reading ‘Registering group of JS files in Yii’ »

When I was studying patterns, I went through main patterns in the alphabetical order. Adapter pattern was in the beginning and Template Method – in the end. And when I came to the latter and read about it, I was confused. Thee solve the same task, implement the same GRASP principle (Protected Variations) – they are the same, but why are they called differently?
Continue reading ‘Difference between Adapter and Template Method pattern’ »

The history

In December I’ve got a project, that required sophisticated and quite complex DB and that DB was subject to change greatly during first development phase. Before that project I was using Sparx Enterprise Architect both for application design and DB design. But, frankly speaking, it’s not good at databases, especially MySQL. So I decided to pick up a new DB modelling tool.
Continue reading ‘MySQL Workbench – The Database Modeling Tool for MySQL’ »