Category Archives: CS-343

Docker/VSCode

This week we will be working with docker, and I must say that before this semester I had not used it.  It can be quite cumbersome to the newly arrived such as I.  As I move through this newly discovered tool, I see the necessity to learn and use such construct.  Working with larger applications that involve more than one developer and maybe a revolving door of developers require continuously tested and proved documentation.  The documentation is only part of what an organic process that you wish will continue with minimal supervision requires. The other important item to achieve the forementioned is requirements and these can vary broadly even in a single project.  

As I see Docker is a repository of images from a variety of Linux base operating systems to which various tools are set to work with. It relies on a lot of shell scripting which I am not very strong with yet and is deserving of colorful language to describe.  When it comes to the shell scripting is like you fell into the matrix, literally, just as cool as the movie cinematics. When the operating system has to share information with a different one on top of the same machine is like matrix meets the Avengers multiverse, and things get out of control unless you have some magic systems admin moves. Well of course I base that on using vscode since I never used docker on any other IDE.

The use of vscode is also something difficult to described. It is a powerful tool; if you know how to use it well it can yield great performance, but if you don’t, it can yield stress, headache and a powerful mess. This is not to discourage the use of it, certainly the more I learn the more I enjoy it. Just recently I discovered that one of the things I dislike the most is easily fixable and I would like to share it here in case it could help someone.

Problem: OS windows 10 does not show “open with vscode” when you right click a folder.

Diagnostic: when installing vscode there are options that need to be selected in order for that to happen.

Easy  solution: reinstall vscode and select the two options

Cool solution: open vscode; go to file then new windows ,close the other windows; go to file then open folder; open the folder /users/yourName; in vscode; open editors; below is yourName file, clique new file; name it something like vsCodeRegistry.reg or whatever.reg; then copy this text to the body of the file.

Windows Registry Editor Version 5.00

; Open files

[HKEY_CLASSES_ROOT\*\shell\Open with VS Code]

@=”Edit with VS Code”

“Icon”=”C:\\Program Files\\Microsoft VS Code\\Code.exe,0”

[HKEY_CLASSES_ROOT\*\shell\Open with VS Code\command]

@=”\”C:\\Program Files\\Microsoft VS Code\\Code.exe\” \”%1\””

; This will make it appear when you right click ON a folder

; The “Icon” line can be removed if you don’t want the icon to appear

[HKEY_CLASSES_ROOT\Directory\shell\vscode]

@=”Open Folder as VS Code Project”

“Icon”=”\”C:\\Program Files\\Microsoft VS Code\\Code.exe\”,0″

[HKEY_CLASSES_ROOT\Directory\shell\vscode\command]

@=”\”C:\\Program Files\\Microsoft VS Code\\Code.exe\” \”%1\””

; This will make it appear when you right click INSIDE a folder

; The “Icon” line can be removed if you don’t want the icon to appear

[HKEY_CLASSES_ROOT\Directory\Background\shell\vscode]

@=”Open Folder as VS Code Project”

“Icon”=”\”C:\\Program Files\\Microsoft VS Code\\Code.exe\”,0″

[HKEY_CLASSES_ROOT\Directory\Background\shell\vscode\command]

@=”\”C:\\Program Files\\Microsoft VS Code\\Code.exe\” \”%V\””

Courtesy of a compatriot from Brazil https://dev.to/matheusgomes062/how-to-open-your-files-with-vs-code-from-the-context-menu-on-windows-5fi9; save it go to that file double clique the file and voila, right clique any file and open on vscode.

Now do you understand what this shell script is doing? maybe you do, but I need to look into these things more deeply and as far as I see it appears to be a must to acquire some systems admin moves.

By the way when I tried the first time the shell open and entered an endless loop of empty entries, I had copied something wrong from the file, it is not suppose to do that. The OS will ask you questions if you want to run this, that is supposed to happen.

From the blog CS@Worcester – technology blog by jeffersonbourguignoncoutinho and used with permission of the author. All other rights reserved by the author.

Self-Directed Professional Development Post #5

For this week’s blog post, I’ve decided to continue watching the video I started in my last professional development post, “Object Oriented Design Tutorial: Creating a UML Design from Scratch” by Derek Banas. The reason I picked this video is because 1. it directly relates to one of our course topics, “Modeling: Unified Modeling Language (UML)” and 2. because it teaches a methodical process to creating UML diagrams. Again, since I will likely be making more UML diagrams in my educational/professional life, I want to further develop this skill. In my last post, I learned how to create a Use Case Description, and in this post, I will discuss how to use a Use Case Description to create an Object Model and a Sequence Diagram.

