Saturday, November 29, 2008

BIOS access keys

Most OEM PC or custom-built clone PC using third-party motherboard (MoBo) allows user to configure various settings in BIOS (CMOS setup) to enter BIOS Setup or Configuration Utility in order to enable or disable devices or ports available, and more commonly, boot device priority or sequence. Some advanced settings also allow user to tweak computer performance, such as CPU clock speed multiplier and CPU front side bus (FSB) rate for overclocking, chipset features, DRAM parity, speed and timing, etc.

To access BIOS configuration screen, user need to press and invoke a specific hotkey or keys combination during the initial BIOS load screen (usually right after the computer is powered on). Here’s a list of the ways and access keys to press to access BIOS Setup Utility on variety of popular OEM computer systems, motherboard makers and major BIOS brands. Note that some BIOS or computer systems may have more than one method of accessing BIOS depending on when the BIOS is released.


Acer (Aspire, Power, Veriton, Extensa, Ferrari, TravelMate, Altos): Press [F2] or [Del] Immediately After Power Up
Acer (Altos 600 Server): Press [Ctrl]+[Alt]+[Esc] or [F1] During Boot (for Advanced Options)
Acer (Older PC): Press [F1] or [Ctrl]+[Alt]+[Esc] to Access BIOS

AMI (American Megatrends AMIBIOS, AMI BIOS): Press [Delete] During Boot
AMI
AMI (American Megatrends AMIBIOS, AMI BIOS) - Old Version: Press [F1] or [F2] During Boot

Award BIOS (AwardBIOS): Press [Del] After Powering Up Computer
Award BIOS (AwardBIOS) - Old Version : Press [Ctrl]+[Alt]+[Esc] During Boot

ALR: Press [Ctrl]+[Alt]+[Esc] or [Ctrl]+[Alt]+[Del] During Boot

ARI: Press [Ctrl]+[Alt]+[Esc] or [Ctrl]+[Alt]+[Del] During Boot

AST Advantage: Press [Ctrl]+[Alt]+[Esc] During Boot

Compaq (Presario, Prolinea, Deskpro, Systempro, Portable): Press [F10] When Blinking Cursor Jumps To Top Right Corner of Screen
Compaq (Presario, Prolinea, Deskpro, Systempro, Portable): Press [F10] When Logo Screen Is Displayed
Compaq (Older Computers): Press [F1], [F2], [F10], or [Del] Key

Cybermax: Press [Esc] Key

Dell (XPS, Dimension, Inspiron, Latitude. OptiPlex, Precision, Vostro): Press F2 When Dell Logo Is Displayed Until “Entering Setup” Appears
Dell (Older 486 Models): Press [Ctrl]+[Alt]+[Enter] During Boot
Dell (Some Models): Press Reset Button Twice (i.e. Power Reset Button)
Dell Dimension L566cx System: Press [Del]
Dell (Older Laptop Models) : Press [Fn]+[Esc] or [Fn]+[F1]

DTK (Datatech Enterprises): Press [Esc] Key Right After Powering On the PC.

EISA Computer: Press the Reset button on the Front of the Computer, then Press [Ctrl]+[Alt]+[Esc] immediately when the memory count begins or Press [Crtl]+[Alt]+[S].

eMachines (eMonster, eTower, eOne, S-Series, T-Series): Press [Tab] or [Del] During Boot
eMachine (Some Older Computers): Press [F2]

Fujitsu (LifeBook, Esprimo, Amilo, Tablet, DeskPower): Press [F2] When Fujitsu Logo Is Appearing.

Gateway Using Phoenix BIOS (DX, FX, One, GM, GT, GX, Profile, Astro): Press [F1]
Gateway (Some Older PCs): Press [F2]

Hewlett-Parkard (HP Pavilion, TouchSmart, Vectra, OmniBook, Tablet): Press [F1] Upon Startup or Bootup
Hewlett-Parkard (HP Alternative): Press [F2] or [Esc]
Hewlett-Parkard (HP) Tablet PC: Press [F10] or [F12]

IBM ThinkPad using IBM BIOS (Early Models): Press [Ctrl]+[Alt]+[Ins] When Cursor Is At Upper-Right Corner of Screen
IBM ThinkPad using IBM BIOS (Later Models): Press and Hold [F1] When Powering Up Laptop
IBM ThinkPad using Phoenix BIOS: Press [Ctrl]+[Alt]+[F11] from DOS Prompt

IBM PS/1 (Late Models), PS/ValuePoint and 330s: Press [Ctrl]+[Alt]+[?]
IBM PS/2 with Reference Partition: Press [Insert] During Boot
IBM PS/2: Press [Ctrl]+[Ins] When Pointer Is At Top Right of Screen
IBM PS/2: Need Reference Disk and ADF Disk for Setup
IBM PS/2 75 and 90: Press [Ctrl]+[Alt]+[?]

IBM (PC, XT, AT): Press [F1] Immediately On Powering On the Computer
IBM (Older Computers or Notebooks): Press [F2]

Lenovo (ThinkPad, IdeaPad, 3000 Series, ThinkCentre, ThinkStation): Press [F1] or [F2] on Boot Up
Lenovo (Older Products): Press [Ctrl]+[Alt]+[F3], [Ctrl]+[Alt]+[Ins] or [Fn]+[F1].

Microid Research MR BIOS: Press [F1]

Micron (MPC Computers ClientPro, TransPort): Press [F1], [F2] or [Del] On Startup

