Dev Leader Weekly Issue 6

Hey there!

Welcome to Dev Leader Weekly, your dose of software engineering and C# goodness! In this newsletter, we’ll explore thought-provoking ideas, byte-sized code examples, and highlight some interesting content from the week to help you excel as a software engineer.

Some housekeeping information… I will be starting to build out a membership portion of my website! This will be a paid-for section where I’ll start adding some premium perks. To start, my Supporter-level perk will include:

  • My newsletter archive so if you’ve recently signed up you can get the full list!
  • My private behind-the-scenes vlogging Patreon content will be migrated over (I bet you didn’t even know I had Patreon, did you!)
  • … And early access to the other features I plan to offer (which will include things like courses and mentorship opportunities down the road)

I’ll keep you posted via this newsletter so… stay tuned!

Now, let’s dive in!


Thought-Provoking Quote of the Week:

Every week a little bit of insight from someone! Whether it’s me or something else I’ve come across to share with you, I hope you find it insightful:

“Code is like humor. When you have to explain it, it’s bad.” – Cory House.

This witty observation underscores the importance of writing clear, self-documenting code. If you need to extensively comment on what a piece of code is doing, it might be time to refactor!

I actually shared a LinkedIn post related to this earlier in the week:

(Don’t see the embed? Sorry! Not all browsers or email readers may render the element above properly)

And there were some interesting comments! So the intention here is not to imply that it’s a universal truth if you write a comment suddenly your code is awful. That’s extreme. But the intention is to remind people that your code should ideally be self-documenting as much as possible. If you find you need comments to explain the code, perhaps it can be written more clearly.


Featured Content:

This week was probably a record-breaker for me! 3 blog posts and 3 videos… But I haven’t shared the third blog post out on social media yet, so you might not have seen it! I’ll include it at the end!

How Baking Cakes Can Improve Your Software Development

YouTube player

This video was created in response to follow-up questions on my vertical slice & plugin video. The focus here was to introduce viewers to vertical slicing since the concept is actually new for many folks! As a way of delivering features, if you think about working on end-to-end functionality instead of building layers and focusing on architecture specifically, you can generally be quite agile.

How You Can Master Vertical Slices Like The Best Developers

YouTube player

This was a follow-up video to the one I just mentioned! Once the basics of vertical slices are out of the way, how do you go about practically implementing them in your software development process? This video covers that in more detail so you can get started putting it into practice.

Balancing Learning with Practical Application in Programming: A Deep Dive

Balancing Learning With Practical Application

This blog post is a companion article to some of the videos I put out in the previous week regarding building projects. The second video actually talks about some simple games you can make! The purpose of those videos and this article is to remind beginner software developers:

  • Practicing what you are learning by actually coding things is extremely helpful for reinforcing your learning
  • You can take ideas for things to build and decompose them into smaller pieces so that you can make progress on them

Dependency Injection: How to Start with Autofac the Easy Way

Dependency Injection and Autofac

I have used Autofac for setting up my dependencies now for ages. I can’t live without it! If you are new to dependency injection and inversion of control principles, this article should set you off in the right direction for using Autofac!

Make Your Art UNIQUE – Build Your Own ASCII Art Generator in #dotnet

YouTube player

How’s that for a thumbnail?! Got your attention, right? Well, if you want to make your very own ASCII art generator, check it out! All of the source code is available.

But wait… It’s a video, so that’s kind of crappy for pausing and trying to copy code. I get it, don’t worry. That’s why I also put together this companion blog that I haven’t shared out yet! So unless you’re monitoring my website already, you’re the first group to see this blog post on ASCII art generation!


C# Snippet of the Week:

// Using local functions in C# for
// improved encapsulation
public int ComputeValue(int x)
{
    int MultiplyByTwo(int val)
    {
        return val * 2;
    }
​
    return MultiplyByTwo(x);
}

Local functions in C# allow you to define methods within another method, enhancing encapsulation and keeping related logic tightly bound.

