Welcome to MSDN Blogs Sign in | Join | Help

My second webcast which was a part of the webcast series done by Visual Basic Team called "Live From Redmond" webcasts on Visual Studio "Orcas" was on building N-Tier application using Visual Studio "Orcas".  I gave this webcast a couple of weeks ago and it wasn't until today that on-demand version became available.  Sorry to those who have been waiting for the on-demand link and a copy of my slide.

During this webcast, I described new "Orcas" data features at high-level and built a simple multi-tiered application as a demonstration.  Specific topics that I covered include:

  • Hierarchical Update Support in Typed Dataset
    • TableAdapterManager class and TableAdapterManager.UpdateAll() method
  • N-Tier Support in Typed Dataset
    • Dataset Designer support to make Typed Dataset N-Tier friendly
    • How to add custom validation logic to Typed Dataset and apply them through multiple tiers
  • WCF
    • How to create and consume basic WCF service
  • LINQ to Typed Dataset

You can watch this webcast on-demand by visiting following Microsoft Events page.  Also, a link to my slide deck below.

 

Visual Basic team is hosting a series of "Live From Redmond" webcasts on Visual Studio "Orcas" and I gave one on LINQ to SQL and the O/R Designer a couple of days ago.  Thanks to all who tuned in.

I covered following topics in my webcast:

  • Mapping database objects to .NET objects via attributes
  • Using the O/R Designer to visually create mapping between database objects and .NET objects
  • Writing LINQ to SQL queries
    • Basic LINQ to SQL queries
    • Relationship navigation
    • Join / Group Join
    • Deferred Execution
    • Identity Mapping
  • Data binding with LINQ to SQL
  • Updating data via LINQ to SQL
  • Stored procedures
    • Using stored procedures to override default runtime Insert, Update and Deleve behavior
    • Using stored procedures to retrieve result-set mapped to existing types

You can watch this webcast on-demand by visiting following Microsoft Events page.  Also, a link to my slide deck below.

Last week I gave two talks during http://www.devconnections.com/shows/SP2007VS/default.asp?s=93.  Below are descriptions and links to slides for both sessions.  Thanks to everyone who attended.  I had a great time!

VMS305: LINQ to SQL: Bringing SQL Code into Visual Studio

Database-centric applications have traditionally had to rely on two distinct programming languages: one for the database and one for the application. LINQ to SQL is a component of the LINQ project designed to help integrate relational data and queries with C# and Visual Basic. With this advancement, database queries that previously were stored as opaque strings now benefit from static type checking, CLR metadata, design-time type inference, and of course IntelliSense. LINQ to SQL also supports a rich update capability that lets you save changes to an object graph back to the database using optimistic concurrency or transactions. This session will cover an introduction to common SQL queries that can be done natively in the language, a discussion around how LINQ to SQL optimizes performance and execution on the server, and how Visual Studio enhancements like the Object-Relational Designer and IntelliSense give developers the power and productivity to leverage LINQ to SQL entities.

Slides

VMS309: Sneak Peak at Visual Studio "Orcas"

Come see how Visual Studio Codename "Orcas" will provide support for building applications for Windows Vista, the .NET Framework 3.0, the 2007 Microsoft Office System, ASP.NET and mobile devices. This session will look at new features like LINQ, and designers for the .NET Framework 3.0 and the 2007 Office system.

Slides

Been 7 months since my latest post. Why? Orcas. It's been a great ride and I can't wait to tell you all the great features my team worked on. March CTP is finally out and Beta 1 is coming soon. My team is putting final touches to the last feature we have left. After it's done, it will be all about getting feedback from the community and improving the quality of the final product.

It's almost done… and I am back to blogging again.

Kris – COO
Jim – EVP of Division X
YJ – Development Manager in Division X
Mike – Lead Developer in Division X
Paul – Development Manager in Division Y

Conversation #3: 3:00 PM, Kris & Mike

KRIS: You better have a good explanation of why project X is not done yet.

MIKE: I am working as hard as I can but it will take some time to finish.

K: Non-sense. If you have been working as hard as you can, you would have finished this project 6 months ago.

M: We started this project 6 months ago.