NEC (PowerMate, Versa, W-Series): Press [F2] During Boot
NEC Versa Notebook: Press and Hold Down [F1] Upon Startup or Bootup

Olivetti PC Pro: Press [Ctrl]+[Alt]+[Shift]+[Del](in Num Pad) During Boot
Packard Bell (8900 Series, 9000 Series, Pulsar, Platinum, EasyNote, imedia, iextreme): Press [F1], [F2], or [Del].
Packard Bell (Early 386 and 486 Dodels): Press [Ctrl]+[Alt]+[S] Sequence

Phoenix BIOS (Phoenix-Award BIOS): Press [Del] During Power On Self-Test
Phoenix BIOS (Phoenix-Award BIOS) - Old Version: Press [Ctrl]+[Alt]+[S], [Ctrl]+[Alt]+[Esc], [Ctrl]+[Alt]+[Ins] or [Ctrl]+[S] During Power On Boot Self-Test Right After Startup

Sharp (Notebook Laptops, Actius UltraLite): Press [F2] On Computer Starts
Sharp (Old PCs): Require Setup Diagnostics Disk to Access BIOS

Shuttle (Glamor G-Series, D’vo, Prima P2-Series, Workstation, X Mini XPC, Surveillance): Press [F2] or [Del] on System Startup

Sony (VAIO, PCG-Series, VGN-Series): Press [F1], [F2] or [F3] After Turning On the Computer
Sony Vaio 320 Series: Press [F2] During Boot

Tandon 386: press [Ctrl]+[Shift]+[Esc]
Tandon: press [Ctrl]+[Shift]+[Esc]

Toshiba (Portégé, Satellite, Tecra): Press [Esc] During Boot
Toshiba (Portégé, Satellite, Tecra with Phoenix BIOS): Press [F1] during Boot

Zenith, Phoenix: Press [Ctrl]+[Alt]+[Ins] During Boot


Miscellaneous and Other Common BIOS Key Sequences

[Ctrl]+[Esc]
[Ctrl]+[Ins]
[Ctrl]+[Alt]
[Ctrl]+[Alt]+[+]
[Ctrl]+[Alt]+[F3]
[Ctrl]+[Alt]+[Del]
[Ctrl]+[Alt]+[S]
[Ctrl]+[Alt]+[Enter]
[Ctrl]+[Alt]+[Ins]
[Ctrl]+[Alt]+[Esc]
[Ctrl]+[Shift]+[Esc]
[Tab]
[F1]
[F3]
[F4]
[F10]
[F12]
[Fn]+[Function Key]


Note that for some older system with Phoenix BIOS, the following steps are required to get to BIOS setup screen:

  1. Exit or boot up to DOS.
  2. Press [Ctrl]+[Alt]+[Esc] to enter setup screen.
  3. If hot key sequence above doesn’t work due to changes or problems been made on the system, then try to use the key to lock the keyboard while leaving computer switched on.
  4. Press the Reset button on the front of the computer. A message will appear asking user to unlock the keyboard.
  5. Unlock the keyboard and press [F2] to run the CMOS setup.
  6. Press [Del] to bring up the CMOS setup program.




( From myDigitalLife )


BONUS: CMOS PASSWORD TOOL http://www.cgsecurity.org/wiki/CmosPwd

Hopefully this list might help some laptops :-) ,

Wednesday, November 26, 2008

J2EE with NetBeans

You can download the following simple demo presentation:
(the presenter's pronounciation is very clear, feel free to practice your listening skill :D ):

http://mediacast.sun.com/users/ArunGupta/media/v3prelude-nb65-webapp.flv

IMHO GlassFish is a fairly good Application Server, compared to JBoss, although the core servlet containers of both are derived from the same (Tomcat).

Tuesday, November 25, 2008

Technical forum structure

Nhân thấy các bạn bên forum của CLB tin học khoa CSE của trường ĐHBK HCM tranh luận về việc định hướng và tái cấu trúc forum, tớ thử nghĩ ra cấu trúc cho 1 forum định hướng kỹ thuật để thu hút được nhiều người giỏi tham gia.


Tuy nhiên chưa kịp post lên forum đó thì tớ đã bị "ban" nick vì "có quá nhiều sense of humour", đến nỗi vài anh bạn không-có-óc-hài-hước cảm thấy tủi thân.
(nghĩ kỹ thì nhờ bị "banned" mà tiết kiệm được mấy $ mỗi giờ, hehe )



Thôi thì cứ để các bạn ấy trưởng thành vậy, mình lo kiếm cơm qua ngày là đủ mệt rồi, gánh chi chuyện thiên hạ.

Monday, November 24, 2008

VIM for dummies [2]

Sau khi biết được cơ bản về VIM thì các bạn đã bắt đầu có thể dùng vim để soạn thảo (edit) rồi, nhưng để hiệu quả hơn thì cần biết thêm một số thiết lập, phím tắt và lệnh.

Bài này sẽ ôn lại một số điểm trong post trước và giới thiệu thêm một số thao tác thường gặp của vim . Hy vọng sau bài này thì các bạn yêu thích máy tính sẽ cảm thấy hứng thú với việc dùng vim trên Linux/BSD.



=== Khởi động vim ===

Ôn lại bài trước:
$ vim myfile.txt

Bài này thì ta khởi động cách khác:
$ vim

Khởi động kiểu này sẽ thấy hiện giữa màn hình các thông tin về tác giả (Bram Moolenaar - hiện đang làm cho Google), phiên bản (7.x.yz) , cách quit bằng :q , cách xem trợ giúp bằng :h , ...
Bây giờ để bắt đầu soạn thảo 1 file (giả sử tên myfile.txt) , ta gõ lệnh
:edit myfile.txt
hoặc đơn giản hơn chỉ cần :e myfile.txt .

Trong trường hợp bạn muốn mở nhiều file cùng lúc (ví dụ: file1.js , file2.cpp, file3.java, ...), thì vim cũng hỗ trợ nhiều cách. Nếu phiên bản vim của bạn hỗ trợ tab các file, thì nên mở bằng cách sau:
$ vim -p file1.js file2.cpp

Hoặc khi đang ở trong chế độ normal của vim, bạn dùng lệnh:
:tabedit file3.java
thì vim sẽ mở cho bạn file3.java trong 1 tab mới :) .
(Để ngắn gọn hơn có thể gõ :tabe file3.java )



