Archive for October, 2007
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.
October 14th, 2007
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.
October 13th, 2007
A common requirement that you may encounter is to have a way to validate a string to determine if it’s in the proper format for a path. While there are .NET functions that you can use that will tell you if a given path exists on the disk there is no built-in .NET function that will tell you if a path string has a valid format. This was the subject of a recent discussion on VBForums. In this article, we’ll look at the function I built and some other related ideas that were suggested.
Our Requirements
For this example, we want to create a function that will tell us if the path entered by a user is a valid path string or not. We aren’t concerned about it already existing on the disk or if we have the rights to create the folder. We only want to make sure that the path string has a valid format.
What Won’t Work
We can’t use methods that check the disk for existence of the folder because we don’t need it to actually exist yet. This means we can’t use the Directory.Exists functions from the IO Namespace or the My.Computer.FileSystem Namespace. Some other IO.Path functions, such as IsPathRooted (which was my first suggestion) and GetDirectoryName weren’t well suited for validating path names.
We could use a folder browser or the textbox file system autocomplete feature. However, this wouldn’t fulfill our validation requirement.
Two other methods were thought of by forumites were to create the directory temporarily and capture exceptions. The folder would be deleted if it wasn’t used. The problem here are the performance killing exceptions and the risk of leaving junk on a user’s drive. The second was to use System.IO.Path.GetFullPath. This method worked OK in some cases but had its own formatting quirks plus it required exception trapping to deal with incorrectly formatted paths.
Solving the Problem With Regular Expressions
The way I ended up suggesting to deal with the problem was to use regular expressions. Here is the function:
Private Function IsValidPath(ByVal pathString As String) As Boolean
Const PathPattern As String = “^(([a-zA-Z]:|\)\)?(((.)|(..)|([^\/:*?”“|<>. ](([^\/:*?”“|<>. ])|([^\/:*?”“|<>]*[^\/:*?”“|<>. ]))?))\)*[^\/:*?”“|<>. ](([^\/:*?”“|<>. ])|([^\/:*?”“|<>]*[^\/:*?”“|<>. ]))?$”
Dim Results As Boolean
Try
If System.Text.RegularExpressions.Regex.IsMatch(pathString , PathPattern) Then
If IO.Path.GetPathRoot(pathString).Length >= 248 Then
Results = False
Else
‘additional checks could go here if desired
Results = True
End If
Else
Results = False
End If
Catch ex As Exception
Results = False
End Try
Return Results
End Function
In this function you’ll notice that I first define a string constant with the regular expression string. I’ve ran several tests with it and it seems to work right but if you throw something at it that it can’t handle correctly, please let me know. Next, we look for a match between the pattern and the passed in string.
After passing the first test there is a second one. We need to determine if the path is too long. Windows paths can’t be longer that 247 characters. If this value is exceeded, a False value is return. Notice that there is room to add additional checks if you need them. For example, you could add a check for a local hard drive vs. a network or removable drive.
To call this function, you would just need to call it from the TextChanged event of the target textbox.
That’s my solution. I want to thank VBForum members stimbo, techgnome TokersBall_CDXX, penguin5000, VBDT, and JuggaloBrotha who participated in this discussion and rjbudz who got the whole thing started. If you have an idea or question on this function, please leave a comment here or in the VBForum thread linked at the top of the article.
Share This Article:
These icons link to social bookmarking sites where readers can share and discover new web pages.
October 12th, 2007
A question that gets asked often by students trying to decide on a technical career is would programming be a good career choice. In recent tech site columns, like this one by Jason Hiner of TechRepublic, Sanity Check: Is IT still a profession worth recommending to the next generation?, and this one on WindowsITPro, Are IT Pros Steering Their Children Away From IT?, many commenters say that they would not recommend it. Let’s examine why this is a common response and the reasons behind it.
The number of jobs in the US for software development have been declining since 2000. Computer programmer employment has fallen from 530,730 in 2000 to 396,020 in 2006 according to the Labor Department. When inflation is factored in, salaries have also declined by about $850 a year since 2000 and continue to fall. H-1B visas and offshoring have contributed to this trend as have other economic factors. The sad truth is that the US software development industry is on the decline. No wonder there has been a decline in technical degrees, there simply isn’t any money in the field.
Then why do tech moguls complain that they can’t find enough programmers, you might ask. What they’re really complaining about is that they can’t find enough cheap programmers. Many older software developers are forced to work short term, temp, contracts to make ends meet. Rampant ageism in IT and the desire to hire the cheapest programmers possible prevents them from landing a perm position even while many well-heeled corporations lobby Congress for more H-1B visas because they can’t find enough (cheap) programmers.
All in all, the prospects for software developers in the US market isn’t good. If you want an IT career with some durability, then you should look a growth areas like network system administration or plan to quickly move from programming into a more lucrative and stable area such as project management or general IT management. If you have a love for programming, you might find it better financially to pursue it outside of work by contributing to an open source project.
However, in spite of all the negatives, there is one major good reason to pursue a programming career if programming is your passion. One of life’s greatest rewards is being able to enjoy your work because it really isn’t work to you. The best programmers I’ve worked with have had this attitude and are willing to continue programming in spite of career instability, crazy management decisions, brain-dead users and other such banes of a programmer’s life.
What do you think? If you already have a programming career would you do it all over again, knowing what you know about it now? If you’re a student, do you think your passion for programming is strong enough to make it in this field? Leave me a comment and let me know what your thoughts are on this issue.
Share This Article:
These icons link to social bookmarking sites where readers can share and discover new web pages.
October 11th, 2007
I found so many good links this week that my “link bucket” is overloaded so I’m going to publish this week’s Link Round-Up a day earlier than usual.
Web and .NET Development
I don’t talk about web development too often but here are some good articles I found recently that I found helpful.
If you need some ideas on the best ASP.NET practices to follow, Ode To Code has compiled this list of reference sites: Best Practice Resources For ASP.NET.
Unless you’ve been programming under a rock you know that AJAX enabling your Web 2.0 apps is that latest thing. Over at Design Vitality they’ve compiled a list of 43 Exceptionally Useful AJAX Applications.
CSS is almost a black art given the intracities of different browsers and the esoteric methods required sometimes to avoid dull old HTML tables. Design Vitality also has this helpful compilation article on how to Lose the Images: How to Get Rounded Corners, Gradients, Drop Shadows and More Using CSS.
Security is always a worry on the Internet. Sanjeev published this handy article on the Top 5 Application Security Vulnerabilities in Web.config Files. It’s packed with several good tips. Sanjeev should publish more often. He’s got some good stuff.
Mashable is offering a list of good .NET resource sites in this article: .NET TOOLBOX: 25+ Tools and Tips For Working With .NET.
Last up in this category is Joseph Guadagno. He provides us with a list of Database Drivers not provided by Microsoft.
Careers
On the career front, Jeff Atwood of Coding Horror tells the tale of writing a programming book in this article, Do Not Buy This Book. In it he describes why he prefers blogging to book writing.
In short, do not write a book. You’ll put in mountains of effort for precious little reward, tangible or intangible. In the end, all you will have to show for it is an out-of-print dead tree tombstone. The only people who will be impressed by that are the clueless and the irrelevant.
Charles Petzold responded to him in a post of his own, Hard Work, No Pay: What’s the Point?, which is also quite good, particularly considering his long career in authoring programming books.
Basically, the point is that if you want to write a book and make money, write the next Harry Potter. If you want to write a programming book, write a blog instead.
On the lighter side, over at Software Creation Mystery there is this post: Guide to Job Security for Software Developers: 15 Sure-Fire Methods. It gave me a laugh because I’ve worked with a few characters who used these job security methods.
Processes and Methods
James Golick talks about making the case for testing in this article: We don’t write tests. There just isn’t time for luxuries. If you need some good nuts-and-bolts figures to show a boss or project sponsor why testing is important, James has them for you.
Over at Developer.com Robert Bogue has this article on code reviews, Effective Code Reviews Without the Pain. Excellent work.
If you have “magic bullet” proponents in your organization, you’ll appreciate this article by Matt Stephens, Why UML won’t save your project
Pragmatic Jim had this interesting article on Agile Culture. It’s an interesting insight into this methodology.
Lastly, and also on Agile development, is the Q&A session with programming guru Steve McConnell: 5 Questions on Agile Development.
That’s all the links for this week. As always, let me know of any interesting .NET or general software development links by leaving me a comment or dropping me an email.
Share This Article:
These icons link to social bookmarking sites where readers can share and discover new web pages.
October 10th, 2007
Next Posts
Previous Posts