Practice, Practice, Practice

Let Your Programming Make Beautiful MusicThe old joke has a guy asking pianist Arthur Rubinstein "Pardon me sir, but how do I get to Carnegie Hall?" and Rubinstein replying, "Practice, practice, practice." The question that novice programmers often ask is like it, "How do I become a professional programmer?" And, like the guy who only wanted directions they want to know which classes to take or certifications to earn to become a programmer. However, the real answer is that one must practice programming just like one practices the piano in order to master it.

How Do You Practice Programming?

The obvious way to practice is to write programs just like if you expect to learn piano you play the piano. But, it goes deeper than that. To learn, to effectively practice, you need to work on things that aren’t easy for you. For example, if you struggle with understanding how to write a good SQL Join, practice writing them until you get good at it. If the ins and outs of ADO.NET baffle you, work on them. Find areas that you’re weak in and practice them by writing actual working code.

Another way to practice programming, particularly when you’re learning a new language, is to take an algorithm that you wrote in one language and figure out how to write it in the new one. For example, if you’re transitioning to VB.NET from VB6, take some of your old code and figure out the .NET way of writing it. If you know VB.NET and want to learn C# or Java, do the same thing. You will find that this exercise not only helps you learn something new but also increases your knowledge of your original language.

Make Your Practice Structured

To make your programming practice more effective create a schedule or structure that you follow. For example, you might set a goal of practicing for 1 hour a week to improve your database coding and dedicate another hour in the week to learning something new. If you don’t set goals you’ll find that your practice becomes less and less until it doesn’t exist at all. It’s also a good idea to chart your progress so that you have hard evidence to yourself that you’ve achieved your learning goals. The sense of accomplishment when you do this is quite rewarding.

Practice While Working

You can practice while you work as well. The way I do this is to have a ’scratchpad’ program where I create little snippets of code. These often match my main work but this gives me a place outside of it to work through ideas without the overhead and distraction of the core program. Often you’ll find these little practice pieces will fit well into your existing program or even earn a place in the snippets plug-in.

Do you practice programming? If you do, what are some of your practice techniques? If you don’t, why don’t you? Do you have anything you would like to add or ask about concerning programming practice? If so, please leave a comment.

Share This Article: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Reddit
  • StumbleUpon
  • Technorati
  • DotNetKicks
  • DZone
Not That GoodCould Be BetterOKGoodGreat (3 votes, average: 3.67 out of 5)
Loading ... Loading ...

3 commentsOctober 18th, 2007

How To Create a Blog Badge in VB.NET

Visual Basic Notebook For .NET Blog Badge

I’m sure you’ve seen blog badges around like this around the Internet. Perhaps you’ve also wondered how to create one in VB.NET. Here’s a simple class that you can use to create 80×15 pixel badges. You could even add this class to your own ASP.NET web site and, with a little fleshing out, make your own badge generator.

The Basics

What we will be doing is creating a new 80×15 System.Drawing.Bitmap object. We will then create a Graphics object for the bitmap and drawing our rectangles and text on it. Then we’ll save the bitmap image out in PNG (Portable Network Graphics) format.

The Code

Here’s our code.

Public Class BlogButton

    Public Shared Sub GenerateBlogButton(ByVal buttonSaveLocation As String, ByVal leftText As String, ByVal leftTextColor As Color, _
                                         ByVal leftBackgroundColor As Color, ByVal rightText As String, ByVal rightTextColor As Color, _
                                         ByVal rightBackgroundColor As Color, ByVal borderColor As Color, ByVal backgroundColor As Color)
        Dim ButtonPicture As New Bitmap(80, 15)
        Using ButtonGraphics As Graphics = Graphics.FromImage(ButtonPicture)
            Dim ButtonFont As New Font("Verdana", 6, FontStyle.Regular)
            Dim TextBrush As New SolidBrush(leftTextColor)
            ButtonGraphics.Clear(backgroundColor)
            ButtonGraphics.DrawRectangle(New Pen(borderColor, 1), New Rectangle(0, 0, 79, 14))
            ButtonGraphics.FillRectangle(New SolidBrush(leftBackgroundColor), New RectangleF(2, 2, 31, 11))
            ButtonGraphics.FillRectangle(New SolidBrush(rightBackgroundColor), New RectangleF(34, 2, 44, 11))
            ButtonGraphics.DrawString(Mid(leftText.ToUpper, 1, 4), ButtonFont, TextBrush, 3, 3)
            ButtonGraphics.DrawString(Mid(rightText.ToUpper, 1, 8), ButtonFont, TextBrush, 34, 3)
            ButtonGraphics.Flush()
        End Using
        ButtonPicture.Save(buttonSaveLocation, System.Drawing.Imaging.ImageFormat.Png)
    End Sub

End Class

A few of things to note about the code.

First of all, why am I using the Mid function? Isn’t it suppose to be ‘evil’? I’m using it here because it can be used to limit the length of text in a very simple and readable manner. SubString(0,4) would throw an exception if the length was shorter than that. To avoid the exception and be “.NET Pure” I would have to have more length checking code in the routine. I decided not to do that and instead make use of a handy VB function that does this for me.

Another thing to note is that I’m using hardcoded values in several places. Since I’m working with a fixed size I didn’t go to the trouble of using constants or variables for these values. However, if I were to expand this implementation I would want to replace any hardcodes.

