CSCE Inspection Activity Name(s):

Similar documents
HALCoGen TMS570LS31x Help: example_sci_uart_9600.c

Open Source Used In TSP

ColdFusion Builder 3.2 Third Party Software Notices and/or Additional Terms and Conditions

System Log NextAge Consulting Pete Halsted

Intel Stress Bitstreams and Encoder (Intel SBE) 2017 AVS2 Release Notes (Version 2.3)

MUMPS IO Documentation

Ecma International Policy on Submission, Inclusion and Licensing of Software

IETF TRUST. Legal Provisions Relating to IETF Documents. Approved November 6, Effective Date: November 10, 2008

Table of Contents Overview...2 Selecting Post-Processing: ColorMap...3 Overview of Options Copyright, license, warranty/disclaimer...

Data Deduplication Metadata Extension

NemHandel Referenceklient 2.3.1

NemHandel Referenceklient 2.3.0

ANZ TRANSACTIVE MOBILE for ipad

IETF TRUST. Legal Provisions Relating to IETF Documents. February 12, Effective Date: February 15, 2009

Ecma International Policy on Submission, Inclusion and Licensing of Software

Static analysis for quality mobile applications

ProgressBar Abstract

SW MAPS TEMPLATE BUILDER. User s Manual

Open Source Used In Cisco Configuration Professional for Catalyst 1.0

Open Source Used In c1101 and c1109 Cisco IOS XE Fuji

Preface. Audience. Cisco IOS Software Documentation. Organization

Explaining & Accessing the SPDX License List

pyserial-asyncio Documentation

Copyright PFU LIMITED 2016

User Manual. Date Aug 30, Enertrax DAS Download Client

About This Guide. and with the Cisco Nexus 1010 Virtual Services Appliance: N1K-C1010

Documentation Roadmap for Cisco Prime LAN Management Solution 4.2

Open Source and Standards: A Proposal for Collaboration

License, Rules, and Application Form

MagicInfo Express Content Creator

The Cron service allows you to register STAF commands that will be executed at a specified time interval(s).

