Archive for the ‘Programming’ Category
When designing some architecture, you face with the problem “which object should perform X task?” We discussed this question in my previous post in this series. There we noted, that object should perform the tasks he has enough info for. He should be an “expert”. But because one of the main OOP characteristics is interaction between objects, it’s often hard to answer this question.
Continue reading ‘Low Coupling and High Cohesion - GRASP (Design patterns series)’ »
Posted by Konstantin Mirin on October 6, 2009 at 8:00 AM under Design patterns, OOP, Programming.
Tags: design pattern, grasp, PHP, polymorphism, tutorial, UML
2 Comments.
Websites, that aggregate something become more and more popular because we need all information available in one place and accessed fast and easily. From time to time, you come across with tasks, that require retrieving some data from the password-protected area. For example, I use Guru.com for my job search. They post lots of the projects there, but they don’t offer convenient listing and filtering. So I developed my own tool, that grabs everything from there and ranks it all in the way I need. So, we’ll take a look at different types of password-protected areas and see how to deal with any of them
Continue reading ‘Grabbing password-protected content with cURL’ »
Posted by Konstantin Mirin on May 24, 2009 at 9:00 AM under PHP, Programming.
Tags: experiece, PHP, tip, trick, tutorial
10 Comments.
Personal productivity depends on the tools greatly, so I pay much attention to the programs I use. My previous post in this field was about MySQL workbench which I consider the best free DB design tool for MySQL.
When I started coding PHP, I used Linux so I used Kate, which only had syntax highlighting and allowed to save multiple files opened as a project
Next was Quanta, the Linux IDE for PHP. I spent lots of time developing there until I installed trial version of Zend Development Environment (ZDE) 5.5. That was really cool. I liked it very much and used for quite long time. Around half a year ago I heard about NetBeans and decided to try it out. I was thinking quite long about it, I didn’t have enough time to install and go through all it’s functions. Finally I saw that I will never have this time, so I started using it around 1.5 months ago. While using, I was putting down some notes about the things I liked and the ones I didn’t. So now I just want to present my list
Continue reading ‘NetBeans 6.5 for PHP - My Experience’ »
Posted by Konstantin Mirin on May 22, 2009 at 9:00 AM under PHP, Programming.
Tags: choice, experiece, feedback
13 Comments.
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)’ »
Posted by Konstantin Mirin on March 28, 2009 at 3:37 PM under Design patterns, Programming.
Tags: design pattern, efficiency, grasp, OOP, polymorphism, tutorial, UML
11 Comments.
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():
-
-
function ret()
-
{
-
//something useful here
-
return array($varA,
$varB);
-
}
-
list($a,
$b) = ret
();
//we’ll have $varA in $a and $varB in $b after this
-
Posted by Konstantin Mirin on March 6, 2009 at 9:38 AM under PHP, Programming.
Tags: Add new tag, PHP, tip, trick
Comment on this post.
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’ »
Posted by Konstantin Mirin on March 3, 2009 at 9:19 AM under Design patterns.
Tags: adapter, design pattern, OOP, template method, UML
Comment on this post.
OOP stands for Object-Oriented Programming. What does it mean? And what’s the difference between OOP and procedural programming? We’ll go through all these terms, We’ll demonstrate the difference of these approaches and advantages of the OOP over procedural concept. Examples are for PHP, but concept is the same in all object-oriented languages.
So, let’s start with defining, what OOP is and how it differs from procedural programming. Just take a look around. For example, you see a table. Consider you have to program it. When using procedural approach, you focus on it’s behaviour (for example, you write function, that calculates height or that assembles it from the given dimensions). However, table has properties besides behaviour. When following procedural paradigm, we create variables for each property - height, width, length, square, weight. All that data - properties (variables) and behaviour (functions) describe the object from the real world - table. What’s wrong with this approach? Nothing wrong, everything is fine, when we’re dealing with one table.
Continue reading ‘What is OOP (Object-oriented programming)?’ »
Posted by Konstantin Mirin on February 28, 2009 at 4:27 PM under OOP, PHP, Programming.
Tags: basics, concept, encapsulation, inheritance, OOP, polymorphism, tutorial, UML
30 Comments.
Recently I’ve learned one nice trick with for loop. When you use it, you should know he number of itereations. Most people do it like this:
-
-
-
$s =
sizeof($a);
//you may use count(), but sizeof if 5% faster
-
for ($i = 0; $i < $s; $i++)
-
{
-
//do something clever here
-
-
‘;
-
}
-
But this requires counting number of elements before using a loop. Continue reading ‘Nice trick with FOR loop’ »
Posted by Konstantin Mirin on February 20, 2009 at 9:28 AM under JavaScript, PHP, Programming.
Tags: FOR loop, programming technique, tip, trick
9 Comments.
Once I had a task to import a number of data from datafeeds (that are in CSV or XML) into MySQL database. See solution in my another post. Here I want to tell about handling large files.
Datafeeds there are 50-200M each, so reading all file at once was not possible due to memory limitations. So we need to split it into portions. Here is the class, that solves the problem of downloading remote file, saving it locally and then reading by portions. Continue reading ‘Working with large files eficiently’ »
Posted by Konstantin Mirin on June 16, 2008 at 6:59 PM under PHP, Programming.
Tags: efficiency, file, PHP
Comment on this post.