I’m not using any overloads on this function although it probably could benefit from some if it was production code. For example, you might want to have overloads for the size of the graphic and the font object or you might want to have an overload with fewer parameters for a default version.

Lastly, I made it shared so that it could be called without having to worry about the state of an object. You could create a version that did not use shared if you wanted.

More You Can Do

In addition to making the size flexible you could also add dynamic sizing between the right and left columns by using MeasureString. Using it to calculate the size of the passed in strings you could determine where to draw the rectangles. Another thing you could do is make the font changeable. 

You could also take this code and develop your own CAPTCHA or hit counter components. The basics would be the same. You could also take this same code and put it into a desktop app for graphic generation there although you might want to create a version that passes back a bitmap rather than writing it to disk.

Let me know if you have any questions or observations about this code sample by leaving me a comment.

Share This Article: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Reddit
  • StumbleUpon
  • Technorati
  • DotNetKicks
  • DZone
Not That GoodCould Be BetterOKGoodGreat (1 votes, average: 1 out of 5)
Loading ... Loading ...

1 commentOctober 16th, 2007

Guest Blogging on AjaxNinja

Aaron at AjaxNinja asked me to write an article for his website with my suggestions for someone who’s just starting a career in programming. He’s posted it this evening: How to Jump Start Your Programming Career. Check it out and let me know what you think.

Share This Article: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Reddit
  • StumbleUpon
  • Technorati
  • DotNetKicks
  • DZone
Not That GoodCould Be BetterOKGoodGreat (No Ratings Yet)
Loading ... Loading ...

Add commentOctober 15th, 2007

VB.NET Interview Questions #4

The first pirate takes 98...Here’s installment #4 of my VB.NET interview questions. Here are the earlier installments:

VB.NET Interview Questions #1.
VB.NET Interview Questions #2.
VB.NET Interview Questions #3.

Feel free to add a comment with your answers. Try to answer them before looking at the comments or searching MSDN or Google for an extra challenge.

No True or False this week

General VB.NET Questions

1. If you wanted to load a bitmap from disk into an object how would you do it?

2. If you have multiple event handlers registered for the same event is it safe to assume they will be fired in a particular order? Why or Why not?

3. When would it be appropriate to create your own exception class?

4. What criteria do you use to balance between code clarity and code performance?

5. Give an example of where you might use recursion. What are some pitfalls of using recursion?

Tough General Interview Questions

1. What do/did you consider your most important duty at your current/previous job?

2. What resources do you feel that you need in order to do your job well?

3. What is your most important career goal right now?

4. What would you say is your strongest skill and why?

5. Would you find more career happiness in a job that allowed you gain new skills or one where your current skills were fully utilized?

Open Ended Questions

1. You have been asked to develop a class that can be used to evaluate user entered email addresses for both desktop and web applications. What approach would you take to designing and coding this class?

2. You have written a web service class that uses several stored procedures on a SQL Server database. It works fine on the development and test servers but, when it’s deployed to production, it fails sporadically with seemingly inconsistent error messages. What would you look for in analyzing this problem?

Have fun with these and let me know what you think about them by leaving a comment or answering the questions.

Share This Article: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Reddit
  • StumbleUpon
  • Technorati
  • DotNetKicks
  • DZone
Not That GoodCould Be BetterOKGoodGreat (No Ratings Yet)
Loading ... Loading ...

1 commentOctober 14th, 2007

Site News for 10/06/07 through 10/13/07

BlogRush Sucks!New Computer In The House

I’m switching over to a new computer over this weekend, a HP Pavilion a6200n. Since it has Vista Home Premium installed on it I’m going to give it a try although I’m wondering just how much isn’t going to work quite right. Now I’m trying to get all my settings and software onto the new system. Fun, Fun.

Most Popular Posts

Here are the 10 most popular posts of the week:

OpTempo - My New Blog

I wanted to branch out from just blogging about VB.NET and software development topics but I didn’t want to hurt the focus of this site. So, I started a new “anything goes” blog, OpTempo. If you get a chance, check it out.

TTZ Media

I’m trying out ads from TTZ Media right now in the header position. I wasn’t that happy with with WidgetBucks look and feel and the load and down time. Remember, if you want to advertise here on VB Notebook for .NET you can buy this header banner space.

BlogRush

Yes, BlogRush Sucks. That is all.

Coming Up Next Week

I’m still looking into coaching material and trying to put together an article. If all goes as planned I’ll have a guest post on AjaxNinja on Monday on starting a programming career. I’m tossing around some ideas on XML and ADO.NET but I’m still trying to narrow them down. If you have a topic you would like for me to cover, let me know in a comment or email.

Share This Article: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Reddit
  • StumbleUpon
  • Technorati
  • DotNetKicks
  • DZone
Not That GoodCould Be BetterOKGoodGreat (No Ratings Yet)
Loading ... Loading ...

Add commentOctober 13th, 2007

Next Posts Previous Posts


Visit Me At My New Site, Programming In C#

Most Popular Articles

Highest Rated Articles

Categories

Most Recent Articles

Feeds

 Subscribe in a reader

To subscribe by e-mail
Enter your address here

Delivered by FeedBurner

VB Opportunities

Archives