Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a simple server that uses simple design patterns Factory: Your server should parse the routes and create a new Processor class depending on the

Create a simple server that uses simple design patterns

  • Factory: Your server should parse the routes and create a new Processor class depending on the route

  • Builder: The process method of your Processor should use the Builder pattern to create a response.

  • DAO: Make a class that abstracts the data interactions away from the rest of the app

  • Singleton: Wrap your dao instance as a singleton class

  • Lazy Loading: DAOs should only load data when requested

  • DTO: Your JSON parsing, as well as response objects must be DTOs

First parse url, then use factory to instantiate correct Processor class. The factory will internally use the builder pattern to give the processor relevant data. Use builder to set the time, and input parameters.

Processor Class

  • Has a process() method that returns a ResponseDto object

  • Each endpoint is a subclass of Processor

  • Takes a hashmap of key value args

  • User a factory to create these, based on the endpoint

  • Every processor uses a builder and returns the output of builder.build()

Response Class

  • This class gets stringified with GSON

  • Needs a ResponseBuilder helper

  • Needs Params Map (String, String)

  • Needs response dto

  • Needs Response Code (String)

UserDao class

  • Singleton

  • Lazy load data

  • 1 DAO per type of endpoint to hold the data

Endpoints

  • Payment Methods

    • /addPaymentMethod?method=name

      • creates a new payment method and stores it in the paymentMethod DAO

      • assigns a machine code

      • needs Payment DTO + Payment DAO

      • fields: name, machineCode

    • /getAllPaymentMethods

      • Returns list of all payment methods

  • Items

    • /addItem?name=name&price=price

      • Creates a new item and gives it a price

      • Assigns machine readable code and returns it

      • needs ItemDAO + Item DTO

      • fields: name, price, machineCode

    • /listItems

      • returns all items

  • Transactions

    • /createTransaction?itemCode=code&paymentMethod=paymentCode

      • Must have valid payment method

      • fields: itemCode, paymentMethod

    • /listTransactions

      • returns all transaction

      • needs TransactionDAO + Transaction DTO

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data And Databases

Authors: Jeff Mapua

1st Edition

1978502257, 978-1978502253

More Books

Students also viewed these Databases questions

Question

What advice would you provide to Jennifer?

Answered: 1 week ago

Question

What are the issues of concern for each of the affected parties?

Answered: 1 week ago