=== Di chuyển / Cuộn màn hình ===

Ôn lại bài trước:
* trái và phải : là "h" và tương ứng "l"
* còn xuống , lên : là "j" , "k"


Di chuyển bằng các phím (ở normal mode):
+ Đến tab kế tiếp: gt , tab trước đó: gT
+ Đến file mà tên nằm ở dấu nháy: gf (để trở lại, dùng Ctrl+o hoặc Ctrl+6 )

+ Đến đầu file: gg
+ Đến (đầu) dòng cuối file: G (tức là Shift+g )
+ Đến dòng thứ 17: 17G

+ Đến cuối dòng: $
+ Đến đầu dòng (ký tự đầu): ^
+ Đến đầu dòng (cột 0): 0


Cuộn màn hình :
+ Cả trang : Ctrl+f (forward), Ctrl+b (backward)
+ Nửa trang : Ctrl+d (down), Ctrl+u (up)
+ Từng dòng : Ctrl+n (next), Ctrl+p (previous) . Hoặc phím cũ là Ctrl+e và Ctrl+y

Lưu ý: các tổ hợp phím scroll màn hình này cũng giống như khi dùng lệnh man, more hoặc less , nên khi xem manpage hay file nào các bạn cũng có thể scroll bằng các tổ hợp phím kể trên.



=== Tìm kiếm / Thay thế ===

Ôn lại bài trước:
phím / : tìm từ trên xuống
phím ?: tìm từ dưới lên (thường dùng để tìm cụm từ có chứa / )
Khi đã tìm thấy thì có thể bấm tiếp phím n hoặc N để tìm đến từ kế tiếp (next) .

Tìm ngay các từ giống từ đang ở dấu nháy (cursor) : phím * , hoặc #


Thay thế (substitute) thì dùng cú pháp mới gần giống sed: ( s/OLD/NEW/option )
+ thay toàn bộ chuỗi "OLD" bằng chuỗi "NEW" trong cả file:
:%s/OLD/NEW/g

+ thay toàn bộ chuỗi "OLD" bằng chuỗi "NEW" trong đoạn từ dòng 5 đến dòng 17 :
:5,17s/OLD/NEW/g

+ thay toàn bộ chuỗi "OLD" bằng chuỗi "NEW" trong 1 dòng (đang chứa cursor) :
:s/OLD/NEW/g

+ chỉ thay chuỗi "OLD" đầu tiên trong dòng bằng chuỗi "NEW" thì ko cần "g" :
:s/OLD/NEW

+ nếu muốn có xác nhận (confirm) trước khi thay thì ta thêm option là "c" :
:%s/OLD/NEW/gc


Các thao tác tìm kiếm và thay thế trên VIM cũng hỗ trợ biểu thức chính quy (Regular Expression) khá tốt. Các Regex được hỗ trợ trên vim hiện nay giống như của egrep, khá giống của perl . Nhưng để tránh phức tạp cho người mới dùng thì tớ chưa nêu ví dụ ở đây :D .



=== Sao chép / Xóa / Dán ===

Đơn giản:
- chép (copy/yank) : phím y
- xóa : phím d (hoặc phím x)
- dán : phím p

btw, trong VIM thì xóa (delete) luôn có nghĩa là cắt (cut), tức là mất đi trên màn hình hiển thị , nhưng ngay lúc đó đã lưu lại trong vùng nhớ nào đó (gọi là vùng register hoặc còn gọi là vùng buffer). Khi đó có thể dán (paste) lại màn hình soạn thảo của vim bằng phím p .


Để xóa 1 đoạn thì ta có thể làm các cánh sau:

1/ chuyển qua chế độ visual rồi chọn vùng cần xóa và bấm phím xóa

2/ dùng chức năng đánh dấu (mark) bằng phím m , đánh dấu 2 điểm rồi xóa từ điểm đầu đến điểm cuối

3/ chuyển sang chế độ chuột
set mouse=a
hoặc
set mouse=i
rồi dùng chuột để chọn vùng cần xóa, rồi bấm phím xóa.

4/ Ánh xạ các thao tác xóa thành tổ hợp phím nào đó (VD: kiểu Ctrl+C của Windows) , để chọn và xóa dễ hơn.

5/ Chuyển sang chế độ soạn thảo giống các chương trình trên Windows , tức là dùng lệnh behave mswin để nó chuyển chế độ chuột và các phím tắt giống kiểu Notepad++ trên Windows.

Đại khái như vậy, nhưng phần này tớ khoan nói rõ, ai quan tâm sẽ tự tìm hiểu :D .




