September 21

gRPC + .NET: Lessons from the Trenches Retrospective

Now that I've had a chance to slow down a bit let's do some creative writing. Let's talk about the "gRPC + .NET: Lessons from the Trenches" talk I gave at the North Houston .NET User Group. As I said previously, the talk was received well and I was really happy about that.

The inspiration or the idea to talk about gRPC came from the work I was doing at a large oil & gas company located in the Energy Corridor in Houston, Texas. My stint on the project lasted about 20 months.

This was actually the 3rd time I've given the talk. The first time was for an internal BJSS event in April of 2024. The second was at the Houston .NET User Group back in June 2024. The neat thing about taking a talk from scratch all the way through several iterations is how the presentation "feels". You should find potholes as you go and make notes to double back to correct and/or add to them.

The intent with the talk was to answer the following questions:

  • What is gRPC?
  • Can you give some evidence that shows that gRPC out-performs REST API?
  • Have you ever used gRPC on a real project?
  • What were some of the issues/problems you encountered and how did you work around them?
  • When should you use gRPC?
  • When should you NOT use gRPC?

I feel like when I got to the 3rd iteration of the talk I was answering all those questions completely and coherently. Including the benchmarks in this version of the talk was a good addition and I'll credit Daniel Wright, Principal Technologist @ BJSS Houston with the idea for that one.

I was surprised that the audience this time around had more experience with gRPC than I was expecting. This lead to alot of good questions and some leading questions that came up right before I answered them on the next slide. The talk started to take on more of a conversation kind of feel than a lecture.

While I did have fun putting this talk together and giving it, I don't think I'm going to hang up my developers hat yet. I'm sure there is still a project out there that needs my help! Now it's time to find another topic to talk about and then probably re-do the circuit next year.

Category: .NET, BJSS, C#, gRPC | Comments Off on gRPC + .NET: Lessons from the Trenches Retrospective
September 20

gRPC + .NET: Lessons from the Trenches Powerpoint Slide Deck

Hey! If you were one of the people who came out to the September 2024 North Houston .NET User Group meeting tonight...thank you! You all were a great audience and I loved the interaction.

As promised, here is a copy of my Powerpoint slide deck (gRPC + .NET: Lessons From the Trenches). Feel free to ask questions if you still have any.

Have a suggestion for another talk I should do? Let me know and if there is enough there I can put one together.

Category: .NET, ASP.NET, ASP.NET Core, C#, gRPC | Comments Off on gRPC + .NET: Lessons from the Trenches Powerpoint Slide Deck
September 11

How to Host a gRPC Service With an Azure App Service (as of 9/10/2024 anyway…)

I'm giving a talk on gRPC next week and I wanted to add more content around some gRPC benchmarks. The recent work I was doing for a client with gRPC was hosted in containers and hosted in AWS. This worked well and we had minimal issues once we got it up and running. For the benchmarks I'm looking to run, I just needed to host the gRPC service in an Azure App Service. Now that I found the correct documentation, this is a piece of cake and I'd like to point it out to anybody else who might be looking for this information in the future.

This is the documentation for deploying a gRPC app on an Azure App Service:

I can confirm that this will also work for .NET 8. It was not working for .NET 9 as of 9/11/2024. I'd expect that to get fixed in the near future.

Category: .NET, ASP.NET, ASP.NET Core, Azure, C#, gRPC | Comments Off on How to Host a gRPC Service With an Azure App Service (as of 9/10/2024 anyway…)
August 6

H2 2024 Update

Well...we're alittle over 1 month into the second half of 2024. It's been a bizarre July filled with a hurricane, a vacation, and some unexpected twists and turns.

