top of page

Multitasking is a myth!
At best, you're simply context-switching rapidly.

Development Principles:

One Thing at A Time

One Thing At a Time

Humans are incapable of true multitasking. Instead, we switch rapidly between tasks, putting the task being switched from on a shelf, of sorts. This process is called Context (or Task) Switching.

Context Switching

Context Switching is the process of moving your focus from one task to another and back. Each time you switch context, there is a cost of mental energy. Switching between tasks often leads to slower completion of both tasks as well as increased errors.
While context switching cannot be avoided, as there are often interruptions in our day that require us to switch from what we’re doing to address something else, when possible, we should avoid bouncing
between tasks.

Do A Single Thing

Whether we’re talking about working on a development Task or a User Story, developers should work on a single item and see it through to completion/hand-off before picking up another item of work.
If you find yourself blocked and pick up new work, always be prepared to shelve that work once the blocking issue is resolved. Your first priority is the work you started first.
By following this principle, developers can focus solely on completing the task/story and avoid context-switching.
A team should focus on a Feature during a sprint.
A developer (or sub-group of developers) should focus on a single story at a time.
A developer should focus on a single task at a time.

Single Responsibility

The idea of doing a single thing applies to code as well. A class is easier to maintain when it has a singular purpose and code is easier to diagnose when each component has only one purpose.
A method is easier to maintain when it has a singular purpose.

Multi-responsibility Method

This method has the responsibility of creating the objects it depends on as well as returning a PackageInfo object.

private async Task<PackageInfo> GetMaxVersionValuesAsync(PackageInfo currentPackageInfo)
{
     var nugetPackageInfo = new PackageInfo(currentPackageInfo.PackageName,            currentPackageInfo.Version.ToString(), currentPackageInfo.Source);
      ILogger logger = NullLogger.Instance;
      CancellationToken cancellationToken = CancellationToken.None;
      SourceCacheContext cache = new();
      SourceRepository repository = Repository.Factory.GetCoreV3("https://api.nuget.org/v3/index.json");
       FindPackageByIdResource resource = await repository.GetResourceAsync<FindPackageByIdResource>();

 
       var packageVersions = await resource.GetAllVersionsAsync(currentPackageInfo.PackageName, cache, logger, cancellationToken);
 
        nugetPackageInfo.Version = packageVersions.OrderByDescending(v => HygieneVersion(v.Version.ToString())).FirstOrDefault().Version;
 
      return nugetPackageInfo;
}

Single-responsibility Method

This is a refactored version of the same method. In this case, all dependencies of the method are instance methods of the parent class. The method now returns a Version object which brings alignment between the name and the output. Construction of the dependencies has been moved to the class constructor.

public async Task<Version> GetMaxVersionValueAsync(PackageInfo currentPackageInfo)
{
     var packageVersions = await this.resource.GetAllVersionsAsync(currentPackageInfo.PackageName, this.cache, this.logger, this.cancellationToken);
     var maxVersionPackage = packageVersions.OrderByDescending(v => HygieneVersion(v.Version.ToString())).FirstOrDefault();
     return maxVersionPackage != null ? maxVersionPackage.Version : new Version(DEFAULT_VERSION_NUMBER);
}

Email the Coach

Thanks! We'll get back to you soon!

© Sean Cooper 2025
bottom of page