JSF: Java Server Faces Tutorial: Video Training: Step by Step

Comments

MVC:Struts:Java - Web Application Development

Industries use frameworks for application development quite often.

For example: Java concepts like JSP, Servlet, Swing, Bean, JDBC can

be used directly to create web-applications but when such

applications become big, it becomes difficult to maintain and

develop them further. Hence, frameworks like struts are used to develop

large web-based Java applications. This makes maintenance and

further development easier. If you need to write a very simple web

application with a few pages, then you might consider using

JSP/Servlet directly otherwise Struts like frameworks are better

options.

Struts-1 uses the concept Model View Architecture (MVC) and provides

the controller. In MVC model, Model represents business logic, View
represents user interfaces, and Controller represents/controls control
flow of the application.

Struts' control layer is based on standard technologies like

Java Servlets, JavaBeans, ResourceBundles, and XML, as well as

various Apache Commons  packages, like BeanUtils and Chain of

Responsibility.

For the Model,  struts-1 framework can interact with standard
data access technologies, like JDBC  and EJB,  as well as most
any third-party packages, like Hibernate,  iBATIS,  or Object Relational
Bridge.  For the View,  the framework works well with JavaServer Pages,
including JSTL and JSF,  as well as  Velocity Templates,  XSLT,  and
other presentation systems.

The framework's Controller acts as a bridge between the application's Model and the web View.
When a request is received, the Controller invokes an Action  class. The Action class consults
with the Model to examine or update the application's state. The framework provides an ActionForm
class to help transfer data between Model and View.

Struts-1 Configuration
-----------------------
web.xml is one of the configuration files. It is an XML-formatted file that works as a
deployment descriptor.

struts-config.xml is another resource file to initialize the applications resources.
These resources include  ActionForms  to collect input from users,  ActionMappings
to direct input to server-side  Actions,  and ActionForwards to select output pages.

Sample struts-config.xml file.

?xml version="1.0" encoding="ISO-8859-1" ?>

Other resources like Validators can be initialized here.

Comments

10 Database Design Tips


10 Database Design Tips
1. Develop A Prototype

2. Split database structure into multiple tables

3. Use understandable field names

4. Avoid illegal file names

5. Ensure Consistency

6. Avoid blank fields

7. Use standard descriptors for date and time

8. Use currency fields if appropriate 9. Avoid proprietary extensions

10. Avoid the use of field dividers

Comments

Tools to create ER diagrams from a database dynamically

Microsoft Visio, and dbVisualizer provide features to create ER diagrams from existing database tables.

Why needed?
In early days many companies did not create documentation/ER diagrams for their databases. However, ER diagram is very useful to understand the total database structure that helps a new programmer to work on the database more efficiently.

Visio:
While creating Database diagrams, a menu item named database is displayed. Reverse Engineering option under Database menu helps to create ER diagram from existing database tables. Before that, target database drivers for visio need to be installed. If the database is in db2/mysql/postgresql, then db2/mysql/postgresql drivers for visio should be installed. From Database/options/drivers, the driver needs to be configured. Afterwards, Reverse Engineering option may be used to create the ER diagram. There is no suitable driver for postgresql databses for Visio. ODBC drivers may be used for the purpose (the ER diagram may not be accurate from ODBC driver for postgresql).

dbVisualizer:
In dbVisualizer, when the TABLEs group/option is selected in the left pane in the right/middle pane there will be a references option. When the references tab is selected, an ER diagram is displayed using all tables. The ER diagram can be displayed as Hierarchical, circular, orthogonal, or organic. There are options for the purpose.

When a single table name is selected, the table and the associated tables are displyed in an ER diagram.

In the rightest column, selected tables option allows to create ER diagrams only for the selected tables. When ’selected tables’ is clicked a list is displayed in a dialogbox. Tables can be selected from this list (use control key). Build graph option creates and displays the ER diagram.

Comments

Personal Character and Programming

If I worked with a programmer who looked busy all the time, I’d assume that he was not a good programmer
because he wasn’t using his most valuable tool, his brain. — Steve Mcconnell

Personal Character and Programming
———————————-
For a software engineer the only building material is the human intellect and the primary tool is he himself.

Character is the more decisive factor than intelligence in the make up of a superior programmer.

The best programmers of the world are the most humble. They realize how small their brain is for programming
and they agree their limitations.

Being humble gives opportunities to learn more about programming

Human brain is really limited to understand an average program fully. So what better programmers do (adopt better habits) are:

1. Decompose systems into smaller sub-systems. Write short routines. It reduces load from the brain

2. Good programmers review, inspect, and test their codes/designs to compensate for brain limitations

