Author Archives: cjsteinbrecher

Exploring the Singleton Design Pattern

As we start to learn about more design patterns and their implementations in class, I wonder more and more about their application in the real world, as well as how they are perceived by modern developers. So far, for each design pattern we have learned, a relatively good job has been done in showing the advantages and pitfalls associated with them.

I became particularly interested in the Singleton pattern after finding the blog post: “Understanding What Singleton Pattern Costs You.” found here: https://blog.ndepend.com/singleton-pattern-costs/. There are also other sources I found that seemed to really dislike the Singleton design pattern, and I wanted to delve deeper into why that is.

In our in-class example with ducks, the Singleton solution seemed to make some sense for what we were trying to do. Rather than creating a new object every time we wanted our ducks to fly, we could have a single object and change its instance when needed. Because of the limited scope of what we were doing with the singleton pattern, we didn’t get a clear example of this practice potentially going south.

One way this can cause problems is that it can obfuscate code. Because a singleton is now essentially “global” and can be called everywhere, certain methods can do things that are part of this singleton that the method itself might not even indicate that it does. An example that the author of the blog provides is this:

In this example, the method is named BuildSimpleOrder, however, this method also logs the order. This makes it so you can make no assumptions about what your methods do, as many of them may have hidden behaviors. This has lead to a phrase that I have seen around tech blogs saying “Singletons are liars.”

This also causes problems in unit testing for similar reasons. Because you can use these singletons essentially globally, it can make it a lot harder to track problems in individual classes. This leads to high coupling. This also breaks the single responsibility principle – something that has been repeated in class a few times.

Learning about the different design approaches that we can take, with implementations evolving as the requirements change has been a good learning experience. It is becoming pretty clear that there is no “one size fits all” design and there can be advantages and pitfalls of each. However, I did want to do this deep dive on singleton, because I had seen it garner almost nothing but flak.

From the blog CS@Worcester – Alan Birdgulch's Blog by cjsteinbrecher and used with permission of the author. All other rights reserved by the author.

The Importance of Writing Well

Today I stumbled upon a blog post titled: Undervalued Software Engineering Skills: Writing Well by Gergely Orosz. That can be found here: https://blog.pragmaticengineer.com/on-writing-well/. I found this linked tangentially where the author was mentioning that in order to create clear diagrams that everyone can follow, honing your writing skills in general is one aspect of accomplishing that.

In this blog post, the author talks about how writing and communicating is a very under-appreciated skill that a software developer can have. I think that software devs have this stigma that they are not great communicators and maybe not particularly good with words, so this may be a surprise to some. However, writing well is the first step in creating diagrams that can be followed and amended by a team that is working on a project.

As someone that has worked in the corporate world for a long time with massive amounts of cross-communication between different departments, I can tell you that writing is something that people in every profession could stand to do better. Sometimes something as simple as communicating your thoughts precisely, concisely, and interestingly can be enough to get you noticed, even in a large corporate environment.

The author mentions that for a software dev, writing can be a tool to “influence engineers and other teams outside of your immediate peers.” He also frequently mentions durability, and how the better you are at writing, the more “durable” your decisions, trade-offs, and ideas will be. This will not only help your own career, but will help your team manager their project better.

I am pretty passionate about writing, and I think that in any career, having a grasp on good writing practices can make a huge difference for how you are perceived by your peers, and for a skill that is often seen as ancillary, can be a real game-changer.

From the blog CS@Worcester – Alan Birdgulch's Blog by cjsteinbrecher and used with permission of the author. All other rights reserved by the author.

Introduction

Hello my dear readers. This is my first attempt at blogging since I was a teenager. I have created this blog for CS-343 at Worcester State, but hope to continue to update it beyond my time with the class. I am a 29 year old student enrolled full-time at Worcester State, and feel that I have a unique perspective on the college experience. I hope to share topics related to this course, to the field of computer science in general, and maybe some insight to my perspective as an adult college student trying to transition to a new career path.

From the blog CS@Worcester – Alan Birdgulch's Blog by cjsteinbrecher and used with permission of the author. All other rights reserved by the author.