=== Thiết lập / vimrc ===

Ôn lại bài trước:
* Chuyển theme màu khác cho vim, chẳng hạn theme "murphy" :
:colorscheme murphy

* Bật syntax highlight màu cho các ngôn ngữ lập trình, script :
:syntax on

* Bật số dòng (line number) lên cho dễ theo dõi:
:set number

* Bật chức năng hiện các lệnh (show command) đã gõ :
:set showcmd

* Bật "cây thước" để hiện số dòng, số cột, số ký tự đã gõ:
:set ruler

* Bật chức năng highlight các từ được search :
:set hlsearch

* Bật chức năng ignore case của từ được search để tìm được nhiều hơn :
:set ignorecase




=== Ánh xạ phím tắt ===

Ôn lại bài trước:
Để undo, thì trước tiên chuyển về normal mode (nhấn ESC) , rồi bấm phím u , thế là undo 1 lần. Muốn undo nữa thì nhấn u nữa, cứ thế. Còn để redo thì ở Normal mode ta bấm Ctrl+r (trong VIM thường ký hiệu là C-R) . Nếu muốn redo nữa thì lại bấm Ctrl+r tiếp, bạn có thể redo đến hết lần undo liên tục gần nhất.



=== Một số tham khảo ===

Ôn lại bài trước:
:h word
(với "word" là từ mà mình muốn coi help)

vim cũng có built-in sẵn 1 cái tutor về cách dùng VIM:
$ vimtutor

Sunday, November 23, 2008

Object-oriented programming principles

Sau khi đã biết được các nguyên lý cơ bản để phát triển phần mềm, một lập trình viên nên biết qua về các nguyên lý lập trình hướng đối tượng.

Một số bạn thì gọi cái này là các nguyên tắc thiết kế hướng đối tượng (OOD principles) . Theo tôi thì gọi như vậy là không chính xác. Các nguyên tắc OO này áp dụng cho lập trình (programming), từ thiết kế (design) đến viết mã (coding) đến kiểm thử (testing) , đều cần biết các nguyên tắc này và nên áp dụng ở từng giai đoạn luôn chứ không chỉ ở giai đoạn design.

Nói một cách ví von, so với cờ thì: các nguyên lý KISS, DRY, YAGNI,... là các thế tàn cuộc cơ bản, các nguyên lý OOP là các cách chơi trung cuộc, còn như Design Patterns thì là các kiểu khai cuộc . Mặc dù ngày nay Design Patterns được nhắc đến nhiều nhưng thực sự thì để nâng cao nội lực thì nên nắm vững OOP principles , còn DP thì ban đầu chỉ cần biết một ít đủ để áp dụng OOP là được.


Trong vài bài post sau này chúng ta sẽ thảo luận về Design Patterns , còn bây giờ tôi sẽ nêu 4 nguyên lý OOP cơ bản :

1/ Nguyên lý đóng mở - OCP : (open close principle)
Open for extension, but closed for modification.

Tạm dịch: Dễ mở rộng các hành vi, mà không cần phải sửa lại (class/interface/method)


2/ Nguyên lý thay thế Liskov - LSP : (Liskov substitute principle)
Derived classes must be substitutable for their base classes.

Tạm dịch: Các lớp dẫn xuất phải có khả năng thay thế hẳn lớp cơ sở


3/ Nguyên lý nghịch đảo phụ thuộc - DIP : (dependency inversion principle)
Depend on abstractions, not on concretions.

Tạm dịch: Nên phụ thuộc ở mức trừu tượng, tránh phụ thuộc cụ thể


4/ Nguyên lý phân tách giao diện - ISP : (interface segregation principle)
Make fine grained interfaces that are client specific.

Tạm dịch: Tạo các interfaces đã lọc kỹ và hướng tới người dùng


4 revisited/ Nguyên lý trách nhiệm đơn định - SRP: (single responsibility principle)
(Cái này là 1 góc nhìn khác của ISP, nếu bạn thích gọi là nguyên lý 5 thì cũng không sai mấy)
A class should have one, and only one, reason to change.

Tạm dịch: Khi thay đổi, mỗi lớp chỉ nên có 1 và chỉ 1 lý do



Ngoài ra còn các nguyên lý về phân gói (package), chia làm 2 nhóm:
+ tăng độ kết dính (increase cohesion) : REP, CCP, CRP
+ giảm độ ghép cặp (decrease coupling) : ADP, SDP, SAP

Tuy nhiên nên nắm vững 4 nguyên lý cơ bản ở trên trước khi tìm hiểu các nguyên lý về package & granuality .

Saturday, November 22, 2008

Double-clicked Java

Nice article from Dmitry Leskov:
http://javalobby.org/articles/java2exe/




"How do I make an .EXE file from my Java application?",

"Need help converting jar to exe",

"Is it possible to create a Windows executable using Java?"

--- these and similar questions are among the most popular topics on Java developer forums. Should you start such a topic today, you are likely to encounter the following three types of replies:

1/ "You cannot"
2/ "You should not, because that would kill the very purpose of Java"
3/ "You can do that with third party software X and Y"


The truth is that there exist two completely different approaches to the creation of native executables from Java applications, addressing different sets of problems. Moreover, under certain conditions some of those problems may be solved without making an EXE. So the most correct way to reply to such a post would be a request for more information, namely what is the goal of conversion to EXE. And the most frequent answer would be



=== Simplify Java Application Deployment ===

