first month of coding, a reflection

Photo by Andrew Neel on Unsplash

first month of coding, a reflection

·

5 min read

Although picking up something new is always nerve-racking, it is way scarier when you know close to nothing about it. That was me roughly a month ago, or more specifically on 26 September 2023, when I decided to start learning coding.

While coding was something that I always wanted to start learning, I found myself quickly losing interest and motivation once I got stuck on a problem. To make things worse, the pros and cons of different languages, combined with the differing opinions of different people made it way more confusing than it needed to be.

Finally, I settled on C++ and thus began my journey to become a developer.

In this one month, I started from the very beginning. I decided to start by learning from Codecademy due to the interactive exercises it offered. Slowly but surely, I could feel myself becoming more and more confident, from having to refer extensively to the simplified "cheatsheets" provided by Codecademy, to eventually searching for references on Mozilla Developer Network (MDN) on my own.

At that point, I didn't know that I was barely scratching the surface of C++. As I watched my course progress inch closer and closer to 100%, I felt a great sense of accomplishment.

Being the overly excited person that I am, I started diving into resources, including YouTube videos, Reddit posts and good ol' books to find out what I should do next. I hated the feeling of being lost, and I needed to have a very clear roadmap to motivate myself. This would probably explain how I progressed so quickly through the Codecademy course, with the directions and steps being listed so clearly and explicitly for me.

That was when I realised how blissfully ignorant and oblivious I was. As I was looking through resources, I landed on this page that carefully listed out the step-by-step guide to becoming proficient in the different languages. It was at this point when I felt an overwhelming sense of despair, as I realised how much more there was to the language, and how inadequate Codecademy was.

Don't get me wrong, I have no regrets about starting with Codecademy. It allowed me to experience coding through a web browser. It was simple and straightforward. This simplified process largely reduced any starting inertia. However, the lack of depth in the concepts covered proved how inadequate it was to paint a comprehensive picture of C++.

The dread of "where do I go on from here" struck me hard, as I tried to figure out my next game plan. The roadmap was helpful, but where and how can I learn about the listed topics?

While pondering and planning for this, I took a break from coding. I found myself watching videos after videos on things like best coding practices, others' experiences starting as a developer, game development specifically and much more. Different from previous times, however, I found my motivation growing stronger in the short break I took, and with a clearer plan, I went back to coding.

I started diversifying out, and as many have suggested, the most effective way of learning is through hands-on projects. With that, I found this site that suggested 20 projects, with source codes. This was immensely helpful, as I was able to look through the source codes when I got stuck at something I couldn't resolve.

My workflow was a 5 steps approach, with the first being to just visualise the end product. From there, I note down the key features of my ideal end product and break down the project into smaller chunks. I then lay down the structure through the use of comments, splitting the code into various segments. Finally, I get to coding, and making sure the code runs smoothly. For my last step, I try to reflect and see if there is anything that I could improve on to make the code more efficient.

The last step was derived during an exercise on Hackerrank.

My first attempt was done literally with zero thoughts for efficiency, but hey I mean, it works...

    if (n == 1){
        cout << "one";
    }
    else if (n == 2){
        cout << "two";
    }
    else if (n == 3){
        cout << "three";
    }
    else if (n == 4){
        cout << "four";
    }
    else if (n == 5){
        cout << "five";
    }
    else if (n == 6){
        cout << "six";
    }
    else if (n == 7){
        cout << "seven";
    }
    else if (n == 8){
        cout << "eight";
    }
    else if (n == 9){
        cout << "nine";
    }
    else if (n > 9){
        cout << "Greater than 9";
    }

While I was typing that long chain of "else if", I kept thinking this can't be the only way to do this... It was too inefficient, long and tedious... Once I submitted this attempt, I started looking through the code and figuring out where I could add a loop to simplify this. Ultimately, I ended up with this.

    //given positive int n, print lowercase english word
    int n = 0;
    cout << "Enter a number.\n";
    cin >> n;
    vector <int> numbers = {1, 2, 3, 4, 5, 6, 7, 8, 9}; 
    vector <string> numbers_word = {"one","two","three","four","five","six","seven","eight","nine"};

    for (int i = 0; i < numbers.size(); i++){
        if (n == numbers[i]){
            cout << numbers_word[i] << "\n";
        }
        else if (n > 9){
            cout << "greater than 9\n";
            break;            
        }
    }

Undeniably, I took way longer to derive my second solution than my first. However, this not only reinforced my concepts on loops, but it also helped me realise the importance of reflection.

It was this that drove me to start a journal, recording my thoughts and reflections through this journey of coding and programming. With that, I conclude the first post of my Code of the Day. See you in the next post!

// feel free to leave tips on how to improve and suggestions on what to do next! thanks for reading!