Author Archives: dylanbrowncs

Strategy Pattern Design Article

This article shows the “intent” of the strategy design pattern and how to successfully use it when refactoring code which is our current class topic. According to the article the strategy pattern (a behavioral design pattern in CS helps define a group of algorithms in separate classes which will effectively use each other’s objects.

One of the larger issues addressed by using the strategy pattern helps keep the main class from growing into a more complex mess. The strategy pattern allows for a developer to take/extract a class that has different functions and funnel them into a new class which is what this pattern refers to as a strategy.

Interfaces are commonly used with the strategy pattern in order to communicate with the other “strategies” that you previously extracted from the main class. The use of interfaces in the strategy pattern also allows your code to switch between algorithms at run time by using sub objects that perform their own tasks.

I chose this article as I feel it gives readers like myself a good general understanding of how to use and implement the strategy pattern. The article effectively shows you when you should or should not use the strategy pattern along with the pros and cons of using it. Similarities between the strategy pattern and other patterns it also outlined in the article which helps you tell the patterns apart and when you should use one pattern over another.

This article from refactoring guru has helped me to better understand the strategy pattern as a whole and helped me gain a somewhat smaller but still important understanding of some aspects of other design patterns (for example command and state). There are also examples of the strategy pattern being used in different coding languages found under the “Relations with Other Patterns” section.  I plan to use the information in this article to help me understand the Strategy pattern more in current and future assignments as well as in my professional career whenever I may need to refactor code through the different design patterns.

Overall I believe the general understanding of the strategy pattern gained from this article can help myself and any other student that may be having trouble with the topic or even someone who is just curious and would like to learn more about design patterns as their are articles on the other design patterns on the same website that can be accessed easily through links near the end of the page.

From the blog CS@Worcester – Dylan Brown Computer Science by dylanbrowncs and used with permission of the author. All other rights reserved by the author.

Object Oriented Programming Podcast

This podcast directly relates to our class as its main topic is Object Oriented Programming. The speaker starts off explaining that Object orientated programs are made of objects which interact with each other. These Programs are class based and in object oriented programming the objects are instances of the classes and their types are determined by said classes. Many different coding languages are used in object oriented programming such as Java, and Python because they support object programming which the speaker says is in combination with procedural programming. Most languages that support object programming are multi paradigm and contain variables which store information in a lower amount of data types for example integers which can include strings or lists. Methods used in object programming take inputs and generate outputs based on the data used which can be attributed to loops and conditionals. In object programming you can group methods into files (or modules) to help keep your program organized. The files or modules that you use will not conflict with methods or variables in a different file that may share the same name. The languages that support object programming are known for using inheritance in order to reuse previous code (classes). Classes contain the methods and data used in the code and they also contain class functions including the classes objects and instances. According to the podcasts author objects can at times correspond to things in the real world, the example he uses is when a graphics program uses shapes like circles or squares or when a shopping website uses a “shopping cart”. While some objects represent things relating to the real world other objects represent things that are more abstract like a file or a translation of some sort. Object programming is based on the concept of objects and the data they contain whether it be methods, data fields, etc. If you use an object to organize unlike classes that is not object oriented programming, you are meant to use objects to organize data that has similarities. An object being an instance of a class will contain methods which contain variables, the variables in objects still belong to the class and can also be called class variables. A variable can also be solely attached to the object and it will be called an instance variable. Class methods only have access to variables contained in the class but ther can also be instance methods which like instance variables belong to an object and they only have access to the instance variables for the specific object. Objects also provide a layer of abstraction which separates internal and external code. Objects can be called upon by the code using the method and parameters for the object, you must call a constructor to call upon an object. In some languages objects can be composed by using traits, class based languages instantiate the objects with the classes while in prototype languages there are no classes and objects are their own entities. The Podcast explains the basics of Object Oriented Programming and the different languages and components used.

From the blog CS@Worcester – Dylan Brown Computer Science by dylanbrowncs and used with permission of the author. All other rights reserved by the author.


My name is Dylan Brown and I am a Computer Science major. I will be using this blog as a way to document accomplishments and assignments through my courses and afterwards.

From the blog CS@Worcester – Dylan Brown Computer Science by dylanbrowncs and used with permission of the author. All other rights reserved by the author.