Code Katas Can Be Helpful

After reading a few posts in the development community lately about code katas, I felt I should put out my own opinion about the subject. 

At work, a few of us developers decided to take a couple of lunches each week and get together to work on a code kata that we all decide on prior to the meetings. This was mainly so we can increase our skills in development, but mainly it was a way for us to use a new or not so familiar language for a fairly small coding project.

For our first shot at a kata we decided to try Poker Hands (you're always welcome to view my progress), which we had to rank two player's poker hand and determine who won and display how they won (high card or higher set of cards). Not exactly the easiest kata to do, especially when doing it in a language you're definitely not familiar with, but we thought it was one that could give us a good challenge.

Another aspect to doing katas is to do solve very small problems. One of my favorite ways to do this lately is by playing around at Code Wars. I've been messing with the JavaScript and Ruby katas there and have been learning quite a lot about the languages as each new kata I do gets progressively harder. They have a pretty slick interface, as well.

I feel this site does a lot of things right. Most importantly, once you've successfully finished a kata it will also display how others have successfully implemented it. Looking though those can help see how other people use the language to their advantage.

Sure, you can also be doing other things in order to learn, such as messing around GitHub for a project to contribute to or volunteering. However, a big benefit to doing these small katas is because they are small compared to these other types of projects. You won't feel as overwhelmed by the size of the project or try to figure out where to start. Here you just create the appropriate class or function and make sure all the tests pass. 

Of course, you want to do code katas because you believe they help and because you find them enjoyable. I feel like I'm learning new languages little by little the more I do these. I seem to have rekindled my love of programming just by doing these katas. I hope I'm not the only one.

YUI: The Other JavaScript Framework

When you think of JavaScript frameworks, what pops into your mind? JQuery, KnockoutJS, or EmberJS? Did you know that Yahoo! has one of their own? It's YUI  and it's actually not too bad of a framework. 

It's definitely not what you'd think of when creating a new web application. For any kind of DOM manipulation, I'm sure the first thought will be to use jQuery. I wouldn't exactly count out Yahoo!, though. They have some of the top engineers of the country and they released YUI as an open project for anyone to fork and contribute to.

Below is a very small example of using YUI. How easily can you read through it? 

Fairly simple, right?  You get one instance of the element with the "btn1" ID and on the click event run the function that has the alert.

Let's look at a more complex example of YUI in action. We're going to make a JSONP call to the GitHub API. Let's take a look.

Not too much more here than in our first example. I'm still using the selector and click event handler as we've seen but in the click handler of the button I make a JSONP call to the GitHub API. The real magic happens during the function that handles the response from the JSONP call. The Y.Lang.sub  call takes in an HTML template and uses the data from the response to bind the items in the brackets. Of course, the names have to match what you get back in the response.

Conclusion

These are just very small examples of what you can do with YUI. The documentation contains a ton more examples and functionality of what the framework is capable of.

I do believe this is easier to maintain and use than using jQuery. I do have to say, though, since I've found AngularJS, I believe I'll be using that more and more. If I couldn't use that, however, YUI would be my framework of choice. 

Small Introduction to AngularJS

I know what you're probably thinking, "Oh, another JavaScript library/framework for me to learn." Well, yes, that's correct. However, I believe this is one worth learning. 

Why this one over the many other ones available to you? AngularJS has a different approach. Instead of providing a library, it's goal is to make HTML dynamic like most modern web sites are instead of being the old, boring static HTML we're all used to.

Of course, when you first see AngularJS in action, it can look pretty weird. That can be said of a lot of libraries, frameworks, or technologies until you get used to it. I was the same thing when I first started messing with lambdas in .NET.

Below is a small example for AngularJS mostly showing controllers and some basic data binding.

At first, you may notice all the ng-* attributes in the HTML. This is all AngularJS and, as mentioned above, it extends HTML to be more dynamic. The double curly braces ( {{ }} ) tell Angular that it's a two way binding. Inside the braces is the name on the model to use. You can also tell that most of the functions and properties are in the EmployeeController JavaScript file, which we'll take a look at next.

The first line tells what application Angular will be using. This is the same as the ng-app  attribute in the HTML. The empty array will be for any dependencies we may need, such as additional JavaScript files. The next section is where we're defining the actual EmployeeController, which sets our initial Employee object and defines the add and remove methods. These methods get called in their appropriate places inside the HTML. You may notice we also pass in the $scope object into our controller function. This is mainly for AngularJS and can be used for dependency injection later on, if you need it.

Below is the full demo in action. Note that JSFiddle automatically puts in the html tag, so I had to wrap the body tag with the ng-app attribute for Angular to work correctly.

Additional Resources

The one tutorial that got me started on the path of Angular is Dan Wahlin's AngularJS in 60ish Minutes.

Another good tutorial is the one from Thinkster.  They combine a lot of the articles and tutorials from all over and give them all to you piece by piece along with their own videos.

Conclusion

This was just a very  small introduction to AngularJS. While there are tons of other things you can do, this should be good to get something up and going. Once a little bit is understood, the tutorials and all will make so much more sense and you will be able to learn a bit more than you did before. Hope you enjoy learning AngularJS as much as I have!

You Are Good Enough

"I don't think I'm a good developer." 

I think a lot of developers out there think this or something similar at one point in their career. Mainly during the first few years when they started out. Maybe they just started their first job or even thinking of moving to a second job.

Here's my advice if you're one of those who think this...just relax.

Yes, I definitely have done this myself. All through college, when interviewing for my first job, during my first job, interviewing for my second, and during the first couple of months of my second. Seems like a lot of times worrying and doubting yourself, doesn't it? 

It's kind of nice that you worry about this stuff. It means you actually care, right? But just think, if you weren't as good as you may think, how would you have gotten the job you do now? How would you have been able to stay there for as long as you have? 

If you still feel the same about your skill, take this opportunity to learn new stuff. The internet has tons of stuff online to get you started. One tutorial doesn't make sense? Go to the next one.

So go on, challenge yourself. After doing that you'll become better than good enough.

Learning Python Using IronPython

Not too long ago when browsing the Coursera courses I found an interesting one about learning to program using the Python programming language. Once I saw this I jumped right on it and installed IronPython, a .NET library that lets you use Python to interact with .NET applications. Unfortunately, I never really finished all the assignments. I got a bit stuck with converting a .NET List object to a Python List object. I believe I finally got the program to actually do the conversion, but my test would still fail for some reason (any insights on this would be awesome).

The code for IronPython that really does the work in my project is in the PythonEngine class.

As you can see, it’s taking in a parameter for the location of the Python script file for it to execute. From there the engine compiles the file and executes it. I get the variable (or method in this case) by the name and then I send it the list of parameters and invoke it getting back the results that are returned as a dynamic type.

One of the cool things you can do with IronPython and using the dynamic keyword is that, if your app has a different set of rules, you can create the rules within the Python script and use the C# to invoke them. This way only the Python script will need to be updated for the logic of the rules and no compiling of the C# is needed to execute the new rule set.

This course was a fairly easy introduction to the Python language and I believe it’ll be offered again fairly soon on the Coursera site, if you’re interested in taking it. Using it with IronPython also shows how powerful it can be in enterprise applications as well as how much power using the dynamic keyword can be.

Podcasts Are Back...For Me, At Least

I still remember back at around 2006 or so while still getting over the breakup of the best television network ever created, TechTV, I find out about this fairly new thing call podcasts. This was big back then, especially since the people I loved watching on TechTV came together for their own podcast, This Week in Tech (TWiT). I believe this is still one of the most popular podcasts still around. While I think the TWiT network has some of the best podcast shows out there I have a few others that I get excited to see to have new episodes.

  • HanselminutesScott Hanselman is one of the guys to follow if you’re doing any kind of development using the Microsoft technology stack and his podcast is just as good. Usually Scott has a guest on to talk about a certain topic and it’s always informative.
  • Get Up and Code – A fairly recent addition, this is a good one for anyone who wants to get more into fitness and nutrition, and it's not just for developers as the name suggests.
  • Lifehacker – The popular life hacking blog has their own podcast that highlights the popular posts of the week.
  • This American Life – Probably the biggest podcast currently still going on that has a theme for each show and true stories based on thattheme.

Speaking of the TWiT network, they do have quite a library of shows. Here are my current favorites.

  • This Week in Tech – The podcast that started it all. This is still the popular one of tech podcasts and definitely a fan favorite of many TechTV fans.
  • Tech News Today – What better way to get tech news than a daily podcast?
  • The Tech GuyLeo Laporte’s weekend radio show where he helps callers with their tech questions.
  • This Week in Law – I've always had an interest in law and this show plugs that gap in for me in an easily digestible format.
  • Triangulation – An interview type show that lets you get to know people in tech.
  • Windows Weekly – A weekly show about all things Microsoft!

That’s quite a lot of shows. They usually come out once a week so that’s basically a week’s worth of entertainment right there. I’m sure there’s tons of other awesome shows out there that I have yet to discover and I can’t wait until I do get to discover them.