Archive for September, 2007
Part of a development lead or manager’s job is to be a good coach to other members of the team. The further you go along the management track the more important this becomes, however, even at the team lead level it is quite important. Here are six tips you can use to become a better development team coach.
1. Provide Encouragement But Be Sincere
When a team member is doing things right, notice it. Far too often it’s easy for a lead to forget to offer praise for a job well done. Don’t let the opportunity to praise a team member slip by. Managers who take their team’s good work for granted only insure that their team’s morale and performance will eventually suffer.
Don’t do something silly like Schrute Bucks or other such vapid or vague gestures to show your approval. Programmers generally despise such things more than the general population. Also, avoid contests between team members since this can cause undesirable in-fighting. Instead, say something simple and to the point, like “You handled the deployment of the new version very well” or “I was impressed by your solution to the memory leak problem.”
2. Share Praise in All Directions
If praise is unheard it has a lesser impact than praise offered in public. Make sure that everyone on the team knows that if they do a good job they’ll win your approval and that you’ll let everyone know about it. If you hold team meetings, mention it there. If there is a company web site or newsletter, get it mentioned there. Make sure your managers are told about the excellent work that members of your team are accomplishing. Note that you give the credit to the team members, not yourself.
3. Keep Criticism Private and Positive
If you need to criticize the performance of a team member, do it in private. Never do this in public where other members of your team can hear. Also avoid making a show of calling someone into your office or a conference room for a one-on-one meeting when it is obvious to everyone that you’re intent on criticism of that individual. Nobody else needs to know or even guess about anything that was said.
Never criticize a team member when you or the team member are angry, tired or stressed out. This can quickly devolve into a shouting match or, later, bring out passive-aggressive behaviors or other negative actions. Be sensitive to both your emotional state and the employee’s. It can be very difficult to retract hurtful things said in the heat of the moment. Don’t let this situation happen to you.
When you need to make a point about substandard behavior, make sure you work toward a positive outcome. If you approach it like, “Improve your code or you’re fired.” or “Your code isn’t functional or elegant” , you will only put them on the defensive. Defensiveness shuts down listening.
Instead, state your exact problem with the team member’s performance, such as “When you’re telecommuting we’re having trouble contacting you by phone and email.” or “Your work has been behind schedule for the past month”. Then follow it up with a way to have the person participate in the solution such as, “What do you think would be some ways we could improve your communication with the rest of the team?” or “What can I do to help you get back on track?”
4. Define Your Expectations and Goals
If you don’t say what you want, how you define successful work, then you will find it difficult to provide appropriate praise or criticism. For example, if you expect a particular part of a project to be completed in 2 weeks but don’t tell this to the responsible team member it is quite unfair to criticize them for not meeting your expectations. They can’t read your mind and you don’t want them guessing about what you want.
5. Be Fair
One common problem is where one or more team members are held to a different standard than others. For example, you might like Joe and, although you know he slacks off regularly with long lunches and personal activities, you let him get away with it. But you don’t really care for Bill so when he leaves early one day for a dentist appointment you criticize his dedication to the team, project, and company. Team members will pick up on this quickly even if you do try to keep it private so don’t let favoritism or your personal dislikes and prejudices enter in to your treatment of team members.
6. Do It Now
One common problem in the personnel review process at many companies is that it’s once a year or once every six months. If you wait that amount of time to impart your praise or criticism the opportunity is lost. Also you’re more prone to creating a defensive reaction to criticism or a “so what” attitude toward praise if you delay. Instead insure that both excellent work and problems are dealt with in a timely manner.
As I mentioned above, you want to avoid jumping right into a negative situation but neither do you want it to fester for months. Handle the situation calmly and appropriately within a few days. Problems don’t resolve themselves. Likewise, praise for something a team member did 4 months ago won’t mean as much as praise within the first few days after their accomplishment.
What do you think? Are there any coaching tips you have? Any other thoughts on this topic? If so, leave me a comment.
September 30th, 2007
Advertise On Visual Basic Notebook for .NET
Starting on October 1, 2007, I’m offering monthly (30 days) advertising space on this site. Please see my Advertise Here for more details.
I decided to try this in order to display more relevant ads than what I can get through Google Adsense and various affiliate programs.
Most Popular Posts
Here are the 10 most popular posts of the week:
7 Ways To Hire Smarter Programmers
An Undercover Guide to Programmer Job Interviews
3 More Useful VB.NET String Functions
3 Handy VB.NET String Functions You Can Use
Comparing String to Integer Conversion Methods in VB.NET
How To Update Controls Using BackgroundWorker in VB.NET
Introduction To VB.NET Delegates
Introduction to Constructors and Destructors in VB.NET
How To Do Credit Card Validation in VB.NET
The VB.NET Salary Gap
Coming Up Next Week
I’ve got a few ideas percolating for next week but nothing definite yet. I’m trying to narrow down some ideas on ADO.NET, XML, and Web Services into article sized bits. I am open to requests, so if there is a topic that you would like for me to cover, let me know in a comment or email.
September 29th, 2007
Here’s the second in my series of VB.NET interview questions. You can try out the first in this series here: VB.NET Interview Questions #1.
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.
True or False
For ‘extra credit’, explain your answer
1. VB.NET does not support optional arguments.
2. VB.NET supports operator overloading.
3. A TcpListener object can only accept one connection at a time.
4. Any object returned by a web service must have a default constructor.
5. The string, “2nd_Base” is a valid XML element name.
General VB.NET Questions
1. Name at least 3 ways to fill a DataSet object with data.
2. What is the difference between a Protected and a Private member of a class?
3. Describe some of the differences between Binary Serialization and XML Serialization.
4. Explain how to add a control to an existing form.
5. Name at least 3 XML reserved characters.
General Interview Questions
Here are some tough general interview questions that you might want to use or be prepared to expect.
1. What was the most important thing you learned on your last job?
2. What do you think were some of the weakest points in the way things were done at your (previous/current) job?
3. What accomplishment in your career are you most proud of?
4. If someone else on your team asked for your help but you were busy with your own tasks, what would you do?
5. Have you ever been in a job where you felt (over/under) qualified?
Open Ended Questions
1. Your task is to program a web service that will provide sales leads to independent sales organizations. What would be some of the things that you would want to ask the architect or project sponsor about in your initial discussions?
2. You have written a data layer for a web site that collects customer satisfaction survey information. It is currently in production. It has been reported that about 1 in 10 surveys are being lost when the user presses the save button. You can’t duplicate the problem on your test servers. What steps would you take to debug the problem?
Have fun with these and let me know what you think about them by leaving a comment or answering the questions.
September 28th, 2007
A common question that comes up rather often in VB discussion forums is how to pass data between forms. One of the common solutions offered are to use global variables in one way or another, for example, creating a module specifically for holding these values. These methods have all the typical problems with associated with globals. Another common strategy is to make the desired data available via properties on the forms. This can work in some cases but also can lead to undesirable interdependencies between forms. However, there is another approach that is often overlooked.
This article is about this overlooked strategy, overloading the New, Show or ShowDialog methods of forms. The reason this gets overlooked is that it isn’t obvious, particularly to someone who is new to programming or those who’ve transitioned from VB6. Forms get thought of as a special case because they contain a lot of generated code. But, actually, behind the scenes, they’re just another class in the application. And, like other classes, we can adapt them to our needs by overloading their base methods.
As with other classes with no explicit New method, a parameter-less New method of a form is automatically generated by the .NET compilation process. If we want to add our own overload method, we just add it to the code for it to our form. Here’s what it should look like:
Public Sub New(ByVal customerOrder As Order)
In this example, we’re passing in an order object to our new form. Note that we call the InitializeComponent method first to create the controls on the form. This method is generated by VB.NET and is located in the [form name].Designer.vb file that contains a partial class definition for our form. Once the controls are created, we can then call our routine to load data into the controls.
When you define your own New method you will lose the default parameter-less New method and thus lose the VB.NET created default instance. To restore the default instance, add your own Public Sub New() as shown here:
Public Sub New()
' This call is required by the Windows Form Designer.
' Add any initialization after the InitializeComponent() call.
In Visual Studio, if you just type in the first line and press enter the rest will be generated for you. If you don’t add this routine, you will need to explicitly create instances of the form using your New method as in this example.
Dim frmCustomerOrder As New frmOrder(CurrentOrder)
You can use this way to insure that the form is properly loaded with data before it is displayed.
Show, as you probably know, displays the form modelessly and does not return a value. This function comes with one overload which allows you to specify the owing window/form. To continue our example, let’s add a Show method that takes our order object.
Public Overloads Sub Show(ByVal customerOrder As Order)
If customerOrder Is Nothing Then
'load up order defaults
'load from parameter
Notice at the end we call the form’s base class to show the form. If you don’t have this line, then the form will not be displayed.
While the stock methods don’t return a value, did you know that you can write a version of this method that returns a value? You can. Here’s an example:
Public Overloads Function Show(ByVal OrderID As Guid, ByVal viewOnly As Boolean) As Boolean
If LoadCustomerOrder(OrderID) Then
In this example, we return a True if the order is found and the form is loaded but a False if the order ID isn’t found. Remember that processing doesn’t stop at the MyBase.Show() to wait for user input but continues onward.
ShowDialog shows the target form modally and, in its built-in methods, it returns a Windows.Forms.DialogResult value. Here’s an example of overloading it
Public Overloads Function ShowDialog(ByRef newCustomerOrder As Order) As Windows.Forms.DialogResult
newCustomerOrder = New Order
'load up order defaults
In this case we’re passing in an order object by reference so that the dialog can modify it and return it and we’re returning a DialogResult like the other overloads. Also, just like with the show method, we need to call the base class to show the dialog.
Note, however, that we don’t need to return the DialogResult value, we can return anything we want, as seen in this code that returns an order object.
Public Overloads Function ShowDialog(ByVal orderID As Guid) As Order
Dim ExistingCustomerOrder As New Order(orderID)
'load up order defaults
If ExistingCustomerOrder.OrderDetail IsNot Nothing Then
If MyBase.ShowDialog() = Windows.Forms.DialogResult.OK Then
It is probably best for consistency in most cases to return the same value as the default methods though.
That’s how you can pass values around between forms without having to use global variables (or work-alikes) or properties. Let me know if you have any questions, additions, or corrections by leaving me a comment.
September 28th, 2007
In .NET nullable data types are data types that can be set to a null reference or, in VB.NET terms, Nothing. They can either contain a value or have no value at all. Reference data types, like strings and classes, are nullable. However, Value types, such as integers and dates, are not nullable. If you set a value type to Nothing the result is a default value such as 0 for numeric types or #1/1/0001 12:00:00 AM# for dates.
As you can probably guess, there may be times when you will need to have value data types that can be Null/Nothing. For example, a database column of date values could be Null in the database and you want your class to reflect this situation. In the .NET Framework 2.0, we have the Nullable class and the Nullable structure that allows us to add the ability to have a value of Nothing to an underlying value type.
In practice, we will want to use the Nullable structure since it supports Generics and thus allows you to define a specific data type. This gives you greater type safety and it’s easier to work with.
To start things off, let’s create a fragment of a class that uses a Nullable structure as a property.
Public Class Orders
' Other property variables
Protected _orderShippedOn As Nullable(Of Date)
' Other methods and properties
Public Property OrderShippedOn() As Nullable(Of Date)
Set(ByVal value As Nullable(Of Date))
_orderShippedOn = value
In this example, we have an order shipped on date value. Since we will want the order in the system prior to shipping it out the door, the value in our database will be Null until this event happens. We don’t want to hard code values like this in several places in our application…
If CurrentOrder.OrderShipDate = #12:00:00 AM# Then
…to fake out null values. Instead, we wrapper our dates in a Nullable class.
HasValue and Value
But, you’ll notice that if you code a line like this…
If CurrentOrder.OrderShippedOn Is Nothing Then
…we’ll get an error. This is because we’re still dealing with a structure, not a class. Here’s what our code should look like:
If Not CurrentOrder.OrderShippedOn.HasValue Then
dtpOrderShipDate.Value = Now
dtpOrderShipDate.Value = CurrentOrder.OrderShippedOn.Value
The HasValue property returns a Boolean value that lets us know if there is a value or not. Then, when we want to retrieve the value to load it into a Date Time Picker control, we use the Value property. This allows us to return the correct type for the control. You can’t use = or Is to compare a Nullable type, you have to use the HasValue or Value properties.
Loading Nulls from the Database
Now let’s look at how we should load our object from our database. In this example, we’re assuming that we’re loading our object from a DataRow.
If orderDataRow.Item("ShipDate") Is DBNull.Value Then
_orderShippedOn = Nothing
_orderShippedOn = CType(orderDataRow.Item("InventoryDate"), Date)
We have to check for a Null value since we can’t convert a DBNull to a Date.
That’s it for this introduction to Nullable types. I hope you’ve found it useful. Let me know if you have any questions, additions, or corrections by leaving me a comment.
September 27th, 2007