Derek starts his Object Model by using the actors he listed in his Case Description to create 3 separate object boxes in his Object Model diagram. He connects the actors/boxes with a line to show what action is carried between the given object and the multiplicity that each box has. Next, Derek fills in each object he has created with pertinent data fields, for example, since there is one object box for two players, he adds name as an important piece of information to differentiate the two players. This process was valuable to me because I tried to predict what information would be important before Derek did. I wanted to include some methods in the object model, but I learned this is not where I do this. Derek only includes attributes of the objects and other objects that a specific class will use (e.g. the CoinGame includes both the players and the coin actors).

The next thing Derek does is create a Sequence Diagram. It is important to mention that in this video, Derek mentions that he has another introductory video into Sequence Diagrams so he goes somewhat quickly through this process. Either way, there was a lot that happened and that I learned from observing this process. Overall, the main takeaway from this part of the tutorial is that Derek uses the Steps of Execution from the Case Description to lay out the logic of the program he is creating. Throughout this process I thought it was interesting that there were some things that Derek, himself, was not sure of as far as what made the most logical sense, but he went forward with what worked for him. This was really insightful because as I practice this process on my own, I’m realizing that I can create a similar program with a slightly different logical order of what makes the most sense to me.

My goal is to continue following Derek along in this process so I can use a similar approach to create a simple program on my own. For my next post, I’m considering following Derek as he creates a UML he describes to be “easy” now that he has his Sequence Diagram created.

Tutorial link: https://www.youtube.com/watch?v=fJW65Wo7IHI&list=PLGLfVvz_LVvS5P7khyR4xDp7T9lCk9PgE&index=3

From the blog Sensinci's Blog by Sensinci's Blog and used with permission of the author. All other rights reserved by the author.

CS-343 Post #2

After working with docker in the past couple activities, I wanted to learn more about docker, particularly how docker uses images and containers after working with them in activity 6. I have a good idea on how they work and some differences between them, but I wanted to look more into images and containers to have a better idea and clear up some questions I had from the activity. The post that I read that talked about these two elements relating to docker and was helpful to me was “Docker Image vs Container: What is the difference?” from phoenixNAP.

Docker images are the executable files that have the source data for the containers to run, and the containers run by the images. Containers are environments in docker where users can interact with applications. Containers need images to run, and without a container to run, images aren’t very useful. Images cannot be edited because they are almost always in read-only mode, and can act as a preview to the container.

What I did not know about images was how an image can have multiple layers, with one of those layers being the base for the container. Unlike containers, they can not be stopped or run.

I knew that containers were the main places where you can interact with the program and incorporates standardization, but I did not know for sure that the visualization was taking place at the app level of containers rather than the hardware level. Containers are also autonomous and are very secure due to their isolation.

From activity 6, one of the main things I saw that separates the two is that containers have images as a part of them and when a container is created, both the container and image are created. But when the container is removed, the image stayed while only the container was removed. The image cannot be removed on its own because it is being used by the container, stopping the container will not allow this either.

One quote from the post that I think best sums up the relationship between the two is “When discussing the difference between images and containers, it isn’t fair to contrast them as opposing entities. Both elements are closely related and are part of a system defined by the Docker platform.” There are things that separate them, but images and containers aren’t meant to be compared and contrasted, but to be used together to efficiently run the programs and data given from the Dockerfile.

https://phoenixnap.com/kb/docker-image-vs-container

From the blog Jeffery Neal's Blog by jneal44 and used with permission of the author. All other rights reserved by the author.

Blog Discovery

Why do we use Docker?

I decided to choose this article because it goes in-depth on the way we use docker in real life and how efficient it can be when it comes to “virtualization” in a sense, which allows it to run smoother. Plus, BMC blogs are filled with potential reads about software development, implementation, methods, etc. filled with blogs about other project they have accomplished to supply on  how we are already learning the basics on docker and command lines, this information on how docker works will be used in my class for future projects will give not just give me insights but other students that have a need to gather an understanding on how to operate docker and its components and valuable resources.

What is Docker exactly?

Docker is an open-sourced platform that is Linux based towards virtualization but using containers to build, run, test and packages applications with pure efficiency without losing its integrity because it doesn’t rely on the computer’s hardware but on the OS (Docker Engine). Docker is broken down into different elements that helps it run a bit smoother than virtualization, which are containers, images, registries, docker file, and Docker engine. Docker image are set instructions that make up the containers and processes on how to run the application. To run the images, we have the docker engine that helps maintain the virtualization said container on the host machine. If docker is installed it can be applied the same when it comes to container since they run the same. For example, when we want to build a website and add in a web server along with a database such as MySQL, we can simply make an image for the MySQL and give it instruction to the specific port you wish. then package the web server in a container to run the images you already preconfigured and its dependencies, so if you need more servers to be added, easily deployable and easy to migrate said containers to new server. 

