Thursday, September 22, 2011

Apple: New iPhone 5 To be Announced on October 4


iPhone 5 & Apple lovers, I have good news for you. According to John Paczkowski from AllThingsD, Apple will be holding an event on October 4 and announcing the new iPhone 5 hardware on that day.

 Instead of Steve Jobs, Apple’s new CEO Tim Cooke will be presenting the new iPhone 5 during the event. Although the iPhone 5 will be announced on October4, the actual iPhone 5 won’t be released until some weeks later.

The new iOS 5.0 software will most likely be released once the new iPhone 5 is out. It will have over 200 new features including Notifications, and over the air updates.


Monday, September 19, 2011

SDLC: Agile Processes

In the past few years, there's been a lot of interest in agile software processes.

Agile is an umbrella term that covers many processes that share a common set of values and principles as defined by the Manifesto of Agile Software Development (http://agileManifesto .org) . Examples of these processes are Extreme Programming (XP), Scrum, Feature Driven Development (FDD), Crystal, and DSDM
(Dynamic Systems Development Method).

In terms of our discussion, agile processes are strongly adaptive in their nature. They are also very much people-oriented processes . Agile approaches assume that the most important factor in a project's success is the quality of the people an the project and how well they work together in human terms. Which process they use and which tools they use are strictly second-order effects.

Agile methods tend to use short, time-boxed iterations, most often of a month or less. Because they don't attach much weight to documents, agile approaches disdain using the UML in blueprint mode. Most use the UML in sketch mode, with a few advocating using it as a programming language.

Agile processes tend to be low in ceremony. A high-ceremony, or heavyweight, process has a lot of documents and control points during the project . Agile processes consider that ceremony makes it harder to make changes and works against the grain of talented people . As a result, agile processes are often characterized
as lightweight . It's important to realize that the lack of ceremony is a consequence of adaptivity and people orientation rather than a fundamental property.

Development: Continuous integration

Continuous integration
keeps a team in sync to avoid painful integration cycles. At the heart of this lies a fully automated build process that can be kicked off automatically whenever any member of the team checks code into the code base.

Developers are expected to check in daily, so automated builds are done many times a day . The build process includes running a large block of automated regression tests so that any inconsistencies are caught quickly so they can be fixed easily.


Test: Automated regression tests

Automated regression tests


help by allowing you to quickly detect any defects that may have been introduced when you are changing things.

The xUnit family of testing frameworks is a particularly valuable tool for building automated unit tests . Starting with the original JUnit, there are now ports to almost every language imaginable (see http://www.xprogramming.com/software.htm ) .

A good rule of thumb is that the size of your unit test code should be about the same size as your production code .

SDLC: Iterative and Waterfall Processes

One of the biggest debates about process is that between waterfall and iterative styles . The terms often get misused, particularly as iterative is seen as fashionable, while the waterfall process seems to wear plaid trousers. As a result, many projects claim to do iterative development but are really doing waterfall.


The essential difference between the two is how you break up a project into smaller chunks . If you have a project that you think will take a year, few people are comfortable telling the team to go away for a year and to come back when done . Some breakdown is needed so that people can approach the problem and
track progress .

The waterfall style breaks down a project based an activity. To build Software, you have to do certain activities : requirements analysis, design, coding, and testing. Our 1-year project might thus have a 2-month analysis phase, followed by a 4-month design phase, followed by a 3-month coding phase, followed by a
3-month testing phase.

The iterative style breaks down a project by subsets of functionality . You might take a year and break it into 3-month iterations . In the first iteration, you'd take a quarter of the requirements and do the complete software life cycle for that quarter : analysis, design, code, and test . At the end of the first iteration, you'd have a system that does a quarter of the needed functionality . Then you'd do a second iteration so that at the end of 6 months, you'd have a system that does half the functionality.

Sunday, September 18, 2011

JQuery: Introduction to JQuery -- a Powerful JavaScript Library

JQuery, a popular open source JavaScript Library, provides many advanced and cross-browser functions that can enhance your web applications. This article starts with the basics and then shows you how to extend JQuery with its plug-in system.


This article introduces JQuery, an extremely popular, open source JavaScript library. We will start by looking at the current state of the art in JavaScript technology to see why JQuery is used in many impressive applications.



We will use a case study in order to create a simple HTML page, which will serve as the basis for a hands-on tutorial for performing the following tasks using JQuery functionality:
  • Selecting HTML elements with JQuery
  •  
  • Manipulating HTML elements

  • Adding some animations to the Web page

  • Using JQuery UI to add a custom theme

  • Extending JQuery with the numerous available plug-ins


Why Use JQuery Instead of Just Basic JavaScript?

JavaScript is a fairly low-level programming language. It does not provide advanced page manipulation and decoration functions, and it provides nothing concerning animations. Moreover, using direct JavaScript can cause issues related to browser incompatibilities. Those issues have made many JavaScript applications difficult to code, resulting in high maintenance costs.
JQuery aims to ease all these problems by providing a lightweight library that adds many advanced and cross-browser functions to the standard language. In addition, there is a very dynamic community that adds more-advanced components based on JQuery.
A modern Web application wouldn't be complete without some AJAX functionality. JQuery provides functions for sending HTTP GET and POST requests, and it can work easily with the JavaScript Object Notation (JSON) format we saw in the first article. This functionality enables us to query the REST back end we coded in the first article.

Installing JQuery

JQuery is a JavaScript library, so installing it is just a matter of importing a script inside a Web page. However, there are a few best practices to be aware of:
  • JQuery is available through several content delivery networks (CDN). Using those CDNs instead of installing JQuery on your servers should provide significant performance and bandwidth gains.
  • As with any static content, JQuery files should be served compressed. That's why there are two versions of JQuery available: a minified (or “min”) version, which is small and efficient, and a development version, which is easier to read and debug. For the rest of this article, we will use the min version, which is enough for our needs.
  • JQuery files should be cached on the client side, so you should use the JQuery version number in the file name.
Let's start with a simple HTML Web page, which will be used for our sample application.
  1. Launch NetBeans and re-open the ArticleEvaluator project from the first article.
  2. Right-click the Web Pages node and select New > Web > HTML.
  3. Name your page article and click Finish.
  4. Replace the content of the newly created file with this HTML code:
<html> 
<head>  
  <title>Sample article</title>  
  <script src="http://code.jquery.com/jquery-1.4.2.min.js"></script>  
  <style type="text/css" media="screen">   
   @import "style.css";  
  </style> 
</head> 
<body>  
  <h1>Sample article</h1>  
  <p>Article text</p>  
  <div id="author-wrapper">    
    <div id="author">1</div>  
  </div> 
</body> 
</html>

As you can see, this file refers to a CSS file that you need to create:
Right-click the Web Pages node and select New > Web > Cascading Style Sheet.
Name your page style and click Finish.
Here is the content to copy and paste for this file:
body {     
    background: #ebe9e9;     
    margin: 0px;     
    padding: 0px;     
    font: 12px arial, sans-serif; 
}  


p {     
    background: #ffffff;     
    margin: auto;     
    border:2px solid #666666;     
    text-align: left;     
    font: 12px arial, sans-serif;     
    width: 500px; 
}  


h1 {     
    margin-top: 10px;     
    font: 20px arial, sans-serif;     
    color: #ff3333;     
    font-weight: bold;     
    text-align: center; 

} 
 
#author-wrapper {
    margin: auto;
    text-align: right;
    width: 500px;
    display: none;
}


#vote-form {
    margin: auto;
    width: 500px;
}

