October 31, 2011

Using Facebook Apps in Social Media Marketing

Nowadays Social Media has emerged as most discussed topic in our era. Facebook, Twitter, LinkedIn and many more out there. People, Celebrities, Corporates, Brand Products are very active in these medias. Social Media Marketing has made a big difference over traditional marketing. Facebook Pages are one among them playing key role in this evolution. Have you ever wondered how following companies have done this?


Pepsi Monster


The answer is simple, Facebook Apps.


Today I am going to demonstrate how you can use Facebook Apps with Facebook Pages to market your brand. First of all you need a valid Facebook account.


Step 1: Login to your Facebook Account and Create a Page by clicking the link available in the footer. And proceed with a choice which suites you the best. Available choices are 'Local Business', 'Company or Organization', 'Brand or Product', 'Artist or Public Figure', 'Entertainment' and 'Community'.


Step 2: Create a Username for newly created Page. You can access your Facebook page directly with this name (www.facebook.com/your_username). This will help your fans to reach your page quickly.




Step 3: Develop your application in any platform and host it. Configure http and https for the hosted site. Make sure that the URL is resolving over internet.


Step 4: Now goto http://developers.facebook.com and click on "Apps". Also you can click on 'Developer' link available in the footer.



Step 5: For the first time you will be prompted to add the 'Develper Application'. Proceed with that and click 'Allow' to grant Facebook developers to access your basic information.

Step 6: Now you are all set to create an application. Click on 'Create New App' button.



Step 7: Configure your App. Choose 'Page Tab' option under integration mode. Provide a 'Page Tab Name' and valid URL. Don't forget to provide secured URL.


Step 8: Save the changes, and click on 'View App Profile Page' under Related Links.


Step 9: From App Profile, click on 'Add to My Page' link available on left side of the screen.


Step 10: Choose the page you have created on Step 1, and click Okay.


That's it, you have done Facebook Apps integration with your Page!

April 28, 2011

Practice writing clean code - 10 Tips


How many of us have written clean code always?

Clean code!!!... ahhh am not going to write that. Most of us tends to write bad code. I was also like that and used to write bad code. Often this happen when we are in a hurry to finish something (ha ha always, Right?).

Yes, we are always in a hurry and write bad code. No wonder in getting surprises in production.

Sometimes we get fed-up with twisting, critical, weird issues. We break our heads, skip br-unch (always sleep late and zzzzz up to late morning and have (br)fast + l(unch), weekends @ office and we try all the threads we get from Google. Thanks to Google, always it gives lot of links & answers (only few struck luck). Most of the time we get relaxed that at least someone else in the globe has faced the same issue and we have a company ;-)

What happen at the EoD? Certainly we will solve the issue, but our code will be a mess!

I analyzed my coding style, my approaches in addressing a business requirement into technical solution and my way of writing program logic. Then I started to practice few things to write clean code. Now I realize that everyone can write clean code.

1. Avoid jumping into coding - Think, plan, organize, and if possible write down the problem in a paper (modified pseudo-code).

2. Draw problem diagrams - Express your logic/supposed solution in diagrams. Custom drawings in your language should be fine (use UML if possible)

3. Keep the code simple - We (programmers) are pride after writing a complicated code. What is the meaning in writing something which others don't understand? Sometimes even the person who wrote the code doesn’t understand after a while. Slowly these code will become blockers for enhancements and maintenance. Team starts writing wrappers and all kind of tricks to cover the complicated blocker code. Over the period of time we are gonna carry a huge technical debt.

4. Keep the code readable - I remember an incident, I was working as team leader in my previous company. One day a junior programmer invited me for reviewing the code he just finished for an enhancement. During the code review, he shared his bad experience with the existing code. The form had couple of dropdown and few methods to populate those. Showing the following code he asked me,



LoadCountry() {......}
PopState() {......}
LoadCity() {......}
GetCustomerTypes() {......}


"Who is the dumb who wrote this crap?"


I gave an innocent smile and said "It's written by me!". I realized my mistake. Nothing wrong in his frustration. Reading LoadCountry() he searched for LoadState() and after few searches he found PopState(). Next time he was smart and searched for LoadCustomerTypes() and PopCustomerTypes(). And he got pissed off seeing GetCustomerTypes(). 


Always give meaningful name for the methods, properties and variables. At the same time keep consistency in naming conventions. This will increase the maintainability of the code (no more WTF).

5. Know your code - Writing a method or implementing a loop or whatever it is, know the execution sequence. Build the capability to keep the execution pointer in mind. While writing the code you should be able to say the output without running it. Remember the small exercises we did during the studies to find the value of some variable after a sequence of code.

6. Avoid incremental coding - Write the complete code and then do a test run. Otherwise you will be deviated to something else. Once I was assigned to create a report, and I started to work on the task. As usual I jumped into coding. I wrote couple lines, compiled and ran the program to see the output. This happened frequently and I deviated to UI design issues of the report (where actual task was to render the report).

7. Don't get addicted to debugging tools - Everyone does this mistake. These tools are meant to de-bug to fix a buggy code. But we use these tools while coding. Most of us don't have the confidence in the code we write and get addicted to these tools to make sure that our code is working.

Hey, we are professional programmers. Why can't we predict the output of our code without a debugging tool? After all it’s written by us. For this you must know your code, right?

8. Understand the requirement - Get a better understanding about the requirement (desired output) before coding. If you have any doubt, do not make any assumptions, clarify it.

9. Say YES to re-factoring - Never hesitate to re-factor your code. If you smell something and you got a new idea (better).  Go ahead and implement.

No matter if you are working on an enhancement or maintenance. If there is a scope for re-factoring, do it first with confidence. Don't get afraid of dependencies and impact. After all a code is a group of syntactical words and logic. At any point of time you can build it.

10. Follow a coding standard - Define a coding standard for your platform and framework. Encourage the team to follow the defined coding standard and increase the confidence in the code. New team members can easily understand the pulse of code.

I forgot to say something. If you think above are rules / checklist to write clean code, you are gonna break that... Becoz its human nature to break rules ;-)

So make it as a HABIT to write clean code.