Object Oriented Programming In PHP

 Object Oriented Programming, as the name implies, is about programming with objects.

 But what exactly is an object?

 An object is an entity that encapsulates properties and behaviour that is specific to that entity.

 This might sound a little strange, but it really is not. Objects are all around you. The magazine you are holding is an object. Some objects can consist of even more objects. The articles in magazine are objects. The window in your room is an object. Your room is an object. Everything you can see is an object. But there is a lot more to OOP as a concept.

 Object = variable + functions

 Using this OOP, programmers manipulate objects, which are made of functions and variables, instead of manipulating the functions and variables themselves. Let’s say that you develop an e-commerce web-site. You could use an object to manage a shopping cart, and assign the object different properties and methods, based on what you want it to do. Properties stand for variables holding the information about the object (for example: the name, items in the cart, total value of the items, etc.), and methods stand for the functions that can be used with the object (for example: add an item into the cart, remove an item, empty cart, etc.)

 Class = blueprint for one or more objects

 It sounds simple, doesn’t it? Well, it really is. But for an object to be defined, you have to have a template on which you will define the object. This is where classes come in. A class is a blueprint for one or more objects. Therefore, an object is to a class what a variable is to a type. A class is a set of characteristics, and an object is entity that is defined based on those characteristics. Another example: let’s think about an automobile class. Such a class could have a characteristic (property) called “color”. All objects created based on this class would have such a characteristic, but some objects would initialize this property to “red”, others to “blue”, and so on. This means that the class only holds a definition, and the object holds the actual value.

You can declare a class by using the “class” keyword. Let’s define a simple class:

class automobile_class

{

var $color; //the color of the car

var $max_speed; //the maximum speed

var $price; //the price of the car, in dollars

function is_cheap()

{

return ($this->price < 5000); //returns TRUE if the price is smaller than 5000 dollars

}

}

 In this small example you can notice some of the most important aspects of a class. After the declaration of the class, you can see the variables used within the class, which are called properties. These are declared using the “var” statement. While they can be defined anywhere within the class, you should really define them at the very top, so you can better see the class’ properties. The functions within the class are called methods; they’re used to manipulate the class’ properties and produce results. In that simple method you can see that when we use a class method or property, we must use the “->” operator. The keyword “this” tells PHP that the property of method belongs to the class being defined that means variable belongs to the whole class and not the function itself. $this->contents is a variable which was defined as part of the overall class.

 An object is a special variable that contains a bundle of other variables and functions; you always have to use a class upon which to create an object. You only have to create the class once, then you can create a millions of objects, in a millions of other projects.

 While a class only exists in code and is considered to be a blueprint, an object exists in memory and is a working instance of a class. An instance of an object is created using the “new” statement along with the name of the class the object is based on. Let’s return to our automobile class:

$car_object = new automobile_class();

$car_object->color = “red”;

$car_object->price = 6000;

if($car_object->is_cheap())

{

print “This car is cheap!”;

}

else

{

print “This car is expensive!”;

}

You can see that we use the “->” operator to access and modify object’s properties. After that, we use the same operator to call a method.

Perhaps the greatest benefit of object-oriented code is its reusability. Because the classes used to create objects are self-enclosed, they can be easily pulled from one project and inserted into another. Additionally, it is possible to create child classes that inherit and/or override the characteristics of their parents. This technique allows you to create more complex and specialized objects. Even if you start with a small class, you can develop it to a complex class by time, with adding more properties and objects to its children classes.

Advantages of OO approach:

 Reusability: Objects can stand on their own. They are abstracted; they represent one thing. This means that they can be combined in many ways, which makes for (and encourages) reusability. Reusing objects rather than having to reinvent the wheel over and over again can save a lot of time.

 Extendibility: Instead of writing a completely new object every time you need one (which often takes quite some time), you can often extend one. It is in the nature of objects that they are extendable. One can derive an object from another object, and thus extend its functionality without having to rewrite the whole object and add the required functionality.

 Maintainability: Because of the very natural way, objects (and their hierarchies) can be designed, they are easy to read, which makes it easier to analyse, and thus extend already existing applications. Because of the “pluggable” nature of objects, less code modification is needed to integrate new features into an application.

 Final Words:

Object Oriented Programming is a powerful and often elegant approach to analyze, design, and implement a solution to a problem, but not something you master in days, weeks, or even years. It is certainly not the golden key to solve every problem, that would be too good to be true. It is not realistic to apply OOP theory to that tiny script that makes sure the form is being emailed. It might help you when designing average to large scale applications though.

Adding credit card payment options to your website in India

Many years ago we did not have many options for adding credit card payment gateway to our ecommerce sites and we had to rely on COD, Cheque/DD to accept payments. All that changed with the game changing CCAvenues. They made adding a payment gateway easy and smooth to add to any ecommerce of subscription site. They also opened the doors for many more providers to jump into the market. From almost no choice we went to a buffet of choices in just a couple of years.

Lets take a look at some of the Payment Gateway Providers for India based websites:

CCAVENUES (www.ccavenue.com)

