Tuesday, July 12, 2016

Starting from scratch...

The title is misleading, I guess. I am not starting from scratch. I actually decided to restart the C# book and there are a few reasons that, I at least think, are good enough to start at the first page. I decided to do this probably two weeks back. There had been a large amount of time between me actually opening the book and working on the activities that I felt I would benefit from going back and playing again. Reinsert enough credits to play again.

Two weeks have now passed and I am to the first lab between chapters four and five. Seems pretty quick, right? I will say that the first four chapters went faster the second time around. I did not have to spend as much time looking things up or going back to reread. I guess the first time through those chapters did something, I could remember most of what was going on. I hope that my knowledge from last time will help me finish the first lab before too long. I also guess that if I get really stuck I could reference my pooping dog app from last time, I am going to try not to leave a trail behind the dogs as the run this time.

Although I could remember a lot, I still tried to take better notes this time around in hopes that I won't have a situation requiring me to start from the beginning again. I may have to reference the book, or maybe just my notes. Who knows? Perhaps, after I know how to really code, I won't need to reference the book or my notes (will I ever be that good and make it through the level with all my hit points?).

The next series of blog posts will be me going through my notes and putting them on the blog as a reminder of what I did to have a reference that will be forever immortalized in the cloud as everything in this day and age will soon be (does anyone else use Office 365 to have access to all their computer files?).

Why not start now on posting the Cliffs notes? I hope someone finds this useful and not too redundant from my previous posts.

The first item I found useful, that I did not use before, was the class diagrams. I thought last time I would skip making those and just type everything in code itself. These are easy, and easy to make in any program really, and help to visualize what should be in each class. Here is one class diagrams for the start of my second round at Off to the Races

A few pieces on classes that I wanted to point out:
  • Classes can do anything but generally only do one specific function
  • Classes contain methods that perform actions
  • The way you pass input into a method is through parameters
  • Program will start with a method called Main(). - You can change the main entry point of a program
  • Two classes can be named the same in the same namespace
  • A class can span multiple files but you must use the partial keyword when you declare the namespace

Hello, variables! Variables MUST be declared before they can be used. Visual Studio will give you a red squiggly line if you don't declare it first. You can use the debugger to watch how the variable is changing. This will probably be useful when you are getting some output you aren't expecting.

Loops:
Every loop has three statements.
  • Set up the loop
  • Second tells the true statement
  • Third is executed after each time through the loop

If/else statements use logical operators to check if a condition is true. For all conditional tests you have == (equals), != (does not equal), > (greater than), < (less than), as well as >= and <= to use for checking your conditional statements. A few more points on conditionals:
  • You can combine conditional tests by using the OR || operator and the AND && operator
  • Set your variable prior to running the conditional test

Enough for today. I hope that writing these down, and maybe for the second time, helps cement them in my brain. I also hope that I didn't miss anything important. Oh, and my Git is still there with all the projects this time and I think I know how to use it a little better now (I better! we are starting to use Git for work).


“It's never too late to start over!” 
― Lynne GentryReinventing Leona

Thursday, June 9, 2016

Today I decided to exercise...

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!

Wednesday, May 4, 2016

Vivaldi...no longer just a composer

Oops, I was drafting this and must have hit publish. Ten people saw my not even half written blog. I need to get better at this whole process. Sorry to those ten readers that probably won't reread this post.

About a week ago I read an article about internet browsers. There aren't many new entrants into this realm and the players seem to be pretty stable. I moved from Internet Explorer to Firefox to Chrome way back in the day. I apparently don't have a good track record with my browsers. Give me one the has better functionality and I will at least look at it. I don't feel there have been many other options come into the market since the release of Chrome in 2008 (granted I am most likely wrong). Well, in comes Vivaldi (don't worry it doesn't play classical music the entire time it is open). Vivaldi was created by the same people that brought us Opera (see a theme here?). I never used Opera, I know that I wasn't as into tech when it came out, 21 years ago! I thought I would give Vivaldi a try, the slogan is "A browser for our friends"