3. Good programmers follow standard and proven conventions to reduce load from their brain

Ways to be a good programmer:

Curiosity is important

Experiment

Read about problem solving

Read books and periodicals

Read case studies

Network with other programmers

Adopt good programming habits

Avoid laziness

Experince, persistence, and guts are sometimes hurtful to the programmers

To be a good programmer developing the right programming habits is the most important strategy

Comments

Key Strategies in Software Debugging

Key Strategies in Software Debugging

1. Understand the requirements well. Design the software well. Code well. It will reduce the number of defects in your system.
2. Don’t use random guessing about defects. Use a systemetic and scientific method to detect and fix bugs.
3. Identify the root cause of a defect. Understand the program and then try to solve
4. Set the compiler warning in it’s pickiest level. Solve all the issues as listed in the warning messages
5. Make wise use of debugging tools but use your brain in parallel

Debugging?
Is a process to find the cause of an error/issue/defect wheras testing is the process to find the error/defect in the first place.

Defects are opportunities for a good programmer. How?

When you are a good programmer, you will code well.
Still if you have defects than something is missing somewhere,
it will give you opportunities to learn many stuffs like:

1. Check: Did you understand the program/requirements?
2. Learn: what kinds of mistakes you make
3. Learn: how you solve problems
4. How you fix defects

When you know your own patterns then there will be opportunities to improve yourself.

Bad ways to debug software:
1. Find defects by random guessing, by using print statements randomly.
2. Don’t try to understand the program just find the defect and fix
3. Use most obvious fix. You see the code does not work for 23 as input otherwise fine. So write a special case for 23
4. Debugging by superstition.

Finding a Defect
Scientific method of debugging

1. Stabilize the error through experiments. Be sure about the error and when it happens.
2. Gather the data through repeatable experiments that produces the defect
3. Form a hypothesis that states the cause of the error
4. Design experiments to prove or disprove the hypothesis.
5. Prove or disprove the hypothesis.
6. Repeat as needed
7. Fix the defect
8. Test the fix
9. Look for similar errors in your code.

Checklist for finding defects:
Reproduce the same error in several different ways.
Brainstorm for possible hypotheses
Use a notepad to list the things to try
Find the suspicious region of your code
Check the error-prone classes and routines
Check recently modified/added codes
Check for common defects
Check region by region. Expand your region after one region is covered
Talk to someone about the problem
Relax a bit. It works great sometimes.
[but if your boss sits just behind you to watch your screen, to follow your each key press and mouse move, and
he does not understand the point of relaxing a bit,
THEN YOU ARE in trouble]

Comments

Opening and reading files with Java JDK 1.0.x

Opening and reading files with Java JDK 1.0.x

1. Open the file with the File class;
2. Create a FileInputStream object using the File object;
3. Convert the FileInputStream to a BufferedInputStream to greatly increase file reading speed;
4. Convert the BufferedInputStream to a DataInputStream; the methods of DataInputStream give me a fair amount of flexibility in reading the data.
5. Read the file until the end

File f = new File("mydata.txt");
FileInputStream fis = new FileInputStream(f);
BufferedInputStream bis = new BufferedInputStream(fis);
DataInputStream dis = new DataInputStream(bis);
String record = null;

try {

while ( (record=dis.readLine()) != null ) {
//
// put your logic here to work with "record"
//
}

} catch (IOException e) {
//
// put your error-handling code here
//
}

Comments

Java XML Example - XML File Parse and Use Attributes

Java XML Example - XML File Parse and Use Attributes

A good example: http://developerlife.com/tutorials/?p=25
Another very good example: http://www.developerfusion.co.uk/show/2064/: I followed this code to extract attribute values from an xml file.

Comments

Little note on CVS

CVS Version Control System:

  • There will be a repository where the files(of different versions) will be saved. Its just like a central storage of files. You will need a software that will provide this facility.
  • You also need a client software. The client software can get copies of the repository files. After, modifying clients can update/save to the repository. While saving from clients steps are needed so that version control is maintained [no inconsistency arises].
  • Linux has command based clients, also there are CVs servers for linux. Download them from the internet.
  • I have some experience of using WinCVS - a windows based CVS client.
  • In WinCVS, You can set command line parameters using Admin->commandline parameters option. You have to provide some information like: CVS server, repository path, username, password.
  • In WinCVS, you can checkout files from the CVS server using the checkout option from the menu (tools). You need to specify local path to store the files. Also, you need to mention some information like the previous step (or you can copy a string from the previous step and provide here):

Comments

Books - Resources

http://books.justetc.net — browse for 1000s of free books.
http://ebooks.justetc.net — browse for 100000s of free ebooks.

Comments

« Previous entries ·