I have no prior experience with docker but have a great understanding on how it can be useful in software development and how it can used efficiently especially when compared to cost and using VMs. I could have used this practice in combine with my database class of when I built a MySQL sever and could’ve practice my database with a docker container and saw first handedly how to implement and observe the inner workings of composing it into a container to save the hassle if I wanted to build a web server or application entirely on the docker services. 

Blog resource link: https://www.bmc.com/blogs/docker-101-introduction/

From the blog cs@worcester – Dahwal Dev by Dahwal Charles and used with permission of the author. All other rights reserved by the author.

DevOps With Docker

This week, as we have begun to use Docker and explore how to use it further, I thought it would be a good time to look further into what Docker is and why it is used professionally. In doing so, I found a relatively short blog post by Sudip Sengupta called Introduction To Docker: A Beginner’s Guide that I think does a pretty good job of explaining the positives of using Docker as a development tool.

The post begins by covering why a lot of companies are switching to a containerized framework for development. Mostly, they explain, it is due to the ease of use. It allows for reduced complexity and vulnerability, and generally makes the development process more resilient to the introduction of bugs that are introduced by developers using different dependencies, or using different versions of different software dependencies. If developers are using Docker, they have a consistent container that is completely independent of what they have installed on their own system. So there is no variation in how a build will go, and no bugs can be introduced in the build process, making both building and testing more stable. The post also contains a brief but helpful explanation of how Docker actually functions. A customized docker image can be used to tailor instances of the container to use what is needed for development, and allow for a more modular work environment, as everything needed is stored in the image.

I chose this post because it felt like a pretty good introduction to what Docker is, how it works, and why it is being used more and more in professional software development. From my own experience using Docker so far, it seems like an extremely useful tool. There is no longer a need to have Java installed on my system just for software development, I don’t have to worry as much about what versions I have installed, or have to worry about having multiple versions that can introduce issues into my development. There just seem to be so many perks to using containerization, especially as part of a development team. After the initial setup of getting Docker to work, all the dependencies of your code are just stored in an image that can be used by everyone on the dev team. There is no longer a need to worry about somebody having an out-of-date version of something that can break the code, or cause inconsistent testing results. I will definitely continue to use Docker in the future, it just seems like an invaluable tool for any kind of software development, either personal or professional. And the amount of development tools that are made for Docker or can interact with Docker makes it even more useful.


Source: https://www.bmc.com/blogs/docker-101-introduction/

From the blog CS@Worcester – Kurt Maiser's Coding Blog by kmaiser and used with permission of the author. All other rights reserved by the author.

 GRASP

General Responsibility Assignment Software Patterns – is composed of various instructions which make the definition of classes but also of objects in the design that are oriented by different objects. GRASP has 9 different principles and models, each of which presents as a start the problems and solutions they have:

Information expert – What is the basic principle from which the responsibility for objects is determined?

                                    -We have to assign a class responsibility that has

                                     necessary information in order to fulfill it

In this example, the customer class carries references to all the messages that customers have. In this way, taking responsibility from the candidate to do the calculation of the total value of the various orders, comes gradually naturally. For this reason, this is one of the main principles, but also for the fact that if we do not have all the data we need, at that time we would not be able to meet the requirements and determine the responsibility.

Creator Who creates object A?

                We need to define class B in order to create object A (or e

                in other words, B contains the data of A, records them, uses them closely, and with

                most importantly I have the initializing data that A) has.

This model tries to help in order to be able to decide which class should be responsible for creating a new example of a certain class. In principle, creating an object as a whole is one of the most important processes, and it is important to have a principle for deciding who should have the opportunity to create a possible class example.

Controller – Who is the first object to be used beyond the UI layer which receives and

                      coordinates the control that a system operation performs?

                    – The responsibility of an object which represents: “system” e

                     generally represents the “root object” as well as a usage scenario from

                     where the operation of the system is possible.

The high-level design of our system creates dependence on the implementation of this principle. However, we always have to define the object in order to process the business transactions that we have.