Let's go over the TODO list of the things that I know I need to do.

  • Take and pass the GitHub Foundations exam (holdover from H1 2024)
  • Renew Information Protection and Compliance Administrator Associate (< 9/28/2024) - Completed 8/6/2024
  • Renew Identity and Access Administrator Associate (< 10/9/2024) - Completed 8/7/2024
  • Renew Security Operations Analyst Associate (< 10/28/2024) - Completed 8/8/2024
  • Renew Cybersecurity Architect Expert (< 11/21/2024) - Completed 8/9/2024
  • Give gRPC + .NET: Lessons from the Trenches talk to NHDNUG in September 2024
  • Attend HDNUG meetings
  • Attend NHDNUG meetings
  • Attend HAUG meetings
  • Attend Clear Measure Architect Forums
  • brainstorm ideas for another talk to give in 2025 (maybe with more of a Azure-cloud flavor?)

And then the areas that still need more clarification:

  • Decide on a cert path to go down
    • GitHub - Actions, Advanced Security, Administration
    • Azure AI - AI-900, AI-102
    • AWS - AI Practitioner, Solutions Architect Associate, Developer, DevOps Engineer, Solutions Architect Professional

That's all I've got so far. I still need to have some conversations with people at work to figure out what I need to prioritize with respect to my employer. I'll provide an update when I have one.

Category: .NET, Azure, Career, Certifications | Comments Off on H2 2024 Update
August 9

Moq phoning home with/to SponsorLink? What to do about it.

Hopefully you've heard about the latest changes to a popular Open Source Software Project used by the .NET ecosystem. No? Well here is some reading material:

This issue in Moq's GitHub repo has more information as well.

https://github.com/moq/moq/issues/1372

Ok...so how do you handle this? I'm sure most of us out there in the world have other projects in flight and don't want to end up accidently pulling in this problematic NuGet package. Most clients/project managers/projects don't respond well to having to stop active development on a dime just to refactor a bunch of test code. So what do we do? Microsoft has us covered in this scenario. In this case we only want to allow Moq v4.18.4. We will come back later on when we have time to refactor/replace Moq. Let's consult the docs shall we?

In the beginning we see that we have Moq v4.18.4 installed and there is an update to v4.20.2.

We need to go through our solution and replace each PackageReference for Moq in each project that uses it. So we're going from this:

<PackageReference Include="Moq" Version="4.18.4" />

to this:

<PackageReference Include="Moq" Version="[4.18.4]" />
After changing all the PackageReferences for Moq in the solution, you'll notice that the package is no longer showing up in the Updates tab.

Is this foolproof? No, you can still update the Moq package. By removing the option in the Updates tab, you will have removed the temptation to update it.

Category: .NET, unit testing | Comments Off on Moq phoning home with/to SponsorLink? What to do about it.
November 18

When I Get a New Job, I’m Updating My Licenses

If you've been paying attention to LinkedIn, you've probably noticed that I am looking for a new job. If you are hiring and you would like to talk, shoot me an email.

When I get this new job and I have some income, I'm going to update my licenses for the following Linqpad and NCrunch.

LINQPad

I love this app. I first used this back during my tenure at Logica when we were working with StreamInsight. It's a good app to use to be able to quickly test out chunks of C#, VB.NET, and F# code. The app is extensible so you can download other drivers that let you hook up to other SQL/NoSQL databases. Really cool for learning/prototyping code. Check out the website for more information: https://www.linqpad.net.

NCrunch

NCrunch is an automated concurrent testing for Visual Studio. What that means in English is that you can configure it to run your unit tests as you are typing your code. You can configure it to run the unit tests that are impacted by the changes you make so you aren't running the entire suite of unit tests. This is very handy, especially if you have good code coverage. It even collects code coverage numbers and performance metrics. More information can be found on the website: https://www.ncrunch.net.

Category: .NET, Reactive Extensions, Tools, unit testing | Comments Off on When I Get a New Job, I’m Updating My Licenses
April 26

Another Update to My High Score

I have a job change coming up and I thought it would be a good idea to do an update to New High Score (update)! and New High Score! posts. Since those 2 posts I've had a couple work items that required updates to that monster class. Here is what the metrics look like now.

