Introduction
It’s a wonderful time to be a developer with rich tools, documentation, and artificial intelligence. Still, at least for now and the foreseeable future, developers must learn to write code, as artificial intelligence tools are not perfect and may produce code that is difficult to integrate into an existing code base.
For developers just starting out, they need to learn the basics, then OOP and database work.
For experienced developers, the next step is to hone their skills to get and keep a full-time job. For instance, C# .NET Core has a new feature; take time to learn it, even if there is no immediate use for it. Another path is to check out questions in developer forums, analyze all aspects of a question, and what can be learned or avoided.
The following applies to developers using Microsoft Visual Studio, C#, and .NET 8 or higher.
Visual Studio solution for learning
Create a Visual Studio solution for learning and use solution folders to categorize topics.
When code appears useful across multiple projects, place it in a class project (note the folder for class projects in the screenshot below).
Starter learning ideas
Request for a login for a console project
First, check out the following thread in its entirety, which is what AI might form a response from. Now let's explore a better way using Spectre.Console NuGet package.
Spectre.Console TextPrompt prompts users to enter text input with validation, default values, and secret input masking.
- Will be used to ensure a non-empty string is returned
- The password text is masked
- Both username and password use the same colors
- Has sufficient validation for testing purposes, hard-coded
using Spectre.Console;
using SpectreLoginSample.Classes.Core;
namespace SpectreLoginSample.Classes;
internal class Prompts
{
public static string PromptStyleColor { get; set; } = "cyan";
public static string PromptColor { get; set; } = "bold";
public static bool TryLogin(int maxAttempts = 3)
{
for (int attempt = 1; attempt <= maxAttempts; attempt++)
{
var username = GetUserName(allowEmpty: false);
var password = GetPassword();
if (ValidateCredentials(username, password))
{
AnsiConsole.MarkupLine("[green]Login successful[/]");
return true;
}
/*================================================================
* The text displays remaining attempts which is optional.
* Showing remaining attempts can be a helpful for testing.
================================================================*/
if (attempt < maxAttempts)
{
AnsiConsole.MarkupLine($"[red]Invalid credentials[/] - Attempts remaining: {maxAttempts - attempt} press [bold]ENTER[/] to retry");
SpectreConsoleHelpers.ContinuePrompt();
}
else
{
AnsiConsole.MarkupLine("[red]Maximum attempts reached. Access denied.[/] press [bold]ENTER[/] to exit");
SpectreConsoleHelpers.ContinuePrompt();
}
}
return false;
}
public static bool ValidateCredentials(string username, string password)
{
return username == "admin" && password == "password";
}
public static string GetUserName(bool allowEmpty)
{
return allowEmpty
? AnsiConsole.Prompt(
new TextPrompt<string>($"[{PromptColor}]User name[/]")
.PromptStyle(PromptStyleColor)
.AllowEmpty())
: AnsiConsole.Prompt(
new TextPrompt<string>($"[{PromptColor}]User name[/]:")
.PromptStyle(PromptStyleColor));
}
public static string GetPassword() =>
AnsiConsole.Prompt(
new TextPrompt<string>($"[{PromptColor}]Password[/]:")
.PromptStyle("grey50")
.Secret()
.DefaultValueStyle(new Style(Color.Aqua)));
}
This is considered a good learning experience, as once the login code is finished, there is more to explore in this library. Where this library is good for: dotnet tools and console project utilities.
File Globbing to the rescue
File globbing is a topic every developer needs to learn. A glob is a term used to define patterns for matching file and directory names based on wildcards. Globbing is the act of defining one or more glob patterns and yielding files from either inclusive or exclusive matches.
Imagine a developer uses OneDrive for backups, and once the backup completes, all files are removed from the local drive. So the developer reverts the backup and learns that some files have copies. Rather than manually deleting the copies (in this case, 5,000+ copies), after learning about file globbing, the developer can write code to remove them in a simple console project.
Code to create a list of copies.
💡 AddExcludePatterns excludes folders that may need special permissions to read.
public static async Task<List<FileMatchItem>> GetDuplicatesTask(string parentFolder )
{
List<FileMatchItem> list = [];
Matcher matcher = new();
matcher.AddIncludePatterns([
"**/* - Copy .*",
"**/* - Copy (*.*"
]);
matcher.AddExcludePatterns([
"**/My Music/**",
"**/My Pictures/**",
"**/My Videos/**"
]);
await Task.Run(() =>
{
foreach (string file in matcher.GetResultsInFullPath(parentFolder))
{
list.Add(new FileMatchItem(file));
}
});
await File.WriteAllLinesAsync($"Duplicates.txt",
list.Select(item => item.ToString()));
return list;
}
Code to remove files
public static async Task ProcessOneDriveDuplicates()
{
var folder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
var list = await Globbing.GetDuplicatesTask(folder);
if (list.Count >0)
{
AnsiConsole.MarkupLine($"[bold green]Found {list.Count} duplicate files.[/]");
}else
{
AnsiConsole.MarkupLine($"[bold green]No duplicate files found in {folder}.[/]");
return;
}
foreach (var (index, item) in list.Index())
{
try
{
if (File.Exists(item.FullName))
{
File.Delete(item.FullName);
}
else
{
AnsiConsole.MarkupLine($"[yellow bold]{item.FullName}[/]");
}
}
catch (Exception e)
{
AnsiConsole.MarkupLine($"[red bold]Failed to delete " +
$"{index} {item.FullName}[/]");
}
}
}
Summary
No matter if a developer vibes codes, uses artificial intelligence for what they get stuck on or doesn’t use AI try and learn something new at least once a week. Karen tries to learn something new several times a week.


Top comments (0)