K: According to my estimate, this should only have taken 2 weeks.

M: …

K: What time did you get to work this morning?

M: 9 AM.

K: What time did you leave yesterday?

M: 5 PM.

K: This is exactly what I am talking about. You are not motivated at all to finish this project. You have no urgency!!

M: I completely understand how important this project is to you. And as I said, I am working as hard as I possibly can.

K: No, you are not. What percentage of your time was spent on this project past 6 months?

M: I would say 50%.

K: What have you done with the other 50%?

M: I still need to support the team with their current project. I am the only one who knows about modules they are modifying. That project is suffering also since I am not available full-time to support.

K: Why did you let that happen? What happened to sharing knowledge? Let them figure it out. Everyone in your team is wasting company's money!!

M: They are also trying their best to avoid interrupting me. But when we worked on those modules, you put everyone on another project and I was the only one available to work on them.

K: Oh, now you are blaming me?

M: No, sir. Just trying to explain.

K: Your team has never been reliable! The other team working on this project has already finished their part and is doing final testing. It only took them 2 weeks!

M: I would like to understand how that's even possible.

K: Go talk to Paul. I had a status meeting this morning with him. Let's do this. You tell me when you can really finish this thing. Give me the date.

M: …

K: …

M: …

K: …

M: I guess another two weeks maybe.

K: Ok. Here's what I will do to help you. Since all the noise coming from your team is making you less productive, I can put you in a separate office all by yourself. If you need faster computer, I will have IT set it up for you tonight. I can even throw in two 32" monitors. I will buy you lunch and even dinner if you need everyday and will provide car service for your commute. I can also talk to your wife. Let's get this done in two weeks.

M: …

K: I will see you in two weeks.

 

Conversation #2: 2:00 PM, YJ & Mike

YJ: KRIS will come down to talk to you. He's very unhappy about the project.

MIKE: What else is new?

Y: He's serious this time. I had a meeting this morning with him. He said that Paul's team already finished their part and is about to start testing. According to him, it only took two weeks which is what Paul has been telling everyone since the beginning.

M: You mean for past six months, right?

Y: Yeah. Paul's been saying "two weeks" for past six months. Anyway, I have a feeling that Kris will try to make a deal with you.

M: What do you mean?

Y: He thinks putting you in a locked room with fastest workstation and feeding meals to you will make you finish the project.

M: What the…

Y: I know. Jim was there, too. Jim has been telling Kris that there are other more important commitments to make. This is Jim's division after all and if Jim can't meet financial goal, he's screwed. You know that Jim is betting everything on the project our team is currently working on, right?

M: Yeah. I've been trying to help them. They are lost without me. I should have never worked on those modules alone.

Y: Jim and I have tried to stop Kris but he did not listen. He will come and talk to you at 3:00 PM. Just be honest with him about the progress.

M: We are months away. How can I tell him that?

Y: Jim and I explained where we were. So, he should be expecting it. Remember, just be honest with him.

M: Ok, I guess.

 

Conversation #1: 10:00 AM, Kris, Jim & YJ

KRIS: So, how's Mike doing?

YJ: He's still working on the project.

K: You know this is 6th month that he's been on that project. Why is he still not done?

Y: Haven't we told you that it was a big project? From what I see, Mike is making a tremendous progress on the project.

K: Your division has been doing very poorly financially. No contribution to the company's bottom-line at all!

JIM: Kris, that's exactly why I need Mike on another project YJ's team is working on. That project is too critical for my division.

K: Mike would have been on that project if he finished his 6 months ago.

Y: Kris, it's a big project and there's no way we could have finished it in two weeks.

K: Paul's team did it. Met with Paul right before this meeting and he said they were pretty much done with a couple of bugs to address.

Y: Their scope was much smaller than ours.

K: I don't get it. You guys are making same changes to your systems. I can't understand why it takes longer to do it on your side. Paul's team only spent two weeks!

Y: We have two completely different systems.

J: Kris. I seriously need Mike back. The project he's working on adds no value to my business. We've wasted enough time already.

K: You are wrong, Jim. It has long-term strategic value. It's very important for our company.

J: I cannot meet my commitments this year if we keep spending money on Mike's project.