Java compiles to platform-independent bytecode (.class files), which is not directly supported by PC hardware. So a Java program needs a Java Runtime Environment (JRE) to run, which would either interpret the bytecode instructions or compile them to native code on the fly. This in turn means that the author of that program has to ensure somehow that the proper version of the JRE is installed on an end user system.


In a general case you may not expect that your end users will know what a JRE is, how to check its version, and how to download and install it. This is especially true for consumer applications, such as games or multimedia. And those who already have a JRE installed may not like the idea about installing a different version, because it may break their existing Java applications and favorite applets.


Then, even if you can make sure the right version of the JRE is properly installed on enduser systems, which is quite possible in a classroom or enterprise environment, the command line required to launch your Java application can be quite long:

java -Xmx200m -cp whatever.jar -Dsome.property MyApp

Yes, you may put that line into a batch file and call it runme.bat, but it looks so much easier to give your program to a friend, teacher or colleague as a single file that can be run by a double-click. Or, even better, enable it to be installed and uninstalled in a native manner without affecting other applications.


So it comes as no surprise that the primary motivation for seeking a way to convert a Java application into an EXE file is to make its deployment and use simpler and safer for an average user, that is, a Windows user. What surprises newbie Java developers is that the JDK does not offer such functionality. Before J2SE 1.4, all you could make with JDK tools were



=== Executable Jars ===

You can make your Java application runnable via a double-click by packaging it into a so called executable jar. You do that by specifying the main class of your application, any extra jar files it may require and so on in the jar's manifest file

Main-Class: MyAppMain
Class-Path: mylib.jar

Then you use the jar utility from the Java SDK to package your classes and resource files, specifying the m option and the name of your manifest file:

jar cvfm MyApp.jar MyApp.mf *.class *.gif

This will result in the creation of MyApp.jar. Now, if you type

java -jar MyApp.jar

the Java launcher will read the manifest from MyApp.jar and invoke the main method from the class MyAppMain. Moreover, if you double-click that jar file on a system that has JRE installed, the java launcher will be invoked automatically.


Note: As of J2SE 5.0, jar files are associated with the javaw launcher on Windows, which does not open a console on startup. If your application needs a console, write a batch file which would start it using the java launcher.


If your application consists of more than one jar file, there is an open source tool called One-JAR that claims to correctly repackage multiple jars into one.


The major problem with executable jars is compatibility. The default JRE may be of an older version than is required by your application or may not have the necessary Java Optional Packages (previously known as Standard Extensions) installed. For instance, if your app uses the java.nio package introduced in Java 2 version 1.4, it will not work on JRE 1.3.x. Similarly, if it uses JavaMail 1.3, and the default JRE has JavaMail 1.2 or JavaMail is not present at all, the double-clicked jar will not run.


Fortunately, Sun has created a Java application deployment technology that eliminates this compatibility problem and adds some nice features. It is part of the Java 2 platform since version 1.4 and is called



=== Java Web Start ===

Java Web Start (JWS) and the underlying Java Network Launch Protocol (JNLP) enable Java application delivery from a standard Web server. The end user initiates application installation by clicking on an URL. If the Java Web Start engine is not present on the system, the user is prompted to download and install it. Once Java Web Start is in place, clicking on the same URL will initiate the application download and installation procedures. It may involve download and installation of the required version of the JRE and Optional Packages. Upon their successful completion, the application is launched. The application will be cached on the user's system so next time the user clicks on the same URL, the JWS engine will launch the local copy of the application from the cache, if it detects that the computer is offline or the application was not updated on the Web site.


Another important feature of JWS is its ability to run your application in a sandbox - a restricted container based on Java security architecture. But, unlike an applet, your application can gain access to local system resources like the filesystem, printer and system clipboard using the JNLP API even if it comes from an untrusted environment, after prompting the user for confirmation.


Java Web Start is available for Windows, Linux, and Solaris, and is part of MacOS X since v10.1. There are also third-party implementations of the JNLP protocol, some of them also include tools that assist you in the creation and maintenance of JNLP packages.


That was the bright side. Now, what is not so good about JNLP? First off, for seamless operation both the browser and the Web server that hosts the JNLP-enabled application must support application/x-java-jnlp-file MIME type. Some hosting providers do not support it. Moreover, versioning and incremental updates require additional support from the Web server, which has to be implemented using servlets, cgi-bin scripts, etc.


On the client side, a major browser would be configured to recognize the above MIME type during installation of the JWS engine, but users of less popular browsers, such as Opera, may have to do that manually.


JNLP-enabling an application may involve minor changes in its code and (re)packaging it into a set of jar files.


Before J2SE 5.0, JWS had very little to offer in terms of desktop integration - all it could do was create a desktop icon and/or a Start Menu entry for the application. On Windows, the application will not show up in Add/Remove Programs, so end users would have to run the Java Web Start application manager in order to remove your application.


Finally, JWS user interface needs much polishing. As of J2SE 5.0, users still complain about ugly windows with incomprehensible messages.


To sum it up, JWS can be a viable option in a controlled environment, such as corporate intranet, but it is not ready for the consumer market, where you may be better off using



=== Custom Java Launchers And Wrappers ===

When a Java program is invoked using one of the methods discussed above (batch file, executable jar, or Java Web Start/JNLP), the operating system runs a Java launcher from the JRE. The Windows version of the JRE has separate launchers for command-line and GUI apps, called java.exe and javaw.exe respectively.


