Sunday, July 1, 2012

Pro jQuery - Chapter 4 (JavaScript Primer)

It took me forever to go through this chapter. It was incredibly slow, and nothing too interesting. If you're reading a book on jQuery. jQuery has its bases in JavaScript, so a key foundation for it is JavaScript. Plus a lot of it was so long, with many examples that I went through on principal that it just got me really uninspired. I am glad to have finished it.

So it uses a lot of console logging, and created objects for its own demonstrations. It went into how you'd add a method onto a function, which is very different from how you would in c#. It was actually very good at explaining how to determine if an object has a property, explaining the differences between null and undefined. I spent a good portion of my time on this since it is a little different from c#.

The book did touch on array methods, but didn't go into depth. I'm glad about this because as I said earlier, it was longer than it needed to be.

So they had to put this chapter in for sure, but I feel that it was still a little long. It isn't really going to be of any assistance if you have a problem. You're going to need to go to another JavaScript reference and look at it there.

I am excited though because I see the next part is called "Working with jQuery".

Sunday, June 24, 2012

Syntax Highlighter - Show code directly in your Blog

You may have noticed that in the recent gridview radio button blog post, that I had code formatting directly in the blog post. This is something that you cannot easily do with blogger. Bummer. I recently came across Syntax Highlighter, and it allows a syntax highlighter to be implemented into any web page (or blog) with a few lines. It works for a number of languages, and is open source. I really like it so far.

Friday, June 22, 2012

RadioButtonGroup Across Multiple Rows in a Gridview

At work, I have a grid view, and in that grid view, every row is a different option. .Net is too smart for its own good in this case, as it puts every radio button in its own group rather than allowing you to use the same group along multiple rows. As a result, when you go to use the radio buttons, they do not deselect the previous selected option. So I thought about this from my point of view. How would I break it down?  Here's what I came up with.

Loop through every row, and find the radio button you want, then turn it off. Go back to the radio button that was originally selected, and then select it. We can do this because we can go back to the sender, find it, and modify it. Here's the code that does it:

protected void rdoPolicy_CheckedChanged(object sender, EventArgs e)
      RadioButton sendingRB = (RadioButton)sender;
      sendingRB.Checked = true;


private void DeselectRBButtons()
      int x = 0;
      foreach (var gridviewRow in grdPolicies.Rows)
          var rb = (RadioButton)grdPolicies.Rows[x].FindControl("rdoPolicy");
            rb.Checked = false;

Monday, June 4, 2012

Improving the quality of software using Code Reviews

Peter Sergeant recently wrote an article about code reviews. He had a lot of really interesting points and ideas about code reviews, like using a review tool, and scheduling review time regularly. I've never really used a review tool, but I use ReSharper's ToDo Explorer to keep track of notes, review areas, and code smells. I like the idea of a regular review, but in some teams (especially where I work today), I highly doubt it would work. 
I believe code reviews are an invaluable tool that have in your SDLC. I believe this because it does many different things. Code reviews help improve code quality coming from all developers, it helps enforce domain level knowledge among developers, and allows for communication among developers to be opened up.
As a junior developer, I initially thought as code reviews as a way to improve my code quality. I was easily intimidated, and insecure in what I was producing. I stuck with it, and after the second review or so, I learned that wasn't the case.  There is a sense of "You don't know what you're doing," at times, but you can't have that attitude. I believe everything is done for a reason, and that every developer chose a specific solution for a reason. 
Code reviews allow developers to ask questions, and learn new things. For example, if I had a question how to write an automated unit test a specific area, I could put a note in there asking for help. "Is this sufficient for testing?" is a review note I frequently had. By finding those areas, and having a conversation about them you're producing better quality code, and then you're going to be able to build on top of that quality to ask better questions such as "Can we use a row test to increase the efficiency of these test?" Further more, when I looked into more experienced developers' code, I see new methods and patterns I've never seen or used before. I can then ask questions about them. If these patterns are easy to make sense, the senior developer will easily be able to explain his logic. If he can't then there probably needs to be some refactoring.
Domain level knowledge is very difficult to obtain. On all of my major projects, they've been on subjects that I know nothing about. I've always talked to the users to get information I needed. But as I became more exposed to that project and product, I was able to contribute that knowledge to newer developers.  As an example, I may say "This is unnecessary for us to write because we've never allowed users to input strings into this field." That is communicating business rules and experience into each others' code base.
Finally, it forces communication about architecture among developers. I see a lot of code duplication in my project I currently work on. I found nearly the same functionality in 7 different spots. And when there was a bug, I had to go in and fix it in 7 different spots. The question of "Can we tear that out and put it in one spot?" was asked. However, I asked the question of, "Why is it this way in the first place?" There's always a reason - even if it is laziness. Unfortunately, it took me 3 attempts to find all 7 spots. So it looked like I had a ton of bugs come back. Had we had a code review on the development on one of these areas, perhaps we may have said "Keep it DRY", and go forward. Maybe the developer didn't know about the other six spots with that functionality? Perhaps it can go into a class with other similar functionality that another developer is working on?
So code reviews are valuable for a number of reasons, to anyone of any skill level. I've only listed some of the reasons here, but it is interesting to think about. I'd like to hear stories and reasons for others' stances on code reviews.