K: Have Mike finish his project so that he can help. By the way, Paul's division has been making great progress with their business. New deals are coming in.

Y: Kris, we should pull Mike out of his project right now. Otherwise, we won't meet our goals this year.

K: Guys. You are making me to do something that I never want to do. I've only done this once in the past and I believe this is the only solution.

J: What is it?

K: I will put Mike in a locked room with fastest computer we can get. I will buy him food everyday. I will let him use our car service to commute. I will make sure that no one bothers him so that he can focus. It always works. I've done this once before and it worked beautifully.

Y: Jim actually told me about that plan you had discussed with him. I disagree. It will not only hurt his pride, it could have significant impact on others. Please don't go there. Those things won't help him a bit.

K: That's the only way you guys can get out of this mess and have a chance to get back on track. Please set up a meeting with Mike this afternoon. I will talk to him.

J: Kris, YJ and I talked about that and YJ really doesn't think it's such a good idea.

K: Then finish the damn project now! You guys are wasting my money!

 

Conversation #4: a couple of months later, YJ & Mike

YJ: Mike, I was in a meeting with Kris and Paul. We discussed the project you are working on. Paul's team apparently lost the developer who originally worked on it. And no one can figure out where things are right now.

MIKE: I thought they were done?

Y: Apparently, they were nowhere near done. It's not even testable.

M: Huh? Didn't Paul say that it only took them two weeks and they were just fixing a couple of bugs?

Y: Yeah, he did. But when they were asked to do some demo, they couldn't produce anything. Maybe they did some very basic stuff. Or maybe they used crap load of hacks to finish in two weeks and never tested it. Anyway, they are rolling back their changes completely.

M: What the… Are they going to start over?

Y: No. They have something else they need to address and they have no idea when they will be able to get that project started again.

M: Did Kris let them do that?

Y: Yeah. They were losing so many customers because their product was so unstable. They've been losing a lot of money.

M: …

Y: By the way, thanks for going beyond to help with the team to finish and launch their project. Jim has been working with marketing and product teams to talk to our customers. I think customers are really happy about those new fixes.

M: Well, I couldn't let the team suffer because of the mess I created.

Y: It wasn't your fault that you were the only one who knew ins and outs of those modules. You did great.

M: Well, I contributed to the problem.

Y: I think Linda will help you finish your project. Since your project also involves those modules you trained her on, it will definitely help you.

M: Yeah, I've already started talking to her.

- THE END –

 

Joel's The Econ 101 Management Method inspired me to write this. Yes, this really happened even though above story has some exaggerations. I owe a lot to Mike (not a real name, of course) and his team. I could have stopped the mess very early on had I been brave enough. I will discuss what I've learned in future posts.

Special thanks to Daryl who forwarded Joel's article to me and help bring out ugly side of my career. You have an amazing skill to make me think. :)

This blog was written and published using Microsoft Word 2007 Beta.

Technorati Tags:

If you've been trying to figure out why you cannot access the return value when using stored procedures in TableAdapter, here's the answer and the solution for you.

Assume I added a new query to my TableAdapter via Dataset Designer and named it ReturnSomething. For this query, I used a simple stored procedure that just returns an integer value. Without looking at the generated code, most people expect the return value of the generated query method to contain the return value of the stored procedure and try something like below:

   Dim returnValue As Integer
   
returnValue = taQuery.ReturnSomething

However, above call results in either compile error or run-time error. The problem is that these query methods actually return something else depending on what option you chose for 'Choose the shape of date returned by the stored procedure' dialog when adding your query via TableAdapter Query Configuration Wizard.

  • Single value: Query method returns the value of the first column of the first row in the result set returned by SELECT statement in your stored procedure. If SELECT statement returns nothing or if there's no SELECT statement, then the return value is NULL.
  • No value: Query method returns the number of rows affected by the stored procedure.

Definitely not the return value from the stored procedure. If you look at the generated code, this all makes sense. Here's the example code for these methods.

''

'' Singe value    

''

