General Array Sorting in PHP

December 23rd, 2005
Posted in PHP | No Comments

PHP offers several array sorting functions. These array sorting functions sort array values only ( “sort” ), rearrange array values by sorting the array key ( “ksort” ), or rearranging array keys by sorting the array values ( “asort” ). Reverse sort functions rsort, krsort, and arsort are also available. In addition to these simple sort functions, PHP provides corresponding versions of these sorting functions that use user-defined comparators. This is useful when an array is populated with user-defined types. An example of using uasort, a version of asort that uses a user-defined comparator, is given below.

<?php

  function nameComparator( $a, $b )
  {
    $field = "Name";

    if( $a[$field] == $b[$field] )
      return 0;
    else
      return $a[$field] > $b[$field] ? 1 : -1;
  }

  function classComparator( $a, $b )
  {
    $field = "Class";

    if( $a[$field] == $b[$field] )
      return 0;
    else
      return $a[$field] > $b[$field] ? 1 : -1;
  }

  $a[] = array( "Name" => "Steve", "Class" => "A" );
  $a[] = array( "Name" => "Jennifer", "Class" => "B" );

  uasort( $a, "nameComparator" );
  print_r( $a );

  uasort( $a, "classComparator" );
  print_r( $a );

?>

The sort functions that use user-defined comparators are more flexible than the simple sort functions. The sorts that use user-defined comparators may be stable, where the original ordering is preserved in cases of ties. This behavior can be altered by handling ties explicitly in the comparator. The PHP array sorting functions that use user-defined comparators are great examples of function callbacks and the Strategy pattern.

New Year’s Resolutions: Organize, Rethink, Focus, and Succeed

December 22nd, 2005
Posted in - blah - | No Comments

Time off has allowed me to re-establish my objectives. It gave me time to prepare for the upcoming year.

Neglect caused severe disorganization in my personal workspace. Disorganization at and around my desk is distracting enough to encourage me to find an alternate place for work. I am finding places like local coffee shops, which tend to host a lot of people, less distracting. Managing a development effort requires a lot of organization. Each developer’s workspace is a good place to start organizing a team. By dealing with organization at a lower level, I gain a better position in managing the organization of a team overall. Organizing my workspace now will set me on track for fulfilling one New Year’s resolution: maintain organization.

Aside from organization, the lessons that I received in 2005 have brought up problems that need resolution. I have found a fault within myself, which has hampered many development efforts. My problem is perfectionism. As a young inexperienced programmer, I strove for designing and implementing ideal software systems. Reaching for general solutions that are highly extensible and reusable increased the complexity of many software systems’ designs. Severe fixation on achieving an ideal implementation caused projects to be intractable.

I need to rethink my approach to software system design. There are several constraints that must be observed when developing software. Software quality must be maximized under the constraints set by time, requirements, and available talent. I will continually rethink my development processes instead of blindly moving along never-ending quests toward perfect systems. Recognizing the marginal utility gained with additional time used in a particular cycle will help me rethink the process. Minimizing my idealism will allow me to rethink and reconsider solutions that are less than optimal.

I have many interests that span the computing field. They include interactive computer graphics, artificial intelligence, network protocols, and system administration. Maintaining focus on the procurement of medium and large-scale Web 2.0 Applications is one resolution that I have set for myself. Every piece of knowledge that I choose to acquire shall be useful in the development of Internet applications. All experimentation with products and technologies shall aid in forming better decisions on the implementation of applications for the Internet. Because it is very important in becoming the best in a particular field, I shall remain resolute on maintaining focus.

Next year is special, because it is the first year for which I have made resolutions. It is also special, because it is the year that I set a resolution for myself to achieve success. Success for me includes success for others. I will receive success only after my team is successful in delivering success to our clients. I depend on the success of my team, and my team depends on me to succeed. This high degree of interdependence makes success important. Accomplishing success is my primary New Year’s resolution with all others that I have made to support it.

From Infosearch Media, Steve Doria Signing Off

December 15th, 2005

I joined TrafficLogic, Inc., now known as Infosearch Media, over a year ago. They gave me a software development opportunity, which I desired, when other companies were more interested in the software quality assurance abilities that I listed in my curriculum vitae. When I took up my appointment at TrafficLogic, I knew nothing about the technologies they used. I could only give the people who interviewed with me a promise to quickly learn and adapt to their business needs. TrafficLogic made a risk by accepting me, and I hope that I have provided adequate returns for those risks.

TrafficLogic has influenced my career path significantly. Before joining the company, I was very interested in becoming a team member in a standard software development environment that uses traditional programming languages like C++ or Java. I never considered Web applications development in the past, but TrafficLogic exposed the exciting opportunities that the Internet provides. Fulfilling the business needs of the company and its clients also motivated me to develop myself as a computing professional in several areas of expertise.

