Understanding Edge Cases in Programming
When working on programming tasks, it's crucial to consider edge cases - those scenarios that push the boundaries of input values. By carefully examining assumptions and handling all possible variations, you can ensure your code functions robustly. Learn how to address edge cases for different data types like numbers and strings, enhancing your problem-solving skills and code reliability.
Download Presentation
Please find below an Image/Link to download the presentation.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.
E N D
Presentation Transcript
CSE 121 Lesson 12: Putting It All Together, Part 1 Matt Wang Spring 2024 Andy Anju Archit Arkita Autumn Christian TAs: Hannah H Hannah S Heather Hibbah Janvi Jessie Jonus Julia Luke Maria Mia Ritesh Shayna Simon Trey Vidhi Vivian Gumball? sli.do #cse121-12 Today s playlist: CSE 121 lecture beats 24sp
Announcements and Reminders Quiz 1 is tomorrow! many resources available! practice quizzes, quiz review session, starred section problems, PracticeIt, and last-minute IPL help if you re sick please email me before your quiz date today: some more quiz tips from me :) R3 due tomorrow (eligible: P0, C1, P1, C2) P2 due next Tuesday, May 14th Lesson 12 - Spring 2024
Quiz Tips: Overall Prepare for the open-book quiz! consolidate your notes! bookmark helpful practice problems, Ed lessons, and slides before the quiz, clean up your desktop & open relevant tabs reminder: no communication, generative AI work must be yours Budget time during the quiz (45 minutes) spend more time on what was tough during quiz 0 leave time to make a submission for each section Lesson 12 - Spring 2024
Quiz Tips: Debugging & Programming Hit run, and hit run often Problems are primarily autograded, so make sure your code compiles and runs! Grading rubrics are in the spec read and think strategically! pay special attention to the S criteria, especially if low on time Testing you on reading the spec (+ debugging, programming) Today: how to think about edge cases Lesson 12 - Spring 2024
Edge Cases (and testing, debugging) When writing a method that takes in input (e.g. parameters, Scanner), think carefully about the assumptions you can (and can t) make! Edge Case: a situation that is at the edge of an input s valid values. In today s example: are all possible months and days handled? what about leap years? are all possible combinations of months and days handled? Lesson 12 - Spring 2024
Edge Cases and Types In languages like Java, it s helpful to think of common edge cases related to the type of the value. For example, for numbers (e.g. int, double) can you handle 0? division is especially nasty! for Strings, can you handle the empty string "" charAt is especially nasty! In future programming, you ll learn about many more of these (e.g. biggest and smallest numbers, null, empty array). Lesson 12 - Spring 2024