Public Overloads Overridable Function ReturnSomethingSingleValue(ByVal MyParam As System.Nullable(Of Integer)) As Object

    ...

    ...

    Dim returnValue As Object

    Try

       returnValue = command.ExecuteScalar

   Finally

       If (previousConnectionState = System.Data.ConnectionState.Closed) Then

            command.Connection.Close

       End If

   End Try

   If ((returnValue Is Nothing)  _

      OrElse (returnValue.GetType Is GetType(System.DBNull))) Then

        Return Nothing

   Else

        Return CType(returnValue,Object)

   End If

End Function

       

''

'' No value

''

Public Overloads Overridable Function ReturnSomethingNoValue(ByVal MyParam As System.Nullable(Of Integer)) As Integer

    ...

    ...

    Dim returnValue As Integer

    Try

        returnValue = command.ExecuteNonQuery

    Finally

        If (previousConnectionState = System.Data.ConnectionState.Closed) Then

            command.Connection.Close

        End If

    End Try

    Return returnValue

End Function

Notice that for single value query, ExecuteScalar method is used and for no value query ExecuteNonQuery method is used. And both query methods return what corresponding execute methods return. ExecuteScalar method returns, as described above, the value of the first column of the first row in the result set and ExecuteNonQuery returns the number of rows affected by the command.

Ok. It's very comforting to know what these methods return and we now understand where errors come from. But where do we get actual return values from then? If you read through the generated code carefully, you will notice that TableAdapter actually has places for return values.

Private Sub InitCommandCollection()

    ...

    ...

    CType(Me._commandCollection(0),System.Data.SqlClient.SqlCommand).CommandText = "dbo.ReturnSomething"

    ...

    CType(Me._commandCollection(0),System.Data.SqlClient.SqlCommand).Parameters.Add(New System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue, 10, 0, Nothing, System.Data.DataRowVersion.Current, false, Nothing, "", "", ""))

    ...

    ...

    CType(Me._commandCollection(1),System.Data.SqlClient.SqlCommand).CommandText = "dbo.ReturnSomething"

    ...

    CType(Me._commandCollection(1),System.Data.SqlClient.SqlCommand).Parameters.Add(New System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue, 10, 0, Nothing, System.Data.DataRowVersion.Current, false, Nothing, "", "", ""))

    ...

End Sub

As you can see from above code sample, each SqlCommand object has ReturnValue parameter in its Parameters collection. So, it's just a matter of retrieving these values after you execute your query method. To demonstrate how this can be done, I wrote below code in partial class. Note that this is very simple code sample that has no error handling or validation. It just demonstrates the idea.

Namespace MyDatasetTableAdapters

    Partial Class QueriesTableAdapter

        Public Function GetReturnValue(ByVal commandIndex As Integer) As Object

            Return Me.CommandCollection(commandIndex).Parameters(0).Value

        End Function

    End Class

End Namespace

After you add above code to your partial class, you can retrieve return value of specific command by doing something like below.

Dim taQueries As MyDatasetTableAdapters.QueriesTableAdapter

Dim returnValue As Integer

Dim myInputParam As Integer

 

myInputParam = 999

taQueries = New MyDatasetTableAdapters.QueriesTableAdapter()

taQueries.ReturnSomethingSingleValue(myInputParam)

returnValue = taQueries.GetReturnValue(0)

Above code will execute the first query method in the commandCollection and retrieve the return value of the same command via GetReturnValue method added to the partial class. Notice that 0 is passed as the parameter value for GetReturnValue method to specify that we want to retrieve the return value for the first command in the collection. Yeah, it's ugly. But, again, you get the idea. :)

Typed Dataset simplifies your data access coding. But there are many things that you might not be able to do using generated Typed Dataset. If you are faced with that situation, look for ways to leverage partial classes to add/modify Typed Dataset behavior. That's exactly why we added partial class in Visual Studio 2005!

If you have better ways to handle return values, please let me know. See something wrong with above approach? Don't be afraid to send me hate email! :)

Technorati Tags:

I got a perfect article for you if you've been wondering about what the heck your manager does and how to work with him/her so that you can be successful.

Deconstructing Managers Day 1
Deconstructing Managers Day 2
Deconstructing Managers Day 3
Deconstructing Managers Day 4
Deconstructing Managers Day 5
Deconstructing Managers Day 6

