Showing posts with label C#. Show all posts
Showing posts with label C#. Show all posts

Tuesday, July 18, 2017

The failure to a win

My last post was about not being able to get some code to work. I declared it a failure. A failure that I should learn from. I am here, a couple weeks later, to say that I did learn something from the whole experience. I think most of us have seen the comic, or a similar comic as what I have below


That was exactly what happened except it wasn't a semi-colon. I was missing two words and an equal sign, Mode=TwoWay, where I was giving my binding information. In that particular XAML file, I was not using Mode=TwoWay in any other lines of code. However, I did use it on other pages. Why did I miss this one piece?

I came back to my solution a week later with new eyes. It took me about 15 minutes to see what my issues was. I add Mode=TwoWay and, presto!, my code is working as I expected. What was it about taking a step back from the code that helped me see what was missing?

The important lesson I feel I came away with, is that sometimes it is good to have a fresh set of eyes take a look at the code. In my case, it was taking a week off allowed me to get a fresh perspective, but we can't always do that at work. Yet, it can still be important to get a fresh set of eyes.

We look at code all day and may start missing pieces that would actually help solve our issues. Making sure we know when to ask for help and get another person looking at the code can be very beneficial.

Take that "week" off  and get fresh eyes to look at your code.

Here is a screen shot of my minimal viable product (I know the UI isn't great that will be coming...soonish). Now to see if I can get some services to the online movie providers (not looking so great, I have only been able to find an API to Plex Servers and the rest of the providers are either hidden really well, don't exist, or I am searching for the wrong things).

"It is better to know some of the questions than all of the answers." - James Thurber

Monday, April 17, 2017

Experience of #100DaysOfCode