But what are your thoughts on this? Why not just make a private function outside of the scope of the method?

At first, I thought this local function concept was kind of silly or useless. But I realized that do semi-regularly write anonymous delegates that I will store in an Action<T> or Func<T>, and I realized that it’s the exact same idea… but now it’s a first-class feature. I’ve started using these a little bit, but still sparingly.


Insightful Tip:

Choosing the Right Collection Type in C#

In C#, the .NET Framework provides many collection types to handle groups of objects. Your choice of collection can have significant impacts on performance, readability, and functionality. Here’s a brief guide to help:

  1. List<T>: This is your go-to for a general-purpose, dynamically resizing collection. It can mainly be used like an array but specifically when you need dynamic sizing. Otherwise… stick to your friendly array class 🙂
  2. Dictionary<TKey, TValue>: When you need fast access by a unique key, Dictionary is the ideal choice. However, remember that it uses more memory because it stores both key-value pairs.
  3. HashSet<T>: If you’re looking for a collection that prevents duplicates and don’t need key-value pairs, HashSet is the way to go. Remember, there’s no looking up a value for a specified key (that would be the dictionary class)
  4. Queue<T> and Stack<T>: These are perfect for situations where you need first-in-first-out (FIFO) or last-in-first-out (LIFO) behaviors, respectively. Many algorithms use stacks and queues as their core, so these can be interesting choices!

Remember, the above is just a start. There are other specialized collections in the .NET Framework, like SortedSet, ConcurrentDictionary, and ObservableCollection. And that’s a good opportunity for a reminder: consider thread safety with your collections because enumeration and modification of these basic collection types don’t work well. Always consider the specific needs of your use case and the operations you’ll be performing most frequently when selecting a collection type!


Learning Resource AND Community Spotlight:

A double-whammy this week goes out to Jordan Cutler!​

I wanted to mention Jordan here because a lot of the other spotlights are around people more specifically sharing code or programming knowledge. These are great, of course, and I know you and I appreciate them all!

Jordan, however, touches on more than that. As an engineering manager, I really appreciate this kind of perspective being shared – All the other stuff in software engineering that isn’t code. Read through some of Jordan’s posts and you’ll see exactly what I mean.

As for learning resources? Well, you’re reading a newsletter, and here’s a WHOLE PILE of additional ones shared by Jordan:

(Don’t see the embed? Sorry! Not all browsers or email readers may render the element above properly)


Last Week’s Question:

Last week we looked at how we could replace vowels in a string with the next vowel. So given AEIOU, A would map to E, E would map to I, I to O, etc…

I wanted to share a functional submission that was sent in by screenshot:

This solution uses a dictionary of chars for upper and lower case values, and the values are the next value corresponding to the key! In this case, a StringBuilder with an initial capacity was set (since we know the size) and then each character is appended unless it’s a vowel (then the next vowel is appended).

Awesome work! Are there any improvements that could be made with spans or character arrays? Thanks for the submission!


Quiz Time: In C#, which keyword is used to prevent a class from being inherited by other classes?

  • a) final
  • b) sealed
  • c) protected
  • d) static

Reply with your answer, and find out the correct one in our next issue!

Final Thoughts:

That’s it for this week’s edition of Dev Leader Weekly! I hope you found something valuable in our short time together. Remember, consistency is key to success in software engineering, so keep learning, keep coding, and never stop improving.

If you have any questions or topics you’d like me to cover, feel free to reply to this email or reach out to me on social media. I strive for all of my content to be as focused on topics that YOU want to hear. My goal is to help you become a better software engineer, and that means addressing your curiosities and questions.

Until next time, happy coding!

Nick “Dev Leader” Cosentino
[email protected]

Socials:
Blog
Dev Leader YouTube
Follow on LinkedIn
Dev Leader Instagram

P.S. If you enjoyed this newsletter, consider sharing it with your fellow developers. Let’s grow our community together!

author avatar
Nick Cosentino Principal Software Engineering Manager
Principal Software Engineering Manager at Microsoft. Views are my own.