By the way, if you are not reading Rands In Repose, you are missing out a lot.  I stopped my daily visit to Joel's blog once I discovered Rands!

 

Technorati Tags:

Change the world.

Will take my entire life to achieve this goal. But I will never get bored for sure.

Technorati Tags:

I certainly did not exepct to see our Corporate VP to be on video like this and even show silly side of him.  Video itself is not that interesting.  But outtakes at the end made me laugh out loud.  Glad I had my door shut in my office.  :)

Ed Helms' on-scene report (from Microsoft College Careers site)

Technorati Tags:

Doug Seven wonders accountability issue with Scrum.  And yag wants to discuss this further.  If you read follow up comment Doug posted for his entry, you can easily discover that the team is still in learning phase.

Folks.  Scrum is not a magic bullet.  There is no such thing as a magic bullet.

Only three sprints.  Do not expect the productivity to go up dramatically after three sprints.  It doesn't matter how many training sessions team had with who.  It doesn't matter how many books team members read.  And it really doesn't matter whether you have an experienced Scrum Master in the team.  It takes time.

Scrum Master should be careful about painting a rosy picture when working with a team that does not have any Scrum experience.  Scrum Master is responsible for setting the correct expectation with the team and working with the team to guide them through the initial dark-period.  Team productivity will dip.  It will probably be worse than whatever previous process the team was using.  Team moral will dip.  People will start questioning whether Scrum is the right thing or not.  Management will put increased pressure to the team as the team struggles to meet their commitment sprint after sprint.

Every aspect of Scrum is very different.  User stories instead of full spec, size-based estimates, daily meetings, acceptance tests, velocity tracking, new engineering practices such as TDD, Continuous Integration, pair programming.  It requires a mind shift.  And expecting the team to produce more stuff after just a few sprints is just wrong expectation.  It will NOT happen.

So, going back to the accountability issue.  I think management and Scrum Master should be held accountable in Doug's team's situation since they set the wrong expectation and have not given ample opportunities to the team to learn this very different way of developing.

Technorati Tags:

Today I am full of ideas around community and customer.  Here's my top 10 list of how you as a software engineer should view customers as.

  1. Customers pay your salaries, not your CEO.
  2. Customers never complain.  They demand.
  3. Customers are not stupid.  They are smarter than you are most of times.
  4. Customers do not hate YOU.  They hate paying for something that does not help them.
  5. Customers love your product more than you do.
  6. Customers know your product better than you do.
  7. Customers do not understand your jargon.
  8. Customers know they have other options even though they complain about your company's monopoly (whether it's true or not).
  9. Customers will listen only if you are honest with them.
  10. Customers want working software not cool software.

Amen.

Tags: ,

BlakeHandler told me that he's keeping track of Microsoft Bloggers Directory List.  Thanks Blake! Very useful and something we should definitely provide on our side.  I often wonder how people find our team blog when I receive feedback from it.

Update: yag just alerted me of Microsoft Feeds Directory.  Thanks yag!

Tags: , , ,

Yag moves on.  He used to be the Group Manager of Visual Studio Data team before the team got merged into Visual Basic product unit and became a part of Visual Studio Professional Data team.  Although I only spent a couple of months in Visual Studio Data team and only had 1 face-to-face meeting with him, I learned a lot from him.  You see, it really doesn't require multiple encounters to learn great stuff from a great person.  You know it when you meet that kind of person and you naturally absorb great stuff from that person like a dry sponge.  That's what happened when I met yag.

Well, I actually had two face-to-face "official" meetings with him.  One was during my interview and one was after I joined VS Data team.  I think I only spent abouut 30 min with him during my interview.  But that 30 min definitely helped me decide to eventually accept the offer.  I met great people during my interview process and yag just sealed it at the end.  We mostly talked about my passion around Agile Development.  The second "official" meeting was the 1-on-1 he scheduled with me.  During that meeting, he showed his passion around community.  We also shared some frustration about how community stuff was done.  Oh, don't get me wrong.  That frustration was from being too passionate about something.  I guess "frustration" is the wrong word for that...