I did a post at the beginning and now I am doing one at the end (I should have done in between, but I can't go back now) of 100 days of code. You think that 100 days is a long time, but it isn't even a third of the year and the time flew by! Some days coding was really difficult and I wasn't able to get a full hour of coding done while other days were much easier and I didn't feel that an hour of coding was enough (don't worry on those days I would spend more time coding). But do I feel that it was beneficial to take time out of each day to learn to code?

I often thought that it was too difficult to code everyday, after all, I do have things to do on the weekends, like go to a movie or something. Okay, honestly, I have a three year old and I can't tell you the last time I did that on a weekend. It still felt that coding everyday, including weekends was going to be too difficult, at first. I stuck to it and coded everyday (the 100 days of code does allow you to take a day off every now and again and I took advantage of that on a few occasions). I also felt that coding on Saturday and Sunday got easier as the end got closer, in fact I almost felt my day wasn't complete without doing some code for the day.

I also logged my progress every night in a log file on github and posted tweets to Twitter each night. Knowing that the people on Twitter would see my progress helped keep me motivated and a few times I actually got support from the Twitter community when I posted a question. This helped in knowing that, if I got stuck, there was someone out there in the Twitterverse that knows the answer and would be able to help. Keeping the log is very helpful and I will continue keeping some sort of log about my learning. Maybe I will keep the same format as the link above (that is what I used tonight) or maybe I will find something that will work better for me, only time will tell.

Did I learn anything while doing all this? The answer is yes, I did learn more then a few things. My first project was to learn how to build an API. I have a working API now, it is still on a local DB and hasn't been deployed, but it works! And I have made a number of Xamarin Cross-Platform apps using Xamarin.Forms, although I must admit, none of these were my own ideas and either came from Xamarin University, Pluralsight, or Udemy. Even though the mobile apps were not what I dreamed up, they did teach me so much about the different platforms available and XAML.

Why do these matter to me? The team I work on at work is over an API that was just released a few months ago. The team built it from ground up and I tested it. Often, the developers would talk about the context or the model or pretty much anything else and I was clueless. Now I hear what they are saying and am actually able to comprehend what it actually means. I have even fixed a few bugs on my own (I have been given the ability to do this, I didn't go rogue). It feels good to be able to pick up an item from our backlog and debug the issue AND actually find the root cause. Then when I send out that pull request, it feels good!

We have other tools at work that my team does not own. Some of those are written using XAML. Before 100 days of code I would have no idea how to debug anything in these products. In fact, I would avoid them at all cost, because I would not only waste my time looking for the issues, I would also waste another developers time having them walk me through the issue and how to fix it. Guess what! I have also been able to dive into these products and fix one bug in XAML code (we just got one product under our charter that is in XAML so I get the API and XAML now). This bug didn't require me going to another dev asking for hours of help to debug the issue.

Was it worth it? There is definitely something to coding every day. I was able to fix bugs before 100 days of code, but I didn't spend enough time learning for myself. 100 days of code made me think about a project or two of my own. These personal side projects kept me wanting to learn every day and kept my motivation high. The side benefits to my personal projects were that I learned better what my team and department do every day. So, yes I think it was worth coding every day for 100 days. Will I keep coding every day? I think that I will code a lot more often then I did before. I have formed new habits. I used to sit down and watch T.V. at night after everyone else had gone to bed. Now, I code. I enjoy the coding every night so much more then watching T.V. I think watching T.V. was a time filler for me. I wanted to learn how to code, but I didn't know where to start or what I should be doing. I had to actually think about what I was going to do and this was the best thing for me. I have a list of things that I need to do to continue learning to code and there is so much more to learn!

Would I do it again? That is the question. I do enjoy coding every night, but having to do it every night is rather difficult. Some nights you just don't want to do it and you have to tell yourself this is a pledge I made to myself and just do it. I may do it again in the future, we will see. For now, I will keep coding most nights and keep posting progress.

My Github Projects during 100 days of code:
100 days of code log
Xamarin Layouts
Xamarin "Essentials" Project
Movie API
Others at https://github.com/robertjorg/ (I know I need to clean them up, at least a little bit!)

Tell me and I forget. Teach me and I remember. Involve me and I learn. - Benjamin Franklin

Wednesday, February 24, 2016

cSharpDictionary.ContainsKey("GoFish") - Another section of chapter 8

I still am not done reading Chapter 8. Although I have been reading and coding most nights (except the nights my wife and daughter were both sick or doing my taxes which are always phone *please insert sarcasm*) it takes me a while to get through the material. 

Well, since my last post a week and a half ago, I have mostly been working on a project in chapter 8. I tried really hard not to use the help for this project and perhaps I have learned something during the week. I just finished the Go Fish project in chapter eight and I did use the code that is provided in the book. I was stuck, what was I to do? Sometimes I ask myself, is object oriented programming for me? I felt when doing VBA that I got a relatively good grasp on what I was doing and didn't have to refer to the web much after doing it for a while. Perhaps I will start feeling that way with C#. I will say there are pieces that I look at what needs to be done and a light bulb goes on. Those are the days that help me continue spending any small amount of free time I have trying to become a coder. Just code more each day I guess (I try to do CodeWars but feel sometimes they are above what I know, maybe those are the good ones to actually test my skills) and have joined some communities like codenewbie.org (full of people wanting to learn to code from all backgrounds). What helped you learn to code?

One great thing about this chapter is that it made me really look at overloaded objects. As usual, We have talked about overloading before at work and I have never really grasped what that meant. This chapter was discussing overloaded methods and I probably missed it early on in the book, but I was really feeling lost. I spent some time investigating to find out that I really didn't know much about overloaded objects. Come to find out, they can probably come in handy. I like the definition from MSDN:

Members can have the same name as long as their parameter lists differ. When two or more members in a type are the same kind of member (method, property, constructor, and so on) and have the same name and different parameter lists, the member is said to be overloaded.



Just pass the correct parameters and the code will use the correct overloaded object. The Go Fish project actually uses one so you can find what card the computer will choose and then call the method that the human player uses. pretty nifty.

Hey, you can also create a dictionary to store definitions of keys. Just do:
Dictionary kv = new Dictionary ;

You set your TValue object type and key (keys must be unique just like the dictionary you use!) and enter data. You can then count the data, see if objects are in the dictionary, remove items you don't like, and add items you do like. There seems to be a lot more you can do with dictionaries. 

GoFish! Game - I still have not won the computer, I can only tie the computer. AI must cheat.

Until next time.

"I like to fish. Fishing is always a way of relaxing." Tom Felton

Sunday, February 7, 2016

if (catchyTitle.Text == "Interface Inheritance" ) { MessageBox.Show("Chapter 7 is done!") }

This chapter took a little longer than prior chapters. Maybe it is because there is more material and the coding projects try to use the majority of code I have learned in the prior chapters. So, since a few blogs ago I decided that I wasn't going to use the "help" as much as I had been prior. I would say I succeeded pretty well in this chapter. Building a house with places to hide I did go to solution after I got stuck and was unable to make progress. I hope it helped me learn what I was actually using better. I think it also helped that I didn't have many days between actually looking at code I started and code I was finishing. Instead of having to remind myself of what I did before, I was able to remember it pretty well.

While my code doesn't look the same as the solution, and probably has more lines then what is needed, I ended up having an issue where my form wasn't updating correctly. The issue showed itself after I implemented the interface for a hiding place. I forgot to call a method when moving from one room to another called ReDreawForm(). Hence, the form was not redrawing and giving incorrect information about where the hiding place was in the different rooms.

Well, the hide and seek project (I called it long project because when I started it the book said it was going to be a long one) contains both outside rooms and inside rooms. Both inherit from the Room class. Then there are two interfaces for rooms that have exterior doors and rooms with hiding places. I had to do some searching on what to display depending on the room type (IHasExteriorDoor or IHidingPlace). In comes upcasting and downcasting (aka Polymorphism). Example of finding a class that inherits from an interface:

if (currentLocation is IHasExteriorDoor)
            {
                goThroughTheDoor.Visible = true;
            }

That brings me to another point, Object Oriented Programming has four principles (why the book waited to chapter 7 is a good question):
  • Inheritance - one class or interface inherits from another
  • Encapsulation - creating an object that keeps track of its state internally using private fields, and uses public properties and methods to let other classes work with only the part of the internal data that they need to see
  • Abstraction - When you create a class model that starts with more general - or abstract - classes and then has more specific classes that inherit from it. Cannot instantiate these
  • Polymorphism - "Many forms" Take an instance of one class and use it in a statement or method that expects a different type, like a parent class or an interface that the class implements. Upcasting or downcasting allows us to get polymorthism.

We have used all of the principles so far, it now is a matter of being able to remember each principle and how each is used (so much to remember, but I think coding more often will help that). 

This chapter also talked about access modifiers. You know, like public or private but with a few more. 
  • Public - anything can access this (as long as access to the declaring class.) Least restrictive. Only use if you have a reason to make it public.
  • Private - only other members in the class can access it (other instances of the class can use these as well). You can only mare a class private if it is encased in another class.
  • Protected - public to subclasses, private to all else.
  • Internal - public only to other classes in the assembly. Protected Internal can only be accessed from within the assembly OR from a subclass.
  • Sealed - class which cannot be subclassed. Not an actual access modified, it only affects inheritance.

I think something to help remember the implementations, inheritance from a class allows you to modify the methods or use the methods how they are written in the base class. Interfaces have abstract methods and cannot be instantiated. The methods in the interface do not have any code in the contained methods, it only tells a class that inherited from the interface that all the methods MUST be used. The class can then implement any type of code needed for the given method, but it has a framework of what needs to be implemented from the interfaces.

I am only touching the surface I know. So much to learn!

Thursday, February 4, 2016

The Communities we belong to...

We are given time to innovate each week and sometimes I do it and sometimes I don't. I really need to get better at not only spending innovation time innovating, but also what I am innovating on. Well, we had a really interesting and fun experience at work yesterday. We were able to participate in Open Space (more information at http://openspaceworld.org/). We weren't given much information as to what the day would entail or what would be expected of us. At the beginning we discussed passion and that maybe Open Space would help Innovation Time to get some real quantifiable results (sometimes the innovation projects got lost and nothing comes of them). We were given 45 minutes blocks to bring up topics we felt passionate about. I brought up C# learning. I didn't expect many people to come to this session.

When the session started in the afternoon, I was surprised at how many people came to talk about C# learning. It makes sense, another team is going to start using C# more and wanted to see what I, a person on engineering using C# everyday, was doing to help in my learning. Our discussion led us to what I was using and how we could all learn what resources and communities others were using in order to stay on top of their coding.

I thought that I had a limited number of resources I used...but then I really looked at the sources I am using. Between blogs, people I follow on Twitter, and my network at work I actually do have quite a few resources. Of course there is the obvious one, I use the book resource that leads to most of my blogs. I feel it is a great resource, I get in-depth training on the basics of C# and I (hopefully) provide what I learn in a blog. 

At work I obviously have my co-workers that I can work with and ask questions of. One, K.C., appeared to take particular interest in me and I ask many questions of him. You could say he is acting as a mentor to me. Strange thing, I have never asked someone to mentor me that is younger than me. I am getting old, but then I guess that happens when you switch careers.

Then I follow other coders on Twitter and try to read their blogs (at least when I don't think that the subject will be a mile over my head). I like getting their perspectives and I hope that the bits of information I get from reading their blogs and posts will help in my learning. I follow (to name a few) Scott Hanselman, Troy Hunt, Jeff Atwood, John Papa, Visual Studio and those are just a few of those I feel can add to my learnings. Hey, maybe one day I will post a question in Twitter and receive a response from those I follow or that follow me.

I was lucky one day and found a retweet from one of those I follow about CodeNewbie (funny that I picked Newbie Programmer). CodeNewbie is a set of blogs, podcasts, Twitter discussions, and probably more that I haven't found out about yet. From listening to the podcast I have already found a couple great communities to use in my code adventure. Some of the stories are similar to mine, 30 somethings that switch careers and trying to learn to code. I hope to take part in the weekly discussions that are held on Wednesday nights and that I will be able to contribute my knowledge gained.

There are more like Free Code Camp (I just started following them and need to check it out more), Evasium Programmers (need to look more into this one too) and the usual Microsoft accounts to help in all things Microsoft. I know my world will keep expanding too.

So, I have a few communities I use to learn, and it continues to grow as I dive deeper into coding. In the Open Space meeting where we talked about what everyone uses, I am not aware of anything used at work for one person to pass along the resource and communities one person belongs to those that are trying to learn C#. Maybe I should start a Slack channel at work, or is there a better way to pass this knowledge on? I need to let others know what I am reading and who I am following. They may prove useful to someone else just starting to learn to code.

What communities have you found to belong to?

Thursday, January 14, 2016

Bee Management

Well, it is another week and I find myself saying, "I am not moving as fast as I would like." There is always more learning to be done. The amount of learning for me to feel comfortable telling people I am a developer is a large amount! Luckily, my job title is only doing part time coding, but that doesn't mean I should go slow on my learning.

This chapter took me longer than I had hoped. Not only did it take a long time, I also feel I did myself a small disservice in this chapter. The book provides the code that they want you to write. That is great when you are stuck, but I feel I was using the "help" too much. I created a Bee Management system in two parts. The first part used code that I should already know, I do. The problem, I should have taken the opportunity to learn it better. I felt I didn't have enough time to do this though and looked at the "help" more than I ought to have. I need to slow down and spend more time doing the code myself. That is a New Years resolution 14 days late.

Now, house cleaning out of the was and the confession of my sins is done. I already blogged about the inheritance in chapter 6 and, as I thought, I redid the party planner and used inheritance instead of writing extra code. Before doing that I learned a little about the hierarchy used in the code. If you don't override you can run into some issues with code not doing what you want when using inheritance.


The bee management program was done in two steps. First just writing the program that assigns the jobs to the bees, no inheritance used. The next piece was to use inheritance by adding a class that all bees used for honey consumption. Hey! I got to override the honey consumption for the queen, she apparently is real hungry when the bees work.

Not only did I override a method, I also added parameters to a subclass. This requires a little different syntax then the virtual/override. The bee class (base class) has a weight parameter and the worker bee (subclass) also tells you what jobs they can do. Do something like:

public Worker(string[] jobsICanDo, int weight) : base(weight)
(the string is an array and I hard coded the jobs a bee can do in the Form1.cs file.)

The Bee class has the weight parameter and the worker class added the jobs parameter.

So much you can do with code!

Here is the bee management program. Happy bee management!

Now that 15 days of the year have gone, I hope you are still doing your resolutions. If not, I hope you have a great new start with your old habits!

Wednesday, January 6, 2016

Inheritance

First, I did take some time off of EVERYTHING (except being a dad and husband and all the stuff I normally do at home). Okay, let me rephrase that, I took some time off work and coding. I should have spent at least some of my time of during December to learning me some code but, alas, I did not. No going back now, so now I have two weeks of family time only, which is good! Next, I just started reading the next chapter on inheritance yesterday and am not finished, but I feel I need to provide an update.

Ah, inheritance. Sometimes you inherit really great things, like the genius gene or money, and sometimes not so great things, some sort of really bad gene. Coding, you can luckily change what gets inherited, kind of. More on this later.

Coding, a subclass inherits everything from the base class (return type, fields, parameters, everything). Do something like:

Class A {
public int field1;
}

Class B ; A {
public int field2;
}

That allows the coder to do a lot less code duplication. The code above, class A has one field called field1 and class B has two fields, one called field2 and one it inherited from class A called field1. One less line of code to write, yeah!

 I started out with an exercise from the book, I took the Party Planner tool from the last chapter and added the ability to cost out birthday parties.

The two cost structures were almost identical with a few minor differences. At work I had seen, and actually used, inheritance before. I knew that it was possible, although when I used it I was more copying what I learned from Google and didn't understand what I was doing. So, when the book had me typing everything out for my new class that was pretty much the same code as another class that already existed I thought, "Man, this seems like a lot." And it was. Too much.

The book must have the readers go through that to see if we will stop and think that there has to be a more simple way (the reader should know that there is because it alludes to this fact at the beginning of the chapter). I am just past this point in the book and I think in the next few pages it will have me create another project, probably just like the party planner before, but this time use a base class for my overall Party and have sub-classes: one for dinner parties and one for birthday parties (just my guess but knowing the structure of the book, it is probably a pretty good guess, we will see on the next post...ooh, I cliff hanger).


WAIT! What about my kind of statement above? I did get a little further after re-writing all my party code. I read that you can change something that gets inherited from the base class. You just need to make sure your method is marked with "virtual" like below:

In Class A:

public virtual void CoolMethod () {
   //do some CoolMethod here
}

This needs to be followed by an override in the subclass like, say class B that inherited from A:

public override void CoolMethod() {
  //do an even more CoolMethod here
}

No you inherited everything else that is in class A, such as field1, but the CoolMethod does some other awesome stuff that A doesn't do, and also has field2 (see above).

More to come on inheritance.

A few definitions:
Subclass: A class that inherits fields and methods from a base class

Override the method: A subclass changes the behavior of an inherited class

Class Hierarchy: Classes at the top are base classes with subclasses below it. Those subclasses can have their own subclasses that inherit from them

P.S. Maybe I should spend more time this week learning GitHub...I deleted the Chapter 6 code...again! Anyway, I took a shortcut on recreating the code..You can get the program here.

https://github.com/robertjorg/Ch6

Saturday, December 26, 2015

A Christmas GitHub

Well, I know that I am passed my week deadline. December seems to be a busy month, don't you think?

In the time since I last wrote, I was able to create a Github account using the name robertjorg and create a few repositories for the coding I have done. I first tried just one repository for all the code that I have done for the C# book. Maybe I should have kept just one repository for the entire book, but I decided I was going to break up the repositories by bigger projects. Each bigger project in the book will have it's own repository. Which is the better way? I still am not sure and am still learning about forks, repositories, and working together in GitHub. Maybe I will decide that I should have one repository for the entire book as a move along and discover more.

I had a great experience (and I am glad I wasn't developing something that I will need down the road)! I somehow deleted all of my code I had written for the book. I saw it there, then when I was moving from one repository to many, it was deleted. Not sure what I did, but I am glad I wasn't more attached to the code. I had saved the Day at the Races code on my Google Drive so that was easily recovered. I had one more chapter of code that I lost (to save time I went to the books website and downloaded the code). Lesson learned, when trying something new, make sure I have a backup so I don't lose the code. Then again, maybe GitHub removes the need to have to create backups as long as I am using it correctly? I was using the Desktop client, which seems to be pretty user friendly, and plan to continue using that (unless someone tells me there is a better way of doing things).

I found another GitHub repository that contains some code for A Day At the Races. I checked the solution for walbalooshi and it they did implement some of the same code that I did, but was pretty different. walbalooshi has three repositories with two appearing to be solutions for the C# book and only the projects (maybe they are two of the labs).  The Day at the Races as five forks. I am interested to learn if those that are forking that code are  forking to help make changes to the original code?

I hope to keep learning and using GitHub more. Maybe one day I will be a paying customer because I will need a private repository or two.


Thursday, December 17, 2015

A better understanding

Well, I now have a better understanding of the get set accessors. I think the blog is a great idea. I have a coworker, K.C., that has been reading all my posts and reached out a few hours after I posted on Tuesday. K.C. and I spoke about my questions on Wednesday.  My team leader, Taylor, read and knew I had questions as well.I made sure to reread pieces of the book and look at the code I had written for the chapter to try and gain a better understanding before speaking with anyone at work. I spoke a few minutes with Taylor and he helped with my understanding. K.C. and I spent close to half an hour going over my questions.

Now, what did I learn? First, just like I said last time, I need to go back and create a list of vocabulary used so I can stop confusing the terms. I will be doing that this week. Maybe writing down the words and their definitions will help me retain them better. K.C. was great and gave me some history that the book didn't present. A property is a C# creation and not known by other languages. Without the idea of property there will be a few more lines of code (it actually looked like A LOT more coding).

The get portion of the property is used anytime the property is read and returns the value of our private property. The set accessor is called when the public property needs to be set and in turn can set the private object in the class. Anytime the private object changes, there may be other objects that need to be changed, hence our private object.

Constructors, no return value. Constructors allow us to initialize the private fields in a class.Then to change our private property we have to go through our public property to change the private field. Using the property will change everything needed to change (the reason for our private property).

Automatic Property: public int MyProperty { get; set; } - C# automatically creates the private piece needed when using the generic structure.
Field: Variable declared directly in a class

I had some co-workers speak to me about how I was putting my code and programs on the web. I have just been using my Google drive. What about something like Git? I will be working on that and my definitions list. 

Tuesday, December 15, 2015

Privatey privates

Another week down. I understand why you want pieces to be private. I don't want everyone knowing all of my business and I am a pretty private guy. I like my privacy. There are certain things we all tell people and other pieces we keep to ourselves (or share with only a select few). I like the sentence at the beginning of the chapter that states "...good objects don't let other objects go poking around their fields." Enter encapsulation.

Encapsulation allows you to keep your privates private without impacting the integrity of your program. I can tell my class that, hey, this parameter or method is private and only this class can use it. It's like keeping a secret. The problem becomes, when do I make something private vs. public? I guess that is a subject that one really needs to think about when programming. Some pieces are ok to be viewed by the entire program while others we want to keep locked down, we just want to get it write to help with the readability and ability to understand our code. Nothing new to programmers that have been in the game, but I found this piece helpful.

To help with encapsulation you have properties, or the get and set accessors. I know, right? Honestly, I see that these work, but am fuzzy on the how they work. Ok, I reread a paragraph. It states "A property can be used to get or set a backing field, which is just a name for a field set by a property." I need to go back and keep a list of vocabulary words. I have to keep looking up what the different words mean. Anyway, I am fuzzy here, but I could just use the automatic properties and we will be all good right? I mean, type prop, tab, tab and it is done! Well, I still need to understand what this is doing to make the program work as expected in a clean way. Plus, I am sure just throwing gets and sets out there doesn't help with encapsulation and determining if I should have a public or private object.

More reading this week on this subject...watch for it

A screen shot from the program the book helped walk me through

Tuesday, December 8, 2015

A Day at the Races...Finally

Well the day has come. I finally finished the first lab in the C# book. The book reads that we should know everything you need to in order to complete the lab. I found there were a few things that either I glossed over or the book did not touch on the subject. That was moving pictures in the Windows Form. A quick Google search (yes I used Google in the lab) helped me understand that I needed to find the location of the picture and then I change the location by changing one of the points (X axis or Y axis). I then joked with my cousin (who is a much better coder than I am) that I didn't know how to move the dogs and he said to use dog.Move();. Great idea I said, except they returned dog.NotListen();.

Here is the opening screen of the wonderful Day at the Races app.
The dogs and the race track are 5 pictures and, as discussed above, the key was figuring out how to get the dogs move by changing the point on one of the axis. That movement is supposed to be random. The randomness comes between zero and four spaces forward (I decided to add 0 to try and make it more random). Well, it is random, but the races are always very close. You have to stay on the edge of your seat in anticipation.

And don't worry, you can see where the dogs have been! They leave a trail of...let's call it droppings. I tried a few different sets of code in the Run() object to fix this issue. I found that I was reliably able to get all the dogs to run at the same speed and finish at the same time, except it always had dog number one win. Hey, you could make a lot of money betting on number one! I found that if I used Application.DoEvents(); the droppings don't appear anymore, but the races get stuck in an infinite loop. Then if I add a break; the loop is broken, but all the dogs finish at the same time. I am thinking it maybe has to do with the order which I have the code written, but I tried rearranging and in some cases made it a little better, but generally made things worse.

This was the first project in the book that required multiple classes in order to run. I have a guy, greyhound, and bet class. It was fun trying to instantiate an instance of bet for the guy class (or is that backwards?). I have instantiated an instance or two at work, but I have not fully understood what or why I was doing it. I feel that having walked through having to write a  program that uses an instance of another class helped me understand these much better.

In the end I wasn't given much direction on how to write the code, just a skeleton frame. I added a few objects that weren't in the original skeleton I was given. I hope it was needed and that I am not just adding objects that aren't needed (I will say I used all the objects somewhere in the code).

I want to include the SLN so that if anyone wants to take a look and provide constructive feedback they can. This is the first time I have ever shared code, so I hope I included everything that is needed. If it matters I have the solution saved at C:\Source\Personal\CSharpBook\labADayAtTheRaces (maybe it matters for where it will look for the dog and racetrack pictures). Here is the code and sln files (code was written in Visual Studio 2015).

Well, here is the Day at the Races (don't worry, no actually money is exchanged so it is legal in every state). Have fun playing with Joe, Bob, and Al's money. Happy betting!

12/8/2015 Update - I was able to fix the dog droppings. The pictures were not not refreshing so each picture was left behind leaving a trail of the back of the dog legs. All it took was talking to my team lead about the issue and he said, "Try this.Refresh();" Easy fix. No more trails. (I have updated the link above).

Monday, September 21, 2015

Programmer Blog

Well, if you have ever read my blog before you know that for all of my prior posts, except one, I told you about my life or thoughts of the day. For a while I was using the blog as therapy after my head injury. Looking back at those posts I realize how much therapy I really needed back then (and maybe still today). The one blog that I used to show my programming prowess (or lack thereof) was to give the world an Excel time tracker I created. Okay, saying it is for the world is over stating those that actually read my blog at the time. Of all my posts, the Excel post was the most viewed post.

I am not saying that a spreadsheet was more important than the brain injury I sustained in Mexico and the work it took in order to get back to my normal self. Perhaps it shows that I got better at writing the content in my blog. It could also mean that I used words that were a better hit in Google and the blog was higher in the hit list for readers. Or, really it was that I figured out how to show the post on the fun social site Facebook.

At any rate, I discovered that a blog can be a good medium for getting information across, be it information about me or the coding adventure I was trying with VBA. I have done a number more coding projects since the Excel time sheet. In fact, I created the time sheet while working at a financial firm. My position had nothing related to programming. I just took it upon myself to teach myself VBA. Maybe I was lazy and was tired of doing the same processes over and over or maybe I had the mindset of creating more effective work flows. Either way, I started to learn coding.

Now I am in a position where I code part time. No longer do I use VBA to code. I spend a large amount using C# and any other language my work uses. This is very difficult, I don't have a programming background. The fact is that Google and I have become best friends.

In my searches in Google, I found a blog site that I found interesting. The blog is called Simple Programmer and  provided some great ideas about programming. The blogs don't necessarily tell one how to program but practices that could apply across any job (just change the idea a little bit). One of the blog posts is entitles "How NOT to Email Famous People." I don't even know how one finds famous peoples email addresses. I guess perhaps you just try every combination of their name and add @gmail.com. I am pretty sure everyone has a gmail address, unless of course you are stuck using your AOL email address from the early 90's.

John Sonmez (the blog author) provides a blogging course that will help you advance your career. That is why I am re-purposing my blog. I am not writing as much as perhaps I should, but I wanted to help solidify my learning of C# and the frameworks we use at work. I may not post anything earth shattering, but I hope that I am able to help someone that reads my posts and learn something myself. I am going to put my schedule out there...once a week. Now hold me to it. We will see