Lab evaluation-3 -Nagaraj

Case study:  Web framework for online book store

Activities

1)      The programming paradigm applicable for the case are

Object  Oriented programming paradigm

Functional oriented Programming paradigm

Multi paradigm programming language

2)      The elements of coding standards included in this case

Commenting code

Java Comments

 

Comment Type Usage Example
Documentation

Starts with /** and ends with */

Used before declarations of interfaces, classes, member functions, and fields to document them. /**

* Customer – a person or

* organization

*/

C style

 

Starts with /* and ends with */

Used to document out lines of code that are no longer applicable. It is helpful in debugging.

 

/*

This code was commented     out by

*/

 

Single line

 

Starts with // and go until the end of the line

Used internally within member functions to document business logic, sections of code, and declarations of temporary variables. // If the amount is greater

// than 10 multiply by 100

 Naming Accessor Member Functions

 

Getters: member functions that return the value of a field / attribute / property of an object.

Use prefix “get” to the name of the field / attribute / property if the field in not boolean

Use prefix “is” to the name of the field / attribute / property if the field is Boolean

A viable alternative is to use the prefix ‘has’ or ‘can’ instead of ‘is’ for boolean getters.

 

Examples

ex.getMessage();

Setters: member functions that modify the values of a field.

Use prefix ‘set’ to the name of the field.

Example

setMessage();

Member Function Visibility

 

A good design requires minimum coupling between the classes. The general rule is to be as restrictive as possible when setting the visibility of a member function. If member function doesn’t have to be public then make it protected, and if it doesn’t have to be protected than make it private.

3)

    Maintainability is achieved , ability of the system to undergo changes with a degree of ease. These    changes could impact components, services, features, and interfaces when adding or changing the functionality, fixing errors, and meeting new business requirements.

Usability  can achieved  how well the application meets the requirements of the user and consumer by being intuitive, easy to localize and globalize, providing good access for disabled users, and resulting in a good overall user experience.

Reliability is achieved f a system to remain operational over time. Reliability is measured as the probability that a system will not fail to perform its intended functions over a specified time interval.

Note:

I have used Java programming language, since the java programming language consits of  Object  Oriented programming paradigm ,Functional oriented Programming  paradigm

.

 

 

Code snippets

.login

<html>
<body bgcolor=”beige”>
<center>

<jsp:useBean id=”user” class=”obs.User” scope=”session” />

<jsp:setProperty name=”user” property=”*” />

<%
user.login();
if (! user.isLogged())
%>
<h3>Invalid Login. Click <a href=login.html>here</a> to try again! </h3>
<%
else
response.sendRedirect(“home.jsp”);
%>

</center>
</body>
</html>

Customer:

public class Customer
{

private String custname;
private String password;
private String email;
private String phoneno;

private Context ctx;

public Context getJNDIContext()
{
return ctx;
}

public Customer()
{
ctx = getInitialContext();
}

public void setCustname(String custname)
{ this.custname = custname; }

public String getCustname()
{ return custname; }

public void setPhoneno (String phoneno)
{ this.phoneno = phoneno; }

public String getPhoneno()
{ return phoneno; }

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

public String getPassword()
{ return password; }

public void setEmail (String email)
{ this.email = email; }

public String getEmail()
{ return email; }

// returns true if uname and pwd are valid
public boolean isValid()
{
Connection con = null;
PreparedStatement ps = null;
try
{
con = getConnection();
ps = con.prepareStatement(“select phoneno, email from customers where custname = ? and pwd= ?”);
ps.setString(1,custname);
ps.setString(2,password);

ResultSet rs = ps.executeQuery();
boolean found = false;

if ( rs.next())
{ phoneno = rs.getString(“phoneno”);
email = rs.getString(“email”);
found = true;
}
return found;
}

CART-

public class Cart
{
ArrayList items = new ArrayList();

public Item find(String isbn)
{
Iterator itr = items.iterator();
Item itm;
while ( itr.hasNext())
{
itm = (Item) itr.next();
if ( itm.getIsbn().equals(isbn))
{
return itm;
}
} // end of while

return null;
}

Link of source code

https://github.com/nagrajmetta/Web-framework-for-online-book-store-lab

Advertisements

One thought on “Lab evaluation-3 -Nagaraj

  1. LAB EVALUATION-1 « msritse2012 January 23, 2013 at 2:09 pm Reply

    […] Lab evaluation-3 -Nagaraj […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: