Showing posts with label What is What. Show all posts
Showing posts with label What is What. Show all posts

Monday, May 23, 2011

Understanding JSON: the 3 minute lesson

Source

What does it stand for?
JavaScript Object Notation.

And what does that mean?
JSON is a syntax for passing around objects that contain name/value pairs, arrays and other objects.

Here's a tiny scrap of JSON:

{"skillz": {
"web":[
{"name": "html",
"years": "5"
},
{"name": "css",
"years": "3"
}],
"database":[
{"name": "sql",
"years": "7"
}]
}}

You got that? So you'd recognise some JSON if you saw it now? Basically:

Squiggles, Squares, Colons and Commas
Squiggly brackets act as 'containers'
Square brackets holds arrays
Names and values are separated by a colon.
Array elements are separated by commas

JSON is like XML because:
They are both 'self-describing' meaning that values are named, and thus 'human readable'
Both are hierarchical. (i.e. You can have values within values.)
Both can be parsed and used by lots of programming languages
Both can be passed around using AJAX (i.e. httpWebRequest)

JSON is UNlike XML because:
XML uses angle brackets, with a tag name at the start and end of an element: JSON uses squiggly brackets with the name only at the beginning of the element.
JSON is less verbose so it's definitely quicker for humans to write, and probably quicker for us to read.
JSON can be parsed trivially using the eval() procedure in JavaScript
JSON includes arrays {where each element doesn't have a name of its own}
In XML you can use any name you want for an element, in JSON you can't use reserved words from javascript
But Why? What's good about it?
When you're writing ajax stuff, if you use JSON, then you avoid hand-writing xml. This is quicker.

Again, when you're writing ajax stuff, which looks easier? the XML approach or the JSON approach:

The XML approach:
bring back an XML document
loop through it, extracting values from it
do something with those values, etc,
versus
The JSON approach:
bring back a JSON string.
'eval' the JSON
So this is Object-Oriented huh?
Nah, not strictly.

JSON provides a nice encapsulation technique, that you can use for separating values and functions out, but it doesn't provide anything inheritence, polymorphism, interfaces, or OO goodness like that.

And it's just for the client-side right?
Yes and no. On the server-side you can easily serialize/deserialize your objects to/from JSON. For .net programmers you can use libraries like Json.net to do this automatically for you (using reflection i assume), or you can generate your own custom code to perform it even faster on a case by case basis.

REST Approach

Source

1. What is REST?

REST stands for Representational State Transfer. (It is sometimes spelled "ReST".) It relies on a stateless, client-server, cacheable communications protocol -- and in virtually all cases, the HTTP protocol is used.

REST is an architecture style for designing networked applications. The idea is that, rather than using complex mechanisms such as CORBA, RPC or SOAP to connect between machines, simple HTTP is used to make calls between machines.

•In many ways, the World Wide Web itself, based on HTTP, can be viewed as a REST-based architecture.
RESTful applications use HTTP requests to post data (create and/or update), read data (e.g., make queries), and delete data. Thus, REST uses HTTP for all four CRUD (Create/Read/Update/Delete) operations.

REST is a lightweight alternative to mechanisms like RPC (Remote Procedure Calls) and Web Services (SOAP, WSDL, et al.). Later, we will see how much more simple REST is.

•Despite being simple, REST is fully-featured; there's basically nothing you can do in Web Services that can't be done with a RESTful architecture.
REST is not a "standard". There will never be a W3C recommendataion for REST, for example. And while there are REST programming frameworks, working with REST is so simple that you can often "roll your own" with standard library features in languages like Perl, Java, or C#.

As a programming approach, REST is a lightweight alternative to Web Services and RPC.

Much like Web Services, a REST service is:

•Platform-independent (you don't care if the server is Unix, the client is a Mac, or anything else),
•Language-independent (C# can talk to Java, etc.),
•Standards-based (runs on top of HTTP), and
•Can easily be used in the presence of firewalls.

Like Web Services, REST offers no built-in security features, encryption, session management, QoS guarantees, etc. But also as with Web Services, these can be added by building on top of HTTP:

•For security, username/password tokens are often used.
•For encryption, REST can be used on top of HTTPS (secure sockets).
•... etc.

One thing that is not part of a good REST design is cookies: The "ST" in "REST" stands for "State Transfer", and indeed, in a good REST design operations are self-contained, and each request carries with it (transfers) all the information (state) that the server needs in order to complete it.

3. How Simple is REST?


Let's take a simple web service as an example: querying a phonebook application for the details of a given user. All we have is the user's ID.

Using Web Services and SOAP, the request would look something like this:


12345


(The details are not important; this is just an example.) The entire shebang now has to be sent (using an HTTP POST request) to the server. The result is probably an XML file, but it will be embedded, as the "payload", inside a SOAP response envelope.

And with REST? The query will probably look like this:

http://www.acme.com/phonebook/UserDetails/12345

Note that this isn't the request body -- it's just a URL. This URL is sent to the server using a simpler GET request, and the HTTP reply is the raw result data -- not embedded inside anything, just the data you need in a way you can directly use.

•It's easy to see why Web Services are often used with libraries that create the SOAP/HTTP request and send it over, and then parse the SOAP response.
•With REST, a simple network connection is all you need. You can even test the API directly, using your browser.
•Still, REST libraries (for simplifying things) do exist, and we will discuss some of these later.
Note how the URL's "method" part is not called "GetUserDetails", but simply "UserDetails". It is a common convention in REST design to use nouns rather than verbs to denote simple resources.

The letter analogy
A nice analogy for REST vs. SOAP is mailing a letter: with SOAP, you're using an envelope; with REST, it's a postcard. Postcards are easier to handle (by the receiver), waste less paper (i.e., consume less bandwidth), and have a short content. (Of course, REST requests aren't really limited in length, esp. if they use POST rather than GET.)

But don't carry the analogy too far: unlike letters-vs.-postcards, REST is every bit as secure as SOAP. In particular, REST can be carried over secure sockets (using the HTTPS protocol), and content can be encrypted using any mechanism you see fit. Without encryption, REST and SOAP are both insecure; with proper encryption in place, both are equally secure.

4. More Complex REST Requests

The previous section included a simple example for a REST request -- with a single parameter.

REST can easily handle more complex requests, including multiple parameters. In most cases, you'll just use HTTP GET parameters in the URL.

For example:

http://www.acme.com/phonebook/UserDetails?firstName=John&lastName=Doe

If you need to pass long parameters, or binary ones, you'd normally use HTTP POST requests, and include the parameters in the POST body.

As a rule, GET requests should be for read-only queries; they should not change the state of the server and its data. For creation, updating, and deleting data, use POST requests. (POST can also be used for read-only queries, as noted above, when complex parameters are required.)

•In a way, this web page (like most others) can be viewed as offering services via a REST API; you use a GET request to read data, and a POST request to post a comment -- where more and longer parameters are required.

While REST services might use XML in their responses (as one way of organizing structured data), REST requests rarely use XML. As shown above, in most cases, request parameters are simple, and there is no need for the overhead of XML.

•One advantage of using XML is type safety. However, in a stateless system like REST, you should always verify the validity of your input, XML or otherwise!

Portlets & Portal

Introduction

JSR 168 Vs JSR 286

Portlets Vs Servlets

Portlet Lifecycle

Monday, August 24, 2009

Cloud Computing , SaaS and Prospects

Cloud computing is a style of computing in which dynamically scalable and often virtualized resources are provided as a service over the Internet. Users need not have knowledge of, expertise in, or control over the technology infrastructure in the "cloud" that supports them.

The concept generally incorporates combinations of the following:
* infrastructure as a service (IaaS)
* platform as a service (PaaS)
* software as a service (SaaS)
* Other recent (ca. 2007–09) technologies that rely on the Internet to satisfy the computing needs of users.

Cloud computing services often provide common business applications online that are accessed from a web browser, while the software and data are stored on the servers.

The term cloud is used as a metaphor for the Internet, based on how the Internet is depicted in computer network diagrams and is an abstraction for the complex infrastructure it conceals.

Cloud computing users can avoid capital expenditure (CapEx) on hardware, software, and services when they pay a provider only for what they use. Consumption is usually billed on a utility (e.g. resources consumed, like electricity) or subscription (e.g. time based, like a newspaper) basis with little or no upfront cost. (from wikipedia)

Late 2008, market research group IDC surveyed IT professionals and concluded that 4% of enterprises already have implemented some form of cloud computing, although it's often in the form of software as a service (SaaS). That number will more than double by 2012, to 9% of enterprises, said Frank Gens, senior VP of IDC, as he opened the Cloud Computing Forum in San Francisco

Impact of cloud computing will far exceed those modest figures, he added. Applications designed to run in the cloud "will represent 25% of the net new growth in IT spending," versus spending for on-premises IT, he predicted. SaaS by itself is projected to nearly double from $9 billion to $17 billion in that time period, Gens said.

Joseph Tobolski, director of cloud computing at Accenture's Technology Labs, pointed out that "Achieving a 5% to 9% adoption rate through 2012 might be understating it", He said Accenture's cloud consulting services are growing, and it's even produced an enterprise service bus to make it easier for its clients to link their data centers to cloud services. IT managers should be trying to make their internal operations function more as an enterprise cloud. (from InformationWeek)

In current an uncertain economy, An AMI-Partners survey finds SMB are focusing more on software as a service (SAAS) and managed services solutions as IT budgets tighten.
The study’s focus was to analyze how the economy is impacting SMBs’ perceptions, usage and purchasing behaviors related to IT. Among key changes identified in the study was the drastic increase of SMBs worldwide now showing strong interest in managed services and SAAS and dramatic increases in midmarket companies’ plans to outsource specific IT needs such as storage, security and telecommunications.

The study, released this summer, found that most SMBs feel the economy is starting to stabilize, however, businesses are still seeking ways to significantly reduce costs and increase revenues. This includes exploring IT products and services that can directly and immediately help ease exaggerated pain points like restricted cash flow and limited access to credit. “Solutions like SAAS and managed services offer flexible payment options and usage-based models that are very attractive to SMBs right now, as they struggle to overcome the credit crunch and very tight IT budgets,” said AMI Vice President of Marketing Chad Thompson. (from eWeek)

A SaaS Summit 2009, organized in Bangalore has also echoed & presented the trends of SaaS adoption in the current uncertain economy.

"SaaS is the new reality, which enterprises are facing," said M S Krishnan, professor of Business Information Technology at the Ross School of Business, University of Michigan.

"Recession has taught a lesson for restructuring of businesses as the market becomes more and more competing and giving way for newer technologies like SaaS. The social demand for these models have increased which are going to transform the business models," he added.

Balka Baruah Aggarwal, Manager, Syndicated Research, Springboard Research said IT department in enterprises have begun to move to the back-end and the focus is turning on the large scale business goals.

"IT has become the secondary focus," she said. "SaaS plays a vital role in this fundamental shift of enterprises looking at their technology investments, as it allows them to keep the focus on their business without worrying about the technology as well as successfully tweaks into your business process."

The event witnessed the delivery of ERP on a SaaS model as the emerging trend. With no initial investment costs, affordable pricing models as well as flexibility to customization, ERP on SaaS was seen as the next innovative technology by the speakers of the Summit.

Highlighting as an example, A vice president from Indian metal products compay, said, "One of our purposes is not to have any IT team in our company, that is why we went for a web-hosted ERP model. We also realized that the model can be quickly implemented and also scale our future requirements without any huge investments." (from CIOL)

Resources

Grid Asia - 2009

Basic Introduction to Cloud Computing Applications & Systems

Developing a Cloud Ecosystem in Singapore - Singapore IDA's Approach

Cloud computing - WIKIPEDIA

Cloud Implementation To Double By 2012 - InformationWeek

Economy Ignites Interest in Managed Services and SAAS - eWeek

SaaS gaining grounds in downturn - CIOL

Getting Startedwith Cloud Computing - Sun

´