Maintainability IndexCyclomatic ComplexityDepth of InheritanceClass CouplingLines of Source Code
5094872102660516
Code metrics covering the class in aggregate.
Maintainability IndexCyclomatic ComplexityDepth of InheritanceClass CouplingLines of Source Code
512237822
0215481180
0284221237
Code metrics covering the 3 longest methods in the class.

I'm a big believer in leaving a code base better than you found it. I had a couple work items that required me to go in and refactor this monster class a bit. As a developer I feel a lot more comfortable making these kinds of changes (i.e. Strangler Fig design pattern) when I have the proper tools such as JetBrains ReSharper. The payoff for this change was that it allowed me to write unit tests to cover the part of the class that I needed to complete the work items. When you have a code base that is this convoluted, it's nice to have a series of unit tests to proof that the changes you made to the code base work. This came in handy in a discussion with a QA guy. I was able to walk him through each one of the tests I had written. Turns out the issue was in a basic understanding of the work item the way it was written. However, my code worked correctly in the end and I could prove it.

I wasn't the only one working on this code. There were at least 2 or 3 teams making changes to this code.

Category: .NET, C#, Design Patterns | Comments Off on Another Update to My High Score
August 13

What Is Your Philosophy on Unit Testing?

The purpose behind unit testing is to help ensure the code you have written performs as expected. The running of unit tests can be more effective when it is automated on a developers machine and as part of your CI/CD pipeline. Automated unit tests can also take the load off of limited QA resources by letting them focus on higher level testing (i.e. integration testing, regression testing, and acceptance testing).

Nowadays, when I'm handed a new code base to work on, I treat it as suspect. I have no idea if the code base will even run. If it does run, how do I know that it runs correctly? Unit tests will help me determine what shape the code base is in.

In general, I follow the red-green-refactor approach when writing unit tests. I write my tests in this order typically:

  1. Cover the happy paths through the code you are testing.
  2. Cover the upper and lower ends of inputs to your code.
  3. Cover any know edge cases known at the time.
  4. As a follow on to this process, if and when bugs are reported against code that I'm maintaining, I can then write a unit test to reproduce the bug and it will also tell me when it is fixed satisfactorily.

What unit testing framework do you like the best and why?


xUnit.net hands down. xUnit.net requires fewer attributes to set your tests up (i.e. Fact and Theory). Another feature I think is neat is using a class's constructor (w/o any attributes) as a setup method for your unit tests. This is great because it follows the way classes work naturally.

What other unit testing frameworks have you used?


I have used NUnit and Visual Studio Unit Testing Framework (aka MSTest). I prefer NUnit to MSTest though.

What is the right amount of code coverage?


If I have to give a number, I would say between 70% and 80%. I would have a higher number for code that is heavily used and relied upon by other parts of the solution.

How would you go about writing unit tests?


I like using TDD on more complicated/intricate code because it let's you work your way through the code step by step. I prefer a Given-When-Then (GWT) approach over Arrange-Act-Assert (AAA). The GWT approach allows you to write more human-readable unit tests. The AAA approach works, but is not as easily readable. In general, writing clear and understandable code is the goal. Here are a couple links that talk about GWT vs AAA:

Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. Code for readability.

John Woods

What other tools can be used to improve unit tests?

What are some pitfalls of unit testing?

  • Testing the wrong thing - Software development teams need to make sure they are writing unit tests to cover code that they have written.
  • Getting lost in setup hell - This occurs when the setup for your unit tests starts to become tedious and takes a lot of time to get right. Using a GWT style seems to help with this.
  • "I'll just comment out this unit test to get things working so I can check in my changes." - I think this is just developers being lazy and apathetic about the changes being made to the solution. It is not a behavior I would encourage on my software development team.

So that's my current philosophy on unit testing. What do you think? Am I wrong? Did I miss something? Feel free to post a comment or send me an email.

Thanks to Risa for the good question!

Category: .NET, C#, interview questions, unit testing | Comments Off on What Is Your Philosophy on Unit Testing?