A Journey From Iterators to Paging – Dev Leader Weekly 24

Happy holidays folks!

New Year’s is RIGHT around the corner, so I thank you for spending time with me in my newsletter during these holidays. I wish you and your loved ones a tremendous 2024 and I hope that you have many things to be proud of from 2023. For me, 2023 has been filled with a lot of learning on this content creation journey.

And to celebrate over the holidays, it looks like Nick Chapsas is running a 30% discount on Dometrain, which means you can get my course on refactoring for 30% off using code:
HOLIDAYS23

Let’s go!


A quick reminder that you can refer your friends to sign up for my newsletter! You can get free membership access for a few months to my site to access the newsletter archive and my Behind The Screen weekly vlogs that I do.


What’s In This Issue


Exclusive Article: From Iterators To Paging in – What You Need To Know

If you read last week’s newsletter, you’ll recall that I started to explain some of the history for me moving a lot of logic over to using iterators and IEnumerable in C#. But that’s not where the journey ends! It was a tiring journey, and ultimately I have moved on (mostly) from using iterators in my code for paging implementations instead.


Quote of the Week

This quote is very fitting for the video that was released on Friday!

One of the most important skills that we can work on as Software Engineers is to take complex problems and break them into smaller ones. We’re constantly faced with challenges that are large and complex.

Think about it! Think of some of the software systems that you interact with regularly:

  • Google — How can we, at lightning speed, get users relevant search results for anything on the internet?
  • Microsoft — How can we enable users around the world to have regularly updated and available Office products (this is what I do for work!)
  • Amazon — How can we have a marketplace for consumers to have nearly anything shipped to their door as fast as possible? Sometimes within hours!
  • Netflix — How can we offer a flawless streaming service to users across the planet?
  • Twitter — How can we destroy a perfectly good platform (Just kidding… too soon?)

None of these are simple challenges, and the only way to go about solving them is to break them down into more tangible, smaller problems. While your day-to-day software engineering may not be dealing with challenges on such an extreme scale, it’s still likely that you have complex problems to break down!

Of course, this is going to look different for everyone in terms of what’s considered “complex” and how much something needs to be decomposed before it’s actionable. If you’re a junior software engineer, you might find that starting in a new area of code is completely overwhelming. How you approach breaking down the codebase into smaller more manageable pieces may look different than how a senior engineer does it.

Similarly, how you approach trying to design a new system from scratch given a problem to solve and some constraints may look different depending on your experience level. But in either of these examples, the common aspect is that to make progress on the bigger, more complex problem… we need to decompose it into smaller ones.

Practice this regularly, and when you’re stuck, try asking yourself if there’s a smaller part that you can solve for first.


More articles this week given that I had more downtime! I hope you enjoy!

APIs That Don’t SUCK – Collections & IEnumerables In DotNet

YouTube player

This video continues on the series from last week and right into this week’s exclusive article and early access video. My goal in this video is to give you some thoughts about what types of collection (or similar) interfaces you’re using in your API design.

WARNING: 2 Killer C# Iterator Bugs (And How To Prevent Them)

YouTube player

Building on the previously mentioned video and continuing in the series, this video helps to elaborate some REAL problems with iterators that I’ve had to deal with many times over. Iterators aren’t “evil” but they can be tricky to get right!

7 Tips To Navigate A COMPLETELY New Codebase

YouTube player

This video is a companion video to an article I have listed below. In this video, I explain 7 tips & strategies for how you can navigate a codebase that you’re new to. This is helpful when trying to optimize your ramp up time in new projects!

Why Test Coverage Can Be Misleading – How To Avoid False Confidence

Why Test Coverage Can Be Misleading - How To Avoid False Confidence

I wrote this article to talk about test coverage and why blindly chasing test coverage isn’t the best approach. Yes, test coverage metrics can be helpful for giving us an idea how much of our codebase has test support… But it does not tell us how valuable those tests are. More simply, it’s a helpful indicator but it’s nowhere near a perfect measure.

Examples Of The Factory Pattern In C# – A Simple Beginner’s Guide

Examples Of The Factory Pattern In C# - A Simple Beginner's Guide

Design patterns are everywhere! This article aims to explain one of the most basic design patterns, the factory pattern, with C# examples.

When Should Code Be Refactored? What You Need To Know

When Should Code Be Refactored? What You Need To Know

What types of things should we be considering when refactoring code? How do we know when code is ready or eligible for refactoring? And the more important question: should it be a priority just because it’s a candidate for it? Find out!

How to Understand a New Codebase – Tips and Tricks for Tackling Complex Code