As a result, all running Java applications have the same Taskbar/Alt-Tab icons and appear in the Windows Task Manager as either java.exe or javaw.exe. If you have two or more Java apps running, you have no means to distinguish between multiple instances of the standard Java launcher in the Task Manager.


In fact, those launchers are just small native programs that load the Java Virtual Machine from a DLL/shared library and then feed your program to that JVM using the Invocation API. That API is part of the Java Native Interface (JNI), so it is standardized, and it is also very simple. This makes it relatively easy to write your own launcher with a unique name and icon. What it has to do is find a suitable JRE on the end user's system (unless you bundle the JRE with your application), load and initialize the JVM, and run your application on it.


If you do not have the right tools, skills, or time to develop a custom launcher for your Java application, there are quite a few third-party Java launcher generators listed in the Tools section of the frame. Some of them provide additional features such as instant splash screen, stdout and stderr redirection, and so on, the most notable being wrapping.


A Java wrapper is essentially a custom Java launcher that is also a self-extracting archive containing all the application's classes, jars and auxiliary files. The wrapper unpacks those files on startup and removes on termination. This way, your application is distributed as a single executable.


A wrapper normally looks up the JRE upon startup. If the JRE is not present or its version does not match the application's compatibility requirements, some wrappers may install the JRE (if you have included it when wrapping your application) and/or download and install the required version of the JRE.


The most sophisticated wrappers may also setup file associations and create shortcuts on first run. But if you need something more complex, such as support for automatic updates or uniform cross-platform deployment, have a look at



=== Java-Aware Setup Authoring Tools ===

If all you need is install a private copy of the JRE alongside your application and create shortcuts that run your application on that JRE, you may use any setup generator. However, using a Java-aware tool may give you the following benefits:

* Install-time JRE detection and download
* Generation of native launchers
* User-editable JVM parameter files
* Redirection of stderr and stdout for saving logs and exception stack traces.
* Registration of Java applications as Windows services and Unix daemons

This category is the most diversified in terms of tool pricing and functionality. The differences are explained below by example.


Windows-centric tools, such as Advanced Installer for Java enable you to build MSI (Windows Installer) packages.


Multi-platform tools can generate native installers for multiple platforms - Windows, Linux, Mac OS X, as well as RPMs and tarballs. install4j is one such tool.


There exist also Java-based setup authoring tools enabling you to create cross-platform installations, Those installations are essentially executable jars with platform-specific logic selected at run time. InstallAnywhere is perhaps the most well known tool of this type, but if its pricing is beyond your budget, consider the cheaper JExpress or the open source IzPack.


Finally, there is One Tool to Rule Them All - InstallShield, which can create both Windows desktop (MSI) and cross-platform installations, plus server and mobile ones, for any type of application and for a multitude of platforms. And yes, it does support JRE lookup and bundling, native launchers, and so on.


For straightforward installations, however, InstallShield is an overkill. Also note that InstallAnywhere and InstallShield are aimed at the enterprise developer and are priced accordingly.


All the above solutions do not change the fundamental principle mentioned in the first section of this article. Whether you make an executable jar or create a sophisticated installer, your Java program is still deployed as platform-independent bytecode. In the early days of Java, the only way to execute a Java program on a common PC hardware was to interpret that bytecode. Today, any decent J2SE implementation contains a Just-In-Time (JIT) compiler that compiles frequently executed methods to native code. So it sounds quite natural to take one step further and compile the entire application down to native code before it is deployed. Such tools exist and they are called



=== Ahead-Of-Time Compilers ===

AOT compilers are known also as "static compilers" and "native code compilers". The latter term is the most used and, as it often happens, the least correct from the technical standpoint, because JIT compilers also produce native code.

An Ahead-Of-Time (AOT) compiler takes as input your jars and class files and produces a conventional native executable for the target platform, such as Windows EXE or Linux ELF binary. Just like any other technical solution, this has its advantages and drawbacks.


Advantages

* Performance. A JIT compiler works at application's runtime and shares CPU and memory resources with the application it compiles and possibly other applications. An AOT compiler runs on the developer's system with no resource or compilation time constraints. Therefore it can potentially use more powerful resource-intensive optimizations, yielding better code.

This advantage is amplified if you application will be deployed to embedded systems or low-end desktop PCs, where the JIT compilers simply may not have enough resources to work.

* Intellectual Property Protection. Java bytecode is very easy to decompile - just google for "download java decompiler" and you will get your source code back in 5 minutes. Yes, you may obfuscate names of public classes and methods not accessed via reflection, but control flow obfuscation can render your bytecode unverifiable on future JVMs and hinders optimizations implemented in JIT compilers. Finally, encrypting your Java bytecode does not protect it at all regardless of the encryption algorithm you use.

In contrast, native code produced by an optimizing AOT Java compiler is about as hard to reverse engineer as if you have coded the original program in C++. Needless to say, there is no performance loss. If you are concerned about protecting your intellectual property, have a closer look at native compilation.

* User Perception. Java client applications often suffer from the so called warm-up cycle syndrome. Starting up a Java application involves bytecode interpretation, profiling and JIT-compilation. So Java programs tend to start much longer than their native counterparts and the initial response time of a Java app GUI element is much worse than after it has been used several times, which are the two major reasons for Java still being perceived as slow by many users.

A native executable runs directly on hardware, without the interpret-profile-compile overhead, so it may start faster and immediately demonstrates the best response times.

* Native deployment. Even the most sophisticated Java-aware setup tools have to generate native launchers for better desktop integration, and may need to take care of the JRE download and installation.

