11/27/08

link web hay

Script Code example for php.
http://www.phpro.org/

Use regular expressions to validate/format a string

This is an impressive collection (that I found somehere on the Net) of various functions to validate or format string in Javascript. The code is very compact.

/****************************************************************
FILE: RegExpValidate.js
....

http://www.rgagnon.com/jsdetails/js-0063.html

PHP parse url like javascript

http://simplehtmldom.sourceforge.net/
http://www.phpro.org/examples/Parse-HTML-With-PHP-And-DOM.html

code:
$html = file_get_html('http://www.google.com/');
/*** a new dom object ***/
$dom = new domDocument;

/*** load the html into the object ***/
$dom->loadHTML($html);

/*** discard white space ***/
$dom->preserveWhiteSpace = false;

/*** the table by its tag name ***/
$tables = $dom->getElementsByTagName('table');

/*** get all rows from the table ***/
$rows = $tables->item(0)->getElementsByTagName('tr');

/*** loop over the table rows ***/
foreach ($rows as $row)
{
/*** get each column by tag name ***/
$cols = $row->getElementsByTagName('td');
/*** echo the values ***/
echo $cols->item(0)->nodeValue.'
'
;
echo
$cols->item(1)->nodeValue.'
'
;
echo
$cols->item(2)->nodeValue;
echo
'
'
;
}

Project Manager

Job description
Job title Project Manager

· Phân tích hệ thống, phân công nhiệm vụ cho các cá nhân trong dự án, làm việc với khách hàng, là người kết nối giữa khách hàng, các nhân viên dự án, các bộ phận khác có liên quan trong công ty.

· Lên kế hoạch thực hiện dự án, xác định các điểm quan trọng và các hành động trong dự án (Milestone, Activities…).

· Kiểm soát thực thi dự án.

· Hỗ trợ các nhân viên trong dự án khi cần thiết.

Job requirement
Detail job requirement


· Ba năm kinh nghiệm trong lĩnh vực lập trình Java.

· Một năm ở vị trí tương đương.

· Ngoại ngữ: Tiếng Anh

o Đọc hiểu: Tốt

o Nghe: Tốt

o Nói: Tốt

o Viết: Khá

· Quản trị: Có kỹ năng quản trị nhóm, làm việc với khách hàng, phân tích công việc, phân công nhiệm vụ, giao tiếp tốt.

· Phân tích hệ thống: Có khả năng phân tích, thiết kế hệ thống phần mềm, xác định rõ yêu cầu nghiệp vụ.

· Công nghệ

o Phần bắt buộc:

§ Hiểu biết tốt Java, J2EE, EJB, JDBC, JTA, JNDI, XML.

§ Nắm được UML, qui trình xây dựng phần mềm.

§ Hiểu biết về Web Service (WSDL, SOAP), Struts.

§ Hiểu biết về kiểm soát mã nguồn (CVS, SVN hoặc Visual SourceSafe), kiểm soát lỗi (Trac, Mantis,…).

o Ưu tiên:

§ Đã từng làm việc với các hệ CSDL (theo thứ tự ưu tiên): Oracle, MSSQL, MySQL.

§ Hiểu biết về các hệ điều hành UNIX, LINUX

§ Hiểu biết về BPEL, jBPL, Hibernate, SpringFramework, iBatis, JSR 168

§ Đã từng làm việc với Application Server của: Oracle, IBM Websphere, Web Logic.

Trong Lần Tái Ngộ



Tôi xin gởi về anh lời mừng tái ngộ
Mười mấy năm qua mà ngỡ như giấc chiêm bao
Ôi! giấc chiêm bao, lặng lẽ từng cơn tiếc, cơn đau
Ôi! giấc chiêm bao, chập chùng đại dương nhớ thương nhau

Tôi xin gởi về em lời mừng tái ngộ
Con mắt xưa em cười giờ in dấu chân chim
Tôi tóc xanh đã bồi hồi sợi tơ trắng sương đêm
Em có nghe trong lòng mình một ray rứt không tên?

Gặp lại nhau trên xứ người ngập hoa vàng
Những cánh hoa màu vàng của ngày đầu yêu đương
Ấp úng mãi thôi buổi hẹn xưa trong chiều hồng
Cũng những cánh hoa màu vàng, nhận rồi cho lại cho nhau

Gặp trên con phố giàu rực ánh đèn,
Cơn gió núi xa lạ nào còn làm chạnh lòng không em?
Có vẫn như xưa, hẹn hò nhau tuổi học trò
Bàn tay tìm bàn tay, mà ngẩn ngơ, rồi ngẩn ngơ ...

Thân thương lời trao nhau
Mừng ngày tái ngộ,
Một thoáng nhớ nhung điệu hò, giờ xa quá quê xưa,
Ôi! đã lâu, những giọt lệ cạn khô lắng trong tôi
Ôi! phút giây tái ngộ ... lạ lùng mưa cứ tuôn rơi

Tài Liệu tham khảo: The Best of Nhật Trường - 15 Tình Khúc Trần Thiện Thanh - Nhật Trường Production

Chèn code lên blog mà không cần mod trợ giúp

to insert a "<" you will have to type in: & l t; and for ">" type & g t; in YOUR html code

that should do the trick, the ampersand and the semi-colon are both required

11/26/08

RoR or Ruby on Rails

Với sự ra đời của RoR, Java cũng có một framework tương tự dựa trên Groovy script giúp lập trình viên Java viết web thật đơn giản & tiết kiệm thời gian trong khi vẫn vận dụng được toàn bộ sức mạnh từ Java.

Giới thiệu chút ít về Grails

RoR = Ruby on Rails +=+ Groovy on Rails = Grails
Groovy = script language for Java

1. Cài đặt:
Vì Grails là một web framework cho Java nên cần cài đặt JDK trước vào máy tính. Download tại : +a href="http://java.sun.com/javase/downloads/index.jsp" target="_blank"+http://java.sun.com/javase/downloads/index.jsp+/a+

Download Grails tại : +a href="http://grails.org/Download" target="_blank"+http://grails.org/Download+/a+
Unzip, đặt biến môi trường GRAILS_HOME đến thư mục chứa Grails , đặt đường dẫn GRAILS_HOME/bin vào biến hệ thống (Path)

Vậy là cài đặt xong!

2. Tạo một ứng dụng web với Grails :
Mở command line, gõ vào : grails create-app , enter project name "test" , lệnh này tạo ra một ứng dụng web ngay tại thư mục hiện hành, cấu trúc thư mục này như sau :

