-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial edits and AI generated chats
- Loading branch information
Showing
1 changed file
with
275 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,275 @@ | ||
--- | ||
layout: page-fullwidth | ||
subheadline: Week 8 | ||
published: true | ||
title: "Week 8 β Debuggers" | ||
tags: | ||
- post week | ||
categories: | ||
- week | ||
header: no | ||
todos: | ||
- due-date: "11:59am February 23, 2021" | ||
name: "Quiz 8" | ||
url: "https://www.gradescope.com" | ||
- due-date: "5pm February 25, 2021" | ||
name: "Lab Report 4 (Week 8)" | ||
url: "https://ucsd-cse15l-w22.github.io/week/week8/#week-8-lab-report" | ||
- due-date: "5pm February 25, 2021" | ||
name: "Updates to Lab Report 3 (Week 6)" | ||
url: "https://www.gradescope.com" | ||
notes: | ||
- name: "Monday 1pm" | ||
url: "https://drive.google.com/file/d/1W6AgudjwDFJOWsM4hoBR1Lz0w5bb0ct7" | ||
- name: "Monday 2pm" | ||
url: "https://drive.google.com/file/d/1xKvQgcVXdBUB7Qj0h2Psd2xDd4TB-EbW" | ||
- name: "Monday 3pm" | ||
url: "https://drive.google.com/file/d/1lobaN3IpIMQ4HE8WuidJ3UI6Ju6wk16J" | ||
--- | ||
|
||
<div class="row"> | ||
<div class="medium-4 medium-push-8 columns" markdown="1"> | ||
<div class="panel radius fixed-toc" data-options="sticky_on:large" markdown="1"> | ||
**Table of Contents** | ||
{: #toc } | ||
* TOC | ||
{:toc} | ||
</div> | ||
</div><!-- /.medium-4.columns --> | ||
|
||
<div class="medium-8 medium-pull-4 columns" markdown="1"> | ||
|
||
## Due Dates & Links | ||
|
||
### Due This Week | ||
|
||
<ul> | ||
{% for todo in page.todos %} | ||
<li><a href="{{ todo.url }}">{{ todo.name }}</a> - Due {{ todo.due-date }}</li> | ||
{% endfor %} | ||
</ul> | ||
|
||
### To Watch/Read | ||
|
||
- Videos on `jdb`: | ||
- [Debuggers and `jdb`](https://www.youtube.com/watch?v=0Olg_U0Su_I) | ||
- [`jdb` and Infinite Loops](https://youtu.be/AFkUAwvPTGA) | ||
|
||
## Lab Tasks | ||
|
||
Discuss with your group: | ||
|
||
### Editing at the Command Line | ||
|
||
**Everyone** should do this; it's skill practice that you all need. | ||
|
||
Log into ieng6. Run the command `vimtutor`. Set a timer for 15 minutes. | ||
|
||
Complete the first two lessons (go past lesson 2 if you can in 15 minutes). | ||
Really do the exercises! | ||
|
||
Then quit the tutor, clone (or pull if you've already cloned) **your** copy of | ||
`week8lab` onto ieng6. We have provided you think link here: | ||
[week8lab](https://github.com/ucsd-cse15l-f23/week8lab.git) | ||
|
||
Make sure you can use `javac -cp .:lib/hamcrest-core-1.3.jar:lib/junit-4.13.2.jar *.java` to build it and `java -cp .:lib/hamcrest-core-1.3.jar:lib/junit-4.13.2.jar org.junit.runner.JUnitCore HandlerTests` run your tests. Note that since you last saw ChatServer, our devs have updated a key known bug where the main method did not match the name of the java file. It has since been fixed and the main method is now `ChatServer`. | ||
|
||
Still on your own, open the test file by giving it as an argument to `vim`, like | ||
`vim HandlerTests.java` (you might need to `cd` into the repository | ||
directory first). Add a test using the vim editing commands you learned, then | ||
save, quit, and rerun the tests. | ||
|
||
You've just done programming entirely on ieng6; you didn't need VScode at all, | ||
just a terminal! | ||
|
||
As a group, discuss and **write in notes**: | ||
|
||
- What were two things you thought were annoying about using Vim? Be specific. | ||
- What were two things you thought were cool about using Vim? Be specific. | ||
|
||
### Using a Debugger | ||
|
||
Do this part as a group, while logged into someone's account on `ieng6`. Here we will look at a branch in our code that is currently in developement and a work in progress. You and your group have been tasked with testing the new beta branch which adds functionality to the original ChatServer. | ||
|
||
1. Make a fresh clone of [https://github.com/ucsd-cse15l-w22/week8lab](https://github.com/ucsd-cse15l-w22/week8lab) | ||
2. In the checkout, run </br>`javac -cp .:lib/hamcrest-core-1.3.jar:lib/junit-4.13.2.jar *.java` </br> and </br>`java -cp .:lib/hamcrest-core-1.3.jar:lib/junit-4.13.2.jar org.junit.runner.JUnitCore HandlerTests` </br>Notice that we have test failures. | ||
3. ## Use `jdb` with `ChatServer` to run _just that markdown file_ from the command line using the `main` method of `ChatServer`. Take use `jdb` commands to get the following information and take screenshots of it: | ||
- The stack trace when the exception is happening | ||
- The local variables in `getLinks` when the exception is happening | ||
4. Next, use `jdb` to run the JUnit tests.You can refer to the lecture videos for a good way to | ||
do this. Again, use `jdb` commands to find: | ||
- The stack trace when the exception is happening | ||
- The local variables in `getLinks` when the exception is happening | ||
|
||
Then, diagnose and fix the bug so that all the tests pass. Make a commit with | ||
the fix and push it, then link to the commit in your notes. | ||
|
||
|
||
Write down in notes answers to these additional questions: | ||
|
||
- What is information that you were able to get via `jdb` that you would be | ||
unable to get via the stack trace of the exception? | ||
- What are some pros and cons of using `jdb` to get information vs. adding print | ||
statements to do so? | ||
- Discuss the `findCloseParen` method βΒ are there other places in parsing | ||
markdown where a method like this may be useful? | ||
|
||
|
||
### More Debugger Uses | ||
|
||
Switch to another student to screenshare, still using `ieng6`. | ||
|
||
Change `findCloseParen` so that it has an infinite loop (for example, remove the | ||
increment `closeParen++`, or change the condition). Re-run `make test` and | ||
verify that a test is in an infinite loop. | ||
|
||
Practice using `jdb` with `suspend` to pause the program and show the stack | ||
trace during the loop. You should be able to identify: | ||
|
||
- Which test is triggering the infinite loop | ||
- Which line the program stopped on when the program was `suspend`ed | ||
- What the current values of all the variables are in `getCloseParen` at the | ||
moment the program suspended | ||
|
||
Take a screenshot or copy/paste of your `jdb` session and indicate in your notes | ||
each of the three items above and how your `jdb` session informs you of that. | ||
|
||
|
||
## Week 8 Lab Report | ||
|
||
Consider the following chat histories between the professors: | ||
|
||
### Snippet 1 | ||
|
||
``` | ||
[Joe]: Hey, did you hear about the Java developer who walked into a bar? | ||
[Edwin]: No, what happened? | ||
[Joe]: He said, "Give me a strong cup of Java! And make it Object-Oriented!" βοΈπ | ||
[Onat]: Haha, that's a good one, Joe! Speaking of Java, did you know that Monty Python's Holy Grail was written in Java? | ||
[Edwin]: Really? I thought it was written in Python! | ||
[Onat]: Well, that would make more sense, wouldn't it? But it seems they had a "Java Holy Grail" moment! ππ | ||
[Joe]: And let's not forget the Java programmers who always have to deal with "NullPointerExceptions." | ||
[Edwin]: Yeah, they're like the Knights Who Say "Null"! They're always on a quest to find that elusive object. | ||
[Onat]: True, true! And when they finally find it, they shout, "Eureka!" just like Archimedes. | ||
[Joe]: Haha, the life of a Java developer can be quite the adventure, just like a Monty Python sketch! | ||
[Edwin]: Indeed! But at the end of the day, we all know that "The Spam of Java is not a valid beverage!" ππ«βοΈ | ||
[Onat]: Well said, Edwin! Let's keep the Java and Python jokes rolling, and help our student's code be as legendary as a Monty Python tale! πππ¨βπ» | ||
``` | ||
|
||
### Snippet 2 | ||
|
||
``` | ||
[Onat]: Hey guys, have do you know why the chicken crossed the road? | ||
[Edwin]: Was it late to class? | ||
[Joe]: To get to the other side? | ||
[Onat]: No, to escape the Ministry of Silly Walks! π | ||
[Edwin]: And did you hear about the lumberjack who wanted to be a dentist? | ||
[Onat]: Nope, what happened? | ||
[Edwin]: He got tired of the daily grind! π²π | ||
[Joe]: That's a good one, Edwin! But let me tell you about the time I tried to buy a shrubbery for my garden... | ||
[Onat]: A shrubbery, you say? Did the Knights Who Say "Ni" give you a hard time? | ||
[Joe]: They did! They demanded a sacrifice of... a herring! π | ||
[Edwin]: Well, that's not too bad. At least they didn't ask for a dead parrot. π¦ | ||
[Onat]: Ah, the dead parrot sketch! I love how they could turn the most ordinary situations into comedy gold. | ||
[Joe]: Absolutely! It's like their humor is a cross between a witty intellectual and a three-headed knight! | ||
[Joe]: Agreed! Now, let's not be too silly and get back to work before we end up in a sketch ourselves. π | ||
``` | ||
|
||
### Snippet 3 | ||
|
||
``` | ||
[Joe]: Hey, have you heard about the Java bug that's as elusive as the Force? | ||
[Edwin]: No, tell me more! | ||
[Joe]: Well, it's like a Jedi mind trick. It only appears when you're not looking for it! π§ββοΈ | ||
[Onat]: Haha, that sounds like a classic Java bug. But you know what's even more mysterious? Jar Jar Binks's role in Star Wars! | ||
[Edwin]: Oh, Jar Jar... He's the real mystery of the galaxy. Maybe he's secretly a Java developer trying to fix bugs in the codebase. | ||
[Joe]: Or perhaps he's a Sith Lord in disguise, using the Dark Side of the Force to cause those Java bugs! | ||
[Onat]: That would explain a lot! "Meesa causing bugs, oopsie!" π | ||
[Edwin]: And when you finally find a solution to a tricky Java bug, it's like saying, "These aren't the bugs you're looking for!" | ||
[Joe]: Absolutely! You wave your hand and hope the bug disappears. But it usually doesn't work that way. | ||
[Onat]: Well, as they say in the Java world, "May the stack trace be with you!" ππ | ||
[Edwin]: Haha, that's the programmer's version of "May the Force be with you!" Let's hope we can squash those Java bugs and keep the galaxy safe from code errors! | ||
[Joe]: Agreed! And may our code be as strong as the Force itself. π€πΎπ» | ||
``` | ||
|
||
For **each** snippet, add a test both to **your** implementation of | ||
markdown-parse, _and_ the implementation you reviewed in week 7. Run the tests and show | ||
the results of running the tests on each. This means you should add a total of | ||
**6** test methods (3 to your implementation and 3 to the one you reviewed). | ||
|
||
This means you will need to clone and run both your implementation and the one | ||
you reviewed in week 7, make some small edits, and run them both. | ||
|
||
Your report should include: | ||
|
||
- A link to your markdown-parse repository and a link to the one you reviewed in week 7 | ||
- For each test above: | ||
- Decide on what it _should_ produce by using either VScode preview or [the CommonMark demo site](https://spec.commonmark.org/dingus/) | ||
- Showing the code in `MarkdownParseTest.java` for how you turned it into a test | ||
- For **your implementation**, the corresponding output when running the | ||
tests; if it passed, say so. If it didn't pass, show the specific part of | ||
the JUnit output that shows the test failure. | ||
- For **the implementation you reviewed in Week 7**, the corresponding output when running the | ||
tests; if it passed, say so. If it didn't pass, show the specific part of | ||
the JUnit output that shows the test failure. | ||
- Answer the following questions with 2-3 sentences each: | ||
- Do you think there is a small (<10 lines) code change that will make your | ||
program work for snippet 1 and all related cases that use inline code with | ||
backticks? If yes, describe the code change. If not, describe why it would | ||
be a more involved change. | ||
- Do you think there is a small (<10 lines) code change that will make your | ||
program work for snippet 2 and all related cases that nest parentheses, | ||
brackets, and escaped brackets? If yes, describe the code change. If not, | ||
describe why it would be a more involved change. | ||
- Do you think there is a small (<10 lines) code change that will make your | ||
program work for snippet 3 and all related cases that have newlines in | ||
brackets and parentheses? If yes, describe the code change. If not, describe | ||
why it would be a more involved change. | ||
|
||
|
||
If you're using a direct clone to `ieng6`, you might find it useful to give an | ||
extra argument to `git clone` that specifies which directory to clone into, for | ||
example: | ||
|
||
``` | ||
$ git clone https://github.com/ucsd-cse15l-w22/markdown-parse markdown-parse-target-directory | ||
``` | ||
|
||
Add your lab report as `lab-report-4-week-8` within the same Github pages lab | ||
reports repository you've been using all quarter, and include all of the | ||
elements above. |