cs50.c /**************************************************************************** * CS50 Library 6 *

Copyright PFU LIMITED

Fujitsu ScandAll PRO V2.1.5 README

FLAMEBOSS 300 MANUAL

Package fst. December 18, 2017

Grouper UI csrf xsrf prevention

iwrite technical manual iwrite authors and contributors Revision: 0.00 (Draft/WIP)

Anybus Wireless Bridge Ethernet Bluetooth Access Point Product Guide

AccuTerm 7 Internet Edition Connection Designer Help. Copyright Schellenbach & Assoc., Inc.

iphone/ipad Connection Manual

Internet Connection Guide

Distinction Import Module User Guide. DISTINCTION.CO.UK

Conettix Universal Dual Path Communicator B465

Business Rules NextAge Consulting Pete Halsted

US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.

SAM4 Reset Controller (RSTC)

PRODUCT SPECIFIC LICENSE TERMS Sybase Enterprise Portal Version 5 Application Edition ( Program )

HYDROOBJECTS VERSION 1.1

This file includes important notes on this product and also the additional information not included in the manuals.


Request for Comments: Oversi O. Nicklass, Ed. RADVISION May Definitions of Textual Conventions for Pseudowire (PW) Management

Bosch Smart Home. Plug Instruction Manual

DAP Controller FCO

APPLICATION NOTE. Atmel AT03261: SAM D20 System Interrupt Driver (SYSTEM INTERRUPT) SAM D20 System Interrupt Driver (SYSTEM INTERRUPT)

Definiens. Image Miner bit and 64-bit Editions. Release Notes

FOR TCG ACPI Specification

Flask-Sitemap Documentation

SORRENTO MANUAL. by Aziz Gulbeden

calio / form-input-nginx-module

CB-RBE231 PRODUCT GUIDE

FLAME BOSS 200V2 & 300 MANUAL. Version 2.6 Download latest at FlameBoss.com/manuals

TWAIN driver User s Guide

User Guide. Calibrated Software, Inc.

LabVIEW Driver. User guide Version

openresty / array-var-nginx-module

This file includes important notes on this product and also the additional information not included in the manuals.

HYDRODESKTOP VERSION 1.4 QUICK START GUIDE

Lax-Hopf-based LWR solver. Matlab implementation: Manual

RPly Documentation. Release Alex Gaynor

User Manual for Video Codec

HIS document 2 Loading Observations Data with the ODDataLoader (version 1.0)

PageScope Box Operator Ver. 3.2 User s Guide

Watch 4 Size v1.0 User Guide By LeeLu Soft 2013

Definiens. Image Miner bit and 64-bit Edition. Release Notes

SMS2CMDB Project Summary v1.6

QuarkXPress Server Manager 8.0 ReadMe

Note: The version the Event service must be 1.10 or later (but less than 3.0.0).

Taking the LPC800 into the delta quadrant :)

PRODUCT SPECIFIC LICENSE TERMS Sybase Enterprise Portal Version 5 Enterprise Edition ( Program )

Simba Cassandra ODBC Driver with SQL Connector

PTZ Control Center Operations Manual

Package fst. June 7, 2018

PyWin32ctypes Documentation

Packet Trace Guide. Packet Trace Guide. Technical Note

@list = bsd_glob('*.[ch]'); $homedir = bsd_glob('~gnat', GLOB_TILDE GLOB_ERR);

OKI DICOM Embedded Printer DICOM Printing Function User's Guide

AT11512: SAM L Brown Out Detector (BOD) Driver. Introduction. SMART ARM-based Microcontrollers APPLICATION NOTE

MainWindow.java. Page 1

Trimble. ecognition. Release Notes

Remote Divert User Interface DI. Instruction Manual

Flask Gravatar. Release 0.5.0

SkyPilot OS Installation: Fedora Core 5

Encrypted Object Extension

DAP Controller FCO

HYDRODESKTOP VERSION 1.1 BETA QUICK START GUIDE

<!--Released: February > <!--====================================================================--> <!--March > <!--

Small Logger File System

Pulse Check User Guide and Technical Guide. Quick Start Framework. Version Name: Winter 16 Version Number: 1.5 Date:

Denkh XML Reporter. Web Based Report Generation Software. Written By Scott Auge Amduus Information Works, Inc.

Transcription:

CSCE 747 - Inspection Activity Name(s): You are inspecting the source code for the Graduate Record and Data System (GRADS) - a system that graduate students can log into and use to view their transcript or a summary of their progress towards graduation. Your current task is to inspect the class Session - a class used to track information about a user of the system, as well as to store the contents of databases in memory. You have been provided with a checklist of common Java code style issues, and are to inspect the Session class against that list. The checklist and program are attached. Working in pairs, document below which checklist items were not met, and why they were not met. Provide advice on how to address that shortcoming.

Sample Checklist for Java Programs File Header Are the following included and consistent? Author and current maintainer. File Footer Is there a revision log to minimum of one year or most recent point release? Import Section Is there a brief comment on each import with the exception of standard java.io.* or java.util.*? Class Declaration Is the constructor explicit? Is the class protected or private? If not, is there justification for public access? Does the JavaDoc header include: A one sentence summary of class functionality? Usage instructions? Class Are names compliant with the following rules? Class or interface: CapitalizedWithEachWord Exception: ClassNameEndsWithException Constants (final): ALL_CAPS_UNDERSCORES Field Name: capsafterfirstword Must be meaningful outside of context. Methods Are names compliant with the following rules? Method name: capsafterfirstword Local variables: capsafterfirstword Names may be short (e.g., i for integer) if scope of declaration and use is less than 30 lines. Factory method for X: newx Converter to X: tox Getter for attribute X: getx(); Setter for attribute X: void setx; Fields Are method semantics consistent with similarly named methods? (put(o) matches put(o) use for other classes) Are usage examples provided for nontrivial methods? Is the field necessary (cannot be a local variable)? Is the field protected or private? If not, is there justification for public access? Are there comments describing the purpose of the field? Are there any constraints or invariants documented in the field or class comment header?

Class: Session /** * Session * Author: Gregory Gay and Jason Biatek * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * - Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * - Neither the name of the University of Minnesota nor the names of its * contributors may be used to endorse or promote products derived from this * software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ package edu.umn.csce5801; import java.util.arraylist; // Object that represents a course. import edu.umn.csci5801.model.course; import edu.umn.csci5801.model.coursetaken; // Object that represents a progress summary. import edu.umn.csci5801.model.progresssummary; // Object that represents a student record. import edu.umn.csci5801.model.studentrecord; //Object that represents a system user. import edu.umn.csci5801.model.user; /** * Class Session * Session-relevant information for the graduate record and data system. * Instantiated by the system interface when a user logs in, then * destroyed when they log out. * Used to load contents of course, user, and records databases into local memory. */ public class Session { // Current user private User currentuser;

// List of loaded student records private ArrayList<StudentRecord> records; // Name of the records file. private String recordsfile; // ID of the requested item. Private String userid; // List of courses offered. private ArrayList<Course> coursesoffered; // List of users private ArrayList<User> users; // Progress summary builder private ProgressSummaryBuilder builder = new ProgressSummaryBuilder(); // Standard set of getters and setters protected User getuser(){ return this.currentuser; // Sets the user, requires that the user data file have been read, // and that the user exists. protected void setuser(user user) throws GRADSDataException{ if(users.size() > 0){ if(users.contains(user)){ currentuser = user; else{ throw new GRADSDataException("User "+user.getid()+" does not exist."); else{ throw new GRADSDataException("Users file has not been read."); // Sets the user, requires that the user data file have been read, // and that the user exists. protected void setuser(string userid) throws GRADSDataException{ this.userid = userid; if(this.users.size() > 0){ ArrayList<String> ids = this.getidsusers(); else{ if(ids.contains(userid)){ currentuser = users.get(ids.indexof(userid)); else{ throw new GRADSDataException("User "+userid+" does not exist."); throw new GRADSDataException("Users file has not been read."); protected ArrayList<StudentRecord> getrecords(){ return records; protected void setrecords(arraylist<studentrecord> records){ this.records = records;

// Need to keep track, as we might write changes back to this file. protected String getrecordsfile(){ return recordsfile; protected void setrecordsfile(string recordsfile){ this.recordsfile = recordsfile; protected ArrayList<Course> getcoursesoffered(){ return coursesoffered; protected void setcoursesoffered(arraylist<course> coursesoffered){ this.coursesoffered = coursesoffered; protected ArrayList<User> getusers(){ return users; protected void setusers(arraylist<user> users){ this.users = users; // Private function to get the set of user IDs. // Private to protect data security. private ArrayList<String> getidsusers(){ ArrayList<String> ids = new ArrayList<String>(); for(user user: users){ ids.add(user.getid()); return ids; // Private function to get the set of student IDs for which records exist. // Private to protect data security. private ArrayList<String> getidsrecordsinternal(){ ArrayList<String> ids = new ArrayList<String>(); for(studentrecord r: records){ ids.add(r.getstudent().getid()); return ids; // Public-facing function to get the set of student IDs for which records exist. protected ArrayList<String> getidsrecords() throws GRADSPermissionsException{ if(currentuser.getrole().tostring().equals("graduate_program_coordinator")){ if(currentuser.getdepartment().tostring().equals("computer_science")){ ArrayList<String> ids = new ArrayList<String>(); for(studentrecord record: records){ ids.add(record.getstudent().getid());

else{ else{ return ids; throw new GRADSPermissionsException("User "+ currentuser.getid()+" is not part of the CS department."); throw new GRADSPermissionsException("User "+ currentuser.getid()+" does not have permission to take this action."); // Retrieves the requested student record if the user is either the owner of // that record, or is a graduate program coordinator. protected StudentRecord getrecord(string userid) throws Exception{ this.userid = userid; ArrayList<String> ids = this.getidsrecordsinternal(); if(ids.contains(userid)){ if(currentuser.getrole().tostring().equals("graduate_program_coordinator") currentuser.getid().equals(userid)){ else{ else{ if(currentuser.getdepartment().tostring().equals(records.get(ids. indexof(userid)).getdepartment().tostring())){ return new StudentRecord (records.get(ids.indexof(userid))); else{ throw new GRADSPermissionsException("User " +currentuser.getid() +" is not part of the correct department."); " does not have permission to access the transcript for " +userid); throw new GRADSDataException("User ID "+userid+" does not exist."); protected void updaterecord(string userid, StudentRecord record) throws Exception{ this.userid = userid; ArrayList<String> ids = this.getidsrecordsinternal(); if(ids.contains(userid)){ if(currentuser.getrole().tostring().equals("graduate_program_coordinator")){ if(currentuser.getdepartment().tostring().equals(records.get( ids.indexof(userid)).getdepartment().tostring())){ if(record.getstudent().getid().equals(userid)){ records.set(ids.indexof(userid), record); else{

else{ else{ else{ throw new GRADSDataException ("Not allowed to change user ID."); " is not part of the correct department."); " does not have permission to edit the transcript for " +userid); throw new GRADSDataException("User ID "+userid+" does not exist."); // Adds a note to a student record. protected void addnote(string userid, String note) throws Exception{ this.userid = userid; int index = this.getidsrecordsinternal().indexof(userid); StudentRecord student = new StudentRecord(records.get(index)); ArrayList<String> notes = new ArrayList<String>(student.getNotes()); notes.add(note); for (String n: notes){ System.out.println(n); student.setnotes(notes); records.set(index, student); // Adds course areas from the course database to the student record // This is done to improve maintenance costs. Only have to change course // areas in one central datastore. protected StudentRecord addareastorecord(studentrecord record){ StudentRecord toreturn = new StudentRecord(record); ArrayList<String> courseids = new ArrayList<String>(); for(course course: coursesoffered){ courseids.add(course.getid()); ArrayList<CourseTaken> coursestaken = new ArrayList<CourseTaken>(toReturn.getCoursesTaken()); ArrayList<Integer> toremove = new ArrayList<Integer>(); for(int entry=0; entry< coursestaken.size();entry++){ CourseTaken course = coursestaken.get(entry); // Is this a course that is still offered? if(courseids.contains(course.getcourse().getid())){ // Does it have a course area Course taken = course.getcourse(); taken.setcoursearea(coursesoffered.get(courseids.indexof (course.getcourse().getid())).getcoursearea());

course.setcourse(taken); coursestaken.set(entry, course); else if(course.getcourse().getid().contains("csci")){ toremove.add(entry); for(int entry: toremove){ coursestaken.remove(entry); toreturn.setcoursestaken(coursestaken); return toreturn; // Starts the process of building the progress summary for the requested student ID. protected ProgressSummary generateprogresssummary(string userid) throws Exception{ ArrayList<String> ids = this.getidsrecordsinternal(); if(ids.contains(userid)){ if(currentuser.getrole().tostring().equals("graduate_program_coordinator")){ if(currentuser.getdepartment().tostring().equals( records.get(ids.indexof(userid)).getdepartment().tostring())){ StudentRecord tobuild = this.addareastorecord(records.get (ids.indexof(userid))); builder.setrecord(tobuild); return builder.buildprogresssummary(); else{ " is not part of the correct department."); else{ " does not have permission to generate a progress summary for "+userid); else{ throw new GRADSDataException("User ID "+userid+" does not exist."); /* * Revision History: * 09/03/2014: Added exception handling to control access. * 09/02/2014: Fixed a fault regarding record storage. * 09/01/2014: Initial file creation. */