A little on the build of Vivaldi. It is built off Chromium, an open source project, along with other open source software. Given that, it looks a lot like Chrome, but with a few extra options and customizations to help you get the browser you really want. You are able to use all the plugins that you love so much in Chrome I believe that since it is built on Chromium.



I am writing this in the Vivaldi browser now. I really like all the options that Vivaldi offers. The first is the grouping of tabs. Tabs are great, but don't you ever get so many tabs that you have no idea what each tab is and you have to go through each one in order to find what you are really looking for? Well, you can now group them together (I think Opera allowed this as well, but never used it). The attached image shows the two grouped sites I have, blogger and gmail.


Once you have your tabs grouped you can then tile each tab into the same window. It is helpful if you don't want to have two windows open with the different pages open. Okay, not that big of a deal, but who really wants to have two windows open?


You will notice I have a dark theme for the browser, just one of the many options. There are also great options if you don't like using a mouse. You can set a keyboard shortcut for almost anything! In order to best utilize real estate on my screen I have two shortcuts, Alt + t and Alt + a to remove the tabs (at the bottom of my screen and not the top) and the address bar. There are so many other options for key board shortcuts.

There are also mouse movements that will do actions as well. The one I like the most would be the "Rocker" movements. You quickly press the right mouse button and then the left in order to move back to the previous page. Or, do left then right to move forward in the pages. Pretty nice that the browser is build to accommodate those that like to only use the keyboard and those that like to use the mouse as often as possible.

So many other options that can be done. Like how pressing Ctrl + Tab works. You can have it rotate through the order that the windows were last glanced out or go straight down the line. But not everything is good about the browser.

Really the most glaring downfall is that the browser doesn't appear to be as quick as Chrome. Pages load quicker in Chrome, but not too noticeable. You may lose a few seconds of productivity, but nothing that will keep me from using the browser.

I will continue using Vivaldi.Maybe I will find out more that I like about it. The slogan says "A browser for our friends." I have read they mean this to be a browser for those that were power users and wanted something beyond Chrome. I would venture to say that it is a browser for everyone. Even if you aren't a power user, there is something here for you.

