Well, hello there. I decided that I would exercise today and run a few miles. I like to run, okay, maybe I only like to run because it is a form of exercise that feel works me and I have semi-motivation to do. It has been a while since I have run and boy can I tell! It is amazing how quickly you get out of shape but how long it takes to get back in the shape you were once in. I can see the translation to your coding skills.
It obviously has been a while since I wrote a blog. That most likely (and does) mean that I haven't been able to code much. My wife is now on summer break (yeah!) and I don't need to take our daughter to day care in the mornings. This means that I am able to come in to work earlier and get some stuff done before anyone else gets there (except Levi, I can't seem to get in the office before him).
I have made good use of the time in the mornings. For Monday - Wednesday I did a course on Pluralsight called C# From Scratch by Jesse Liberty. I know, I know, I am not starting from scratch, but I wanted a refresher course. It was good to jump back in the code and feel like I might be able to make some progress.
Today I started with a Code Kata from codewars.com. Let's be honest, even the basic ones take me a while to complete. This one, even though I couldn't get exactly what the kata was looking for, took me about an hour. I think the kata was looking for me to implement something that didn't use the built in Math functions. Well, I took the kata and decided to make a console application that will help you determine if a number is a square root and if it is a square root, find the next square root number. Simple app, I know. And, have I ever heard of a calculator? Or course I have, but who wouldn't want to use a console application to find if a number is a square root.
I ran into some issues while creating this app. I tried to use too few methods and one time got stuck in an infinite loop. I was trying to determine what key was pressed to see if you wanted to try another number. Well, it turns out it was true every time, no matter what you pushed. I decided to try breaking out my the piece that determines what key was pressed into a new method called start(). Hey! No longer an infinite loop!
public bool start()
{
Console.WriteLine("Press 'n' to start again");
var restart = string.Empty;
restart = Console.ReadLine();
if (restart == "n")
{
return true;
}
else
{
return false;
}
}
I know my if statement isn't the most efficient code, eight lines of code (inlcuding the bracket lines). I did a little research (okay, Visual Studio told me) that I could do a switch statement and take out a few lines. I could have also written:
return restart == "n";
Much better! One line! I like it.
Well, I hope this summer I can spent a lot more time on learning C#. Not only can I go in early and use the start of my day to learn, but I also will be moving to a team that I will be working with our code base a lot more.
Program:
Download the Zip
GitHub Repository:
https://github.com/robertjorg/SquareRootsConsole/tree/master/SquareRoots
Happy reading, don't be a square!
It obviously has been a while since I wrote a blog. That most likely (and does) mean that I haven't been able to code much. My wife is now on summer break (yeah!) and I don't need to take our daughter to day care in the mornings. This means that I am able to come in to work earlier and get some stuff done before anyone else gets there (except Levi, I can't seem to get in the office before him).
I have made good use of the time in the mornings. For Monday - Wednesday I did a course on Pluralsight called C# From Scratch by Jesse Liberty. I know, I know, I am not starting from scratch, but I wanted a refresher course. It was good to jump back in the code and feel like I might be able to make some progress.
Today I started with a Code Kata from codewars.com. Let's be honest, even the basic ones take me a while to complete. This one, even though I couldn't get exactly what the kata was looking for, took me about an hour. I think the kata was looking for me to implement something that didn't use the built in Math functions. Well, I took the kata and decided to make a console application that will help you determine if a number is a square root and if it is a square root, find the next square root number. Simple app, I know. And, have I ever heard of a calculator? Or course I have, but who wouldn't want to use a console application to find if a number is a square root.
I ran into some issues while creating this app. I tried to use too few methods and one time got stuck in an infinite loop. I was trying to determine what key was pressed to see if you wanted to try another number. Well, it turns out it was true every time, no matter what you pushed. I decided to try breaking out my the piece that determines what key was pressed into a new method called start(). Hey! No longer an infinite loop!
public bool start()
{
Console.WriteLine("Press 'n' to start again");
var restart = string.Empty;
restart = Console.ReadLine();
if (restart == "n")
{
return true;
}
else
{
return false;
}
}
I know my if statement isn't the most efficient code, eight lines of code (inlcuding the bracket lines). I did a little research (okay, Visual Studio told me) that I could do a switch statement and take out a few lines. I could have also written:
return restart == "n";
Much better! One line! I like it.
Well, I hope this summer I can spent a lot more time on learning C#. Not only can I go in early and use the start of my day to learn, but I also will be moving to a team that I will be working with our code base a lot more.
Program:
Download the Zip
GitHub Repository:
https://github.com/robertjorg/SquareRootsConsole/tree/master/SquareRoots
Happy reading, don't be a square!