AJAX and JSON in Visualforce

Recently I started working with Salesforce for one of the projects and came across a requirement for our Customized Dashboard wherein selecting a row on a Lead table should open up one more row below it with the data from Quotes related to the Lead. Initially these where the several designs/solutions I considered using AJAX and JSON before settling down on one.

1. Use JQuery to make a AJAX call to Controller to fetch the data and display it.

2. Use Visualforce AJAX controls like actionFunction to achieve the same.

3. Use Visualforce connection object to query to database from the Visualforce Page itself and render the results.
Continue reading

When Should I REST

What should I Choose, SOAP or REST. This seems to be a never-ending question as it’s being asked over and over again in forums and blogs without a straight answer. This is also a popular question being asked in the interviews. It’s a big debate as still people’s opinion is divided even though undeniably REST is gaining popularity and being preferred by most of the tech companies for its simplicity. Okay, now instead of getting into the same argument of which is best over the other and getting confused we will see the situations where you can choose REST over SOAP. Continue reading

Data to Presentation – A travel experience

Often in developer’s world there would be debate on how a data should be transformed in terms of applying business and view logic while maintaining it’s integrity. In one of my projects this was a bigger question since the data transformation was not clearly defined and we always run into issues when trying to apply the business or view logic while having the data intact so it could be reused in other modules which had their own logic. After months and months of doing workarounds it was time for us to come up with a strategy that could be followed by all developers to handle this situation.

The Problem

Continue reading

Websphere Cluster and Load Balancing

Let me try to explain Websphere Cluster and Load Balancing from a different point of view.  Let’s say this is the first time you are running the Websphere admin console and trying to setup your server. We will take a ground up approach and try to deploy an application and figure out what is missing and understand Cluster and Load Balancing. Okay, When you try to deploy an enterprise application in Websphere through admin console, after some steps you will be asked to choose the application server.

Application Server

An application server is something that handles the Web application requests and responses. In Tech world, application server is often referred as JVM.

Okay, now assume that you don’t have application server, then you have to create one. You select “Application Servers” from the Left of the console and try to create a new server. In order to create an application server you need to specify a Node.

Node Continue reading

Agile an Arch Enemy of Refactoring

A dark tale of a member of Agile team…Sorry got little carried away with the title. Okay, No I am not saying that. But it certainly feels like that after being in an Agile project for quite some time. I know I am not new and many people share the same thought. In fact this is one of the biggest problems of an Agile project being discussed everywhere.

Agile teams maintain and extend their code a lot from iteration to iteration without continuous refactoring. Why? there are two main issues I would like to discuss about. One, “no body has time”. This is the common complaint from any developer or a team bring forward. This is a valid claim for some level, the reason is you are supposed to make any decisions within a short period of time, but no body is given time to correct it later as you have to move on to the next assignment almost immediately. But as I said it is only up to some level as the other hidden factors are the attitude towards the issues, laziness, not following coding standards etc. There are a lot of developers who would like to refactor the code written by someone else but even they are plagued by the above factors and somehow even if they try to emerge from those issues they are slapped again by something else.

The second issue I am discussing is, “Refactoring has no business value”. Continue reading

Currying and Partial Application

In a functional Programming Language Currying is very basic and an important concept along with Partial application and Closures. So what is really Currying?. I know this topic had been discussed at lot of places in the web but most of them are confusing and not being simple. Moreover the concept of partial application or currying are often conflated. So here I would like to explain some of these topics often discussed in Functional Languages in a simple way.

Closures

In order to understand Currying or anything we should understand closure. Wikipedia says “A closure allows a function to access variables outside its typical scope. Such a function is said to be “closed over” its free variables“. But just for simplicity sake, let’s just remember a Closure is a feature where any call to a function allows it to return a new function instead of just primitive values. We’ll discuss in further sections why this is useful.

Continue reading

Request Based vs Component Based Framework

I came across this question “What’s the difference between Request Based and Component Based Framework” someone posted on the web as a part of an Interview Question. This is little interesting topic(at least for me) however there is not much hype around these days on the Component Based Frameworks even though they exist for a while.

Anyway, what is a Request Based Framework?. We are very familiar with these, they are the classic Web Frameworks exists from the beginning which handles incoming requests through controllers and actions. Any framework implements the MVC model are Request based, frameworks like Struts, Spring MVC are examples of these frameworks. However not all MVC frameworks are considered only Request Based. Let’s look at the following picture to understand the usage of these frameworks.

Looking through the above picture, it is easy to see that a Request Based Framework even how powerful it may be, you need to extend and use 3rd Party Frameworks and Libraries for your application needs.

Now, let’s look at a Component Based Framework usage. Continue reading

Amazon Elastic Compute Cloud (Amazon EC2)

When I first read about EC2 offering from Amazon, I didn’t quite understand it. The service provided by them is an example of IaaS (Infrastructure as a Service) but why do you start the definition with that is a Web Service for Computing capacity in the cloud rather than explaining the infrastructure offer first?. I didn’t get it, so as many others. There were so many questions like whether they are the regular web hosting providers or they do any special service etc. There are other providers like RackspaceGo Grid and many others who explain it upfront but not Amazon. Anyway, for the folks out there who are still struggling to get a grip, let me try to explain it in a simple way.

Amazon EC2 can be explained by comparing with a Web hosting Provider. So What is the difference between a normal Web hosting Provider and the other Cloud Providers?. The difference comes in the flexibility. With a normal provider you are bound to a contract, the minimum is at least a month but with the Cloud providers you don’t enter into any contract rather they provide service by hours. Suppose if you need the platform/infrastructure only for certain period of time it could be hours or days, you can utilize their service only for the time you use it. For example if you are doing a product launch and you anticipate an immediate spike in traffic for certain days, the Cloud providers are the way to go. Not all Cloud Hosting Solutions offer as Amazon’s by hours or days however the concept of hosting, scalability is common between them.

Okay, now let’s get to the details of how this works. In order to understand how to use them, you need to have a little understanding on Load balancing. Once you sign up for EC2 and figure out the options and based on your needs you have to set up some instances and Amazon provides you with IP address(es) which you can use it for load balancing between your server and Amazon servers. If you want the load balancing to be handled by Amazon itself you configure your EC2 instances pointing to the their load balancer and use the DNS name provided by them to set it up in your server’s load balancer. And if you want more control of the instances Amazon provide the web service that enables you to handle the instance management yourself.

I recently encountered a question, whether we can use shared hosting to be configured to Amazon instance, and my answer was ‘No’, since this involves in configuration of load balancers, you should have some control over your servers which you don’t get from a shared hosting.

So that’s it for now. Amazon EC2 offers lot more than what is explained here, so for detailed explanation you can check out their website.