Executables produced by an AOT Java compiler do not depend on the JRE and can be deployed using any setup authoring tool available for the target platform. Moreover, AOT compilers may come with specifically tailored setup generators that create compact, professional installers.


Drawbacks

* Dynamic applications. Classes that the application loads dynamically at runtime may be unavailable to the application developer. These can be third-party plug-ins, dynamic proxies and other classes generated at runtime and so on. So the runtime system has to include a Java bytecode interpreter and/or a JIT compiler.

Moreover, in the general case only classes that are loaded by either system or application classloader may be precompiled to native code. So applications that use custom classloaders extensively may only be partially precompiled.

* Hardware-specific optimizations. A JIT compiler has a potential advantage over AOT compilers in that it can select code generation patterns according to the actual hardware on which the application is executing. For instance, it may use Intel MMX/SSE/SSE2 extensions to speedup floating point calculations. An AOT compiler must either produce code for the lowest common denominator or apply versioning to the most CPU-intensive methods, which may result in code size increase.


FYI, there used to be half a dozen AOT Java compilers on the market in the year 2000, but the only two that have survived are Excelsior JET and GCJ (GNU Compiler for Java).



./.


To discuss about this article, please go to JavaLobby forum :-)

Thursday, November 20, 2008

Scrum software development

Việc phát triển phần mềm ngày nay càng lúc càng lưu ý hơn đến việc sử dụng lại (re-use) và đáp ứng (adapt) với thay đổi của yêu cầu khách hàng, bởi kinh nghiệm cho thấy đó là điều tất yếu không thể tránh khỏi.
Vì thế các quy trình phát triển phần mềm cổ điển như WaterFall, Spiral, RUP, ... càng lúc càng ít được dùng, mà thay vào đó là các phương pháp có tính reusable và flexible cao. Các quy trình tập trung vào 2 tính năng trên được gọi là quy trình linh hoạt (Agile process) .

WaterFall fails


Trong họ Agile software development process thì đến nay đã được khoảng năm bảy loại, nhưng nổi bật nhất là Extreme Programming (XP) và Scrum .

Agile Basis



Tuy nhiên đến bây giờ thì Scrum xem như đã vượt qua XP và FDD để trở thành mô hình Agile được công nhận rộng rãi nhất. Bởi Scrum vừa tập hợp các best practices từ các mô hình khác (daily meeting, test automation, iterations,... ), vừa khai thác triệt để các giá trị Agile (team interaction, run first, customer collaboration, embrace change) .


Các thuật ngữ và khái niệm trong quy trình Scrum mới nghe thì hơi khó hiểu hơn bên XP, chẳng hạn chia Roles thành PigChicken , rồi nào là Sprint, nào là BackLog, rồi BurnDownChart, etc... liệu có vi phạm KISS ? (trong Agile thường dùng thuật ngữ "Assume Simplicity" hơn là K.I.S.S)


Lúc đầu tôi cũng nghĩ là chia như vậy hơi rắc rối, làm sao mà lại tốt hơn quy trình XP được. Nhưng sau quá trình chấp nhận làm quen thuật ngữ và áp dụng triệt để Scrum tôi đã cảm thấy nó nhỉnh hơn XP (có lẽ nhờ kinh nghiệm XP đã làm trước đây chăng? ) . Dẫu sao đi nữa thì nó cũng là một quy trình đáng giá và sẽ rất tốt nếu áp dụng cho 1 team gồm những lập trình viên có kinh nghiệm.


Hẹn lại trong 1 bài khác tôi sẽ trình bày rõ hơn các khái niệm trong quy trình Scrum và vì sao nó lại được đánh giá cao trong giới Agile. Nếu có thời gian thì giới thiệu sơ luôn các quy trình Agile khác như: AUP, DSDM, FDD, Getting Real, ...

Tuesday, November 18, 2008

Some eponymous laws

which relates to software development or project management :D .



Brooks’ Law

Adding manpower to a late software project makes it later.



Parkinson’s Law

Work expands so as to fill the time available for its completion.



Hoare’s Law of Large Programs

Inside every large problem is a small problem struggling to get out.



Lister’s Law

People under time pressure don’t think faster.



Pareto Principle

For many phenomena, 80% of consequences stem from 20% of the causes.



The Peter Principle

In a hierarchy, every employee tends to rise to his level of incompetence.



Conway’s Law

Any piece of software reflects the organizational structure that produced it.



Fitts’ Law

The time to acquire a target is a function of the distance to and the size of the target.



Tesler’s Law of Conservation as Complexity

You cannot reduce the complexity of a given task beyond a certain point. Once you’ve reached that point, you can only shift the burden around.



Occam’s Razor

The explanation requiring the fewest assumptions is most likely to be correct.



Hofstadter’s Law

A task always takes longer than you expect, even when you take into account Hofstadter’s Law.



Ninety-ninety Law

The first 90% of the code accounts for the first 90% of the development time. The remaining 10% of the code accounts for the other 90% of the development time.



Hartree’s Law

Whatever the state of a project, the time a project-leader will estimate for completion is constant.



Jakob’s Law of the Internet User Experience

Users spend most of their time on other sites. This means that users prefer your site to work the same way as all the other sites they already know.



Fisher’s Fundamental Theorem

The more highly adapted an organism becomes, the less adaptable it is to any new change.



Clarke’s Second Law

The only way of discovering the limits of the possible is to venture a little way past them into the impossible.




Have fun !

Sunday, November 16, 2008