To test your HTML page, you can launch GlassFish (as in the first article) and point your browser to http://localhost:8080/ArticleEvaluator/article.html. You can also open this Web page directly from the file system, because it is just a static HTML file.

Selecting Elements with JQuery

The easiest way to get started with JQuery is to select some elements on our sample Web page.
Let's select the author division, which we copied and pasted in the previous section, in order to change this element to display some user information. As you can see from the HTML code and the CSS file, it currently contains the user ID, and it is included in a hidden <div> element. There are several ways to select this HTML element. Let's start by using its ID:
  $("#author");

$ is not a JavaScript-specific keyword. It's a one-letter function that is defined by JQuery. The text that is passed to this function is parsed by JQuery, which then generates the correct series of JavaScript functions to select the requested Document Object Model (DOM) elements. This method of selecting DOM elements is concise and browser-independent, which addresses the two most important problems that arise with JavaScript programming. As a result, JQuery enables quick, simple, and powerful cross-browser selection of DOM nodes in the Web page.
Of course, the ID is not the only way to select elements. You can use the elements' class or some properties of those elements. For example, you can select all the elements with the vote class:
  $(".vote");

In order to read the author's ID from our Web page, add the following code just before the closing </body> tag:
      <script type="text/javascript">
          $(document).ready(function() {
            var id = $("#author").text();
          });
      </script>

