Family Map Server: Design and Implementation Tips

Slides:



Advertisements
Similar presentations
SOAP.
Advertisements

George Blank University Lecturer. CS 602 Java and the Web Object Oriented Software Development Using Java Chapter 4.
Classes/Objects. Creating Objects Much like creating variables of primitive types –String name; –type name; Object variables hold references, not values.
Scott Grissom, copyright 2004Ch 3: Java Features Slide 1 Why Java? It is object-oriented provides many ready to use classes platform independent modern.
Test. A software house decides to develop a DVD renting program. The product manager identifies the following requirements: Every DVD will have a title,
+ Java vs. Javascript Jessi Style. + Java Compiled Can stand on its own Written once, run anywhere Two-stage debugging Java is an Object Oriented Programming.
JavaScript & jQuery the missing manual Chapter 11
“is a”  Define a new class DerivedClass which extends BaseClass class BaseClass { // class contents } class DerivedClass : BaseClass { // class.
Overview of Previous Lesson(s) Over View  ASP.NET Pages  Modular in nature and divided into the core sections  Page directives  Code Section  Page.
Java Programming, 3e Concepts and Techniques Chapter 2 - Part 2 Creating a Java Application and Applet.
Coding Methodology How to Design Code. © 2005 MIT-Africa Internet Technology Initiative Pay Attention to Detail When implementing or using APIs details.
Introduction to Programming Writing Java Beginning Java Programs.
Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 1.
Java Programming, Second Edition Chapter One Creating Your First Java Program.
Chapter 6 Server-side Programming: Java Servlets
FIRST JAVA PROGRAM. JAVA PROGRAMS Every program may consist of 1 or more classes. Syntax of a class: Each class can contain 1 or more methods. public.
Centre for Computer Technology ICT214 Object Oriented Design and Programming Week 02 – Classes, Objects, Instances Richard Salomon and Umesh Patel Centre.
Chapter 6 Applets and HTML  Overview  HTML tags for Applets  Applet Life Cycle  Applet Class  JAR files.
Programming in Java CSCI-2220 Object Oriented Programming.
Introduction to Programming Writing Java Beginning Java Programs.
Server-side Programming The combination of –HTML –JavaScript –DOM is sometimes referred to as Dynamic HTML (DHTML) Web pages that include scripting are.
Programmeren 1 6 september 2010 HOORCOLLEGE 2: INTERACTIE EN CONDITIES PROGRAMMEREN 1 6 SEPTEMBER 2009 Software Systems - Programming1 Programming.
Identifiers Identifiers in Java are composed of a series of letters and digits where the first character must be a letter. –Identifiers should help to.
Hello Computer Science!. Below is an example of a Hello World program in JAVA. While it is only three lines of code, there are many things that are happening.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
Recitation 8 User Defined Classes Part 2. Class vs. Instance methods Compare the Math and String class methods that we have used: – Math.pow(2,3); – str.charAt(4);
Interfaces and Polymorphism CS 162 (Summer 2009).
Java Basic Syntax. Object - Objects have states and behaviors. –Example: A dog has states-color, name, breed as well as behaviors -wagging, barking, eating.
Announcements Final Exam: TBD. Static Variables and Methods static means “in class” methods and variables static variable: one per class (not one per.
SourceAnatomy1 Java Source Anatomy Barb Ericson Georgia Institute of Technology July 2008.
© 2006 Pearson Addison-Wesley. All rights reserved 1-1 Chapter 1 Review of Java Fundamentals.
Unified Modeling Language (UML)
Cs205: engineering software university of virginia fall 2006 Programming Exceptionally David Evans
Simple Web Services. Internet Basics The Internet is based on a communication protocol named TCP (Transmission Control Protocol) TCP allows programs running.
SUMMARY OF CHAPTER 2: JAVA FUNDAMENTS STARTING OUT WITH JAVA: OBJECTS Parts of a Java Program.
Java Programming Fifth Edition Chapter 1 Creating Your First Java Classes.
Lecture 3: More Java Basics Michael Hsu CSULA. Recall From Lecture Two  Write a basic program in Java  The process of writing, compiling, and running.
The Essentials of a Java Program JavaMethods An Introduction to Object-Oriented Programming Maria Litvin Gary Litvin Copyright © 2003 by Maria Litvin,
Variable Scope & Lifetime
Java Methods and Applications CSIS 3701: Advanced Object Oriented Programming.
Java Programming in Unix
Object-Oriented Design
Conventions … learning
JAVA MULTIPLE CHOICE QUESTION.
GC101 Introduction to computer and program
Java Course Review.
USING ECLIPSE TO CREATE HELLO WORLD
Chapter 6 Server-side Programming: Java Servlets
Testing and Exceptions
Inheritance "Question: What is the object oriented way of getting rich? Answer: Inheritance.“ “Inheritance is new code that reuses old code. Polymorphism.
Chapter 4 Procedural Methods.
JavaScript an introduction.
How to Run a Java Program
Command Line Arguments
File I/O ICS 111: Introduction to Computer Science I
Chapter 1: Computer Systems
Lecture 16 - Interfaces Professor Adams.
Assignment 7 User Defined Classes Part 2
Coding Concepts (Data- Types)
Chapter 7 Procedural Methods.
Chengyu Sun California State University, Los Angeles
CS 240 – Advanced Programming Concepts
CS5220 Advanced Topics in Web Programming Secure REST API
Chengyu Sun California State University, Los Angeles
Exceptions.
Random Numbers while loop
Exceptions.
Chengyu Sun California State University, Los Angeles
Introduction to C CS 3410.
Presentation transcript:

Family Map Server: Design and Implementation Tips CS 240 – Advanced Programming Concepts

Recommended FMS Implementation Steps Model Classes (not really anything to test, especially if your IDE generates most of the code) DAO classes and JUnit tests Main server with File Handler for serving the Web API test page Needed to test the rest JSon Serializer (Object Encoder/Decoder) and Web API (Handler, Service, Request and Response classes) for /clear, /load, and /user/login with JUnit Tests Ancestor generation logic with JUnit Tests The Rest of the Web API with JUnit Tests

Json Deserialization A generic Gson deserialization method that will return a runtime specified data type public static <T> T deserialize(String value, Class<T> returnType) { return (new Gson()).fromJson(value, returnType); } Called by specifying the return type: MyDataType value = JsonSerializer.deserialize(jsonString, MyDataType.class);

Generating a Random Character String with Full Control Put available characters in an array Upper and lower case letters Digits Special characters (be careful not to include any Json syntax characters) Randomly generate numbers between 0 and array.length import java.util.Random; … Random random = new Random(); random.nextInt(array.length) Use the randomly generated numbers to pick characters from the array to be included in the String

Generating a Random Character String with UUID import java.util.UUID; public class UUIDGenerator { public static void main(String [] args) { String uuid = UUID.randomUUID().toString(); System.out.println(uuid); } }

Request Handlers Use inheritance to avoid duplicate code Handlers to consider: RequestHandler Top-Level parent handler Code to write a Json response Other code??? AuthorizingRequestHandler Parent for handlers that require authorization Read the authorization header to get the auth_token. Return a 401 if missing or invalid PostRequestHandler Parent for handlers that handle post requests Read the request Json and convert to a Java object Others???

Request Handler Implementation: File Handler See HttpHandler Examples and Writing a File Handler slides in WebAPI slides For the Family Map Server project, in addition to returning a 404 for “File Not Found”, also return the “/HTML/404.html” document provided in the files for the server project

Response Class Parent class for common response attributes ‘message’ instance variable and getter/setter ‘success’ instance variable and getter/setter Optional: You could just check to see if the message is null or not in the response when you need to know if a request was successful