They are the grand daddy of credit card gateway providers in India. With one of the largest subscriber base they are the front runners in India.

  • Easy to install. You can be up and running in a few hours.
  • Lenghty paperwork before  approval though and risk management is stringent.
  • Huge choice in payment options – credit card, debit card (select banks), bank transfer, EZcash etc.
  • Site is sometimes slow and we have experienced service drops many times. Although lately they have upgraded their servers.
  • The are secured with Verisign
  • They have 3 schemes for Indian Rupee payments, 3% at Rs.40,000/-, 5% at Rs.25,000/- and 7% at Rs.7,500/- .
  • They are always adding new payment options and are now offering mobile payment as well.
  • Money is credited to your account at the end of every week either directly into your account or via cheque.
  • They did have some trouble processing Mastercard payments, so check on that before signing up.
  • Biggest advantage is that it supports American Express which is very important for the US market.

ICICI Bank Payment Gateway (www.payseal.com)

Another one of the older payment gateways. Its fast and its reliable.

  • Supports only Visa and Mastercard.
  • Will require extensive support for integration from your hosting provider. Some providers charge yearly for this so check on that too.
  • Very high upfront payment and deposit (over 1 lakh) required.
  • Vigorous documentation and risk analysis process.
  • Payment credited the next day so quicker turnaround.

Times Of Money DirecPay (www.direcpay.com)

A recent entrant into the field. Very similiar to CCAvenue.

  • Supports only Visa & Mastercard and a few bank transfers.
  • Easy to install and get going.
  • Standard documentation and risk analysis process
  • Money is credited on a weekly basis.
  • Subscription plans are very simliar to CCAvenues.

Paypal (www.paypal.com)

Recently paypal started remitting money to India via credit card, bank transfer or cheque. This has opened up a huge opportunity for Indian Merchants catering to the west. Its fast and relatively hassle free.

  • Simplest possible registration process.
  • Integration also very simple.
  • Payments accepted in dollars or euros. Rupees not accepted.
  • Payments are credited to your account which can then be withdrawn whenever convenient.
  • Lower percentage fees but withdrawals in some cases do attract fees.
  • You could loose money in the exchange rate transfer to Rupees.
  • Is widely used so the money accrued in dollars can be used for purchasing other services in dollars without remitting to India.

HDFC Bank – Avoid, service is terrible. Integration can take months. Does not support Linux  server based sites well.  Problematic.

The above are the ones I have had direct experience with but there are others like Axis Bank, ABC Payment etc. Cannot comment on these as I have not had direct experience with them.

Caution: Since the gateways are always upgrading some of the above mentioned facts might not stand true forever. Do visit their sites and get the latest directly from them.

If you have any comments on the above do mail me at ron@miracleworx.com. Would love to hear your experiences with these gateways.

Will keep posting interesting gateway related issues as we experience them.

Cheers,
Ron

Do visit us at http://www.miracleworx.com or check out our portfolio at http://www.miracleworx.com/portfolio.htm

A round of thanks for a great year

I would like to wrap what most probably be the last post of 2009 (We’re going on a small break) with a round of thanks.

A big Thank You to my brilliant team – Sonali, Sachin, Smit, Leena & Aakanksha for thier fantastic efforts and hard work. You can never know how much I appreciate you guys.

Thank you to our amazing clients who are always pushing us to deliver better and better results. Their blessings and support  makes us who we are. We are indeed privileged to serve you.

Thank you to Indialinks, our web hosting partner for thier rock solid support and superb service. Bhavin, you have built a cool organization. Our association continues now for the 9th year.

Thank you to my family and friends among whom we have a few fresh entries (welcome Dvij). Thank you Sopan & Priya Prabhu for your help in upgrading our office and off course the fantastic timepass we do with you guys. Thanks Dad for your inspiration and postive attitude.

A very special thanks to Dr.Malpani for his guidance and wisdom. He’s a true inspiration.

Thank you to  our chai wallah, the courier boys, our  bai and the countless others who have an unseen hand in our success. Good bless you all.

Thank you to the wonderful people at In Defence Of Animals for thier brilliant work in animal welfare, Sudnya, Fizzah, Naina, Goodisha, Vivienne, Vishruti, Anand and other including the excellent center and ambulance staff. Do visit http://www.idaindia.org and donate.

If I have missed anyone please don’t mind..you’re also important to us.

Wow, I feel like I just won an Oscar or something.

Anyways see you all in 2010.

Cheers,
Ron

Saying Goodbye to 2009, Hello to 2010

“May you live in interesting times” goes a Chinese curse/blessing. The year 2009 was certainly interesting in many ways.

Personally I will always remember 2009 as the year we took on holistic web design concept and really applied it. This change has made all the difference to our clients and to our revenues as well. Now we never look at an engagement just through the narrow view of the current deliverables but on what we can deliver over the long term across length and breath of online services.

Looking back at this year there were some memorable projects.

www.Turtleandhare.co.in – Where we animated an entire website using hand drawn illustrations.

www.yeva.in – A unique concept for a pharma website

www.uva24×7.com – A quiz portal for the young and not so young.

www.drmalpani.com – The brilliant InFertility Expert’s award winning site. This was our 3rd avatar of the site.

