Monday, September 22, 2014

SignalR

SignalR

Okay, so I skipped ahead.  I looked at SignalR.  I felt compelled to do a search on Pluralsight for courses on SignalR and picked this one to watch:  Building a Game of Memory with SignalR.  But on the bright side, the project required the use of a singleton which is one of the design patterns that I need to know.  How's that for rationalization?

Overall, it was enjoyable.  I did my best to follow along with the code.  I've got a lower subscription, so no source code for me, but that's okay.  It's good to type it out and work out the missing parts on my own.  The instructor was creating an MVC 4 website.  I tried that at first, but I couldn't get SignalR to install.  NuGet needed to uninstall a JSON module, but the Web API depended on it.

I didn't want to get bogged down with troubleshooting the environment.  I started up a new project using .NET Framework 4.5.1.  I got SignalR 2.2 installed with no problems.  Once I started using it, there were issues.  This article helped me correct the differences between the older and newer versions of SignalR:  Upgrading SignalR 1.x Projects to version 2.

The Memory game matches people up to play a simple memory match game against each other using a Hub to communicate with one another.  When a player joins, they have to wait until another player joins, then a game can begin.  SignalR handles the communication between the client and the server.  It's pretty thrilling to see a card flip simultaneously on different browsers (I used Chrome and IE to test).

I'm not going to post large sections of the code here, but I will talk about some of the gotchas that I had to deal with.  In my opinion, the code belongs to the course, and subscribers have permission to re-type the code and learn how to use it.  Of course, higher subscriptions give access to the full source code which is useful.  The source code should have all the bugs worked out.  If you're not good at debugging, then you may want to pay for that higher subscription...

Upgrading to SignalR 2.2
This did cause a minor issue that was relatively easy to correct.  The correction was to use OWIN.  This is another thing to go on my learning list.  See the link above about upgrading SignalR.

Make Your Own Cards
I needed to make my own cards.  No big deal.  I whipped up some cards quickly in PhotoShop and added them to the project.

Handlebars
This issue was partly my fault, and partly an error in the code shown in the video.  I started a new page to do the final code.  The template failed.  I debugged it in Visual Studio, and it did seem to be giving me the information that I needed.  I switched to the client, and started outputting data to the console.  My game board was undefined!  What?  After a little bit of work, I found the issue.

Original call:
     $("#board").html(template(game));

This seemed correct, until I started looking at the model.  The template was expecting an array containing the cards.  The Game model did not contain a list of cards.  It did contain a property for the game board, Board.  Ah, we're closer.  The Board model is the one with the list of pieces.

Corrected call:
    $("#board").html(template(game.Board.Pieces));

Now, I was getting the correct data out to the console, however, the template was still not working.  This was probably due to not having a dependency added, or having something else out of order.  Again, I didn't want to spend time debugging this part, since I wanted to understand the whole point of the instruction which was SignalR.  This was easy enough to solve.  The template was small, and it was easy to write a simple function in JavaScript to do the exact same work that the handlebars templating engine was doing.  I'll go back later, and set things straight with handlesbars.  It will be good to know what I did wrong, but not right now.

Game Play
Okay, everything seemed to be working.  Only one player goes at a time, and... the player just keeps turning over cards.  Methods to handle the turns and matches don't seem to be firing.  Crikey.  Back to debugging.  A method on the back end was missing a bit of logic.  I kept the code intact, but added another "return true" where I thought appropriate.  Looking at the code, it had some redundancy.  Once I am certain that I understand the code, I intend to go back and clean it up.

It Works!

Huzzah!  It works during my simple testing using two different browsers on my desktop PC.  I still have a few issues to work out concerning the CSS, but it's doing what it needs to do.  I've got two different instances of the webpage in sync.  It's exciting.

Where to Next?
I'll break down the code, and seek to understand it.  I believe that I do, but I'll really know when I go to create a different web application using SignalR.  It'd be fun to make a version of Silent Death to play with a friend.  Silent Death is a turn-based strategy game using miniatures.  If it turned out well, I'd be more than happy to see if the game company that owns the game might be willing to let me release it to the public.  Based on the free time I have right now, all my time should be used on improving my programming skills first.

Tuesday, September 16, 2014

Software Development Game Plan

Software Development Game Plan

I am working in the Microsoft stack right now.  I've worked mostly with Microsoft technology, but I don't consider it to be the one and only option.  That would be limiting.

Before I started my first professional gig as a web designer, I learned the ins and outs of web pages by viewing their source and using Notepad to create my own web pages.  I still enjoy hammering out my own HTML, CSS, and JavaScript by hand.

In the past, I have developed web applications using PHP.  I've coded some basic console applications using C/C++ and have done a little bit of Java programming.  I've even written some ASM for a microcontroller.

C# is my Preferred Language, But That Could Change