Aside from providing an environment where I was able to develop and exercise my skills, TrafficLogic futher developed me as a person. The people of TrafficLogic were the most significant of the company’s factors that affected my personal development throughout my stay. There was friction at times, and I now realize that I created a lot of it, but we worked together and had fun.

Without Sunil Bhanot‘s ability to “remember me” after my dismal interview, I would not have had the opportunity to meet some very awesome people. David Gagne‘s progressive management style is consistent with one that Google’s CEO prescribes. He successfully assembled an adept team, which acted in the company’s interest without requiring intrusive oversight. I view Kelly “the Kloser” Bakst as the great facilitator. He has performed at least two responsibilities very well. Firstly, he coordinates collaboration within the team. Secondly, Kelly exerts his best efforts in minimizing detriments to the team’s progress. As a corallary to the second, he has done his best in providing the means to produce results and addressing the personal needs of each team member so that their focus is more on developing solutions that will bring the company to the next level and less on dealing with their personal problems. Josh Axelman helped me remember about me, especially during times when I worried about other people and lost focus on what I was doing. I did trip out on him once, but he’s a bigger man and I am really sorry. Andrew Pineda has really stepped it up these last few months. He’s been dutiful since he started at Infosearch Media, and his consistency helped us recover from some grave mistakes. On many occassions, Andrew has also been successful in preventing me from being a hazard to myself. That was good looking out.

The members of the technical team resemble siblings such that, although things got intense, bad feelings did not remain permanent. A lean team requires its members to depend on each other. It allows team members to take on varying responsibilities. It also provides opportunities for team members to receive recognition, which increases their productivity and generates cause for future recognition. With this positive feedback loop in effect, the team has gotten things done, and they continue to do just that. Each member of the team has earned my respect, and I’ll continue to cover their six.

There are also many others whose presences I got to enjoy. I miss all who have left the company before me, and with the direction I’m taking in life, I will be missing many more. HW represented the company well. His presentation of the company was comprehensive and filled with optimism. HW has pitched and closed deals with the company’s service vendors, even though it was beyond his role in the company. He inspired selfless action that benefited the company without needing the company’s praise or recognition. I explored solutions with SP. Our deployments would sometimes fail, but we overcame the problems we faced. The experiences between failure and success were amazing in itself. EY got me to get up after falling, and I had a good time. RG gave me a beer on St. Patty’s Day and a couple of very fun moments. LM insists that I just go out there and dance. I’ll get around to doing so. SR gave me some pretty good financial advice. I’ll be able to take advantage of compounding interest and dollar cost averaging someday. TE encouraged people to go full force, but also reminded them to know when to take it at a medium pace. AP pushed people to operate at 100%. BC was with me as the last two people remaining after the party was over, twice. KW let me crash at her place once, and JD hosted gatherings at his place a couple of times. TT got people on the phones, and HS provided some very exciting months. JP and LMW took care of my CPA verifications and cushioned clients before forwarding them to me. LMW also provided me with a favorite drink, which is sweet and razzy. SP and DB provided music, and “I’m searching my soul tonight.” Err… wrong company.

To the people who made TrafficLogic:
Thanks for some great memories.
“So, do you guys have any questions?” Hua asked of the interviewees.

“How do I get from intern to CEO?” Steve asked in return.

Hua replied, “You need to get hired first,” in a tone that suggests the answer’s obviousness.

An exchange between me and Hua at the beginning of my employment solidified my personal objective. Voicing my ambition made my goals more apparent to me. I must not settle on the safety of a secure job. Life is a game with two fundamental choices: play it safe or play it smart. An opportunity with some risks has presented itself. It is an opportunity for higher levels of success, and I cannot resist its attraction. Working at TrafficLogic has prepared me well. Now is the time for me to continue adventuring through life. I’m Steve Doria. Good night, everyone.

 

Keeping New Computers Spyware-Free

December 13th, 2005

Suzi Turner provides the Top 10 Tips to Keep that New Computer Spyware-free. This list focuses on computers that run Microsoft Windows. The list could have been reduced to suggesting that people keep their software updated, prefer Internet applications that are more secure, and enhance operating system security by modifying its default settings. It would have been great if Microsoft Windows was “Secure by Default“. A valuable suggestion from this article encourages people to practice safe hex and avoid contracting unwanted viruses.

Hello, Ruby!

December 12th, 2005

rubyonrails.comAfter months of resistance, I decided to join the Ruby on Rails bandwagon and read up on Ruby at a brick and mortar bookstore. I was unable to find Programming Ruby, but I found Agile Web Development with Rails and was able to read Appendix A, which was an introduction to the Ruby programming language. Ruby is presented as a terse object-oriented programming language. People experienced in other popular object-oriented programming languages will be familiar with Ruby’s OOP features. Before jumping into Rails, it seems wise to develop some background with Ruby. So, I decided against purchasing Agile Web Development for now, and I settled for the first edition of Programming Ruby, which is available online.