and many more which although not mentioned above are close to my heart. Check them out on our web design Portfolio.

What’s to look forward to in the year 2010?

For MiracleworX 2010 is looking like the busiest year ever!! With a large Q of projects lined up along with several in house initiatives in SEO, Social Marketing and website on mobile arenas.

Here’s to a kickass 2010!!!

The Art Of Newsletter Management

Let me begin by making a simple statement.

“The success of your newsletter effort will depend heavily upon the ability of your organization to send relevent information from all parts of the organization to a central responsible person”.

Most newsletter efforts fail because it is relegated to the dark dingy closet of the marketing department where some poor intern is given responsbility for it without a clue on what to put in it. Am I being too skeptical? How many truly interesting newsletters do you receive from a non- marketing, non-media company in your industry?  

There are a lot of issues with the newsletters I get but the biggest one is that THEY ARE IRRELEVANT OR BORING.

A newsletter is a great opportunity to share your company culture , sense of humour and passion for your industry. In contrast most newsletters look like they have been churned out by the company’s humourless accountant or some scientist with thick glasses sitting in a labrinth mumbling to himself.

Would’nt you love to get a newsletter that is…

  • Interesting and witty but also very relevant
  • Is a breeze to read and does not require you to crunch through data ad nauseum.
  • Tells you something about the sending company just by the tone and content.
  • GIVES YOU SOMETHING YOU CAN USE.

Lets face it, everyone asks what’s  in it for me? Unless the receiver doesn’t get some value out of it what’s the point?

TIPS FOR GENERATING A SUCCESSFUL COMPANY NEWSLETTER

  • The Newsletter Hero: Glorify the Newsletter Editor or Compiler in your organization. Ask him to stand up on a stool at the company meetings and let everyone take a look at him/her. Instruct everyone to send whatever information they find interesting to this person so that it can be filtered, edited and broadcast to your newsletter subscribers.
  • Great Content: The newsletter content should be an easy read, avoid big terms and too much data. Tables should be used as sparingly as possible. Make sure there is a liberal dose of humour. Try and make it a conversational piece rather then a dry treatise.
  • Short & Sweet: Rather than sending across a long voluminous newsletter break it into smaller shorter ones sent every two three days. As a thumb rule I recommend one big story and a few relevant links in each newsletter.
  • Categorize if possible: Many newsletters allow subscriptions by category. The visitor can choose the category which is most relevant to him/her and only get that topical one. This is important if a lot of data is coming from the company and has many constituents. You’ll need a good software to manage these.
  • Offer Text Only & HTML: Do offer the subscriber to receive a text only or a full formatted HTML version. Those who want a quick download make opt for the text only version.

Making the effort to create a world class newsletter says to the subscriber that you respect his time, mindshare and share of his mailbox. He will appreciate it back by giving you more business.

Cheers,
Ron

Want us to kickstart your newsletter effort? Do visit us at http://www.miracleworx.com

Or check out our portfolio at http://www.miracleworx.com/portfolio.htm

A Holistic Approach to Web Design

Nowadays a Holistic approach has become very popular where doctors not only treat the symptom but also the entire body, mind and soul. Its acknowledgement of the fact that the overall well being contributes greatly to the health of an individual.

For many years now we have being websites for clients and were quite happy doing so till we realized that although we were addressing the client’s website requirements brilliantly we were not participating effectively in their marketing efforts. We were also losing precious revenue which they would be only too happy to pay us.

Read more »

Optimizing your social media marketing strategy

Social Media Marketing is all about creating touch points for a wide range of people to know about your business, get in touch with you and learn from you. But it can be only effective if it is guided in a coordinated manner.

Many PR and advertising efforts are like unguided missiles. They fly all over the place, some land on target and most don’t. When you take the same effort online there are now many more parts to coordinate and the complexity multiplies.

Read more »

Template websites, do they work?

Years ago when I used to work for Rediff.com I was in charge of their template website department called Rediff Homepages. Basically what we provided was an a quick and simple way to set up your website using a form driven interface without the user having to know any html or coding language. At its peak we have over 50,000 users, many of them were the earliest users of web in India (I am talking of 1999-2002 period). This was quite popular with Geocities and Angelfire having millions of users worldwide.

Read more »

The Interested Client: Case for taking interest in your website.

One of my favorite clients has a very good habit. Every time I go to him for a meeting he is ready with printouts of the website statistics, reports of the enquiries he received and a set of questions and doubts he wants to clear with me. What comes out of these discussions is a clear picture of what is working on the site and what isn’t. Read more »

Putting the Social back in ‘Social Media Marketing’

Clients are wondering whats the brohaha about this Social Media Marketing thing. Most are respected businessmen who are quite adept at ‘Social Marketing’. Many have an enviable network of contacts, friends and business associates. Its when you put the ‘Media’ into the mix that things really heat up or confuse up, take your pick.

The various tools from the wacky ‘Twitter’ to the sublime ‘Facebook’ have really muddied the waters for something which comes very easily to most businessmen i.e. Networking. The gadgets and gizmos, the features and the upgrades, the bells and whistles just blur the fact that Social ‘Media’ Marketing is most importantly about Human to Human contact. Read more »