akshat122805 / akshatCSA

CSA First Blog
MIT License
0 stars 1 forks source link

Week 3 Debugging Manual #3

Open akshat122805 opened 1 year ago

akshat122805 commented 1 year ago

Debugging the Book Dashboard Web App

Welcome back to "Debugging Manuals"! Today, we're diving deep into the challenges faced when creating a Book Dashboard Web App that fetches book data from the Google Books API and displays it in a user-friendly format. Initial Setup and Objective

The initial objective was to create a simple interface where users could input a book title or author, and the app would fetch and display relevant book information.


Problem 1: API Integration

Issue: Our initial code was written without the Google Books API in mind. We had a weather dashboard template that needed to be adapted to work with Google's Books API.

Debugging: By examining the existing code, we determined which parts were specific to the weather API and which could be reused.

Solution: The code was adapted to call the Google Books API endpoint using the user's query. We structured the displayed results to show the book's title, author, publisher, and provided a space for user reviews.


Problem 2: Incorporating jQuery

Issue: The original code relied heavily on vanilla JavaScript for DOM manipulation, event handling, and AJAX requests. For the project requirements, we needed to integrate jQuery without affecting performance.

Debugging: We first included the jQuery library in the project. Then, we analyzed each DOM manipulation and event listener in the original code to determine its jQuery equivalent.

Solution: By converting the JavaScript functions to use jQuery methods (e.g., .val(), .text(), .on(), .getJSON(), etc.), we streamlined the code and made it more readable without compromising on its efficiency. image image


Problem 3: User Experience Enhancements

Issue: The initial setup was quite basic. Users could search for books, but there wasn't a method for them to leave reviews or see previous reviews.

Debugging: To implement this feature, we had to identify a way to store user reviews without a backend database.

Solution: We decided to use the browser's local storage as a simple "database" to save and retrieve user reviews. We added a textarea for reviews and a button to submit them. When submitted, reviews are stored in local storage with the book's title as the key. On subsequent searches, if a book with a saved review is displayed, the review is loaded from local storage and shown to the user. image


Problem 4: Error Handling

Issue: If a user entered an incorrect or non-existent book title or author, the app failed silently.

Debugging: We realized that our AJAX request didn't have proper error handling in place.

Solution: We added a .fail() method to our jQuery AJAX request, which catches any errors during the API call. When an error occurs, a user-friendly message is displayed, guiding the user to try their search again.


NBA Fantasy Debugging:

The Initial Problem

The NBA Player Stats webpage was functional but lacked aesthetic appeal and some desired features. The primary objective was to:

Improve the overall look and feel of the webpage.
Introduce a new column called "Fantasy Rating" that would provide a rating between 1-10 for each player.

The Debugging Process

  1. Visual Enhancements:

The initial CSS styling was basic. To make the webpage more visually appealing, we:

Introduced a softer background color to reduce strain on the eyes.
Enhanced the input fields and buttons with better padding, border-radius, and hover effects to improve user interaction.
Added shadows to tables for a modern look.
Improved typography and spacing for better readability.
  1. Introducing the "Fantasy Rating" Column:

The challenge here was to generate a "Fantasy Rating" for each player based on various metrics. Instead of a random value, we decided to create a proprietary algorithm that considers:

Player's past performance metrics.
Consistency in recent games.
Injury history.
Team dynamics.
Matchup analysis.
Recent form.

Using JavaScript, we processed the player's data through this algorithm to generate a rating between 1-10. This provided a more realistic and data-driven rating, enhancing the user experience. Problems Encountered & Solutions:

1. Fantasy Rating:

Problem: Initially, the "Fantasy Rating" was generated randomly between 1-10. This approach lacked authenticity and could mislead users.

Solution: We replaced the random generation with a detailed algorithm that considers various player metrics to produce a more accurate rating.

image image

2. Responsive Design:

Problem: The webpage layout wasn't fully responsive, leading to display issues on smaller screens.

Solution: We introduced media queries in the CSS to ensure the webpage looks and functions well on all devices, from desktops to mobile phones.

image

3. Data Fetching:

Problem: The webpage fetched player data from an external API. Ensuring that this data was processed correctly and efficiently was crucial.

Solution: We refined the JavaScript functions responsible for fetching and displaying the data, ensuring that the user receives accurate information in a timely manner.

Thanks for reading my first debugging manual!