Friday, June 1, 2012

My Favorite Chrome Extensions

Adblock Plus

Adblock Plus prevents advertisements from being displayed to you. Nearly any big time website now has advertisements on it, and when you visit them regularly, you’re going to become annoyed and get a lot of the same advertisements regularly. It doesn’t matter if it is a video, a banner, text link or even pop up – it gets blocked.
I understand that advertisements help fund the websites I visit. I understand that advertisements help inform me of products that are available. However there are simply too many. Without Adblock Plus, I get advertisements for hockey and software related products all the time. When I go to YouTube I have to watch an advertisement that is longer than the video itself.

Copy Link Text

Copy Link Text is a very simple, but effective extension for copying and pasting links. While I don’t use it regularly, when I do use it, it saves me a lot of time. Rather than having to highlight the link (which can be difficult based on how the browser behaves sometimes), then copying it, I can just right click on the link and select “Copy Link Text” and the text displayed is what goes to my clip board. I use it regularly when in my bug tracking system at work.

Firebug Lite

Firebug Lite is a great tool when it comes to  development. I use it a lot when it comes to styles so I can examine the styles being applied, where they’re coming from, as well as modify them right in the browser to see what rules I need.
However, The DOM explorer, as well as script viewer also makes this tool extremely beneficial to anyone doing front-end web development. There is a console tab as well that looks like a glorified console for JavaScript debugging and logging but I have yet to use it.


A popular tool for your social media needs. TweetDeck allows you to log into multiple twitter accounts, and maintain them all in one area. It is great for people who run different online brands, and don’t want to have to log into many different accounts. Simply compose your update, select which account(s) you want that update posted to and go.
You can also schedule posts, post images, use their auto link shortener, follow trends, and a few other interesting little tools.

Checker Plus for Google Calendar 

The newest addition to my extensions is CheckerPlus for Google Calendar. This extension is fairly powerful and integrates with Google Calendar. In the corner of your screen, a small notification will show up when you’er coming up on an appointment. You can snooze it if you like but it will come back. It is a lot like the notifications for Outlook, but using Google Chrome.
You can also schedule new events in your calendar right from your browser by clicking a button. While there are a ton of configuration settings, it makes it very powerful and a bit overwhelming at first. But once you set the settings to how you want them, you really never go back into it.

Sunday, May 20, 2012

Pro jQuery - Chapter 1-3

