Week-2-Lab-Report

Week 4 Lab Report - Lab Report 2

Incremental Programming and Debugging

Created by: Erwin Madjus

Last Edited: March 24, 2022

3 Code Changes That Were Made During Labs 3 and 4:

The link to all of the commits that I have made can be found if you click on the following link:

Link to MarkdownParse Repository Commits

Problem #1 -

Image

Link to the Code Change Diff #1

Exception in thread "main" java.lang.StringIndexOutOfBoundsException: begin 0, end -1, length 225
        at java.base/java.lang.String.checkBoundsBeginEnd(String.java:3720)
        at java.base/java.lang.String.substring(String.java:1909)
        at MarkdownParse.getLinks(MarkdownParse.java:18)
        at MarkdownParse.main(MarkdownParse.java:27)

Image

The bug was that instead of putting the link inside of (), I put it inside of [], and this resulted in a failure-inducing input stating

Exception in thread "main" java.lang.StringIndexOutOfBoundsException: begin 0, end -1

and led to the symptoms where the program could not read nor find the link that was in the markdown file and could not find the open parenthesis nor the closed parenthesis. To allow the program to display the expected outcome, I had to use the correct code needed to display a link.

[FirstError.com]

Image

Problem #2-

Image

Link to the Code Change Diff #2

erwin@Erwins-MacBook-Air markdown-parse % java MarkdownParse test-file3.md
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
        at java.base/java.util.Arrays.copyOfRange(Arrays.java:4031)
        at java.base/java.lang.StringLatin1.newString(StringLatin1.java:767)
        at java.base/java.lang.String.substring(String.java:1914)
        at MarkdownParse.getLinks(MarkdownParse.java:18)
        at MarkdownParse.main(MarkdownParse.java:27)

Image


[SecondError.com]

Image

The bug was that I included too many open and closed parenthesis (( and ) ) and this resulted in a failure-inducing input stating OutOfMemoryError: Java heap space. This then led to symptoms where the program was unable to find a closed parenthesis where it should be, for example, there was an open parenthesis before there was an expected closed parenthesis. To “fix” this symptom, I had to remove the extra parenthesis that were placed around the link.

Problem #3-

Image

Link to the Code Change Diff #3

erwin@Erwins-MacBook-Air markdown-parse % java MarkdownParse test-file4.md
[]

Image

erwin@Erwins-MacBook-Air markdown-parse % java MarkdownParse test-file4.md
[ThirdError.com]

Image

The bug was that I did not put the link in the correct location, inside of the parenthesis () and this did not result in a failure-inducing input because the program didn’t know what to state since there were no links in between the parenthesis. This then resulted in a symptom where the program had an output with brackets [] but had no link in between them. To “fix” this outcome, I just had to put the link in betweent the parenthesis.