Welcome Guest.   Make a donation to an author on the site September 18, 2014, 02:42:35 AM  *

Please login or register.
Or did you miss your validation email?


Login with username and password (forgot your password?)
Why not become a lifetime supporting member of the site with a one-time donation of any amount? Your donation entitles you to a ton of additional benefits, including access to exclusive discounts and downloads, the ability to enter monthly free software drawings, and a single non-expiring license key for all of our programs.


You must sign up here before you can post and access some areas of the site. Registration is totally free and confidential.
 
The N.A.N.Y. Challenge 2010! Download 24 custom programs!
   
   Forum Home   Thread Marks Chat! Downloads Search Login Register  
Pages: [1]   Go Down
  Reply  |  New Topic  |  Print  
Author Topic: Plz tell me how can i bring high quality to this Java code. it's urgent  (Read 2664 times)
simsim00
Participant
*
Posts: 2

View Profile Give some DonationCredits to this forum member
« on: June 14, 2009, 12:40:42 AM »

well, i have written this code for the problem give below. Plz help me to bring high quality to this i.e use of Hungarian Notation and commnts as required in the problem given below:
Problem:
Writing a maintainable code makes the product with High Quality. Here you are given a scenario where you have to write a maintainable code for the given problem.

Scenario:


Virtual Solutions is an IT solution provider company. It has hired you as a Software Engineer. Your job is to write code, but at the same it should be of High Quality.  Your Team Lead has asked you to write a very small code of user login functionality. The code should be of High Quality.

You are required to

a.   Write correct code for the user login in Java or C++
b.   Make use of Hungarian Notation for coding purpose
c.   Make use of Comments in the Code where required necessary.


code

<html>
<head>
<title>Khalid Mahmood   </title>
</head>

<body>


 

Please enter your user name and
 password



 

 

 <form  action="process2.jsp "    method = "post" >
 
username

 
<input type = "text" name=
 "username">

 
password

 
<input type = "password" name =
 "password">

 
<input type="submit"     name="Submit"
 value="Login">



 </form>

 </body>
 </html>








<%@ page import="java.util.*" %>
<jsp:useBean id="idHandler" class="foo.Login" scope="request">
<jsp:setProperty name="idHandler" property="*"/>
</jsp:useBean>

<%
   if (idHandler.validate()) {
%>
<jsp:forward page="success.jsp"/>
<%
   }  else {
%>
<jsp:forward page="retry.jsp"/>
<%
   }
%>












package foo;
 import java.sql.*;

 public class Login {

   private String username = "";
 private String password = "";

   public Login() {
  }

  public void setUsername(String username) {
     this.username = username;
  }

  public void setPassword(String password) {
     this.password = password;
   }


 public boolean  authenticate(String username2,
 String password2) {
  String query="select * from Registration;";
   String DbUserName="";
   String DbPassword="";
   String finalUser="";
  try {
  Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
   Connection
 con=DriverManager.getConnection("jdbc:odbc:register");
   Statement stat=con.createStatement();
   ResultSet rst=stat.executeQuery(query);
   while(rst.next())

  {
   DbUserName=rst.getString("UserName");

  DbPassword=rst.getString("password");

   if (username2.equals(DbUserName) &&
 password2.equals(DbPassword)) {

 break;
     }


   }
 return true;
 }catch(Exception e){

 e.printStackTrace();
 return false;
 }
}}
Logged
f0dder
Charter Honorary Member
***
Posts: 8,774



[Well, THAT escalated quickly!]

see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #1 on: June 14, 2009, 10:25:04 AM »

Pay more attention in class? smiley
Logged

- carpe noctem
jeremejazz
Supporting Member
**
Posts: 58


hey!

View Profile WWW Give some DonationCredits to this forum member
« Reply #2 on: February 20, 2010, 02:13:45 AM »

Hey, where did ya get that? facebook puzzles?
haha;D
Logged

smiley I love coding
Stoic Joker
Honorary Member
**
Posts: 5,260



View Profile WWW Give some DonationCredits to this forum member
« Reply #3 on: February 20, 2010, 10:45:55 AM »

So just add commenting to the code in Hungarian...

 cheesy
Logged
Pages: [1]   Go Up
  Reply  |  New Topic  |  Print  
 
Jump to:  
   Forum Home   Thread Marks Chat! Downloads Search Login Register  

DonationCoder.com | About Us
DonationCoder.com Forum | Powered by SMF
[ Page time: 0.051s | Server load: 0.11 ]