"If you don't like this, I'll stop writing music." - Vivaldi (or maybe I'll stop writing blogs)

Saturday, April 23, 2016

Topics...who needs them? (I do)

So, I pretend I know about technology. I actually only know a little about a lot. I need to tell the truth to all my readers. I have been very fortunate, and very lucky, to get my job with my current company. I have been writing about my experiences learning code but lately I have been going to work with challenging days and not enough time to do learning at work. Once I get home I have been wanting a little time with my wife and daughter and then taking down time. 

The reason for such the difficult times at work is that both of implementation specialists (my old role) are moving to new teams. I am moving to another engineering team and the the other specialist is moving to the client operations side of the business. Technically he isn't moving until June 1 and up to that date he should be working 50% as an implementation specialist and 50% in his new role. It has turned out that he is spending a lot more time with his new role and less time with the implementation role.

The time spent is in no way Tim's fault. This is a new role for him on a different team, and we all know that once you are leaving a department/job that you are done and ready to move on. Since I am staying in the same department it is much easier for me to keep doing the work and help to keep the team floating. It is wearing on me. I have been doing a bigger work load and just surviving. I should have brought this up to managers sooner, but I didn't and thought I could handle the load.

Taking time out of my nights to learn, when I just needed to unwind wasn't going to happen. I know there are ways to learn, outside or reading my C# book, but I don't know of these places as readily as pulling out a book. Similar to my previous blog about the communities we all belong to, there are places we can learn that will provide quick learning environments, like Code Wars or reading a blog on technology. Anyone know some good technology blogs or coding blogs that would be good for a newbie coder? I know at this point I shouldn't be as newbie, but I haven't been able to spend as much time as I would like to further my knowledge of coding and C#, life gets in the way.

I hope that once my replacement is hired (he starts on May 10th) and trained that I can get the rest of the sustaining team to help pick up the slack until we are able to get another implementation specialist hired for Tim's position and that I will be able to start working on the new team, which will be more coding and using different technologies. Until then, I need to find a list of topics that I can write about for the weeks where I haven't been able to do much learning or even looking at my C# book. So, what are the topics that a newbie programmer should be talking about?

P.S. thanks to Brett for starting to write a blog again, I am hoping it will help keep me motivated to write mine even after I don't sit next to him anymore. You can catch his blog at: http://technophiletester.hintonweb.com/

Saturday, April 2, 2016

Time sure goes by quick...

I recently made a decision. I decided to put the lab on hold because I was running into roadblocks and have been stuck for a while (it appears three weeks have passed since I last wrote!). So, I am moving on in the book and will come back to the lab to complete after I have been working on something different. When I was working on the lab, I would write code and it would do nothing like I would expect and so I would search, change the code, and find it also did not work. Frustration was growing until I finally said I need to take a break and learn something new. So, chapter nine hear I come. I think this will be an interesting chapter, it is teaching me how to read and write to objects, like a file or database. This is nice, we write to databases at work and I think it will be nice to understand how we are doing it.

This has brought me to think about coding in general. How do you know when you need to reach out to someone for additional help? Yes, I can continue working on the lab (and I will return to it) to finish and ask others around me for help on what needs to be done. I have done some bug fixes and small feature work for my job. I have received help all along the way while doing these. Usually, I would search on Stack Overflow or other forums reading to see if I could find the solutions I need. Then I would try some of the code and if it didn't work after a few times I will reach out to someone. The person I reach out to can usually answer my question and show me what to do in a short 15 - 20 minutes. I have just spent a couple hours working on it myself without getting somewhere.

OK, sometimes I do find the answer and I think I am better for it. I will probably remember the answers I took a few hours to find than those that are shown to me by someone at work. There has to be a balance, but what is the right balance? I find that sometimes I find the answer after just asking someone for help and talking through my issue. It makes me think about what I am trying to do and say what the code is doing out loud to someone else.

Sorry for the disappointment on the many weeks between blogs and not having the lab done. Maybe I didn't disappoint you, but I am bummed.

On a side note, I got a new job at work. I have been an Implementation Specialist. I would mostly work with clients to install our product and trouble shoot tier 2 issues. Well, they asked me to move to be a Software Engineer in Test. A lateral move, but I will be testing our product and possibly even coding more. I am excited for the change. I have been doing the implementations for almost two years and it has been great. I like working with the customers and really digging into our product. I will be moving teams and focusing on one specific function of our products so I will be deep diving into the code and how that portion works. I know I will start by writing tests and looking for bugs. Eventually, I will be coding, probably a lot more than when I was doing implementations because I won't have the tier two support to also work on. Exciting times!

Friday, March 11, 2016

Ghosts, Bats, and Ghouls...Oh my!

My work recently did a day called Open Space (I believe the thought was that it would replace what we previously did called Hack-a-thons). I had no idea what to think going to Open Space and it turns out to be a great idea. Whatever happens was meant to happen. Anyway, if you haven't done an Open Space, it is a cool idea and worth doing. What happened at our first Open Space is that I decided to host a session about learning C#. Turns out it was a popular session, I think we had 15 people in the session. I better know my stuff! 

At the session I talked about what I was doing with the C# book, Code Newbies, Code Wars, and just trying to pick up stories at work. We walked through an example of the last program I wrote and everyone was interested in my blog. Well, it has been a couple weeks since I wrote a post on my coding. I have been working on the latest and greatest game, The Quest. I have been slow going and spending time when I can find it to work on this project. This is a lab though and there is no help. I have been making sure I understand what I am doing with the code and it is taking a while. So far, I believe I have most of it written, I need to write what each of the available weapons do and then wire up the Windows Form to start working. I neglected to write more about the process while I was doing and it turns out that people are actually reading my blog. I was asked today if I was going to blog about the time I was spending on this project. Short story, people read my blog and about the adventures I have embarked on.

Now, onto The Quest.
The picture is the base for the form, it contains all the pictures that will be needed for each level. The form will control when the weapons are picked up and which enemies are present for the level. Well, I get to use inheritance quiet often in this project. I have a Mover class, and abstract Enemy class (which inherits from Mover), three different types of Enemy (inherits from Enemy class), a Player class (inherits from Mover), and the weapon classes (also inherits from the Mover class). My move class controls a large number of what the game does.

To make sure I have good encapsulation, I have the form that will only call the Game class and the Game class will call the correct methods from each of their respective classes. Now, I am having a problem, I am having a hard time deciding which class that methods best fit and if I need to have a private object or public objects. 

I talked to my team lead about the problems I was having with this. I just needed a gentle reminder, Private objects will only be used in their class. Objects should only be public when they will be called by another class. To better encapsulate our objects we call the public object, but the private is the only one that can change our public object.

As I have been writing the code and following the "hints" I am given from the book, I have gotten a few errors, like I created a method using public abstract string Name. I had the lovely red squiggly lines in VS. Hey, you can't have an abstract method when the class isn't abstract! The error was pretty helpful, it still took me a few minutes to realize what the error was telling me. I got it. Another error I got while working on the Weapon class. Below is the picture:

 The NearBy class only has two arguments. I remembered this one pretty quick, I need to overload this method and have it use have one method with two arguments and the overloaded method taking three arguments. 

I am also overriding a method called Move for each of my enemy types. Honestly, this confuse me for a minute on what I needed to call. I had the example the book gave me for the Mover class with the Move method. The enemies need to find out where the player is to determine which direction to move. I forgot that I had method in the Game class that determines where the player is at and the enemy class instantiates a game class. 

 
Things are starting to come together and, after I think about what needs to be done for a while, I have started realizing what needs to be done. It is slow going, but I hope I become better and more efficient with the coding and realizing what needs to be done. Maybe I can give you The Quest in the next week.

Thanks for reading, I'm off to read The Marian.

Thursday, February 25, 2016

Anyone hungry?

So, I was almost done with chapter 8. It was just a few more collections that act similar to lists. They are queues and stacks. The book used language I was used to hearing in my prior job, LIFO and FIFO (last in first out and first in first out). LIFO refers to stacks and FIFO refers to queues. I thought about those and how I choose how to treat my lots when buying stocks, do I want to pay taxes on those I first bought when I sell or those that were the most recent purchase. Okay, an easier way to think about it queues: treated like a line, the people who get in line first are the first to get their food or be seated. Stacks are take the top, like Pringles. You have to take the top Pringle in the can to get to the ones at the bottom.

Alright, seems simple. Let's take a look.To create a queue you add some code like:

Queue myQueue = new Queue();

Then to add to the queue:

myQueue.Enqueue("Piece of data");

Or remove:

myQueue.Dequeue;

Remember FIFO. That "Piece of data" we put in will be the first out. And now to show stacks:

Stack myStack = new Stack();

A little different to put in a stack, we push the piece of data in:

myStack.Push("Stack data goes here");

Then to remove data from the stack we pop it out:

myStack.Pop;

Both stack and queue inherit from IEnumerable and, pretty easily, we can move our data from a queue to a stack to a list and back (probably any combination you can think of) by overloading the constructor. Example:

Queue myQueue = new Queue();
*enter data into the myQueue*
Stack myStack = new Stack(myQueue);
List myList = new List(myStack);

At the end of a chapter we created a flap jack tracker to see and feed lumberjacks (does anyone like soggy flapjacks?). A lot of concepts are starting to come together.



Next up is another lab. No help on this one, wish me luck!