Computer hackers exposed !

Alan Cox là lập trình viên máy tính và là người đóng góp chính vào sự phát triển của nhân Linux từ thuở sơ khai 1991.




John Gilmore là một trong những người sáng lập ra Electronic Frontier Foundation, Cypherpunks và Cygnus Solutions. Ông tạo ra thuyết phân cấp alt.* trong Usenet và là người đóng góp chính của dự án GNU.



Jon “maddog” Hall là Giám đốc điều hành của Linux International, một tổ chức phi quyền lợi lập nên từ những nhà cung cấp máy tính muốn hỗ trợ và đẩy mạnh hệ điều hành Linux.



Grace Murray Hopper là một nhà khoa học máy tính Mỹ và sĩ quan Hải quân Mỹ. Bà là một trong những lập trình viên kì cựu của Harvard Mark I, và phát triển trình biên dịch đầu tiên cho một ngôn ngữ lập trình. Do những thành tích đó mà người ta còn gọi bà là “Amazing Grace”.



David Korn, sáng lập ra Korn Shell, thường mặc áo thun in hình ban nhạc Korn. (Cool)!



Eric Steven Raymond là một lập trình viên, nhà văn và luật sư nổi tiếng trong cộng đồng mã nguồn mở. Ông nổi tiếng với câu nói: “Câu văn luộm thuộm thì tư duy cũng luộm thuộm”.



Richard Matthew Stallman là một nhà phát triển phần mềm kiêm hacker. Năm 1983, ông khởi xướng dự án GNU tạo nên Hệ điều hành Unix. Ông còn là người phát triển trình soạn thảo Emacs gốc, GNU Compiler Collection (GCC), và GNU Debugger.



Bjarne Stroustrup là một nhà khoa học máy tính Đan Mạch. Ông đã thiết kế và phát triển ngôn ngữ lập trình C++ vào năm 1983.



Linus Benedict Torvalds - cha đẻ của chim cánh cụt Linux khi còn là 1 SV trường ĐH Helsinki (Phần Lan).



Larry Wall là lập trình viên, nhà ngôn ngữ học và nhà văn. Ông tạo ra ngôn ngữ nổi tiếng Perl. Các hacker ngày nay cần phải cám ơn ông rất nhiều.



Stephan Gary “Woz” Wozniak - đồng sáng lập Apple cùng Steve Jobs.



Dennis MacAlistair RitchieKenneth Lane Thompson - cha đẻ Unix. Ken Thompson tạo ra ngôn ngữ B còn Dennis Ritchie tạo ra ngôn ngữ C.



Bill GatesPaul Allen - miễn bình luận!



Loyd Blankenship, biệt danh: The Mentor (người cố vấn) được biết đến như 1 hacker khét tiếng và là nhà văn từ những năm 1980, khi ông còn là thành viên của các tổ chức hacker Extasyy Elite và Legion of Doom.



Riley Eller, biệt danh: Caezar, là thành viên của Ghetto Hackers.



Dan Farmer là 1 chuyên viên an minh máy tính. Sau khi tốt nghiệp ĐH Purdue, ông bắt đầu phát triển chương trình COPS, chương trình này giải thích tại sao Unix bảo mật đến như vậy. Năm 1995, ông và Wietse Venema sáng lập ra SATAN (Security Administrator Tool for Analyzing Networks). Nhìn ông này trông giống tay vocal của Kreator.



Susan Lynn Headley, biệt danh: Thunder, là 1 trong số ít ỏi các nữ hacker, cô là thành viên của Roscoe Gang.



Richard Pryce - khi mới 16 tuổi, cậu sinh viên âm nhạc này đã nổi danh như cồn vì thành tích phá vỡ hệ thống hàng trăm máy tính của Griffiths Air Force Base, NASA và Korean Atomic Research Institute.



Bruce Schneier là một chuyên gia an minh mạng, 1 nhà mật mã học. Ông là tác giả 1 vài cuốn sách viết về bảo mật và mật mã. Ông phát minh ra các thuật toán Blowfish và Twofish.






Kết luận :
Hackers là những người... tóc dài hoặc rậm râu ! (hoặc cả 2)



Con đường thành nerd/geek vẫn còn xa quá !!

Apache Maven2 POM

Các fan của Java chắc hẳn ít nhiều gì cũng biết đến Ant , nhưng ít lập trình viên VN biết rằng Maven2 đã vượt qua mặt Ant để trở thành build tool chính cho rất nhiều dự án chuyên nghiệp .

Maven ban đầu được đặt tên là Project Object Model , nên file cấu hình của nó là pom.xml (lúc mới ra Maven1 thì là project.xml) . Cũng giống như để sử dụng Ant phải biết cấu trúc buildfile (build.xml) , muốn sử dụng tốt Maven thì nên nắm rõ cấu trúc pom.xml . Đại khái cấu trúc của nó như sau:




hoặc đơn giản hơn:





[BASIC]
groupId
artifactId
version
packaging

parent

modules

properties


[DEPENDENCIES]
dependencies
-[dependency[groupId, artifactId, version, scope, type, classifier]]


[BUILD]
build
-[sourceDirectory, resources, testResources, plugins[plugin[artifactId, executions[execution[phase, goals, configuration]]]]

reporting
-[outputDirectory, plugins[...]]


[PROJECT INFOR]
name
description
url
licenses
inceptionYear


[ENVIRONMENT]
profiles
repositories
pluginRepositories





Well, more confident now ?