Pro jQuery interested me for a variety of reasons.   jQuery itself has been a technology I've wanted to get stronger in since I've seen it in action. It is amazing how widely adopted it is in 2012. Even Microsoft has started embedding it in their template project start ups.
The first chapter talked a little bit about jQuery and node.js.  It was a lot of the typical first chapter stuff such as downloading the source code, browsers, etc. There wasn't a lot there that I found to be too useful. node.js though, I'll need to revisit. I didn't fully understand what it was, how it is used, and what I need to do to get it running. I understand that it is a server side technology, which surprises me, but based on what I read about it, it is a widely accepted tool.
The second chapter was an HTML primer. There was a lot there that was just a lot of technology I use in my day to day activities. Things like element hierarchy, inputs, and the DOM are common day to day tasks in the life of any web developer.
The third chapter was a CSS Primer. I really just kind of flipped through this. I feel I have a strong handle on CSS (or strong enough for now) that I didn't really need the primer. I still looked at it though and made sure I understood all of the concepts on there. It was interesting to me to find the section about Selecting by Relationship. I've seen and used most of these, but there were a few that I had not ever seen.
With the exception of node.js, the first few pages were primer to anyone who has used HTML and CSS. jQuery information was in there, but it was very generic, and most developers already know a little bit about it in terms of what it is, where to get it, and the different things you can do with it.

Monday, March 26, 2012

Creating a Comma Delimited String from an Array

Something I haven't done very often is work with delimiters. But now is a time where I do have to occasionally generate some sort of output from an array and return a comma delimited string from it.

Previously, I would loop through every element of the array, append the delimiter and a space for readability, then go back, and chop off the last two characters. I never did like this, and always thought there may be a better way.

String[] Color ={"Red", "Orange", "Yellow", "Green", "Indigo", "Blue", "Violet"};
StringBuilder loopedColor = new StringBuilder();
foreach (var theColor in Color)
loopedColor.Append(", ");

var returnedLoop = loopedColor.ToString().Substring(0, loopedColor.ToString().Length - 2);

Later I would find the function that takes care of it for me- String.Join();

String[] Color ={"Red", "Orange", "Yellow", "Green", "Indigo", "Blue", "Violet"};
var JoinedStatement = String.Join(", ", Color);

Cleaner, and I'm sure Microsoft has thought about it more than I have. Why re-invent the wheel?

Saturday, March 24, 2012

Using Gmail/Google Apps for your Email

One issue I've always had with hosting websites is the email. I've never liked having to deal with mail servers, configuration, spam blocking, and so on. Google has come out with Google Apps. Google Apps is a suite of web based office tools, offered to businesses for basic organization. Tools like email, spreadsheets, calendars, and so on are just a few of the main tools available.

I'm using this for my personal site, so as long as I stay within a few reasonable limits, I don't have to pay to use this service. I was excited to get this started, and here are the steps to set this up.

1. Go to the Google Apps Home Page. Click on Begin Free Trial.

2. Enter in your domain name in the first box. I assume you've gotten a domain from GoDaddy, or Dotster, or some other registrar.

3. Fill in the remaining information, accept the terms and service, and click the create my account button at the bottom.

4. You may get a message about you being logged into a different Google account, but you'll want to switch to the new account you just made for your domain. It will be considered the Administrator account for your mail.

5. I went with the Express setup, so click Express. Then click next. Click next.

6. Download the HTML Verification file, and post it into the root directory of your website. By putting it there, Google can confirm you own that domain. Go back to the Google wizard, and click Verify.

7. Click the radio button No, and then click next. Click Next. Click Next. You're going to want to use Google's servers for routing, and click next.

8. Find your domain host in the drop down list (I had to select other).

9. Add the MX records to your domain. If you don't know how to do this, contact your registrar for help. You can do some Googling too to find out how to do this. What this does is have all of your mail go to Google's servers.

10. Click next. Make sure yes is selected, and click next. This screen tells you if you did it correctly, but is kind of useless because it'll take your changes quite a while to propagate through the internet. Usually 24 hours is the rule. Click Next.

11. Unless you want Google Calendar right away, click Do this later.

12. Unless you want Google Docs right away, click Do this later.

That's it. There are a lot of tools that you aren't using, but my goal was to get you up and running with your email pointed to Gmail as fast as I could. Any time you want to go in and make changes, like adding users, or setting up other services across your entire domain, you can go to the login for Google Apps, and select Sign In at the top.