Posted on August 12, 2008 by sharat
JDBC Resources
A JDBC resource (data source) provides applications with a means of connecting to a database. Typically, the administrator creates a JDBC resource for each database accessed by the applications deployed in a domain. (However, more than one JDBC resource can be created for a database.)
JDBC Resources
To store, organize, and retrieve data, most applications use [...]
Filed under: JDBC | 4 Comments »
Posted on August 12, 2008 by sharat
Just-In-Time Compilers
The simplest tool used to increase the performance of your application is the Just-In-Time (JIT) compiler. A JIT is a code generator that converts Java bytecode into native machine code. Java programs invoked with a JIT generally run much faster than when the bytecode is executed by the interpreter. The Java Hotspot VM removes [...]
Filed under: Java | Leave a Comment »
Posted on August 12, 2008 by sharat
Avoid synchronization where possible.
ArrayList is faster than Vector
Only List and Map have efficient thread-safe implementations: the Vector and Hashtable classes respectively.
Synchronized methods are slower than the identical non-synchronized one.
Consider using non-synchronized classes and synchronized-wrappers.
FastVector is faster than Vector by making the elementData field public, thus avoiding (synchronized) calls to elementAt().
Use threads. Prioritize threads. Use notify [...]
Filed under: Performance | Leave a Comment »
Posted on August 12, 2008 by sharat
Use the servlet init() method to cache static data, and release them in the destroy() method.
Use StringBuffer rather than using + operator when you concatenate multiple strings.
Use the print() method rather than the println() method.
Use a ServletOutputStream rather than a PrintWriter to send binary data.
Initialize the PrintWriter with the optimal size for pages you write.
Flush [...]
Filed under: Performance, Servlets | Leave a Comment »
Posted on August 12, 2008 by sharat
Use the jspInit() method to cache static data, and release them in the jspDestroy() method.
Use the jspInit() method to cache static data.
Use StringBuffer rather than using + operator when you concatenate multiple strings.
Use the print() method rather than the println() method.
Use a ServletOutputStream rather than a PrintWriter to send binary data.
Initialize the PrintWriter with the [...]
Filed under: JSP, Performance | Leave a Comment »
Posted on August 12, 2008 by sharat
use the flyweight pattern to reduce object creation [The flyweight pattern uses a factory instead of 'new' to reuse objects rather than always create new ones].
The Singleton pattern and the Flyweight (object factory) pattern are useful to limit numbers of objects of various types and to assist with object reuse and reduce garbage collection.
Use the [...]
Filed under: Design Pattern, Performance | 1 Comment »
Posted on August 12, 2008 by sharat
Use prepared statements. Use parametrized SQL.
Tune the SQL to minimize the data returned (e.g. not ‘SELECT *’).
Minimize transaction conflicts (e.g. locked rows).
Use connection pooling.
Try to combine queries and batch updates.
Use stored procedures.
Cache data to avoid repeated queries.
Close resources (Connections, Statements, ResultSets) when finished with.
Select the fastest JDBC driver.
If you are not using stored procedures [...]
Filed under: Performance | Leave a Comment »
Posted on August 8, 2008 by sharat
<html > <meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″><title>Untitled 1</title><script type=”text/javascript” src= “../js/dojo/dojo/dojo.js” djConfig=”isDebug: true”></script><script type=”text/javascript”>dojo.require(“dojox.charting.Chart2D”);makeCharts = function(){var chart1 = new dojox.charting.Chart2D(“simplechart”);chart1.addPlot(“default”, {type: “Lines”});chart1.addPlot(“other”, {type: “Areas”, hAxis: “other x”, vAxis: “other y”});chart1.addPlot(“Grid”, {type: “Grid”, hAxis: “other x”, vAxis: “other y”,hMajorLines: true, hMinorLines: false, vMajorLines: true, vMinorLines: false});chart1.addAxis(“x”, { labels: [{value: 1, text: "Jan"}, {value: 2, text: "Feb"}, [...]
Filed under: Dojo | Leave a Comment »
Posted on August 8, 2008 by sharat
<html >
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″><title>Untitled 1</title><script type=”text/javascript” src= “../js/dojo/dojo/dojo.js” djConfig=”isDebug: true”></script><script type=”text/javascript”>dojo.require(“dojox.charting.Chart2D”);makeCharts = function(){var chart1 = new dojox.charting.Chart2D(“simplechart”);chart1.addPlot(“default”, {type: “Lines”});chart1.addPlot(“other”, {type: “Areas”, hAxis: “other x”, vAxis: “other y”});chart1.addPlot(“Grid”, {type: “Grid”, hAxis: “other x”, vAxis: “other y”,hMajorLines: true, hMinorLines: false, vMajorLines: true, vMinorLines: false});chart1.addAxis(“y”, {vertical: true});chart1.addAxis(“other x”, {leftBottom: false});chart1.addAxis(“other y”, {vertical: true, leftBottom: false, [...]
Filed under: Dojo | Leave a Comment »
Posted on August 8, 2008 by sharat
<html>
<head runat=”server”><meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″><title>Untitled 1</title><script type=”text/javascript” src= “../js/dojo/dojo/dojo.js” djConfig=”isDebug: true”></script><script type=”text/javascript”>dojo.require(“dojox.charting.Chart2D”);makeCharts = function(){var chart1 = new dojox.charting.Chart2D(“simplechart”);chart1.addPlot(“default”, {type: “Lines”});chart1.addPlot(“other”, {type: “Areas”, hAxis: “other x”, vAxis: “other y”});chart1.addAxis(“x”);chart1.addAxis(“y”, {vertical: true});chart1.addAxis(“other x”, {leftBottom: false});chart1.addAxis(“other y”, {vertical: true, leftBottom: false, max: 7, stroke: “green”, font: “normal normal bold 14pt Tahoma”, fontColor: “red”, majorTick: {color: [...]
Filed under: Dojo | Leave a Comment »
Posted on August 8, 2008 by sharat
<html>
<head runat=”server”><meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″><title>Untitled 1</title><script type=”text/javascript” src= “../js/dojo/dojo/dojo.js” djConfig=”isDebug: true”></script><script type=”text/javascript”>dojo.require(“dojox.charting.Chart2D”);makeCharts = function(){var chart1 = new dojox.charting.Chart2D(“simplechart”);chart1.addPlot(“default”, {type: “Lines”});chart1.addPlot(“other”, {type: “Areas”, hAxis: “other x”, vAxis: “other y”});chart1.addAxis(“x”);chart1.addAxis(“y”, {vertical: true});chart1.addAxis(“other x”, {leftBottom: false});chart1.addAxis(“other y”, {vertical: true, leftBottom: false});chart1.addSeries(“Series 1″, [1, 2, 2, 3, 4, 5, 5, 7]);chart1.addSeries(“Series 2″, [1, 1, 4, 2, 1, 6, 4, [...]
Filed under: Dojo | Leave a Comment »
Posted on August 8, 2008 by sharat
<html>
<head runat=”server”><meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″><title>Untitled 1</title><script type=”text/javascript” src= “../js/dojo/dojo/dojo.js” djConfig=”isDebug: true”></script><script type=”text/javascript”>dojo.require(“dojox.charting.Chart2D”);makeCharts = function(){ var chart1 = new dojox.charting.Chart2D(“simplechart”);chart1.addPlot(“default”, {type: “Lines”});chart1.addPlot(“other”, {type: “Areas”});chart1.addAxis(“x”);chart1.addAxis(“y”, {vertical: true});chart1.addSeries(“Series 1″, [1, 2, 2, 3, 4, 5, 5, 7]);chart1.addSeries(“Series 2″, [1, 1, 4, 2, 1, 6, 4, 3], {plot: “other”, stroke: {color:”blue”}, fill: “lightblue”});chart1.render(); };dojo.addOnLoad(makeCharts);</script></head><body><div id=”simplechart” style=”width: 250px; height: 150px;”></div></body></html>
Output:
Filed under: Dojo | Leave a Comment »
Posted on August 8, 2008 by sharat
<html>
<head runat=”server”><meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″><title>Untitled 1</title><script type=”text/javascript” src= “../js/dojo/dojo/dojo.js” djConfig=”isDebug: true”></script><script type=”text/javascript”>dojo.require(“dojox.charting.Chart2D”);makeCharts = function(){ var chart1 = new dojox.charting.Chart2D(“simplechart”); chart1.addPlot(“default”, {type: “Lines”, markers: true, tension:3, shadows: {dx: 2, dy: 2, dw: 2}}); chart1.addAxis(“x”); chart1.addAxis(“y”, {vertical: true}); chart1.addSeries(“Series 1″, [1, 2, 2, 3, 4, 5, 5, 7]); chart1.render();};dojo.addOnLoad(makeCharts);</script></head><body><div id=”simplechart” style=”width: 250px; height: 150px;”></div></body></html>
Output:
Filed under: Dojo | 1 Comment »
Posted on August 8, 2008 by sharat
<html>
<head runat=”server”><meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″><title>Untitled 1</title><script type=”text/javascript” src= “../js/dojo/dojo/dojo.js” djConfig=”isDebug: true”></script><script type=”text/javascript”>dojo.require(“dojox.charting.Chart2D”);makeCharts = function(){ var chart1 = new dojox.charting.Chart2D(“simplechart”); chart1.addPlot(“default”, {type: “Areas”}); chart1.addAxis(“x”); chart1.addAxis(“y”, {vertical: true}); chart1.addSeries(“Series 1″, [1, 2, 2, 3, 4, 5, 5, 7]); chart1.render();};dojo.addOnLoad(makeCharts);</script></head><body><div id=”simplechart” style=”width: 250px; height: 150px;”></div></body></html>
output:
Filed under: Dojo | Leave a Comment »
Posted on August 8, 2008 by sharat
<html>
<head runat=”server”><meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″><title>Untitled 1</title><script type=”text/javascript” src= “../js/dojo/dojo/dojo.js” djConfig=”isDebug: true”></script><script type=”text/javascript”>dojo.require(“dojox.charting.Chart2D”);makeCharts = function(){ var chart1 = new dojox.charting.Chart2D(“simplechart”); chart1.addPlot(“default”, {type: “Lines”}); chart1.addAxis(“x”); chart1.addAxis(“y”, {vertical: true}); chart1.addSeries(“Series 1″, [1, 2, 2, 3, 4, 5, 5, 7]); chart1.render();};dojo.addOnLoad(makeCharts);</script></head><body><div id=”simplechart” style=”width: 250px; height: 150px;”></div></body></html>
Output:
Filed under: Dojo | Leave a Comment »
Posted on August 5, 2008 by sharat
Make Fewer HTTP Requests
Use a Content Delivery Network
Add an Expires or a Cache-Control Header
Gzip Components
Put Stylesheets at the Top
Put Scripts at the Bottom
Avoid CSS Expressions
Make JavaScript and CSS External
Reduce DNS Lookups
Minify JavaScript and CSS
Avoid Redirects
Remove Duplicate Scripts
Configure ETags
Make Ajax Cacheable
Flush the Buffer Early
Use GET for AJAX Requests
Post-load Components
Preload Components
Reduce the Number of DOM Elements
Split Components [...]
Filed under: Performance | Leave a Comment »
Posted on August 5, 2008 by sharat
Automated Reviews
Automate the review where possible. A review conducted by a computer has several benefits:
Reduced manual cost of code reviews
Fast, consistent, and repeatable
Removes emotion from the reviews: pride, ego, and ownership need to be constantly recognized when conducting a review. When offering a critique you should take care to not to step on the author’s [...]
Filed under: Code Review | 1 Comment »
Posted on August 5, 2008 by sharat
Adherence to coding standards Writing to standards has several benefits, such as a shared vocabulary, which makes the code easier to reuse and maintain. One of the primary focuses of a code review is to ensure abidance with these norms. As you’ll see later, this benefit of a review is best derived in an automated [...]
Filed under: Code Review | Leave a Comment »
Posted on August 5, 2008 by sharat
Ask questions rather than make statements. A statement is accusatory. “You didn’t follow the standard here” is an attack—whether intentional or not. The question, “What was the reasoning behind the approached you used?” is seeking more information. Obviously, that question can’t be said with a sarcastic or condescending tone; but, done correctly, it can often [...]
Filed under: Code Review | Leave a Comment »
Posted on August 5, 2008 by sharat
1. Use Firebug or Firebug Lite
Firebug, an open source debugging extension for Firefox, is essential for JavaScript, HTML and CSS debugging. You can download it from the Firebug web site.
2. Logging
In Dojo logging, you can associate messages with severity, just like in log4j. The following code illustrates the five severity levels:
console.log(“Nothing happening”);console.debug(“Checking to make sure [...]
Filed under: Dojo | Leave a Comment »
Posted on August 5, 2008 by sharat
<!DOCTYPE html PUBLIC “-//W3C//DTD HTML 4.01//EN” “http://www.w3.org/TR/html4/strict.dtd”><html> <head> <title>Dojo</title> <!– load the dojo toolkit base –> <script type=”text/javascript” src= “dojo/dojo/dojo.js” djConfig=”parseOnLoad:true, isDebug:true”></script> <script type=”text/javascript”> // Load Dojo’s code relating to the Button widget dojo.require(“dijit.form.Button”); </script>
<script> function helloCallback(data,ioArgs) { alert(data); } function helloError(data, ioArgs) { alert(‘Error when retrieving data from the server!’); [...]
Filed under: Dojo | Leave a Comment »
Posted on August 5, 2008 by sharat
<!DOCTYPE html PUBLIC “-//W3C//DTD HTML 4.01//EN” “http://www.w3.org/TR/html4/strict.dtd”><html> <head> <title>Dojo</title> <!– load the dojo toolkit base –> <script type=”text/javascript” src= “dojo/dojo/dojo.js” djConfig=”parseOnLoad:true, isDebug:true”></script> <script type=”text/javascript”> // Load Dojo’s code relating to the Button widget dojo.require(“dijit.form.Button”); </script>
<script> function helloCallback(data,ioArgs) { alert(data); } function helloError(data, ioArgs) { alert(‘Error when retrieving data from the server!’); }</script>
<button [...]
Filed under: Dojo | Leave a Comment »
Posted on August 5, 2008 by sharat
<!DOCTYPE html PUBLIC “-//W3C//DTD HTML 4.01//EN” “http://www.w3.org/TR/html4/strict.dtd”><html> <head> <title>Dojo</title> <!– load the dojo toolkit base –> <script type=”text/javascript” src= “dojo/dojo/dojo.js” djConfig=”parseOnLoad:true, isDebug:true”></script> <script type=”text/javascript”> // Load Dojo’s code relating to the Button widget dojo.require(“dijit.form.Button”); </script>
<script> function helloCallback(data,ioArgs) { alert(data); } function helloError(data, ioArgs) { alert(‘Error when retrieving data from the server!’); [...]
Filed under: Dojo | Leave a Comment »
Posted on August 5, 2008 by sharat
<!DOCTYPE html PUBLIC “-//W3C//DTD HTML 4.01//EN” “http://www.w3.org/TR/html4/strict.dtd”><html> <head> <title>Dojo</title> <!– load the dojo toolkit base –> <script type=”text/javascript” src= “dojo/dojo/dojo.js” djConfig=”parseOnLoad:true, isDebug:true”></script> <script type=”text/javascript”> // Load Dojo’s code relating to the Button widget dojo.require(“dijit.form.Button”); </script>
<button dojoType=”dijit.form.Button” id=”helloButton”> Hello World! <script type=”dojo/method” event=”onClick”> alert(‘You pressed the button’); </script> </button> <style type=”text/css”> /* CSS [...]
Filed under: Dojo | Leave a Comment »