CS50 Times

This is about how and why I have started to watch lectures of CS50.

Volkan
5 min readSep 11, 2020
I love the last part “Art of Programming”

Nowadays I am looking for an answer to a question. How to be a good Software Developer ? I have been studying IOS development for three years. I have also developed so many softwares with using MATLAB and Python. But all these softwares are for solving some of my engineering problems. Like calculating some output depending on the inputs or trying some new equation with some different situations. But as I want to change my career path to IOS Developer and started to do some applications, I felt like something is missing when I write codes.

How to be a GOOD Developer ?

I am sure there is a better answer for this question. To me o good software developer is the person who writes “Good” codes. Then what is “Good” code ? This question also should have better answer. If you have better answer please write it down on the comments. I think a “Good” code should be easily read by a complete stranger who of course have knowledge about coding on that language. It is something like a good, catchy novel. Of course there is an indicator that shows how good your code is. Which is called Big-O notation.

According to wikipedia, Big O notation is a mathematical notation that describes the limiting behavior of a function when the argument tends towards a particular value or infinity. (https://en.wikipedia.org/wiki/Big_O_notation)

To me, Big-O shows how efficient is your code when things get complicated. If your code still works fine when you get your inputs larger (here I mean infinite like larger), that means your code’s Big-O order is low (means more efficient) enough to solve that problem.

Let’s Transform to a Good Developer!!!

I am afraid, this is not a thing like that you can transform in a second or in a month or may be in a year. I think it takes a life long to be a Good developer. Because evertime you need to search for a more efficient way to solve your problems. You don’t want to mess your computer memories or your CPU. But I need to start from a point. As I don’t have a CS degree, I wonder how Computer Science Lecture gives people the intuition of writing clean, efficient code, instead of just writing codes. So I started to look for Online Lectures about Introduction to Computer Science. Then I found CS50 and my journey begins.

CS50 Week-1

Actually there is a Week-0 which is about What is computer Science?, How computer works ? and What are the some common things that is used on Coding ?.

On Week-1, David (You can see his never ending energy waves that born from his body, pass through your screen and flow to your brain. I really admire him.) is talking about the language C. He explains the syntax, conditions, loops, variables. Yes you can learn all these things from any courses on Youtube. But the best part of this lecture is, David gives some little tricks about coding. Like “Do not repeat yourself!” or “Yes you can start counting from 1 when you are writing loops but Don’t!”. These are the moments that helps you being a good developer. Then, there is an (of course) assignment after the first lecture. By the way you can find whole course and other think on the link : https://cs50.harvard.edu/x/2020/.

Hello Mario

Week-1 assignment is about creating the bricks of Mario.

Do you hear the sound of the game ?

As you see on the picture we try to create this bricks with using printf function of C language with the symbol of “#”. Also we take the height parameter from user and if the parameter is less than 1 or more than 8 we do nothing and ask user again the to enter the height of brick.

First I try to figure out how to solve the problem and I decided to write for loop, inside a for loop to solve the problem.

void draw_pyramids(int height)
{
if (height == 1)
{
printf("#\n");
}
else
{
for (int index = 0; index < height; index ++)
{
for (int inner_index = 1; inner_index < height - index; inner_index++)
{
printf(" ");
}
for(int j = 0; j < index + 1; j ++)
{
printf("#");
}
printf("\n");
}
}
}

As I need to write some whitespace before # I use two for loop inside one for loop. This code passed all tests that have written by cs50 (you write cs50/problems/2020/x/mario/less to the terminal and it tests your code). But this code bothers me after a while and I decided to make it more simple.

void draw_pyramids_new(int height)
{
for (int row = 0; row < height; row++)
{
for (int col = 0; col< height; col++)
{
if (col >= (height - row -1))
{
printf("#");
}
else
{
printf(" ");
}
}
printf("\n");
}
}

And I have written the code above. This is also passed all test cases. But I find it more simple. I am not sure if it is more efficient ( I think not because I still use nested for loops.).

Conclusion

The thing I want to emphasize is this course makes me to think again about the code I have written. I like the idea to re-write a code for making it more efficient or like this time more simple (is it?). I will continue to watch other lessons. And my plan is to write a new article after I finish each assignment. I hop this will helps you to have foresight about CS50.

My solutions for problem set is on the link below. Hope to see you on Week 2. Happy coding.

Github : https://github.com/volkansahn/CS50-Fall2020.

--

--