%PROJECT_HOME%
+ grails-app
+ conf ---+ location of configuration artifacts like data sources
+ controllers ---+ location of controller artifacts
+ domain ---+ location of domain classes
+ i18n ---+ location of message bundles for i18n
+ services ---+ location of services
+ taglib ---+ location of tag libraries
+ util ---+ location of special utility classes (e.g., codecs, etc.)
+ views ---+ location of views
+ layouts ---+ location of layouts
+ hibernate ---+ optional hibernate config
+ lib
+ spring ---+ optional spring config
+ src
+ groovy ---+ optional; location for Groovy source files
(of types other than those in grails-app/*)
+ java ---+ optional; location for Java source files
+ war
+ WEB-INF

Để test thử, vào thư mục "test" vừa được tạo, gõ tiếp lệnh : grails run-app, sau đó mở Browser : localhost:8080/test , sẽ hiện ra màn hình Welcome của Grails ! Vậy là đã tạo xong một ứng dụng web, thật đơn giản với Grails !
+img src="http://i75.photobucket.com/albums/i290/cndkhuong/th_console.gif" border="0" /+
Màn hình command line khi chạy Grails
+img src="http://i75.photobucket.com/albums/i290/cndkhuong/th_welcome.gif" border="0" /+
Kết quả khi view trong browser
3.Tạo một Controller :
Bắt đầu bằng command : grails create-controller, sau đó enter name = login, sau khi hoàn tất, ta sẽ có file LoginController.groovy trong thu mục test/grails-app/controller. Nếu run ứng dụng bằng grails run-app tại thời điểm này, ta sẽ thấy trong trang Welcome có một link đến LoginController vừa mới tạo
+img src="http://i75.photobucket.com/albums/i290/cndkhuong/th_action.gif" border="0" /+
Click link này sẽ dẫn đến một error không tìm được file index.jsp trong thư mục views . Mặc định Grails sẽ tạo một default action index rỗng trong mỗi controller vừa tạo ra và Grails cố tìm kiếm một file index.gsp (Groovy Server Page) tương ứng trong thư mục views. Để khắc phục error này, chúng ta chỉnh sửa file LoginController.groovy như sau :
class LoginController {
def defaultAction = 'login'

def login = {}
}
Đồng thời tạo một file tên login.gsp trong thư mục views/login với nội dung tạo một form login như sau :
+html+
+title+ Login Form +/title+
+body+
+form action="./login/loginAction"+
+table+
+tr+
+td colspan="2" align="CENTER" bgcolor="YELLOW"+Logon+/td+
+/tr+
+tr+
+td+Username : +/td+
+td++input type="text" name="txtUser"++/td+
+/tr+
+tr+
+td+Password : +/td+
+td++input type="password" name="pwdPass"++/td+
+/tr+
+tr+
+td colspan="2" align="CENTER"++input type="submit" value="Login"++/td+
+/tr+
+/table+
+/form+
+/body+
+/html+
+img src="http://i75.photobucket.com/albums/i290/cndkhuong/th_login.gif" border="0" /+
4.Giao tiếp Database
Grails sử dụng Hibernate kết nối Database, nhưng việc sử dụng rất đơn giản. Bây giờ cần xác định cần kết nối với Database nào, ở đây để đơn giản, chúng ta sử dụng Apache Derby (đã được tích hợp sẵn trong JDK 6). Đầu tiên copy file derby.jar đến thư mục lib của ứng dụng (tương tự copy file driver của các Database khác vào đây!). Sau đó định nghĩa lại Datasource trong test/grails-app/conf/DevelopmentDataSource.groovy
class DevelopmentDataSource {
boolean pooling = true
String dbCreate = "create-drop" // one of 'create', 'create-drop','update'
String url = "jdbc:derby:testdb;create=true"
String driverClassName = "org.apache.derby.jdbc.EmbeddedDriver"
String username = ""
String password = ""
}

Chú ý là Grails cấu hình datasource riêng cho develop, test & product tương ứng với tên file trong thư mục conf.
Giả sử cần tạo một table tên là TUSER phục vụ cho việc login , từ command line , tại thư mục test, gõ lệnh : grails create-domain-class, enter tên class là TUSER. Sau khi hoàn tất ta có file TUSER.groovy trong thư mục test/grails-app/domain, table này cần 2 field là username & password, chúng ta edit file TUSER.groovy như sau :
class TUSER {
String username
String password
}

Mặc định Grails tự động thêm primary key (+version field) cho mỗi table.
Để đơn giản hơn, chúng ta sẽ tự động insert một default user vào table, làm việc này bằng cách edit file test/grails-app/conf/ApplicationBootStrap.groovy
class ApplicationBootStrap {

def init = { servletContext -+
new TUSER(username:'cndkhuong', password:'cndkhuong').save()
}
def destroy = {
}
}
Như đã thấy trong login.gsp, ta cần tạo một actionLogin để xử lý việc này, thêm vào file LoginController.groovy
def login = {

}

def loginAction = {
def user = TUSER.findWhere(username:params['txtUser'], password:params['pwdPass'])
if(user) {
redirect(action:'success', params:params)
}
else
redirect(action:'failure', params:params)
}

def success = {render “Welcome ${params.txtUser}”}
def failure = {render “${params.txtUser} login failed!”}
Mã nguồn này chỉ select tương ứng username & password trong form từ table TUSER, nếu user tồn tại thì xuất ra câu welcome, ngược lại là login failed. Vì chúng ta đã insert tự động một dòng trong TUSER ngay khi chạy, nên ta có thể login bằng user này

+img src="http://i75.photobucket.com/albums/i290/cndkhuong/th_success.gif" border="0" /+
Chú ý redirect trên bao gồm luôn cả các param từ form, ngoài redirect, ta có thể sử dụng chain để chuyển toàn bộ đối tượng model... đọc thêm trên trang +a href="http://grails.org/" target="_blank"+http://grails.org/+/a+
Để deploy , ta sẽ dùng lệnh : grails war để tạo file *.war, copy file này lên thư mục webapps của Java webserver như Tomcat.
Trên đây là một bài giới thiệu nhỏ về Grails , có gì sai sót mong mọi người góp ý. Với việc sử dụng Grails, việc viết web sẽ dễ dàng hơn rất nhiều, đồng thời tận dụng được hoàn toàn sức mạnh của Java!
+a href="http://download.yousendit.com/B72D033D515EA4C2" target="_blank"+http://download.yousendit.com/B72D033D515EA4C2+/a+

Tài liệu đủ để các bạn viết một ứng dụng với Grails ! Groovy script khá dễ viết đối với lập trình viên Java, hơn nữa bạn có thể viết = Java, hoàn toàn sử dụng bình thường trong Grails !

Nếu muốn tìm hiểu thêm về Groovy script, quyển sách sau sẽ giúp bạn : +a href="http://download.yousendit.com/5288B29E0DE9627E" target="_blank"+http://download.yousendit.com/5288B29E0DE9627E+/a+

Chúc các bạn viết web với Grails thành công !

P.S : Grails có hỗ trợ để phát triển ứng dụng trên Eclipse rất dễ dàng ! Xem thêm trong ebook 1

chèn biểu tượng SKYPE

Trước bạn đọc hướng dẫn chèn biểu tượng Yahoo! Messenger vào blog hiển thị cho bạn bè biết bạn đang online tại đây (http://www.thuthuatblog.com/2007/05/...qua-yahoo.html ). Bây giờ chúng ta sẽ đề cập đến Skype, trình gọi điện thoại trực tuyến từ PC đến PC và từ PC đến Phone phổ biến nhất thế giới bên cạnh những tính năng thông thường của một trình tin nhắn tức thời (gửi message, hỗ trợ webcam). Nếu công ty của bạn hoạt động trong lĩnh vực thương mại điện tử hay dịch vụ đăng ký tên miền, hosting, việc thêm một biểu tượng hỗ trợ trực tuyến Skype không phải không có ích. Còn với blog, nếu bạn có Skype thì cứ đưa biểu tượng lên cho vui cửa vui nhà!


Việc đầu tiên bạn cần làm là cho phép hiển thị trạng thái trực tuyến trên web. Để thực hiện bạn đăng nhập Skype, chọn thực đơn Tools -> Options -> Privacy và đánh dấu chọn Allow my status to be shown on the web.

Tiếp theo bạn click vào địa chỉ http://www.skype.com/share/buttons/ và thực hiện theo các bước.


Bước 1: Nhập Skype Name (Tên mà bạn dùng để đăng nhập trên Skype).

Bước 2: Lựa chọn biểu tượng hoặc click vào link này để tạo biểu tượng.


Bước 3: Xem hiển thị trước.


Bước 4: Khi đã ưng ý thì chép phần mã nằm trong Copy & pase this code để dán vào HTML/JavaScript trên Blogger hay dán vào mã nguồn website của bạn.

Thêm biểu tượng hỗ trợ online qua Yahoo! Messenger

Sở hữu ngay tên miền CO.CC ngắn gọn, dễ nhớ, miễn phí, không bị chặn bởi nhà cung cấp VNPT...

Không một chatter (người tán gẫu trên mạng) Việt Nam nào mà không biết đến trình tin nhắn tức thời Yahoo! Messenger. Vậy làm thế nào để người đọc blog của bạn có thể biết bạn đang online mà tán gẫu hay đơn giản là để họ nhắn cho bạn vài dòng offline? Hãy làm tìm hiểu đoạn mã sau sẽ cho bạn một số lựa chọn khác nhau.

..a href="ymsgr:sendIM?YahooID" ... img border="0" src="http://opi.yahoo.com/online?u=YahooID&m=g&t=ImageNo&l=us"... ... a



Ở đây chúng ta lưu ý YahooID là nickname của bạn tại Yahoo. Ví dụ nickname của tôi là dv2n. ImageNo là một trong số: 0, 1, 2 tương ứng lần lượt với các hình bên dưới từ trên xuống mà bạn chọn.

linkrapid

http://bienx.webhop.net/rapid/index.php

11/25/08

JUnit Nỗi ám ảnh trong quá khứ

http://junit.sourceforge.net/doc/testinfected/testing.htm

Note: this article describes JUnit 3.8.x.

Testing is not closely integrated with development. This prevents you from measuring the progress of development- you can't tell when something starts working or when something stops working. Using JUnit you can cheaply and incrementally build a test suite that will help you measure your progress, spot unintended side effects, and focus your development efforts.

Contents

The Problem

Every programmer knows they should write tests for their code. Few do. The universal response to "Why not?" is "I'm in too much of a hurry." This quickly becomes a vicious cycle- the more pressure you feel, the fewer tests you write. The fewer tests you write, the less productive you are and the less stable your code becomes. The less productive and accurate you are, the more pressure you feel.

Programmers burn out from just such cycles. Breaking out requires an outside influence. We found the outside influence we needed in a simple testing framework that lets us do a little testing that makes a big difference.

The best way to convince you of the value of writing your own tests would be to sit down with you and do a bit of development. Along the way, we would encounter new bugs, catch them with tests, fix them, have them come back, fix them again, and so on. You would see the value of the immediate feedback you get from writing and saving and rerunning your own unit tests.

Unfortunately, this is an article, not an office overlooking charming old-town Zürich, with the bustle of medieval commerce outside and the thump of techno from the record store downstairs, so we'll have to simulate the process of development. We'll write a simple program and its tests, and show you the results of running the tests. This way you can get a feel for the process we use and advocate without having to pay for our presence.

Example

As you read, pay attention to the interplay of the code and the tests. The style here is to write a few lines of code, then a test that should run, or even better, to write a test that won't run, then write the code that will make it run.

The program we write will solve the problem of representing arithmetic with multiple currencies. Arithmetic between single currencies is trivial, you can just add the two amounts. Simple numbers suffice. You can ignore the presence of currencies altogether.

Things get more interesting once multiple currencies are involved. You cannot just convert one currency into another for doing arithmetic since there is no single conversion rate- you may need to compare the value of a portfolio at yesterday's rate and today's rate.

Let's start simple and define a class Money to represent a value in a single currency. We represent the amount by a simple int. To get full accuracy you would probably use double or java.math.BigDecimal to store arbitrary-precision signed decimal numbers. We represent a currency as a string holding the ISO three letter abbreviation (USD, CHF, etc.). In more complex implementations, currency might deserve its own object.

class Money {
private int fAmount;
private String fCurrency;
    public Money(int amount, String currency) {
fAmount= amount;
fCurrency= currency;
}

public int amount() {
return fAmount;
}

public String currency() {
return fCurrency;
}
}
When you add two Moneys of the same currency, the resulting Money has as its amount the sum of the other two amounts.
public Money add(Money m) {
return new Money(amount()+m.amount(), currency());
}
Now, instead of just coding on, we want to get immediate feedback and practice "code a little, test a little, code a little, test a little". To implement our tests we use the JUnit framework. To write tests you need to get the latest copy JUnit (or write your own equivalent- it's not so much work).

JUnit defines how to structure your test cases and provides the tools to run them. You implement a test in a subclass of TestCase. To test our Money implementation we therefore define MoneyTest as a subclass of TestCase. In Java, classes are contained in packages and we have to decide where to put MoneyTest. Our current practice is to put MoneyTest in the same package as the classes under test. In this way a test case has access to the package private methods. We add a test method testSimpleAdd, that will exercise the simple version of Money.add() above. A JUnit test method is an ordinary method without any parameters.

public class MoneyTest extends TestCase {
//…
public void testSimpleAdd() {
Money m12CHF= new Money(12, "CHF"); // (1)
Money m14CHF= new Money(14, "CHF");
Money expected= new Money(26, "CHF");
Money result= m12CHF.add(m14CHF); // (2)
Assert.assertTrue(expected.equals(result)); // (3)
}
}
The testSimpleAdd() test case consists of:
  1. Code which creates the objects we will interact with during the test. This testing context is commonly referred to as a test's fixture. All we need for the testSimpleAdd test are some Money objects.
  2. Code which exercises the objects in the fixture.
  3. Code which verifies the result.
Before we can verify the result we have to digress a little since we need a way to test that two Money objects are equal. The Java idiom to do so is to override the method equals defined in Object. Before we implement equals let's a write a test for equals in MoneyTest.
public void testEquals() {
Money m12CHF= new Money(12, "CHF");
Money m14CHF= new Money(14, "CHF");

Assert.assertTrue(!m12CHF.equals(null));
Assert.assertEquals(m12CHF, m12CHF);
Assert.assertEquals(m12CHF, new Money(12, "CHF")); // (1)
Assert.assertTrue(!m12CHF.equals(m14CHF));
}
The equals method in Object returns true when both objects are the same. However, Money is a value object. Two Monies are considered equal if they have the same currency and value. To test this property we have added a test (1) to verify that Monies are equal when they have the same value but are not the same object.

Next let's write the equals method in Money:

public boolean equals(Object anObject) {
if (anObject instanceof Money) {
Money aMoney= (Money)anObject;
return aMoney.currency().equals(currency())
&& amount() == aMoney.amount();
}
return false;
}
Since equals can receive any kind of object as its argument we first have to check its type before we cast it as a Money. As an aside, it is a recommended practice to also override the method hashCode whenever you override method equals. However, we want to get back to our test case.

With an equals method in hand we can verify the outcome of testSimpleAdd. In JUnit you do so by a calling Assert.assertTrue, which triggers a failure that is recorded by JUnit when the argument isn't true. Since assertions for equality are very common, there is also an Assert.assertEquals convenience method. In addition to testing for equality with equals, it reports the printed value of the two objects in the case they differ. This lets us immediately see why a test failed in a JUnit test result report. The value a string representation created by the toString converter method. There are other asertXXXX variants not discussed here.

Now that we have implemented two test cases we notice some code duplication for setting-up the tests. It would be nice to reuse some of this test set-up code. In other words, we would like to have a common fixture for running the tests. With JUnit you can do so by storing the fixture's objects in instance variables of your TestCase subclass and initialize them by overridding the setUp method. The symmetric operation to setUp is tearDown which you can override to clean up the test fixture at the end of a test. Each test runs in its own fixture and JUnit calls setUp and tearDown for each test so that there can be no side effects among test runs.

public class MoneyTest extends TestCase {
private Money f12CHF;
private Money f14CHF;

protected void setUp() {
f12CHF= new Money(12, "CHF");
f14CHF= new Money(14, "CHF");
}
}
We can rewrite the two test case methods, removing the common setup code:
public void testEquals() {
Assert.assertTrue(!f12CHF.equals(null));
Assert.assertEquals(f12CHF, f12CHF);
Assert.assertEquals(f12CHF, new Money(12, "CHF"));
Assert.assertTrue(!f12CHF.equals(f14CHF));
}

public void testSimpleAdd() {
Money expected= new Money(26, "CHF");
Money result= f12CHF.add(f14CHF);
Assert.assertTrue(expected.equals(result));
}
Two additional steps are needed to run the two test cases:
  1. define how to run an individual test case,
  2. define how to run a test suite.
JUnit supports two ways of running single tests:
  • static
  • dynamic
In the static way you override the runTest method inherited from TestCase and call the desired test case. A convenient way to do this is with an anonymous inner class. Note that each test must be given a name, so you can identify it if it fails.
TestCase test= new MoneyTest("simple add") {
public void runTest() {
testSimpleAdd();
}
};
A template method[1] in the superclass will make sure runTest is executed when the time comes.

The dynamic way to create a test case to be run uses reflection to implement runTest. It assumes the name of the test is the name of the test case method to invoke. It dynamically finds and invokes the test method. To invoke the testSimpleAdd test we therefore construct a MoneyTest as shown below:

TestCase test= new MoneyTest("testSimpleAdd");
The dynamic way is more compact to write but it is less static type safe. An error in the name of the test case goes unnoticed until you run it and get a NoSuchMethodException. Since both approaches have advantages, we decided to leave the choice of which to use up to you.

As the last step to getting both test cases to run together, we have to define a test suite. In JUnit this requires the definition of a static method called suite. The suite method is like a main method that is specialized to run tests. Inside suite you add the tests to be run to a TestSuite object and return it. A TestSuite can run a collection of tests. TestSuite and TestCase both implement an interface called Test which defines the methods to run a test. This enables the creation of test suites by composing arbitrary TestCases and TestSuites. In short TestSuite is a Composite [1]. The code below illustrates the creation of a test suite with the dynamic way to run a test.

public static Test suite() {
TestSuite suite= new TestSuite();
suite.addTest(new MoneyTest("testEquals"));
suite.addTest(new MoneyTest("testSimpleAdd"));
return suite;
}
Since JUnit 2.0 there is an even simpler dynamic way. You only pass the class with the tests to a TestSuite and it extracts the test methods automatically.

public static Test suite() {
return new TestSuite(MoneyTest.class);
}

Here is the corresponding code using the static way.

public static Test suite() {
TestSuite suite= new TestSuite();
suite.addTest(
new MoneyTest("money equals") {
protected void runTest() { testEquals(); }
}
);

suite.addTest(
new MoneyTest("simple add") {
protected void runTest() { testSimpleAdd(); }
}
);
return suite;
}
Now we are ready to run our tests. JUnit comes with a graphical interface to run tests. Type the name of your test class in the field at the top of the window. Press the Run button. While the test is run JUnit shows its progress with a progress bar below the input field. The bar is initially green but turns into red as soon as there is an unsuccessful test. Failed tests are shown in a list at the bottom. Figure 1 shows the TestRunner window after we run our trivial test suite.

Figure 1: A Successful Run

After having verified that the simple currency case works we move on to multiple currencies. As mentioned above the problem of mixed currency arithmetic is that there isn't a single exchange rate. To avoid this problem we introduce a MoneyBag which defers exchange rate conversions. For example adding 12 Swiss Francs to 14 US Dollars is represented as a bag containing the two Monies 12 CHF and 14 USD. Adding another 10 Swiss francs gives a bag with 22 CHF and 14 USD. We can later evaluate a MoneyBag with different exchange rates.

A MoneyBag is represented as a list of Monies and provides different constructors to create a MoneyBag. Note, that the constructors are package private since MoneyBags are created behind the scenes when doing currency arithmetic.

class MoneyBag {
private Vector fMonies= new Vector();

MoneyBag(Money m1, Money m2) {
appendMoney(m1);
appendMoney(m2);
}

MoneyBag(Money bag[]) {
for (int i= 0; i < bag.length; i++)
appendMoney(bag[i]);
}
}
The method appendMoney is an internal helper method that adds a Money to the list of Moneys and takes care of consolidating Monies with the same currency. MoneyBag also needs an equals method together with a corresponding test. We skip the implementation of equals and only show the testBagEquals method. In a first step we extend the fixture to include two MoneyBags.
protected void setUp() {
f12CHF= new Money(12, "CHF");
f14CHF= new Money(14, "CHF");
f7USD= new Money( 7, "USD");
f21USD= new Money(21, "USD");
fMB1= new MoneyBag(f12CHF, f7USD);
fMB2= new MoneyBag(f14CHF, f21USD);
}
With this fixture the testBagEquals test case becomes:
public void testBagEquals() {
Assert.assertTrue(!fMB1.equals(null));
Assert.assertEquals(fMB1, fMB1);
Assert.assertTrue(!fMB1.equals(f12CHF));
Assert.assertTrue(!f12CHF.equals(fMB1));
Assert.assertTrue(!fMB1.equals(fMB2));
}
Following "code a little, test a little" we run our extended test with JUnit and verify that we are still doing fine. With MoneyBag in hand, we can now fix the add method in Money.
public Money add(Money m) {
if (m.currency().equals(currency()) )
return new Money(amount()+m.amount(), currency());
return new MoneyBag(this, m);
}
As defined above this method will not compile since it expects a Money and not a MoneyBag as its return value. With the introduction of MoneyBag there are now two representations for Moneys which we would like to hide from the client code. To do so we introduce an interface IMoney that both representations implement. Here is the IMoney interface:
interface IMoney {
public abstract IMoney add(IMoney aMoney);
//…
}
To fully hide the different representations from the client we have to support arithmetic between all combinations of Moneys with MoneyBags. Before we code on, we therefore define a couple more test cases. The expected MoneyBag results use the convenience constructor shown above, initializing a MoneyBag from an array.
public void testMixedSimpleAdd() {
// [12 CHF] + [7 USD] == {[12 CHF][7 USD]}
Money bag[]= { f12CHF, f7USD };
MoneyBag expected= new MoneyBag(bag);
Assert.assertEquals(expected, f12CHF.add(f7USD));
}
The other tests follow the same pattern:
  • testBagSimpleAdd - to add a MoneyBag to a simple Money
  • testSimpleBagAdd - to add a simple Money to a MoneyBag
  • testBagBagAdd - to add two MoneyBags
  • Next, we extend our test suite accordingly:
    public static Test suite() {
    TestSuite suite= new TestSuite();
    suite.addTest(new MoneyTest("testMoneyEquals"));
    suite.addTest(new MoneyTest("testBagEquals"));
    suite.addTest(new MoneyTest("testSimpleAdd"));
    suite.addTest(new MoneyTest("testMixedSimpleAdd"));
    suite.addTest(new MoneyTest("testBagSimpleAdd"));
    suite.addTest(new MoneyTest("testSimpleBagAdd"));
    suite.addTest(new MoneyTest("testBagBagAdd"));
    return suite;
    }
    Having defined the test cases we can start to implement them. The implementation challenge here is dealing with all the different combinations of Money with MoneyBag. Double dispatch [2] is an elegant way to solve this problem. The idea behind double dispatch is to use an additional call to discover the kind of argument we are dealing with. We call a method on the argument with the name of the original method followed by the class name of the receiver. The add method in Money and MoneyBag becomes:
    class Money implements IMoney {
    public IMoney add(IMoney m) {
    return m.addMoney(this);
    }
    //…
    }
    class MoneyBag implements IMoney {
    public IMoney add(IMoney m) {
    return m.addMoneyBag(this);
    }
    //…
    }
    In order to get this to compile we need to extend the interface of IMoney with the two helper methods:
    interface IMoney {
    //…
    IMoney addMoney(Money aMoney);
    IMoney addMoneyBag(MoneyBag aMoneyBag);
    }
    To complete the implementation of double dispatch, we have to implement these methods in Money and MoneyBag. This is the implementation in Money.
    public IMoney addMoney(Money m) {
    if (m.currency().equals(currency()) )
    return new Money(amount()+m.amount(), currency());
    return new MoneyBag(this, m);
    }

    public IMoney addMoneyBag(MoneyBag s) {
    return s.addMoney(this);
    }
    Here is the implemenation in MoneyBag which assumes additional constructors to create a MoneyBag from a Money and a MoneyBag and from two MoneyBags.
    public IMoney addMoney(Money m) {
    return new MoneyBag(m, this);
    }

    public IMoney addMoneyBag(MoneyBag s) {
    return new MoneyBag(s, this);
    }
    We run the tests, and they pass. However, while reflecting on the implementation we discover another interesting case. What happens when as the result of an addition a MoneyBag turns into a bag with only one Money? For example, adding -12 CHF to a Moneybag holding 7 USD and 12 CHF results in a bag with just 7 USD. Obviously, such a bag should be equal with a single Money of 7 USD. To verify the problem let's implement a test case and run it.
    public void testSimplify() {
    // {[12 CHF][7 USD]} + [-12 CHF] == [7 USD]
    Money expected= new Money(7, "USD");
    Assert.assertEquals(expected, fMB1.add(new Money(-12, "CHF")));
    }
    When you are developing in this style you will often have a thought and turn immediately to writing a test, rather than going straight to the code.

    It comes to no surprise that our test run ends with a red progress bar indicating the failure. So we fix the code in MoneyBag to get back to a green state.

    public IMoney addMoney(Money m) {
    return (new MoneyBag(m, this)).simplify();
    }

    public IMoney addMoneyBag(MoneyBag s) {
    return (new MoneyBag(s, this)).simplify();
    }

    private IMoney simplify() {
    if (fMonies.size() == 1)
    return (IMoney)fMonies.firstElement()
    return this;
    }
    Now we run our tests again and voila we end up with green.

    The code above solves only a small portion of the multi-currency arithmetic problem. We have to represent different exchange rates, print formatting, and the other arithmetic operations, and do it all with reasonable speed. However, we hope you can see how you could develop the rest of the objects one test at a time- a little test, a little code, a little test, a little code.

    In particular, review how in the development above:

    • We wrote the first test, testSimpleAdd, immediately after we had written add(). In general, your development will go much smoother if you write tests a little at a time as you develop. It is at the moment that you are coding that you are imagining how that code will work. That's the perfect time to capture your thoughts in a test.
    • We refactored the existing tests, testSimpleAdd and testEqual, as soon as we introduced the common setUp code. Test code is just like model code in working best if it is factored well. When you see you have the same test code in two places, try to find a way to refactor it so it only appears once.
    • We created a suite method, then extended it when we applied Double Dispatch. Keeping old tests running is just as important as making new ones run. The ideal is to always run all of your tests. Sometimes that will be too slow to do 10 times an hour. Make sure you run all of your tests at least daily.
    • We created a new test immediately when we thought of the requirement that a one element MoneyBag should just return its element. It can be difficult to learn to switch gears like this, but we have found it valuable. When you are struck by an idea of what your system should do, defer thinking about the implementation. Instead, first write the test. Then run it (you never know, it might already work). Then work on the implementation.

    Testing Practices

    Martin Fowler makes this easy for you. He says, "Whenever you are tempted to type something into a print statement or a debugger expression, write it as a test instead." At first you will find that you have to create a new fixtures all the time, and testing will seem to slow you down a little. Soon, however, you will begin reusing your library of fixtures and new tests will usually be as simple as adding a method to an existing TestCase subclass.

    You can always write more tests. However, you will quickly find that only a fraction of the tests you can imagine are actually useful. What you want is to write tests that fail even though you think they should work, or tests that succeed even though you think they should fail. Another way to think of it is in cost/benefit terms. You want to write tests that will pay you back with information.

    Here are a couple of the times that you will receive a reasonable return on your testing investment:

    • During Development- When you need to add new functionality to the system, write the tests first. Then, you will be done developing when the test runs.
    • During Debugging- When someone discovers a defect in your code, first write a test that will succeed if the code is working. Then debug until the test succeeds.
    One word of caution about your tests. Once you get them running, make sure they stay running. There is a huge difference between having your suite running and having it broken. Ideally, you would run every test in your suite every time you change a method. Practically, your suite will soon grow too large to run all the time. Try to optimize your setup code so you can run all the tests. Or, at the very least, create special suites that contain all the tests that might possibly be affected by your current development. Then, run the suite every time you compile. And make sure you run every test at least once a day: overnight, during lunch, during one of those long meetings….

    Conclusion

    This article only scratches the surface of testing. However, it focuses on a style of testing that with a remarkably small investment will make you a faster, more productive, more predictable, and less stressed developer.

    Once you've been test infected, your attitude toward development is likely to change. Here are some of the changes we have noticed:

    There is a huge difference between tests that are all running correctly and tests that aren't. Part of being test infected is not being able to go home if your tests aren't 100%. If you run your suite ten or a hundred times an hour, though, you won't be able to create enough havoc to make you late for supper.

    Sometimes you just won't feel like writing tests, especially at first. Don't. However, pay attention to how much more trouble you get into, how much more time you spend debugging, and how much more stress you feel when you don't have tests. We have been amazed at how much more fun programming is and how much more aggressive we are willing to be and how much less stress we feel when we are supported by tests. The difference is dramatic enough to keep us writing tests even when we don't feel like it.

    You will be able to refactor much more aggressively once you have the tests. You won't understand at first just how much you can do, though. Try to catch yourself saying, "Oh, I see, I should have designed this thus and so. I can't change it now. I don't want to break anything." When you say this, save a copy of your current code and give yourself a couple of hours to clean up. (This part works best you can get a buddy to look over your shoulder while you work.) Make your changes, all the while running your tests. You will be surprised at how much ground you can cover in a couple of hours if you aren't worrying every second about what you might be breaking.

    For example, we switched from the Vector-based implementation of MoneyBag to one based on HashTable. We were able to make the switch very quickly and confidently because we had so many tests to rely on. If the tests all worked, we were sure we hadn't changed the answers the system produced at all.

    You will want to get the rest of your team writing tests. The best way we have found to spread the test infection is through direct contact. The next time someone asks you for help debugging, get them to talk about the problem in terms of a fixture and expected results. Then say, "I'd like to write down what you just told me in a form we can use." Have them watch while you write one little test. Run it. Fix it. Write another. Pretty soon they will be writing their own.

    So- give JUnit a try. If you make it better, please send us the changes so we can spread them around. Our next article will double click on the JUnit framework itself. We will show you how it is constructed, and talk a little about our philosophy of framework development.

    We would like to thank Martin Fowler, as good a programmer as any analyst can ever hope to be, for his helpful comments in spite of being subjected to early versions of JUnit.

    References

    1. Gamma, E., et al. Design Patterns: Elements of Reusable Object-Oriented Software, Addison-Wesley, Reading, MA, 1995
    2. Beck, K. Smalltalk Best Practice Patterns, Prentice Hall, 1996

    XStream convert objects to XML and back again.

    http://xstream.codehaus.org/tutorial.html

    Create classes to be serialized

    Here's a couple of simple classes. XStream can convert instances of these to XML and back again.

    public class Person {
    private String firstname;
    private String lastname;
    private PhoneNumber phone;
    private PhoneNumber fax;
    // ... constructors and methods
    }

    public class PhoneNumber {
    private int code;
    private String number;
    // ... constructors and methods
    }

    Note: Notice that the fields are private. XStream doesn't care about the visibility of the fields. No getters or setters are needed. Also, XStream does not limit you to having a default constructor.

    Initializing XStream

    To use XStream, simply instantiate the XStream class:

    XStream xstream = new XStream();

    You require xstream-[version].jar and xpp3-[version].jar in the classpath. XPP3 is a very fast XML pull-parser implementation. If you do not want to include this dependency, you can use a standard JAXP DOM parser instead:

    XStream xstream = new XStream(new DomDriver()); // does not require XPP3 library

    Note: This class is a simple facade designed for common operations. For more flexibility you may choose to create your own facade that behaves differently.

    Now, to make the XML outputted by XStream more concise, you can create aliases for your custom class names to XML element names. This is the only type of mapping required to use XStream and even this is optional.

    xstream.alias("person", Person.class);
    xstream.alias("phonenumber", PhoneNumber.class);

    Note: This is an optional step. Without it XStream would work fine, but the XML element names would contain the fully qualified name of each class (including package) which would bulk up the XML a bit. See the Alias Tutorial a more complete introduction.

    Serializing an object to XML

    Let's create an instance of Person and populate its fields:

    Person joe = new Person("Joe", "Walnes");
    joe.setPhone(new PhoneNumber(123, "1234-456"));

    Deserializing an object back from XML

    To reconstruct an object, purely from the XML:

    Person newJoe = (Person)xstream.fromXML(xml);

    And that's how simple XStream is!

    Summary

    To recap:

    • Create element name to class name aliases for any custom classes using xstream.alias(String elementName, Class cls);
    • Convert an object to XML using xstream.toXML(Object obj);
    • Convert XML back to an object using xstream.fromXML(String xml);

    joe.setFax(new PhoneNumber(123, "9999-999"));

    Now, to convert it to XML, all you have to do is make a simple call to XStream:

    String xml = xstream.toXML(joe);

    11/21/08

    Components with ajax support JSF

    JSF ajax frameworks
    • JSF Avatar
    • Ajax Anywhere
    • Ajax4jsf
    • IceFaces
    • Ajax enabled myFaces components

    11/20/08

    Website for ajax tool

    http://www.javapassion.com/ajaxcodecamp/

    In general, the contents (presentation, hands-on labs, and homework's) will be ready on the dates specified below. Due to the fast pacing nature of the Ajax technology, the contents are constantly being changed and improved even after the dates specified.

    Changes made to the 3rd session: New topics added - Mashup, Dojo Widgets, Echo2, Ajax security.
    1. Ajax Basics & Development Tools (July 30th, 2008, Week #1) (homework #1)
    2. JavaScript Basics and DOM APIs (Aug. 15th, 2008, Week #2) (homework #2)
    3. Web 2.0 Frameworks and Toolkits (Aug. 30th, Week #3) - homework is optional
    4. Ajax Application Examples (Sep. 26th, 2008, Week #4) (homework #3)
    5. Dojo Toolkit Basics (Oct. 3rd, 2008, Week #5) (homework #4)
    6. Dojo Toolkit Wigets (Oct. 17th, 2008, Week #6) (homework #5)
    7. Dojo Toolkit Advanced We are going to skip this - there is no homework
    8. ProtoType (Oct. 24th, 2008, Week #8) (homework #6)
    9. JSON (to be determined, 2008, Week #9) (homework #7)
    10. jMaki Basics (to be determined, 2008, Week #10) (homework #8)
    11. jMaki Eventt Model (to be determined) - there is no homework
    12. jMaki Mashup (to be determined, 2008, Week #11) - there is no homework
    13. jMaki Examples (to be determined) - there is no homework
    14. Direct Web Remoting (DWR) (to be determined, Week #12) (homework #9)
    15. Google Web Toolkit (to be determined, 2008, Week #13) (homework #10)
    16. JavaServer Faces (JSF) and Ajax Integration (to be determined, 2008, Week #14) - there is no homework
    17. Echo2 as Ajax-enabled Web App framework (to be determined, 2008, Week #15) (homework #11)
    18. CSS (to be determined, 2008, Week #16) (homework #12)
    19. Portlet/Portals and Ajax - (to be determined, 2008, Week #17) - there is no homework
    20. JavaScript Best Practices (to be determined, 2008, Week #18 - end of the course) (homework #13)

    DWR: Easy Ajax for Java

    Link : click here

    Writing JavaScript with DWR

    DWR generates Javascript code that is similar to the Java code that exported using dwr.xml.

    The biggest challenge in creating a remote interface to match some Java code across Ajax is the (usually) asynchronous nature of Ajax, compared to the synchronous nature of a normal Java call.

    DWR solves this problem by introducing a callback function that is called when the data is returned from the server.

    There are 2 recommended ways to make a call using DWR. Either using by appending a callback function to the parameter list or by appending a call meta data object.

    It is also possible to put the callback function at the start of the parameter list, however this option is not advised because there are some issues when dealing with automatic http objects (see "Alternative Method"). This method mostly remains for backwards compatibility.

    11/19/08

    Tool for web developer!

    Firebug

    Firebug - screen shot.

    Firebug is an extension for the Mozilla Firefox browser that allows you to debug and inspect HTML, CSS, the Document Object Model (DOM) and JavaScript. Though it has many strong features, it’s most known for revolutionizing the way developers debug and profile JavaScript code.

    For example, before Firebug, many developers would use the alert() function to see what a variable contains or to find what line the code breaks. With Firebug enabled, you’re told specifically what the error is and which line it comes from. Firebug is an excellent tool for AJAX application developers because it lets you explore and perform on-the-fly edits on the DOM to see what happens when you manipulate Web page elements after a user action.

    Aside from its popular JavaScript and DOM functionalities, Firebug can also log network activity to allow you to see detailed results of HTTP connections, inspect and edit HTML on the fly and debug and visualize your CSS.

    Further Reading

    Web Developer

    Web Developer - screen shot.

    The Web Developer extension (for the Firefox, Flock and SeaMonkey Web browsers) is an add-on that adds a tool bar with a menu of options for debugging and inspecting Web pages. It has a ton of features, my favorite being the View CSS Information option (CSS >> View Style Information, or Control + Shift + Y on Windows) which makes a page element clickable and shows you CSS selectors that affect that particular page element. It’s helpful for exploring and understanding large CSS files and projects that you’re unfamiliar with (such as a new open-source content management system).

    It has built-in options for syntax validation for popular Web services, such as W3C’s CSS Validator and HiSoftware’s Web Content Accessibility Report, for your convenience. It has many other useful features, such as disable options for CSS, JavaScript and images, to test for degradation and progressive enhancement; a Forms menu with options for working with Web forms; Display Div Order and Display Block Size options to help you visualize the layout; and so much more.

    YSlow

    YSlow - screen shot.

    YSlow is a Firefox extension created by Yahoo! developers that integrates with Firebug (therefore you need to have Firebug enabled for it to work). YSlow analyzes a Web page for front-end performance and, in its simplest usage, gives you a letter grade (A being the best and F being the poorest) for each of the best practices for speeding up your website.

    YSlow also allows you to inspect in detail things that are essential for a high-performance website. For example, the Stats view gives you the total size of a Web page and a summary of items that are loaded when the Web page is requested (i.e. style sheets, JavaScript files, Flash objects and images), so that you can hunt down the bottlenecks that cause a Web page to load slowly.

    The Components view outlines every single component of a Web page in tabular format and allows you to inspect it to see attributes such as size, expiration date (for cached files), whether it uses server-side compression (Gzip) and response time (how long the component took to load).

    Further Reading

    Internet Explorer Web Developer Toolbar

    Internet Explorer Web Developer Toolbar - screen shot.

    If you need similar functionality to that of Firebug and Web Developer for Firefox, but want to debug, inspect and tune your Web pages and applications on the Internet Explorer browser, check out the Internet Explorer Web Developer Toolbar. The IE Web Developer Toolbar, when enabled, opens a toggle-able pane located at the bottom of the Web browser, giving you access to many helpful options for exploring Web page components.

    For example, you can experiment to see how page elements work by editing the Web page’s DOM and HTML directly in the browser, allowing you to quickly change and edit DOM elements to see what happens when you perform certain actions or modify certain parts of the code. You can also debug, test and inspect JavaScript with the IE Web Developer Toolbar, giving you options for setting breakpoints, seeing the call stack and exploring variable attributes.

    It has a ton of other helpful features, such as selectively disabling IE settings (to see how your Web pages degrade in IE); the ability to view the HTML and CSS source of any Web page with syntax-highlighting; and an in-browser ruler to help you measure things on a Web page.

    Further Reading

    Fiddler Web Debugger

    Fiddler Web Debugger - screen shot.

    Fiddler is an Internet Explorer extension that analyzes and profiles a Web page’s HTTP traffic. If you’ve ever wanted to know exactly what happens when a client requests a Web page, Fiddler is the tool that’ll help you do the job. The HTTP Statistics view exposes all components and files required to generate a particular page, giving you details such as the total number of HTTP requests, total page weight, HTTP response headers and cache expiration.

    Fiddler permits you to set up breakpoints, allowing you to step through and edit HTTP traffic (to see how it would affect your Web page), a useful feature for analyzing AJAX-based interaction and potential security flaws in a Web application. Perhaps what makes Fiddler so powerful is its extensibility, allowing you to create your own scripts (or import other developers’ scripts) to perform certain tasks or make interface modifications to the extension itself.

    Further Reading

    DebugBar

    DebugBar - screen shot.

    DebugBar is a debugging in-browser extension for the Internet Explorer browser. It has many helpful features, such as the ability to send a Web page screenshot via email, a color picker, the ability to view both the original and interpreted code (i.e. if you use JavaScript to manipulate the styles of a DOM object, then you can see the interpreted HTML source code of that manipulation) and a Console API (after installing Companion.JS) to help you gain information through a command-line interface about particular components of a Web page.

    DebugBar is free for personal and educational use, but you are required to buy a license if you use it for commercial purposes.

    HttpWatch

    HttpWatch - screen shot.

    HttpWatch is another HTTP traffic viewer and debugger for Firefox and Internet Explorer that is similar to Fiddler. It has many unique features and a more intuitive, less intimidating interface than Fiddler. Some notable features are the ability to generate request-level time charts (useful for documentation and presentation purposes); decryption of HTTPS traffic to help you debug, inspect and tweak your secure SSL-based connections; and the ability to export captured data to XML and CSV formats for importing into spreadsheet applications such as Microsoft Excel or Google Spreadsheets.

    HTTPWatch has a Basic edition, which is free, and a Professional edition, which has more options. Check out the comparison table between the two editions to see the exact differences.

    Live HTTP Headers

    LiveHTTPHeaders - screen shot,

    Live HTTP Headers is a Firefox extension that allows you to inspect HTTP request and response headers. Exploring HTTP headers allows you to debug Web applications, glean some information about the website’s server and inspect cookies sent to the client requesting the page.

    For example, the Server response header gives you a website’s HTTP server type (Apache, IIS, nginx, etc.), the HTTP server version and the operating system (though server administrators can remove or limit the information you see for security purposes).

    Web Accessibility Toolbar

    Web Accessibility Toolbar - screen shot.

    The Web Accessibility Toolbar is a freeware extension for Internet Explorer and Opera that gives you a slew of options for quickly evaluating and analyzing your Web content’s accessibility. It has validation options for submitting your URL to content accessibility web services such as Juicy Studio tools, a grayscale converter to simulate the user experience of individuals with color-blindness and poor eyesight, and a search function for particular page structures (e.g. finding list objects and unordered lists).

    Other useful tools released by Vision Australia are the Colour Contrast Analyser, which analyzes the contrast of foreground and background colors for readability, and the Complex Table Mark-Up (or Com Tab) Toolbar, which can help you understand (and construct) complex tables that are usable by non-traditional Web browsers (such as screen readers).

    Further Reading

    Fangs

    Fangs - screen shot.

    Fangs is an in-browser tool for Firefox that emulates what a screen reader “sees” when visiting a Web page. Its function is simple: to output a transcript of what a screen reader will read out to a user when a Web page is visited. It’s a helpful tool for quickly analyzing if you’ve structured your content effectively so that it’s understandable and usable by vision-impaired individuals, without forcing you to learn to use (and purchase) a screen-reader application such as JAWS or Windows Eyes.

    Further Reading

    Venkman JavaScript Debugger

    Venkman JavaScript Debugger - screen shot

    Venkman is the codename for Mozilla’s very own JavaScript debugging environment. It is available as an add-on that can be used to extend browsers such as Firefox, Netscape, and SeaMonkey. It is a robust environment for doing complex JavaScript debugging and troubleshooting. The Console view gives you a command-line interface for interacting with the debugger. It has an excellent Stack view feature that allows you to step through active functions when it reaches breakpoints.

    Further Reading

    ColorZilla

    ColorZilla - screen shot.

    ColorZilla is an incredibly simple — but very useful — extension for Firefox. If you’ve ever wanted to determine what colors are used on a Web page, ColorZilla is the tool for the job. It adds an eyedropper icon to the bottom-left corner of Firefox.

    Clicking on the eyedropper icon makes objects on the Web page clickable, and upon clicking a particular section of a Web page, it outputs the hexadecimal, RGB and hue/saturation values of that area . Before ColorZilla, you might have pasted a screen capture of a Web page into a graphics editor like Photoshop and then used the eyedropper tool in the editor to sample colors. ColorZilla saves you time and streamlines color-sampling processes.

    FireShot

    FireShot - screen shot.

    FireShot is an in-browser tool for Firefox and Internet Explorer that allows you to take screenshots and then annotate, edit, organize and export them. Screen-grabbing is a common activity for Web developers to document previews of Web application prototypes and share them with clients, and FireShot gives you a feature-packed in-browser option to manage and streamline your screenshot needs.

    Web Inspector

    Web Inspector - screen shot.

    Web Inspector is part of the Webkit open-source browser engine project. It’s an ultra-sleek tool for inspecting the DOM hierarchy in a separate, compact HUD-style window. You can easily search the DOM, explore the DOM tree (hierarchy) and have a useful interface for isolating DOM sub-trees and nodes so that you can focus on particular sections of a Web page. The Web Inspector also provides you with a Style pane to explore CSS rules applied to particular page elements.

    FireFTP

    FireFTP - screen shot.

    FireFTP is a free, cross-platform Firefox extension for FTP’ing files. It offers several advantages to stand-alone FTP applications, such as its operating system-independent requirements. What’s exceptional about FireFTP is that even though it is an in-browser (and free!) application, it has all the features you would expect from a standalone FTP application, such as support for secure (SSL, TLS, SFTP) protocols, a synchronization feature to sync up local and remote files, and directory comparison to help you see what files are missing or different between two directories and much more.

    What’s your favorite in-browser tool?

    There is an overwhelming amount of in-browser tools for Web development out there. Some are specific to particular Web technologies and set-ups (such as FirePHP for PHP developers, SQLite Manager for developers using SQLite databases, and Opera Dragonfly for developers who prefer using the Opera browser). If your favorite tool isn’t on the list, let us know in the comments section why it’s your favorite and why we should check it out.

    About the Author

    Jacob Gube is a Web developer/designer and author of Six Revisions, a blog on Web development and design. If you want to connect with the author, you can follow him on Twitter.

    Thủ thuật php

    PHP với MYSQL + Tiếng việt:

    varchar(100) utf8_general_ci


    PHP với MYSQL + Timestamp

    date("d/m/Y",strtotime($row['date_create']));?>

    11/17/08

    15 useful project management applications

    Below are 15 useful project management applications, almost all of which are targeted directly at Web developers, designers (both Web and print) and other creative types. The last one is not geared specifically to creative types but is the most unique project management application I’ve found and is included on that basis as well as because of its potential usefulness for designers and developers.

    Also consider our previous article:

    1. Basic Project Management Apps

    These applications are marketed specifically for project management. Most include things like task-, team-, and goal-management features. Some include additional features such as time tracking and invoicing.

    Lighthouse

    Lighthouse is a bug- and issue-tracking app that tracks timelines and milestones, integrates with your email client and more. You can update tickets through your inbox, manage your beta testing (by making tickets and milestones public), integrate it with subversion and manage and prioritize your tickets.

    Lighthouse Dashboard Screenshot

    Project creation is simple; only a project title and description is required. Once a project is created, tickets, messages and milestones can be entered. Ticket creation can be done by email (the email address to send tickets to is displayed on the “Tickets” page). You can show tickets based on a variety of criteria, including date, state (open or closed) and who is responsible for them. Message creation is easier than email, and you can attach files up to 50 MB in size. When you create a milestone you simply enter the title, the date it’s due and the goals or focus for that particular milestone. It doesn’t get much simpler than that.

    Permissions are easy to set, and you can invite users by email. One of the best features of Lighthouse is its Beacon and API integration. With the API, you can customize tickets, projects, changesets, milestones, messages and more. Integrate it with other services (such as Google Calendar), or make desktop applications that use Lighthouse. The APIs make Lighthouse infinitely more useful, because you can really customize it to fit your current workflow.

    Lighthouse Milestone Creation Screenshot

    Lighthouse is great for Web development teams (or individuals) and has a very easy-to-use interface. They have paid and free plans, all of which include unlimited open-source projects. The free plan lets you manage one private project with up to two people on the account. The paid plans range from $10 per month for the Personal plan (with up to 3 projects, 10 users and 100 MB of file upload storage space) to $120 per month for the Platinum plan (with unlimited projects, up to 50 public projects, unlimited users and 30 GB of file upload space).

    When combined with a subversion app, Lighthouse provides a pretty complete project management app for developers. Subversion integration is pretty straightforward, and the help file provided gives complete step-by-step instructions for setup.

    Springloops

    Springloops is another subversion browser that integrates project management. It counts a unique AJAX code browser and Basecamp integration as among its features.

    Springloops Dashboard Screenshot

    The Springloops interface is very intuitive and easy to use. Tabbed navigation provides access to the log, source and deployment information. Adding users is done via email, along with the ability to create usernames and passwords (making it easier and faster for them to get on board with a project). Creating new projects is simple, with a few different templates available (including a starter template). You can migrate an existing repository into Springloops as well (including plain text dumps). For added project management ability, Springloops can be integrated with Basecamp.

    Springloops Source Browser Screenshot

    Springloops has a number of plans available, both paid and free. The free plan includes 25 MB of space, 3 projects, 3 deployments per day (using FTP or SFTP connections), roll-back capabilities, Basecamp integration, subversion and an unlimited number of users. The paid plans range from the “Flowerpot” plan at $9 per month (including 1 GB of space and 10 projects) to the “Forest” plan at $96 per month (including 18 GB of storage, unlimited projects, automatic deployment and secure SSL encryption). All of the paid plans include a free 30-day trial.

    CreativePro Office

    CreativePro Office offers complete office management tools. CreativePro Office is completely free, setting it apart from the other apps here.

    CreativePro Office Dashboard Screenshot

    CreativePro Office has the usual tabbed navigation, including tabs for clients, projects, time sheets, finances and team members. The dashboard presents a calendar with upcoming events, a list of your projects, outstanding invoices, notes and search functionality. Project creation is a bit more in-depth than with most other apps listed here, though only a client name and project name is required (you can also fill in a project URL, description or comments, category, date range, status, contacts and tags). Client tracking is integrated, making this handy for those who work with lots of different clients, and it could even serve as a simple CRM program, depending on your needs.

    CreativePro Office Finance Tab Screenshot

    Integrated invoices and financial information is handy, and the finances page gives you options for viewing and creating invoices, expenses and reports.

    CreativePro Office is very robust for a completely free application and is definitely worth checking out before shelling out for an expensive paid solution.

    Jumpchart

    Jumpchart is a website planning application that allows you to plan the navigation of your website by creating, dragging and dropping pages into the plan. You can also add text and formatting to pages and then export your CSS files and site map when you’re finished.

    Jumpchart Home Page Screenshot

    This is a great planning app for Web designers, though it’s not strictly a project management application. You can add comments to each page, which could serve to keep track of tasks related to specific pages. More traditional project management functions could be kept track of in the text of each mockup page or through the comments. The mockup and planning capabilities of Jumpchart make it worth using, even if hacks are needed to make it more conducive to full project management.

    Jumpchart Add Sub-Page Screenshot

    The free Jumpchart plan offers 1 project with 1 MB of storage and a maximum of 10 pages and 2 users. The paid plans range from the Simple plan at $5 per month (including up to 5 projects, with 25 pages and 5 users per project, and 100 MB of storage) to the Deluxe plan at $50 per month (including up to 30 projects with unlimited pages and users and 5000 MB of storage).

    No Kahuna

    No Kahuna is a simple project management and issue-tracking platform. It’s very straightforward and easy to use, with an excellent user interface. Features include task and activity tracking and collaboration tools.

    No Kahuna Activity Page Screenshot

    No Kahuna is excellent for basic project management and ticket tracking. There aren’t a ton of features, which can be a very good thing. It’s very quick to get started, also a big plus.

    No Kahuna Project Info Screenshot

    There are free accounts available that include unlimited projects and users. However, if your projects accumulate more than 30 open tasks, you will need to upgrade. Paid options are reasonably priced, ranging from 3 projects for $9 per month up to 100 projects for $99 per month. Open-source projects are always free, no matter how many open tasks you have.

    Basecamp

    Basecamp is often considered to be the best project management and collaboration platform out there. Its features are impressive: to-do lists, file sharing, message boards, milestones, time tracking, project overviews and commenting.

    Basecamp Dashboard Screenshot

    The user interface is definitely one of the best out there, and because of its popularity, tons of other companies are making products that integrate with Basecamp, extending its capabilities.

    Basecamp Time Tracking Screenshot

    Pricing is reasonable, though it’s definitely not the cheapest solution out there. The Basic plan is only $24 per month and includes up to 15 active projects, 3 GB of file storage and unlimited clients and users. The Max plan is a hefty $149 per month, but includes unlimited projects, 50 GB of file storage, time tracking, SSL security and a free Campfire Premium account.

    2. Wiki-Based Project Management

    Wikis are another option for project management, whether you use one instead of a basic project management application or in addition to one. One of the solutions below is geared to complete project management and includes additional features, while the other is just a wiki and is suitable for project management and other uses.

    Trac Project

    Trac Project is a project management app that is based on wiki functionality. It also includes a subversion browser, a timeline, ticket tracking, a road map (showing milestones and the number of current open and closed tickets) and builds status tracking.

    Trac Project Main Wiki Page Screenshot

    One of Trac’s best features is the range of plug-ins available for it. There are plug-ins for Web administration, authentication, code documentation, file management, ticketing, testing, user management and version control.

    Trac Project Ticket Management Screenshot

    Another big advantage: Trac is free and licensed under a modified BSD license.

    PBwiki

    PBwiki is one of the easiest free wikis out there to use. You can share files with other users, set access controls for individual pages and folders, add other users to your wiki, monitor and track version changes and more.

    PBwiki Main Page Screenshot

    Setup is quick and easy and can be done in less than a minute. The PBwiki interface is very intuitive, and there is virtually no learning curve. Creating folders and pages is straightforward, as is editing existing pages. You can also comment on each page, and get a printable version with a single click.

    PBwiki Page Creation Screenshot

    There are multiple themes you can choose from for the design, as well as templates for individual page content (or you can start from scratch). There are a few different plans available, both paid and free. The free plan allows from 1 to 3 users. Paid plans range from $4 per month per user (if you have more than 10,000 users) to $8 per month per user (for 4 to 999 users).

    3. Bug and Ticket Tracking

    Any time you work on a Web application or website, there are going to be bugs and issues that crop up. While some basic project management applications have built-in ticket tracking, others don’t, and sometimes the built-in solution doesn’t quite meet your needs (either because it’s too robust or is missing key features).

    16bugs

    16bugs is a very simple bug-tracking system. Its main advantage is the color-coding system used for different types of information (like updates, comments and closed tickets).

    16bugs Activity Report Screenshot

    Setup is quick and easy. The user interface is easy to figure out. Creating bugs is easy, and the color-coded labels on the activity tab make it easy to see what’s going on at a glance.

    16bugs Bug Submission Screenshot

    There are a variety of account types available. The free account allows 1 project, 1 MB of storage and Basecamp imports. Starting at $8 per month, paid plans include more projects (3 with the Basic plan), 150 MB to 10 GB of storage, RSS and email notifications, Campfire notifications and SSL (starting with the $15-per-month Big plan).

    JIRA

    JIRA is issue- and bug-tracking software that includes a lot of great features. It has advanced reporting features, workflow mapping as well as issue and project organizing; it is also customizable.

    JIRA Dashboard Screenshot

    JIRA also offers a number of plug-ins to extend its functionality, including Bamboo integration, charting, time tracking, project management, a calendar and more. By using plug-ins, you can customize JIRA to meet your exact project management and issue-tracking needs.

    JIRA Issue Navigator Screenshot

    JIRA’s biggest drawback is its pricing; it’s not cheap. A hosted account starts at $299 per month for up to 25 users and goes up from there (250 users costs $599 per month). If you want to download JIRA and host it on your own server, it starts at $1200 for a single project team, and goes as high as $4800 for an entire organization. If you need an academic license, solutions start at only $600.

    4. Collaboration and Conferencing

    If you’re working with a remote team on your project, you’re probably going to need some online space to collaborate and meet, whether it’s to work on general concepts or to work out specific bugs. Here are three solutions to help you collaborate with those on your team or with your clients.

    activeCollab

    activeCollab is a project management and collaboration tool that lets you set up a collaboration area right on your website. You can have unlimited projects, organized into groups for easy management.

    activeCollab Dashboard Screenshot

    Collaboration features include file sharing, discussions (set up like an online forum), assignments, collaborative writing and reminders. Project management features include printing and exporting, time tracking, calendar and schedule functionality, ticket management and milestones. Plug-ins (modules) mean that activeCollab can be extended to suit your specific needs.

    activeCollab Project Overview Screenshot

    There are two pricing options available: Corporate and Small Business. The Small Business edition includes source-code browsing, plug-in support, themes, discussions, milestones, checklists, files, project templates, a mobile interface and localization support. It’s priced at $199, with support and upgrades being an additional $99 per year after the first year. The Corporate edition has all of the above features, plus the calendar, tickets, time tracking, pages (with collaborative writing and more), a project explorer, and status updates. Both packages include unlimited projects and users. You can also purchase a Copyright Removal license, which removes the “activeCollab Powered” graphic from the footer of each page, for an additional $199.

    DimDim

    DimDim is a Web-conferencing platform that provides collaboration tools for meeting online. It’s scalable, reliable and flexible, with both hosted and on-site versions available.

    DimDim Main Page Screenshot

    DimDim allows you to share your desktop with those you’re meeting with, as well as share and present documents (both PowerPoint and PDFs). You can also share Whiteboards, and it has built-in voice-over-IP and teleconferencing capabilities. There are public and private chat capabilities as well as annotation and markup tools.

    DimDim New Meeting Screenshot

    There are free and paid plans available. The free plan offers the complete feature set, with support for meetings of up to 20 people. DimDim Pro offers the complete feature set, plus custom branding and up to 100 people in a meeting for only $99 per year. There is also an Enterprise-level package that includes all of the above but also allows simultaneous meetings with up to 1000 attendees for $1998 per year.

    Vyew

    Vyew is a browser-based Web presentation service that allows for custom branding and PowerPoint-like authoring. With Vyew, you can give a live presentation or just post a document for your colleagues to review at their convenience.

    Vyewbook Creation Screenshot

    Features include real-time desktop sharing, whiteboarding and drawing tools, embedded comments, built-in voice over IP, free teleconferencing, built-in webcam video support, text chat, dedicated rooms and direct URLs and more. It’s a complete solution for Web conferencing.

    Vyew Document Explorer Screenshot

    Vyew has a number of plans available, including a free plan, which includes unlimited meetings, SSL secure log-in, up to 20 participants (all seeing ads) and up to 5 VyewBooks (presentations) with up to 50 pages each. There are two paid plans: Plus at $6.95 per month, which includes everything the free plan has plus up to 25 participants (or 5 with no ads), and up to 25 VyewBooks with up to 100 pages each, and Professional at $13.95 per month, which includes everything the Plus plan has, but with up to 45 participants (or 15 with no ads), and up to 100 VyewBooks with up to 300 pages each.

    5. Invoicing

    Unless you’re working on an internal project, chances are you’ll need to send out invoices. Having an invoice program that also does proposals is helpful, as is having one that integrates directly with your project management app.

    Simply Invoices

    Simply Invoices integrates with Basecamp, More Honey, Tick and Harvest to invoice based on time that you track with those programs. Features include invoice templates, unlimited invoices, the ability to save invoices as PDFs and invoice tracking.

    Simply Invoices Screenshot

    There are a few different plans available, including a free plan that includes up to five invoice templates and SSL support. Paid plans start at $9 per month (which includes up to ten invoice templates, plus a custom logo and link-free invoices) and go up to $25 per month (which includes an unlimited number of templates).

    Less Accounting

    Less Accounting is a simple online accounting and invoicing program that is incredibly easy to use. Less Accounting has a variety of features, including proposal creation and tracking, mileage tracking, sales-lead management and expense tracking. You can import your existing Wesabe.com account, and you can even invite your CPA to look at your books. Less Accounting also sends a weekly email with an update on the status of your accounts.

    Less Accounting Screenshot

    There are a variety of account plans available, including a free plan. The free plan includes up to 5 invoices, expenses, sales notes, deposits, proposals, mileage logs each month, SSL encryption, reports and bank-account integration. The paid plans range from the Even Less plan at $12 per month (including invoicing, expenses, contacts, SSL encryption, technical support, deposits and reports) to the More plan at $24 per month (including everything in the Even Less plan, plus sales notes, bank accounts, proposals, mileage logs, bank reconciliation, support for multiple types of sales tax and more). A 30-day free trial is available for all plans.

    6. Time Tracking

    Whether you need to keep track of your time for billing purposes, for your boss, or just to measure your own productivity, chances are you’ll need a time-tracking application.

    LiveTimer

    LiveTimer is an easy-to-use time-tracking program that works on both your computer and iPhone. It can be used for billing purposes or simply to improve your productivity and accountability.

    LiveTimer Summary Report Screenshot

    Features include a daily ledger, bulk time entry (by day or week), customizable classifications, multiple currencies, custom billing rates, intelligent report filters and a developer API. The iPhone integration makes it easy to track your time even if you’re not at your desk, making it more useful than many other Web-based time-tracking applications.

    LiveTimer Time Ledger Screenshot

    Pricing is cheap, at only $5 per active user per month. Qualifying non-profits get a 50% discount. There is a 30-day free trial available.

    fourteenDayz

    fourteenDayz is a time-tracking program specifically for teams. It features day-by-day time sheets, exportable reports (in both PDF and Excel formats), drag-and-drop categories and no user limit.

    fourteenDayz Time Sheet Entry Screenshot

    There are 6 different plans offered, including a free account (which includes up to 4 active projects/clients, 10 project categories, an unlimited number of users and reporting functions). The paid plans range from the Personal at $5 per month (which includes the free account features plus up to 7 active projects/clients, 15 project categories, 30 project subcategories and PDF reports) to the Platinum at $99 per month (which includes all the Personal features plus unlimited active projects/clients, unlimited project categories and subcategories, XLS/CSV exportability and SSL connections).

    Further Resources

    For more project management applications, check out:

    • Simple Spark
      Directory of Web 2.0 applications, with a list of more than 300 project management apps.
    • Listio
      Another directory of Web 2.0 applications, with a huge list of project management apps.

    About the author

    Cameron Chapman is a professional Web and graphic designer with over 6 years of experience. She also writes for a number of blogs, including her own, GreenStyle Magazine, which will be relaunching later this year.

    (al)