Skip to main content


Showing posts from 2009

Importance of learning Mathematics for Computing

Today, many IT under graduates don't see the importance of learning mathematics needed for computing. And also there may not any compulsory subjects for mathematics in some degree programs. Basically, learning some areas of Pure Mathematics is very important, if you want to become a real Software Engineer. Actually, when I was schooling, I also didn't know how important it is to learn these maths stuff for the job I am hoping to do in future. So those days, I had no any motivation. But after starting to follow an IT degree, there were some compulsory maths subjects for us, and then I had the motivations to learn them because there was some awareness in me about how these things are used in real life. According to my point of view, this is one of the biggest problems in Sri Lanka's school education system, specially in advanced level, no body knows what the reason for learning these subjects. But some times, there are reasons to be happy about not getting an effort to learn

Add slashes, strip slashes, and magic quotes...

Today, I was fixing some bug related to text processing in one of our projects. When saving a text that was typed in a text area, for some characters, additional slashes are added. Ex: TEST\TEST becomes TEST\\TEST This was because, the "magic quotes gpc" setting is turned on, and the slashes are not striped after retrieving the saved data. When you saving the data again and again, additional slashes are added due to this situation. Actually, these slashes should be added before you're entering data into a database. The "magic quotes gpc" does it automatically in PHP. You can turn this setting off, and do it manually using the "addslashes" function as well. After all, it is advisable to write your code so that it handles both of these situations. Something like given below can be used for this. if (!get_magic_quotes_gpc()) { $notification->setSubject(addslashes($subject)); $notification->setContent(addslashes($content)); } else { $no

Concatenating a string to a class constant in PHP

Today I wanted to concatenate a String value to a Class constant to get some task done. I wrote a line as follows. class DeadlineNotifications extends AppraisalObject { const ROOT_PATH = '/var/www/dev/nus'; const EMAIL_TEMPLATE_DIR = ROOT_PATH . '/lib/models/performance/emailTemplates/'; Expected value in second constant: ---------------- /var/www/dev/nus/lib/models/performance/emailTemplates/ Actual result: -------------- Parse error: syntax error, unexpected '.', expecting ',' or ';' In a way, some one can consider this thing as a bug of PHP. But this is not a bug. You can only initialize class constants with constant values. Here I have passed a statement which has to be evaluated at runtime. But the class constants are defined at compile time which comes earlier.

Test Driven Merging

Few weeks a go, I was doing some source code merging works. Some features developed in some branches of the repository were merged into some other branches. For the simple merging tasks, we directly use the "svn merge" command. But, in most of the times, we can't achieve what we need just using the "svn merge". That is, because the branches we do the merging between, have been grown largely, and independently. For these situations, we have to use a good merging tool such as "Meld". Actually, this is the best tool I have ever seen for this task. "Meld is a visual diff and merge tool. You can compare two or three files and edit them in place (diffs update dynamically). You can compare two or three folders and launch file comparisons. You can browse and view a working copy from popular version control systems such such as CVS, Subversion, Bazaar-ng and Mercurial." [ ] When you merge some thing did by other per

Patterns of Enterprise Application Architecture

These days, I am reading the book "Patterns of Enterprise Application Architecture - Martin Fowler". In the introduction of the book there are some definitions about the terms such as Patterns, Enterprise Applications, and Architecture etc. The features of Enterprise software, and how they differ from other types of software are described in detail. After the introduction, there are two main sections. The Narratives, and Patterns. The first section is a short tutorial on developing enterprise applications. The next section, is a detailed reference to the patterns themselves. At the moment, I finished reading the Introduction and willing to start reading the first section.

CakePHP and composite primary keys

Today, I was doing some comprehensive research about CakePHP framework, as a part of our web application framework research. I installed it and developed a sample application following the official documentation. Some interesting facts were found. And, here, I am listing down few of the advantages and disadvantages of this framework in relation to our existing systems. CakePHP has many good characteristics such as easy configuration, easy installation, light weight etc. And also, it's a excellent RAD tool, and it will save development time in a great margin. The database tasks can be done without writing one single sql query. And, CakePHP can be used with or without apache rewrite module, there is a clean url mechanism inside the framework instead of url rewriting. Naming convention is very important in CakePHP. Database tables should have the same name as the relevant model classes. For example, by naming the model "Orange", CakePHP can automatically infer that this

Ubuntu 8.10 - the Intrepid Ibex

Currently, the main OS platform I am using for developments and other tasks is Linux, Fedora in the office and Ubuntu in my note book. Windows is also used but very rarely. Although I can use Linux for everything I do, I prefer to use Windows for some tasks. Few weeks ago, I did install the Ubuntu 8.10 in my lap top. So, I thought it's worth writing something about the new features of this Ubuntu version. I have used so many Linux distributions so far, but any of those was not more user friendly than this new Ubuntu version. When compared with Ubuntu 6.x this version has great deal of improvements. Few of them, that I found very useful, are listed below. Support for connecting to the wireless networks is greatly improved. All the available Wireless networks are shown and you can connect to them using very user friendly GUI tools. The support for mobile broad band Internet devices and blue tooth devices are also greatly improved. You can mount NTFS file systems, read and

Methods overloading in PHP

Yesterday, one of my friend, coworker wanted to know about how to overload methods in PHP. So, I decided to write something about this in my blog, because there may be many programmers who faced this problem. Method overloading is common in many object-oriented languages but is not as use-ful in PHP because you tend to use flexible types and the (easy-to-implement) optional function parameters instead. Therefore the method overloading in PHP is implemented some what differently than other programing languages such as Java. In PHP there is a special class method for implemenging methods overloading. In PHP there are a number of class methods with special meanings whose names begin with a double underscore (__), such as __get(), __set(), __construct(), and __destruct(). Here, we use the method __call(), which is used in PHP to implement method overloading. To use it, you implement a __call() method, as given below: public function __call($method, $param){ if ($method == ‘display’) {

Some change of my career...

I did resign from my current job yesterday. That decision was taken by me about two moths a go. My new working place is Orange Software Inc, the company that develops OrangeHRM. OrangeHRM became the project of the moth in sourceforge last December. The description given below was extracted from OrangeHRM is a Human Resource Management (HRM) system that facilitates personnel information management, employee self service, leave, time & attendance, benefits, and recruitment of a company. It's is the most active open source human resource management software. With over 175,000 downloads, OrangeHRM is also fast becoming one of the most widely used HRM applications in the world. We believe in providing users simple to use robust software, and iteratively improving it based on feedback we get from them. This rapid evolving of the product is driven by agile development practices, and weekly product releases to SourceForge.