cse15l-lab-report

Part 1 – Debugging Scenario

Design a debugging scenario, and write your report as a conversation on EdStem. It should have:

The original post from a student with a screenshot showing a symptom and a description of a guess at the bug/some sense of what the failure-inducing input is. (Don’t actually make the post! Just write the content that would go in such a post)
A response from a TA asking a leading question or suggesting a command to try (To be clear, you are mimicking a TA here.)
Another screenshot/terminal output showing what information the student got from trying that, and a clear description of what the bug is.

Edstem

Student:

Hello, I’ve been trying to work on some code to work on my bash calls so I wrote some simple code on with the Fibonacci seqeunce however I can’t even get my code to work, I’m getting this crazy bug where it just prints a bunch of stuff over and over again that doesn’t even look like high values of fibonacci. Luckily I was able to ctrl c before my terminal got too crowded. The bug must be in the while loop but I don’t understand, it shouldn’t go on forever because I know I’m incrementing i.

image

TA:

I think I have an idea of what you issue may be. I know you confident are your incrementation of I in you code, but have you actually tested whether or not it is?

Student:

Nothing Changed! But it’s odd that it’s the same result as the previous one, could I have broken something else now?

image

TA:

Hmm that’s odd, did you recompile the code after you made changes to it with javac class.java?

Student:

Oh my goodness that’s embarrasing, but still why doesn’t i change at all? I’m certain I’m incrementing it. It it not being recognized by the while loop for some reason.

image

TA:

Maybe go where you incrementing it over one to see why this could be the case.

Student:

Hmmm I realised I had my incremetation of I outside of the loop , but it still didn’t change anything after I did it.

image

TA:

This one is a little harder to explain why it’s not working, perhaps try a more normal approach like a = b + c

Student:

Hmm interesting symtop I wonder why it didn’t increment even though i++ add’s one, so it i was 0 and it added 1 setting it to i wouldn’t that work I’ll have to look up why that is later. But it seems to work when I do this. .

image

TA:

Nice! And yeah always explore and try new things. And Hey it happens to the best of us sometimes.

Student:

Okay I think I have it figure out now. So not only was I not incrementing it in the while loop the syntax that I choose wouldn’t even have done anything Cool lets get to the bash stuff!

image

TA:

Well done! And it happens to the best of us.

Student:

Hmm that’s odd

image

TA:

Recall when trying to clone something from git hub, you need to add git clone rather than just use command clone cause it wouldn’t recognize it either.

Student:

Ah right I need to write bash fib.sh. But weird I it won’t count again? I would think that $0 looks at the first argument and not the command but it seemed to work. What happened? (ignore my mistake)

image image

TA:

You are right and wrong. It’s more accurate to refer to everything as a command line argument, so fib.sh is actually the first where what every you put after as the second, so on and so forth. Fun fact if you changed it to $5, it could still work but you’d need to make 6 arugments instead.

Student:

Ahhh I see thank you for your time and patients. I was really struggling there and you really saved me and I learned a little more about how the command line works that I wasn’t quite crystal clear on!

At the end, all the information needed about the setup including:

image

FibCalc.java

public class FibCalc {
    public static void main(String[] args) {
        int num = Integer.parseInt(args[0]);
        int first = 0, second = 1;
        System.out.print("Fibonacci sequence: ");
        int i = 0;
        while (num > i){
            System.out.print(first + ", ");
            int next = first + second;
            first = second;
            second = next;  
        }
        i = i + 1;
    }
}

Fib.sh

   java FibCalc $0



java FibCalc 8

to trigger the infinite loops

bash Fib.sh

to trigger the incorrect bash command




Part 2 – Reflection

I really liked learning about Vim. It seems like such a impressive tool that is able to do many different things, specifically without having to use a track pad or mouse which I’ve been told drastically increases the speed of the work you do which, based on my personal experiences am inclined to agree with. Although I’m still new to things in it I hope the skills I’ve learned from in lab/class and from friends will be of help in the future. I’m still fairly unclear on some of the things but I’m sure if I dedicate a decent amount of time, consulting the internet, friends and perhaps even chatGPT I’ll get quite good at it!