Low Merger – How do we enable the impact of change? How to make it possible to

                             do we support low dependency but also increased reuse?

                          -To determine the responsibility that belongs to us so that the union (Which in this case is

                            Unnecessary, to remain the same Low.

The relation is basically about the mass, how one element relates to another. In this way, the higher the union is, the greater the dependence that one element has on another.

High cohesion – The way we keep objects focused, manageable,

                                 understandable, but also as a side role to support the low link?

                                -We have to assign a certain responsibility, for the sole reason that cohesion

                                 to remain high again.

The definition of cohesion is that it has the role of a measure of how tightly all the responsibilities that the element has can be related. In general, classes that have low cohesion, have within the data that are unrelated, or that have unrelated behaviors.

Indirect – The place from where responsibility should be assigned to avoid merging in order

                   direct between two or even more things.

                 – A responsibility must be assigned to an object that is intermediate, from where

                  mediation of services or other components is done, for the sole reason that they

                  not have a direct connection.

At this moment, the position of the mediator model enters the game. Another role that Indirection has is that it supports low fusion, but at the same time reduces all readability and reasoning to be used for the whole system as a whole.

Polymorphism – How are alternatives that are based on their type treated?

                         -At the moment when the alternatives or even the behaviors which are

                          interrelated    change

                       based on the type of class, determine the responsibility we should have for

                       behavior towards the species from where the behavior also changes, using in this way

                       also polymorphic operations.

Polymorphism is a term that indicates the basic design principle that is object-oriented. This principle has very strong links with what is otherwise called the Strategy Model.

Clean fabrication – Which object should have more responsibility, when we need it to violate the

                                  High   Cohesion but also the Low League. But in addition to these, the solutions

                                  which are offered by other principles and which are not considered appropriate?

                                -We need to define a group that is responsible for a certain class

                                  artificial or even a suitable class that can not do the representation of

                                  a concept that has the domain of the problem.

In some cases, it is very difficult to understand the moment where we have to place the responsibility. This is the main reason why there is a Domain Service concept in Domain-driven Design. The logic behind these services is not directly related to the entities that are separate.

Protected variations – How to design subsystems, objects, and systems in

                                              these elements, not to be influenced by other elements?

                                             -How to identify points that have variations or

                                              even the instability that is predicted, must

                                              define the responsibility we need to create an interface that is with

                                              stable.

This principle is the most important and is indirectly related to the other principles that GRASP has. But we must always be ready for the demands that are constantly changing, as programmers that we are.

Refereces:

https://titanwolf.org/Network/Articles/Article?AID=c96c4845-28c5-46c8-ae48-

https://yamm.finance/wiki/GRASP_(Object_Oriented_Design).html

From the blog CS@worcester – Xhulja's Blogs by xmurati and used with permission of the author. All other rights reserved by the author.

What is Docker and why are we using it?

For the past few weeks in class, we have been working with something called Docker. I have been working on projects that used docker, and we recently did an activity on Docker commands. With all this work revolving around Docker, I wanted to familiarize myself with it further. I did some research on what Docker is, how it works, and why we use it. There are an abundance of sources and blogs that go in depth to how Docker works. That being said, this blog post will just relay most of that information, and you may find it useful if you have been confused about docker up until now.

Let’s first understand what Docker is. A very informative source that I found was an article by IBM that explains this topic very well. Docker is an open source platform that utilizes containerization to package applications, their dependencies and required operating systems into containers. This in turn allows software developers like us to write code and build applications no matter the environment. Though it took a bit to get set up, I found that it made the whole process of writing programs more convenient.

For our second homework assignment, to get the project running in Visual Studio Code, we needed to reopen the folder in a dev container. Docker revolves around the process of containerization, a variation of virtualization. When you hear the term virtualization, you may think of virtual machines, which is the process of emulating a physical machine, virtualizing the OS, underlying hardware, the application and their dependencies. Containers on the other hand virtualize the OS and only the application and their dependencies. As a result, containers offer more portability because “unlike a virtual machine, containers do not need to include a guest OS in every instance and can, instead, simply leverage the features and resources of the host OS” as stated in another article by IBM.

Now that we have a better understanding of how containers differ from virtual machines. I just wanted to conclude by listing the benefits of using Docker and containers. IBM mentions that containers are more lightweight. I have definitely noticed the difference in system usage between running a virtual machine and just running Docker. Another benefit I have seen is the increase in development efficiency, especially for the second homework assignment, where we were required to run the code against tests several times as we made changes. Overall, I found that writing this blog post helped me get a better understanding of what Docker is, how containers work and their benefits to the software development process. It allowed me to weigh the pros and cons of using virtual machines as opposed to containers. And now I can understand why we are using Docker.

Sources:

https://www.ibm.com/cloud/learn/docker

https://www.ibm.com/cloud/blog/containers-vs-vms

From the blog CS@Worcester – Null Pointer by vrotimmy and used with permission of the author. All other rights reserved by the author.

Week 6

The blog I decided to read this week is UML Diagram Types. As we learn more about UML, it is important to know about the many types of UML diagrams. There are two main types of UML diagrams, Structure and Behavioral. Structure types include Class, Component, Deployment, Object, Package, Profile, and Composite Structure Diagram, while Behavioral types include Use Case, Activity, State Machine, Sequence, Communication, Interaction, Overview, and Timing. The main difference between Structure and Behavioral diagrams is Structure shows what is in a modeled system, while Behavioral shows the behavior, or what is supposed to happen in the system.

Of these diagrams, we have worked with the Class diagram. These diagrams are used primarily for Object-Oriented situations. This is because they show the classes along with their attributes and operations of each class. Component is another type of UML diagram. These, as the name implies, show the structural relationship of components in a particular system. Deployment diagrams are used to show the hardware of a system and the software used with that hardware. These diagrams are useful when you have software deployed across multiple machines. Object diagrams are very similar to Class diagrams, however Object diagrams use real world examples. Package diagrams are used to show dependencies between different packages in a particular system. Profile diagrams are relatively new to UML, and are used to profile things like stereotypes, definitions, and constraints. Lastly for Structure diagrams are Composite Structure diagrams. These are used to show the internal structure of a particular class.

For Behavioral diagrams, we start first with the Use Case diagram, which is used to show an overview of various actors that are involved in a system, how different functions are needed by those actors, and how the different functions interact. Activity diagrams are used to represent workflow, for example business or operational workflow. State Machine diagrams are similar to Activity diagrams, and are used to describe the different behaviors of objects and how they act based on what state they are in. Sequence diagrams show how objects interact with each other and, as the name Sequence implies, what order they interact. Communication diagrams are what the old UML 1 Collaboration diagram was. These are similar to Sequence diagrams, but are focused on the messages based between objects, instead of the order they interact. Interaction Overview diagrams are essentially multiple Sequence diagrams all inside another diagram, to show how many things interact and how they interact with each other, and in the order that they interact. Timing diagrams are also like Sequence diagrams but show the behavior of objects within a specific timeframe. 

I chose the following blog post because it gave clear and concise definitions and explanations of the many types of UML diagrams, and allowed me to appreciate them even more than I did before.

Link

From the blog CS@Worcester – Erockwood Blog by erockwood and used with permission of the author. All other rights reserved by the author.

Blog post 1 – UML Class Diagrams

For my first blog, I wanted to discuss UML Class Diagrams, a topic we covered in class. They help put programs in perspective by showing their structure. UML class diagrams have a very simple set up. Each class is represented by a box, and in each box, there are 3. All classes have these boxes, and all these boxes are divided in the same exact way. They look like this:

When writing class names, they must be in bold, and they must start with a capital letter. The font is also used to show other details like what kind of class it is. If it is in bold then it is a concrete class, if it is in bold and italics then it is an abstract class. If you want to denote a specific type of abstract class, like an interface, then it will use the same markdown setup as an abstract class, however, it will have the classifier «interface» on top of the class name. So, it should look like this:

Attributes are listed in a specific way, and this is something that I had a tough time getting used to. Generally, in programming languages we write the data type followed by the variable name, however in UML Class Diagrams, it’s the other way around. Attributes are listed first by name then by data type, and the two are separated by a colon. There is one more thing to touch on, and that is the visibility of the attribute. To denote a public attribute, there should be a (+) sign in front of it. To denote a private attribute, there should be a minus (-) sign in front. Finally static operations are distinguished by an underline font.

Finally, we get to operations. They work similar to attributes; the only difference is that operations are denoted with parentheses. The return type of the operation, its visibility, and so on works the same way as attributes. If a class a has a parameter, then it listed as an attribute but inside the parentheses. It should look something like this:

Note that the class name in this example should have been bolded.

Finally, we get to the last element that I will discuss, and that is relationships. Since these diagrams are meant to be a blueprint to show how programs are structured, we need to show how the classes interact with each other. Tis done with arrows. There are three different types of arrows that show different types of relations.

Solid Arrow: The class utilizes the attributes of the class it points to.

Hollow Arrow: The class extends the class it points to.

Dotted Arrow: The class implements the class it points to.

This is how they look like in use:

This is a very basic overview explaining my understanding of how UML Class Diagrams work. There are many other elements that left out such as multiplicities and composition. I recommend using the sourced I used for further reading:

https://www.uml-diagrams.org/interface.html

https://www.uml-diagrams.org/class-diagrams-overview.html

https://www.guru99.com/uml-class-diagram.html

From the blog CS@Worcester – Fadi Akram by Fadi Akram and used with permission of the author. All other rights reserved by the author.

Strategy Pattern Design Article

https://refactoring.guru/design-patterns/strategy

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.