How to Understand a New Codebase - Tips and Tricks for Tackling Complex Code

This article was inspired by a question I received on social media — Which is a friendly reminder that you can always message me and ask for content! If you’re a more junior developer or you’re someone that struggles with getting into a new codebase that you’re unfamiliar with, this article is for you.


Learning Resources

C# 12 and .NET 8 – Modern Cross-Platform Development Fundamentals

Full transparency: I was sent a copy of this book and asked to give my opinion about it, and I opted to do so. After last week’s newsletter, Packt has offered to provide books that I can give away to subscribers! This is the extent of my relationship with Packt – They are not paying me for my opinion but I asked them to explore this giveaway prize opportunity after last week and they were interested.

GIVEAWAY CONTEST

If you’re reading this email and you were subscribed before 2023-12-30… You’re eligible for the draw! I’ll be contacting the winner via email and giving them a week to respond. If I don’t hear back from them I’ll select another winner that was subscribed before this period.

The previous winner from last week’s draw decided not to follow through. I’ll be picking TWO winners this week!

Thoughts on the Book

I’ve had many people ask me, especially when starting, what books they recommend to read as a developer. I never have a good answer though, and that’s because I don’t read books. And no — I am not against reading books. I find that I learn much better by doing and I get bored from reading instead of creating. I’ve always been this way.

When this book showed up at my house my jaw hit the ground. It’s 800 pages. It’s enormous. I can’t imagine anyone reading this front to back, but that’s NOT a criticism of this book. I think people could get a ton of value out of this by treating it like a mini encyclopedia. There are hundreds of pages addressing the language features with examples. It’s nuts!

Because I spend much of my outside-of-work time working on my nutrition platform and then trying to publish more “evergreen” content, I often miss out on some of the newer language features. I’ll be certain to give this a scan specifically on those sections so I can catch up.

If you’re the kind of person who learns from books — especially if you’re new to C# and want to have what feels like every possible language feature covered — I’d definitely recommend picking it up. Please remember that I make nothing from this (there’s no affiliate link or anything), I’m just trying to be helpful if this is a way that you find works well for you to learn!


Check Out My Course!

Remember to use code HOLIDAYS23 for a 30% discount!

Courses - Dometrain - Refactoring for csharp devs - wide

Last Week’s Coding Challenge

Did you try out last week’s coding challenge? This was an expense tracker written in a C# console application! Working in console applications can remove some constraints like GUI design and how to make things work on the web. This allows us to focus on different aspects of developing software, so it’s a different way to challenge ourselves!


This Week’s Coding Challenge

Weekly Coding Challenge: Build a Miniature Code Editor in C#

Challenge Overview: For this week’s challenge, let’s create a simple, text-based code editor in C#. This mini editor will run in the console and allow users to write, edit, and save text files, focusing mainly on simplicity and basic functionality.

Problem Statement:

  1. Basic Text Editing:
    • Implement features to allow users to input and edit text.
    • Include functionalities like adding new lines, backspacing, and navigating through the text.
  2. File Operations:
    • Enable users to open a text file, edit it, and save changes.
    • Allow creating a new file and saving it to a specified path.
  3. User Interface:
    • Design a console-based interface where users can type and edit text.
    • Implement simple commands or keyboard shortcuts for saving files, opening files, and other actions.
  4. Error Handling and Feedback:
    • Provide clear feedback for actions (e.g., file saved, file opened) and handle potential errors gracefully (e.g., file not found, unable to save file).

Example:

Mini Code Editor
----------------
File: [None]

Type your text below. Press F1 to save, F2 to open a file, and ESC to exit.

[User's text appears here...]

----------------
Command: [User's input command]

And some example code that you could start with:

public class MiniCodeEditor
{
    public void Start()
    {
        // Main loop for the editor
    }

    // Additional methods for file operations and text editing
}

class Program
{
    static void Main(string[] args)
    {
        MiniCodeEditor editor = new MiniCodeEditor();
        editor.Start();
    }
}

Tips:

  • Start with setting up the basic text input and display system.
  • For file operations, explore System.IO namespace for reading and writing files.
  • Think about how to capture and handle special keystrokes for commands within the console.
  • Keep the user interface clean and intuitive, with clear instructions for the user.

This challenge is a fantastic opportunity to dive into more complex console input/output handling in C#, explore file operations, and create something uniquely functional. I might try this one myself because I think changing the text displayed in the console is a very interesting challenge!


As always, thanks so much for your support! I hope you enjoyed this issue, and I’ll see you next week.

​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.