Now, why do I think our paths will cross again?  It's because we share same passion, creating great software that customer really needs by being pragmatic (Agile + Community).  If you ask me, I rather listen to the customer and provide solution that just works as soon as possible rather than worrying about hundreds of other political, process and architectural things (a.k.a. impediments).  If you ask me, I rather sit with the customer during the project cycle than in my own office guessing what customer needs.  If you ask me, I get more excited when I get a small "thank you" note from the customer I helped than when I receive a "job well done" message from my manager.  And I believe that's where yag's passion lies also.

Best wishes to yag in his new and exciting role. 

Tags: , ,

So far, there were only two fonts suitable for IDEs such as Visual Studio, Courier New and Lucida Console.  There's a third choice now.  Go grab Consolas Font Pack for Visual Studio 2005 now.  You can see differences between three fonts from Glen Gordon's blog.

Installing the font pack will automatically change the default font for Visual Studio to Consolas.  I also changed the font for Notepad, Notepad2 and command prompt.  Changing the font for command prompt is a bit tricky.  If you open the properties window from command prompt, you will only see Lucida Console and Raster Fonts as options.  In order to make other fonts appear in the font selection, you will need to make a small registry hack.

* Disclaimer: Don't blame me if you mess up your system while making changes to registries.  You should always backup your registry before making changes. *

Open up registry editor (regedit) and browse to the following.

\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Console\TrueTypeFont\

Then add a new REG_SZ (right-click -> New -> String Value) with following.

Name: 00
Data: Consolas

Or... you can copy below to a new .reg file and just double-click on it to merge the change into your registry automatically.

--------Cut Here (do not include this line) -----
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Console\TrueTypeFont]
"00"="Consolas"
--------Cut Here (do not include this line) -----

Once you are done, restart your system and go back to command prompt property window.  You will then be able to select Consolas as a font.  If you would like to add another font, just create a new REG_SZ key with extra 0 for the name (000, 0000, 00000, etc).

Frankly, I am not sure whether I like Consolas better than Lucida Console.  I guess I will give it a try for a while and see.

Scoble ponders about how Agile methodologies such as Scrum can be applied to Visual Studio, Office or Windows teams in his Another test of "is Microsoft listening" post.  Scrum is everywhere now.  Even Scoble talks about it.

 

I do firmly believe that Agile methodologies can be adopted by ANY development team as long as people understand what benefits Agile brings and plan carefully.  Scoble mentions the deployment issue as one of the reasons why Office or Windows teams won't benefit from Scrum.  Although he has a point, that isn't true.  It's a very common misunderstanding people have about Agile methodologies.  Sure, "ship every two weeks" sounds very attractive.  And it's one of the reasons why people are so excited about Agile methodologies.  However, it's not about ship every x weeks.  It's about building shippable software every x weeks.  People often do not realize that Agile teams have iteration planning and separate release planning.  Iteration planning is about committing to what will be done during a particular iteration.  Release planning is taking what's been done in one or more iterations and actually shipping.

 

Why focus on creating working software (shippable software) at the end of each iteration when you are not sure whether it will actually ship or not?  A couple of reasons.

 

Since team members have to make sure that whatever stories (features) they commit to need to be fully spec'd, implemented and tested, they do not sign up for unrealistic goals which is very typical of waterfall teams.  Instead, they use real data collected from previous iterations to choose what they are going to work on.  This is Yesterday's Weather concept which tells you that the best way to predict what you can do during next iteration is to look at what you've done in previous iteration.  No more, no less.

 

Another reason for striving to create working software at the end of each iteration is to encourage highest level of collaboration between team members.  Since the length of each iteration is very short, if you are not talking to each other and help each other from day 1 till the end of the iteration, you won't be able to finish your committed features.  No more dev doing their work while QA is waiting.

 

Being able to actually ship at the end of each iteration is probably added bonus some extremely mature teams can enjoy.  But what Agile development want you to do is to set realistic goal and work together to create working software.  Deployment is a separate story.

 

By the way, please don't think that you actually have to have your iteration set as 4 weeks long (what Scrum people recommends).  It's completely up to you as long as you don't go too low (less than 1 week) or too long (more than 4 weeks).

More Posts Next page »
 
Page view tracker