I do like C#, but who knows what I'll be writing in the future.  My current plan does revolve around C# as my primary server-side language.  That seems like the wise decision, since I am most familiar with it in comparison to other languages that I've used.  HTML, CSS, and JavaScript are my go-to's for the client-side.

The plan:

  • Gain a deeper understanding of C# and the .NET Framework.
  • Grok design patterns in C#.
  • Have a solid understanding of SOLID.
  • Know ASP.NET MVC.
  • Get my pet project going, and implement it in multiple forms.
  • Work on learning other cool things:
    • AngularJS
    • SignalR
    • KendoUI
    • Onion Architecture
    • And the list goes on...

Gain a deeper understanding of C# and the .NET Framework.
I feel that I have been able to solve all the problems handed to me in the companies where I've worked.  But I'm starting to realize how much that I don't know.  I can blame working for small companies all I want, but that only goes so far.  The development was limited by me and I was alone.  I should have reached out to the community and saw that I need to learn more.

Grok design patterns in C#
I read/heard somewhere that the design patterns are often good habits that we, programmers, should adopt.  I get that.  Also, I see where it creates a common language to talk about potential solutions.  I've worked through some examples with mixed success.  I'll keep at it, until I grok them.

Have a solid understanding of SOLID
I need to understand SOLID and know how it can positively and negatively affect my code base.  I see the value in a lot of it, and I believe that it will help me improve my OOD skills.

Know ASP.NET MVC.
I am familiar enough with it, but need to complete a few more projects using that framework, so that I can be supremely comfortable with it.  I do like it a lot.  I've struggled with ASP.NET Web Forms over control issues.  With classic ASP, I had complete control over my web pages.  With Web Forms, the web controllers caused me no end of grief.  We've reached détente.  I am drawn to MVC, because it gives me back the control, and it seems to encourage OOD more than does Web Forms.

Get my pet project going, and implement it in multiple forms.
I've started working on a pet project.  I'd like to use the Onion Architecture to structure it.  I thought that it would help me design the project, so that I could spin off different versions of my project.  I intend to produce the following, but not limited to: ASP.NET MVC app, AngularJS app with a Web API back-end, WPF, and possibly a Windows Universal App.

Work on learning other cool thing...
Keep on learning.  Too many cool things to know, and not enough time.  Argh... Raspberry Pi, various microcontroller projects, NUI apps, IoT, robotics...  stop. Let me get a handle on the above stuff, before I keep going off on tangents.

Take care,
C.

Monday, September 15, 2014

Trials of Fixing a Software Developer

Hello, me.  I'm writing to you.  Yes, you.

I am going to fix myself.  What's wrong?  Oh, name it.

I'll probably post brain dumps concerning programming (web to be more specific), since I am working as a web developer, and want to remember a few things.  But, I should post other articles concerning what I am doing to fix other parts of myself.  Fix my body, fix my mind, fix my relationships, and all those fixes will bleed over into the facet that composes the programmer.

You'll find no earth-shattering writing or topics here.  Just ramblings whose only connecting thread is me.  Who's me?  I'm a self-taught programmer that got complacent.  I stayed at one company way too long.  I should have left, but it was so close to home, and the pay was good.  I paid the price.  Like I said, I got complacent.  I did my work, but I didn't stretch myself.  I did slowly improve my code, but still so many things to learn and do, and I wasn't doing that.  I was a lone coder just cruising along.

Egad!  Snap out of it, man!

What am I doing to fix myself?  Well, here's a list in random order.  Okay, not random, but not in any kind of real order...

- Fix my body
Yes, I am fat.  According to the BMI charts (that do not take into account body type!), I am obese.  Dang.  Okay, I am not as big as some, but still hefty.  At my heaviest, I was at 242 LB.  In October, 2013, I started changing my habits, since I finally realized that I needed to change.  I wasn't active, so I started simply by cutting my calories.  I lost about ten pounds, but my weight still fluctuated a lot.

In July of this year, by happenstance, I was listening to an old podcast of The Art of Manliness, and the host was interviewing Mark Sisson, the author of The Primal Blueprint, and owner of the site, MarksDailyApple.com.  What he talked about resonated with me.  I bought the book.

I'm down to 210 LB right now, and I haven't even incorporating all of the philosophy of TBP.  I decided to take measured steps and work on my eating habits first.  Then I started the sprint workouts, and will add in the rest as time goes by.  I feel good.  I still get frustrated, since I'm not losing the weight like I'd like, but change does take time.

- Fix my programming
I did go back to school in 2007 and get a Master's in Applied Computer Science.  It was interesting, but I still lack a grounding in a lot of basics that an undergraduate gets while working on a CS degree.

I'm working on fixing that.  I need to know design patterns well, and know SOLID.  There's still a ton of other things on my software developer to-do list, but this is a good start.

That's it for now.
I'll end this post right now.  It's a good start.  I should go back, reread, and edit, but no.  I'm done.  This is for me.  It'd be cool if other's found it useful.  But I need it to be useful to me.

Take care,
C.