This task illustrates a common best practice with JQuery: The $(document).ready() function is launched when the Web page is ready, and it is loaded at the end of the page. From a user point of view, this means the whole page loads normally, and then JQuery is used to enhance the page.
Using the previous code, the author's ID will be read at startup time. You can test this by using the JavaScript alert() function.

Manipulating a Web Page's Elements

After HTML elements have been selected, you will certainly need to manipulate them by changing their CSS class, adding some text, or even replacing them completely. JQuery provides functions for all those tasks.
The use case we are going to implement is to replace the author's ID, which we selected earlier, with this author information: author's first name, author's last name, and a URL. For the moment, this information will be stored statically inside our JavaScript code, but in the third article of this series, we will get this information from the REST back end we coded in the first article.
Here is the author's information we are temporarily hard-coding in the JavaScript code:
function Author(id, firstName, lastName, url) {  
  this.id = id;  
  this.firstName = firstName;  
  this.lastName = lastName;  this.url = url; 
  }  

var author = new Author("1", "Julien", "Dubois", "http://www.oracle.com");

Because we already read the author's ID and we already know how to select the author's <div> element, we can replace the text from this element:
$("#author").replaceWith("Author: <b>" + author.firstName + " " + author.lastName +                 
     "</b><br/>" + "website: <a href=\"" + author.url + 
            "\">  + author.url + "</a>");

JQuery provides numerous other functions to change an HTML element. For example, we can make an element appear or disappear using the show() and hide() functions. An alternative way would be to change the CSS class used by an element; for this, JQuery provides functions to add a class, remove a class, or test whether a class is present.
Now that the author's ID has been replaced by the author information, let's display this information, which is the topic of the next section.

Adding Animations

Displaying an element is nice, but it is a lot more user friendly (and fun!) to add some animations. JQuery provides a rich set of animations that enables a very smooth user experience.
You can test all the animations on JQuery's Web site: http://docs.jquery.com/UI/Effects
Of course, if you abuse these animations, your Web site will become difficult to use. So you need to find the right balance to have a nice-looking Web site.
For displaying the author information, we do not want something too flashy, because the author information is not the most important part of the page. Let's select a simple slide-down animation:
 $("#author-wrapper").slideDown("slow");

Using animations with AJAX is very important from a user perspective:
  • Animations hide the fact that some requests take time to be processed server-side.
  • Animations attract the user's attention to what is changing on the Web page. Without an animation, a user might not notice that part of the page changed.

Using a JQuery Theme

JQuery UI is an extension to JQuery that adds widgets and themes on top of JQuery. JQuery UI is hosted at http://jqueryui.com/.
JQuery UI provides higher-level components, such as calendars, dialog boxes, auto-completed fields, and tabs, that all have the same look and feel. The result is similar to what we can do with JavaServer Faces technology, except the components here are fully rendered using JavaScript. Most of the components can work with AJAX. For example, the Autocomplete widget can get its data from local JavaScript code or from a call to a remote URL.
Several themes are provided as examples, but the most impressive part is an online application,http://jqueryui.com/themeroller/, that allows you to dynamically create your own custom theme. This theme can then be downloaded and used inside an application simply by importing the custom JavaScript, CSS, and images that are generated.
Here is an example configuration, in which the JQuery UI theme was unzipped in the jquery folder:
<head> 
  <title>Sample article</title>  
  <script src="http://code.jquery.com/jquery-1.4.2.min.js"></script> 
  <script src="jquery/js/jquery-ui-1.8.2.custom.min.js"></script>  
  <style type="text/css" media="screen">    
    @import "style.css";   
    @import "jquery/css/custom-theme/jquery-ui-1.8.2.custom.css"; 
  </style>
</head>

We are not using JQuery UI and its widgets system in our sample application. So you should not add this code to your ArticleEvaluator code, because it will not have any effect.
If we were using JQuery UI, the generated theme would have automatically decorated all JQuery UI widgets. Of course, you can still use the theme to explicitly decorate your own elements by directly giving them a specific JQuery UI class.

Extending JQuery with Its Plug-in System

One of the reasons for the success of JQuery is its vibrant community, which provides hundreds of high-quality plug-ins. Our application still needs some very important functionality: the ability to vote for the articles. Hence, we would like to use a rating plug-in that provides us with a graphical view of the vote. At the JQuery Web site, it is easy to find some plug-ins related to our need by using this specialized search engine: http://plugins.jquery.com/
However, for the following reasons, use care when selecting a plug-in: The plug-ins are not supported by JQuery. The plug-ins' authors usually indicate which JQuery version their plug-ins are compatible with, but there can be issues if you use many plug-ins and you want to upgrade JQuery. The licenses can differ; your company probably will want to avoid any GPL-licensed plug-in. There is often more than one plug-in available for a particular need. It is then a matter of selecting the most appropriate one.
For our sample application, let's select the JQuery Star Rating plug-in:
To use this plug-in, you need to import its JavaScript script and CSS file in the sample Web page:
  1. Download the plug-in, using the link above. For this article, we've used version v3.13 of the plug-in.
  2. Unzip the downloaded file to a folder called star-rating inside the web folder of your application. (This web folder is displayed as Web Pages inside NetBeans.)
  3. Add the plug-in's JavaScript and CSS files inside the header section of your Web page:

<head>  
  <title>Sample article</title>  
  <script src="http://code.jquery.com/jquery-1.4.2.min.js"></script>  
  <script src="star-rating/jquery.rating.js"></script>  
  <style type="text/css" media="screen">    
    @import "style.css";    
    @import "star-rating/jquery.rating.css";  
   </style> 
</head>

This plug-in works by enhancing existing radio buttons on the Web page. For this functionality, we need to create an HTML form containing those buttons. Copy and paste the following code just before the author-wrapper division element:
<form id="vote-form">Rating  
<input name="star1" type="radio" class="rating" value="1"/>  
<input name="star1" type="radio" class="rating" value="2"/>  
<input name="star1" type="radio" class="rating" value="3"/>  
<input name="star1" type="radio" class="rating" value="4"/>  
<input name="star1" type="radio" class="rating" value="5"/> 
</form> 
<br/>

Using the plug-in is then just a matter of selecting the radio buttons that have the rating class and invoking the rating() function provided by the plug-in:
$(".rating").rating({  
  callback: function(value, link){   
    alert("The value selected was '" + value + "'.");  
   } 
  });

In the previous example, we added a callback function so we know which radio button was clicked.
Of course, this doesn't trigger any process in our application back end; the votes are not saved anywhere. In the third article of this series, we will send this data to our application back end so we have the full system working.

Conclusion

In this article, we demonstrated how to select, manipulate, animate, and extend a simple Web page. We saw that JQuery is very easy to use and we did not worry at all about cross-browser issues, because JQuery provides an abstraction layer that protects us from those problems.

See Also

Embedded: A Fresh Look at Embedded Java


Defining the Embedded Space


“I use ‘the embedded space’ to refer to any device that includes a general-purpose processor and OS plus a software execution environment, but which would not be identified as a computer by a layperson.” 
Q: How would you define the embedded space?
A: I use “the embedded space” to refer to any device that includes a general-purpose processor and OS plus a software execution environment, but which would not be identified as a computer by a layperson. This encompasses everything from printers to refrigerators to cars to ATMs. To put this in perspective, automakers now claim that about 70% of the perceived value of a new car is in software and electronics. That is an astounding observation! Think about it--the wheels and tires and fins and interior materials are no longer what differentiate cars from their competitors. Car companies are increasingly focusing on electronics and software to enhance the value of what they produce. The rest of the car is pretty similar--all have four wheels, the internal combustion engine, maybe even electric motors now instead of gas. That part is very similar.
My job is to take a fresh look at how to support embedded developers and create an ecosystem in the embedded developer space so that Java is considered a possibility for implementing software on embedded devices. Currently, we have Java being deployed in a wide variety of embedded devices including eReaders, ATMs, routers, multifunction printers, VOIP corporate phones, POS systems, medical devices, industrial controllers, and smart meters. Even deli scales and parking meter systems.
Still, we're just scratching the surface when it comes to Java for embedded. We know there are many developers who, unfortunately, don't automatically think of using Java for their next embedded project. We want to change that since Java has many features valuable to embedded developers, including multicore support, security, multiplatform support, and networking. 
To create new projects, we want to create a VM and library set and some tools to entice the embedded developer to use Java for their next project. So that’s my mission.
Q: How are you trying to accomplish it?
A: It takes persistence. We have to make the case that Java is the right answer. We want to take away the artificial divisions within the Java platform because embedded devices are getting more capable and we might want, for example, to have Web servers and databases on them. There’s a lot more that users want these days, so we might want pieces from all parts of the Java platform and not just some subset that was built with mobile handsets in mind.

Recently we released the Oracle Java ME Embedded Client 1.0. This release is the first significant departure from how ME has been distributed in the past in that we are releasing binary runtimes for particular OS/processor architectures. Now, embedded developers can download, install, and begin creating Java programs on typical embedded hardware in minutes. We are very excited about this addition to our arsenal of tools and runtimes for embedded Java development.
The Rapidly Changing Embedded Space
Q: Give us a sense of how the embedded space is changing.
A: It’s undergoing rapid change. The code bases are expanding exponentially; the code is getting more complex with greater functionality and more multicore functionality. There is more connection to the Web and to OEM headquarters but, of course, bill of materials costs is still crucial.
“Now, embedded developers can download, install, and begin creating Java programs on typical embedded hardware in minutes.”
As I suggested earlier, hardware is no longer the interesting part now, not just with automotive, but with everything. We know how to make printers, stereos, cameras, TVs and DVDs, traffic signal controllers, planes, washing machines, and refrigerators--that is no longer the issue. Manufacturers are now competing with functionality that is created in software, so larger and more complex code bases are required. Traditional embedded code was simple, with maybe 200 lines of assembler language required to do some softening up of the hard edges of the hardware. Now they have to connect to the Internet and to headquarters for maintenance. They have to record information about the behavior of the device, so the manufacturer can support the system and monetize some of that information. So the code is getting more complex and more and more functions are being demanded, because that is how manufacturers differentiate their products. They are telling their embedded teams “We need six buttons because our competitor has only four” and (tongue-firmly-in-cheek) “A six-button washing machine must be better than a four-button washing machine.”
Multicore functionality is a big new thing coming to the embedded space--it’s never been there before and manufacturers have no idea how to deal with it. Embedded developers know little about multithreaded applications. Multicore is brand new to them, so they lack the tools and language support to deal with it. Some of the early C libraries that are still out there are not even multithread safe and can’t be used in a multithreaded environment. So a big change will be coming in embedded software development when multicore hits. Java, of course, has had excellent multicore support from the beginning and we will bring that support to embedded developers.
Car manufacturers want to reduce the number of processors on their machines. To do that, the code base on a particular processor will have to be more complex, because it will have to do what six processors were doing with simple code. Now all that code is on one big processor connected to the network in the car. So, all these trends in the embedded systems lead to the demand for a software development environment that is more advanced and of a higher abstraction. That’s where we are today.
Currently, most of these devices conduct a lot of internal measuring of what’s happening in the device to keep it running. But those measurements are just used internally in the control algorithm to keep the device functioning. Let’s take a refrigerator, which has a lot of mechanical functionality and a processor in it. It has to regulate the temperature in a couple of compartments--it currently does that electromechanically, but there is a move to digital control of the cooling system. It measures the temperature of the compartments, and both when and how many times the door opens. It measures the internal pressure of the Freon in the compressor and the compressor temperature when it is operating and not operating. All this goes into managing the system and the code logic.
It periodically makes decisions based on all this information and then returns to measurement mode. If all that data were collected and stored and moved to large databases on the manufacturer’s IT side, it would be valuable in several ways. There is value for the manufacturer in statistically analyzing how their devices behave in the real world, how they break, and what the repair costs are, as well as in identifying trends in order to refine the design to reduce the failure rate in deployed devices.
This information can be monetized for the customer as well. The easiest example is automotive. If all the information from all the processors on your car was recorded in a local database and then uploaded to the manufacturer, when you got in range of your home Wi-Fi, the manufacturer could provide you with a detailed report about your automobile. The report could tell you how the oil level is changing and provide information about other issues.
The manufacturer could send you e-mail when you need to get an oil change. If the car had the appropriate sensors internally, the manufacturer could describe the condition of the oil. Does it really need to be changed or can you extend the life of the oil?
If you drive freeways, your oil will stay better longer than if you engage in city driving. That is an artifact of how internal combustion engines behave. So if in one 3-month period you are doing a lot of freeway driving, maybe you don’t need your oil changed for four or five months. If you do a lot of starting and stopping, or it’s dusty and the dust degrades your oil, it might be better to change it in two months. With appropriate sensors, monitoring, and analysis, you can monetize that information by sending customized e-mails informing customers about what they need to do, as opposed to having them follow standardized intervals that might or might not apply precisely to a particular car. All of this fits well into the state of the world today, that is, we, as a society, have to optimize the consumption of fuels and energy. Larger, more complex, and intelligent software programs on our devices will allow us to use fuels and energy as miserly as possible while still having acceptable function and performance.
That might save oil--you might not change it as often, plus someone else is keeping track of it for you. There is a lot of value in collecting the operational data to send back to the OEMs for analysis and subsequent monetization.   
Java in the New Embedded Space
Q: How does Java fit into this?
A: I’ve been talking a lot about automotive but let’s generalize a bit now. You need a fairly complex software architecture to integrate these devices into the networked world. Doing that from scratch is pretty tough. Oracle can provide the client-side piece, the piece in the device, as well as the back-end servers and the middleware. That, combined with a very small amount of engineering from the device manufacturers, can enable manufacturers to collect operational data on the device, time stamp it, save it to the local database, and have that data be automatically synced with the back-end database and, thus, available for analysis and provision of new services for the device owner.
“We think Java is the right answer and the next step up in language abstraction. It makes it much easier to build large, complex software artifacts.”
Q: What is Oracle doing along these lines?
A: At Oracle, we have what is called the Oracle Berkeley Database or BDB. It’s an embedded database that comes with a thin client with anything you write for the BDB on the client, so whenever the system is in range and the thin client can get a connection to its mother database, it does so and replicates the data from the client to the mother database. Developers don’t have to think about that--they just install BDB and the thin client, all in one package.
As the control loop executes, it creates a lot of operational data that can be saved to an object in the BDB and reflected at the manufacturer’s headquarters. The BDB runs on Java as a Java program. One feature that differentiates us from the rest of the embedded space is that we have a designed Java VM for writing your app, plus the BDB and the client. That is a package that makes the collection and transfer of operational data pretty much a no-brainer for the embedded developer.
It’s really simple to make this happen. So why Java? And why Oracle for embedded developers? The middleware data-movement infrastructure already exists for the general-purpose world and we are pushing out little arms of this big world to allow it to run on these embedded clients.
Q: When will this happen?
A: We have some embedded Java products now, and we are talking to the BDB folks about packaging together with embedded Java to make it dead simple for developers to take advantage of the function. We have these pieces and we can create these things for customers today. It’s not yet a single product but the pieces are there. Embedded software developers are pushing the limits of their tools and their development capacities. We think Java is the right answer and the next step up in language abstraction. It makes it much easier to build large, complex software artifacts.
Call to Action for Developers
Q: Is there a call to action for developers here? Any appeals?
A: The call to developers is to download Oracle’s Embedded Java products, get one of the supported embedded hardware reference platforms, for example, the SheevaPlug, and write their first Java program.
See Also