Category Archives: CS-343

Design Patterns

  • Creational
  • Structural
  • Behavioral

In what is called software engineering, a design model describes a solution that is determined by the problems found in the design of the software. It makes it possible to represent practices that are best and which evolve over a longer period of time through gaming but also testing that is done by software experienced developers.

1)Creational Design Patterns are patterns that explain how an object can be created. These models make it possible to reduce the complexity but also the instability that they have by making the creation of objects in a more controlled way.

In most cases, the new operator is often considered harmful as it distributes objects throughout the application. This can become even more challenging over time, in order to change the implementation, for the sole reason that the classes have a very close relationship with each other.

Creative design models address this issue here by making the client disconnect from the initialization process that is currently underway.

1. Singleton – Makes it possible to provide a single instance of an object that exists during an application.

2. Factory Method – It is possible to create different objects of different classes that are related, but without making specifications in the exact object that can be created.

3. Abstract Factory – Makes possible the creation of families that are dependent but also connected together.

4. Builder – Has the ability to build complex objects using one approach after another, or in other words step by step.

2) Structural design patterns– These are models that have to do with what is called the organization of objects and classes that are different, but also that change the formation of structures from the largest, but at the same time to make it possible to provide the functionality of ri.

Explain how the structural design model is used-

At the moment when we have two interfaces that have an incompatibility with each other but also that want to have a relationship between them by having adaptation with each other, it is also called as the adapter design model. This model, also known as the adapter model, converts an interface of a class to an interface or another class that the client expects. In other words, what is called adaptability somehow allows the classes to work together, which at another point due to incompatibility could not have happened otherwise.

3)Behavioral design patterns represent the responsibility but also the interaction of different objects.

By generalizing these design models, the interaction that takes place through objects should be in such a way that they too can talk smoothly to each other.

Translated into simpler words, in order to avoid dependencies but also difficult coding, the application and the client at the same time should be connected as loosely as possible.

Behavioral design models have 12 types usable for this model:

1. Enterprise chain model

2.Command model

3.Performer model

4.Iterator Models

5.Broker model

6.The model of memories

7.Observer model

8.The state model

9.Strategy Model

10.Template model

11.Visitor model

12.Object Null

References:

https://www.gofpatterns.com/design-patterns/module2/three-types-design-patterns.php

https://howtodoinjava.com/design-patterns/creational/

https://howtodoinjava.com/design-patterns/structural/

https://www.ifourtechnolab.com/blog/a-complete-guide-on-behavioral-design-pattern-and-chain-of-responsibility-pattern-in-java

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

UML Diagramming

Unified Modeling Language otherwise known as UML is one of many different modeling languages/types used in programming. The purpose of modeling languages such as UML is to show the structure of code in order to better understand it. Widespread use of UML started in 1997 when it was adopted as a “standard”. UML is used with object oriented programming and is separated into two different categories (Structural and Behavioral Diagrams). Structural Diagrams show static aspects of code while Behavior diagrams show the dynamic parts of code. 

Some concepts listed that are a big part of UML are Class, objects, inheritance, abstraction, encapsulation, and polymorphism; all of these are directly related to object oriented programming. A few types of structural uml diagrams are class diagrams which show static structure, composite diagrams which show internal code structure and show how the code being analyzed acts when it comes to the rest of the program, an object diagram shows what instances are in code and their relations/associations, component diagrams show the organization of a systems physical components. Some Behavior diagrams from uml are state machine diagrams which represent the “state” of the system, Activity diagrams show a systems control, sequence diagrams show interactions between the objects. 

I chose this article as we have worked on UML diagrams in class and this article is structured well and tells the readers what exactly UML is without overloading them with information. Readers are presented with what UML is and different ways it is used to show many different things involved in object oriented programming. The site which the article is on also has multiple other articles which show readers more complex aspects of UML so if they want to dive deeper into the subject they are free and able to do so without having to look for another website for the desired information. 

I liked this article because of its simple format and feel that it helped me when working on assignments regarding uml even though we mainly went over class diagrams knowing the other types of diagrams and what they are used for was interesting and even helpful to me in understanding the significance of class diagrams. Each diagram in UML has a “specialty” you could say as each different diagram type maps out something different and even with class diagrams being rather simple they can help you understand the benefits that UML provides for software based fields.

https://www.geeksforgeeks.org/unified-modeling-language-uml-introduction/?ref=lbp

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.

Design Smells

In class several weeks ago we began a discussion on design smells. Design smells, or code smells, are qualities of a code that may indicate a greater flaw in its design. I had not heard this term before, so I wanted to spend this blog post familiarizing myself with it. Luckily, there are plenty of resources available to help me.

Hiroo Kato examines this topic in great detail in a blog post “Code Smells and 5 Things You Need To Know To Achieve Cleaner Code.” This article is a great resource for anyone looking to learn more about design smells.

Kato discusses several common types of design smells: bloaters, object orientation abusers, change preventers, dispensables, and couplers. Bloaters, as is implied by the name, are sections of code that have grown too large to be efficiently worked with. Object orientation abusers refer to improper implementation of “object-oriented programming principles.” Change preventers complicate the development process by necessitating more involved changes to the code. Dispensables refer to elements of a code that are unnecessary, and couplers refer to “excessive coupling between classes.”

Design smells can occur at various levels of a program. These levels include application level smells (e.g. duplicate code, shotgun surgery), class level smells (e.g. large class, little class), and method level smells (e.g. long method, speculative generality).

Fixing these design smells as they are noticed is important to keep a project clean and efficient. Kato suggests implementing a code review process. Ideally, this would involve going through the code, identifying design smells (either by hand or by using an automated detection tool), and refactoring them. The way you wind up refactoring your code will depend on the design smell it is afflicted with.

I chose this resource because I think it offers valuable information. The article is well researched, citing studies where relevant to validate claims. The article was also published very recently, so the information is definitely relevant. The author, Hiroo Kato, seems reputable, having written for the article’s host website for over five years. I was curious about this topic, and Hiroo Kato’s writing has added quite a bit to my understanding of design smells. I was not aware that there were types beyond the few we learned in class, or that there are automated tools available to help identify these smells. It’s really useful to be able to identify and avoid or fix design smells, and I will be utilizing this information in future projects.

From the blog CS@Worcester – Ciampa's Computer Science Blog by graceciampa and used with permission of the author. All other rights reserved by the author.

Visual Studio Code Extensions

Visual Studio Code (VSC) is currently ranked the 3rd most popular IDE by programmers throughout the world [1] and is only eclipsed in usage by Eclipse (pun intended) and by the “full” version of Visual Studio. VSC is considered a lightweight IDE compared to Microsoft’s Visual Studio Enterprise (VSE). In the last 5 years, it has shot up in popularity and is expected to surpass the bigger weightier editors because of its expansive use of plugins. This architecture is groundbreaking in that it can remain compact and easy to use for simple tasks, but, when necessary, can be enhanced dramatically to deal with any level of expansion.

IDE’s can be ranked by size in 3 categories:

There are 3 levels of integrated development environments these days.

  • The smaller variety are enhanced text editors, (e.g., Atom, Sublime Text, and Notepad++).
  • Medium sized, like VSC, are the up-and-coming editors of the future
  • Larger development environments, (e.g., Visual Studio Enterprise, Eclipse and IntelliJ IDEA and editors based on it (like Android Studio))

The great advantage I see with VSC is its ability to be lightweight out of the box, but with the addition of the right plugins, can support most languages, tools, and coding situations.

I have worked over the years rather extensively with VSE, Eclipse, and Android Studio. Eclipse is a good editor, but it is a toy compared with VSE and Android Studio. All 3 of these IDE’s (formerly and pretentiously termed VDE’s) were powerful, but cumbersome. If you wanted to write a simple framework, you had to stumble through a plethora of menu entries, toolbars, and tabs to find what you needed. What you wanted was there, but sometimes it’s location was  not obvious. Developers did their best to memorize or use cheat-sheets of shortcut key combinations to get optimal use out of their coding time but were limited with a lot of minutiae to wade through.

As an example, if I primarily use java, but sometimes write JavaScript code, I only install the plugins related to those languages.  If I want to use Android Studio key-mapping for my shortcuts, I install that one extension. If I want to make my code align automatically, I install “Prettier”. If I want to see my nested code more clearly and visually interesting, I install “indent-rainbow”.

These extensions can be removed or disabled quite easily. VSC’s activity bar (by default on the left view), will add items to the bar as extensions are installed. I have additions for Docker, Testing, and source-code integration that were added by installing the relevant extensions,  

On my next post, I will lay out a list of the extensions I am finding most useful as a student of a Software Architecture class I am taking. We have used Plantuml [2], Docker [3], Object Oriented design, Design Patterns in Java, and semantic versioning for Docker images. We will be proceeding to use REST API’s, Kubernetes, CI/CD, and microservices architectures. As these new subjects are encountered, it is easy to just snap in the appropriate extensions, and more ahead from there. Beautiful!

1. https://pypl.github.io./IDE/html

2. https://plantuml.com/

3. https://www.docker.com

From the blog cs@worcester – (Twinstar Blogland) by Joe Barry and used with permission of the author. All other rights reserved by the author.

Docker, and why it is so important

Docker is a relatively new way of software delivery. With Docker, all that is needed is the image for the dependencies and software needed, and Docker does the rest. This is huge as before you would need to download and install specific versions of software on each and every computer you wanted to work on, but with Docker, you say you want X, Y, and Z and Docker does the rest for you, making life much easier.

The way Docker does this is through what are called “Containers”. Containers allow developers to package an application with everything that it needs, like dependencies and libraries, and then ship it out as one package. This is where the magic happens, as it means that the application will run on any other machine regardless of any customized settings that machine may have that might differ from the main machine that is being used for writing and testing the application. Docker is, in a way, like a virtual machine in this sense, but instead of running an entire virtual operating system, Docker allows applications to run the same kernel as the system they are running on, and only needs applications to be shipped with things not already on the host computer, instead of having to send out everything. This translates to a big performance increase in the speed of the application and reduces the overall size of the application as well.

Docker is also open source, one of the most important things, in my opinion, software can be these days. This means that anyone can contribute to Docker and modify it to their own needs if they need something Docker does not provide by default. This also means that since anyone can modify it, they can also see the inner workings and ensure that nothing is going on that’s not supposed to, like recording private information to sell to advertisers, for example. Docker makes life easy for developers, allowing them to not have to worry about the system that their program will be running on. Docker also gives flexibility in it’s containers and can reduce the number of systems needed for the program to run.

Source

I choose the above article because it gave a good look into what Docker is and how it is useful for software development in today’s world. It explained the key aspects of Docker and what they are useful for compared to past methods. In addition, the article gave a good analogy to Docker by comparing transporting cargo prior to the standardization of using shipping containers to make transporting good easier, as that roughly translates to what Docker does with their containers.

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

Test Post

Testing I can access WSU FeedWordpress plugin

From the blog cs@worcester – (Twinstar Blogland) by Joe Barry and used with permission of the author. All other rights reserved by the author.

API (Application Programming Interface)

Applications such as Expedia, Amazon, Netflix or Facebook are using an API that facilitates the sharing data from one application to another. There are hundreds of APIs for many fields like finance, social network, payments and e-commerce. Nowadays, the fastest-growing category APIs is sharing and analyzing of data across various applications which is a place the characteristics of the API determine the value of the application or deem it untenable for use in the real world. But how could APIs connect each application together, let’s us take a deep dive into the world of APIs.

API stand for Application Programming Interface which includes three important components

  • Procedures: Known as routine which refer to the specific tasks or functions a program performs. For example: Facebook provides a search API for developers to examine data for analytical purpose
  • Protocols: The format is used to communicate data between applications. However application might not have the same format
  • Tools: Simply put – building blocks which is the recipe to construct new program

APIs are needed to bring applications together to perform a designed function which allows to use, share and execute data. APIs act as middle man, this allows developers to build new functions between applications and businesses use on a daily basis.

How APIs actually work?

Application: Enterprise businesses and corporation rely onto user financial data, inventory levels and purchase order confirmation back and forth between suppliers, customers and partners. Consumers and business depend on mobile application, spending much time per day on smartphone and tablet apps to exchange businesses with partner and customers.

Programming: Application relies on programming. The application does not make itself. In other words, we would not be able to make new application without developers who write the code to create, testing and design the application software and user interface.

Interface: This is where users and application interact with each other

API is important that without it we would not be able to order stuff from Amazon or personalize your favorite Google homepage. The simple way to understand APIs is to understand that API is an interface that let this application talk to another inside the application via commands designed by programmers.

Types of APIs

  • Rest APIs: known as RESTful APIs, stands for Representational State Transfer. It has grown in popularity of late, as an essential part of Web Services. It’s designed for developers to perform requests and receive responses via HTTP. There are four types of HTTP commands that REST is based on which are GET, PUT, POST, and DELETE. Instagram uses API for users to pull up information and pictures
  • SOAP APIs: Stands for Simple Object Access Protocol. SOAP is a protocol that is defined by a standard. It is dependent on XML-based systems and programming, has larger and more expensive data. Despite the disadvantages, SOAP provides better security for users.
  • RPC APIs: Remote Procedure Call was the earliest form of APIs. They are designed to execute the block of code on different servers.

APIs are running data for business every day. They give businesses and users the flexibility to increase productivity and improve security. Taking advantage of APIs can help them have innovative approaches. While the potential is undeniable, efficiency is still another matter.

Source:

https://www.cleo.com/blog/knowledge-base-what-is-an-api

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

API Creation, Why Simple is Better

Whenever you interact with a program it is usually done through an API. Every website you visit, most programs you use, even your own operating system uses APIs to communicate with application. APIs are very prominent in modern computing and are essential to establishing the connection between programs and users alike.

Seeing as every programmer will interact with an API at some point or another, it is important to understand their place and how to create a good API should you need to do so. It is important to realize that characteristics such as being easy to work with, complete, and concise must be met when creating an API. Doing so can result in many gains not just in the finished product, but in other aspects of coding projects. Keshav Vasudevan put it, good API design can lead to “improved developer experience, faster documentation, and higher adoption for your API.

As the author puts it, an API must be extremely simple to use while achieving its goals. To that end Vasudevan has outlined key aspects of API design that one should take into account when creating an API. Much of it comes down to proper organization and the use of consistency to avoid confusion while utilizing the API. Small changes such as keeping URLs short and simple along with setting up resource functionality with HTTP methods can make the process much easier. Methods such as GET, POST, PUT, PATCH, AND DELETE are commonly used in these APIs along with many other methods commonly used in HTTP.

Along with proper organization while building the API, it is just as important to ensure that it is not indecipherable by others. A problem that often occurs with developers and product owners is that the developers might the meaning of a feature and implement incorrect functionality. Developers should check that all GET commands needed are implemented and have an example where one can expect a specific output on a successful run. It is important to give and receive feedback for the developers due to the disconnect that can occur between the target audience of a program and the developers creating it.

An example of the GET response as follows:

responses:
200:
description: Successfully returned information about users
schema:
type: array
items:
type: object
properties:
username:
type: “string”
example: “kesh92”
created_time:
type: “dateTime”
example: “2010-01-12T05:23:19+0000”

Once all this is done, it is important to remember that complexity should be handled ‘elegantly’ as Vasudevan puts it. This entails that there are likely large amounts of different data and information that must be accessed. A lot of these are common and it makes no sense from an efficiency standpoint to create a resource for each piece of data, therefore it is important to keep the ability of resources broad. You should keep the retrieval process simple, down to a query and parameters when searching or using a resource. Overall the API must be as user friendly as possible to ensure that it works well with future users who don’t know the API like you.

Bibliography

Vasudevan, Keshav. “Best Practices in API Design.” SmartBear.com, https://swagger.io/blog/api-design/api-design-best-practices/.

https://swagger.io/blog/api-design/api-design-best-practices/

From the blog CS@Worcester – George Chyoghly CS-343 by gchyoghly and used with permission of the author. All other rights reserved by the author.

K8 Crash Course

Blog Discovery

As a newcomer to the software industry, Kubernetes was foreign to me. This is also an article on the K8s, so please indulge me.

Applications: developers who provide a predefined service to stakeholders, Docker is a well-known runtime environment for building and building applications in containers. Creating a sample Go app; let’s create a basic Go app that we’ll use to deploy to our minikube cluster.

Kubernetes: The Kubernetes Engineering Manager is an open source container management and deployment platform. It orchestrates the clusters of virtual machines and schedules the containers to run on those virtual machines based on their available compute resources and the resource requirements of the container.

What are Pods?

A Kubernetes pod is a group of one or more containers, linked together for the purpose of Nodes and clusters: workstation that provides resources to developers a node can be thought of as the workstation that provides these resources and Kubernetes, the manager that allocates these positions to employees. In Kubernetes, a node is a working computer that can be virtual or physical. A node can have many pods, and Kubernetes automatically manages the scheduling of pods among the nodes in the cluster.

Deployment: the team’s objectives and structure defined at the start of the year a deployment provides declarative updates for Pods and ReplicaSets. In a deployment, we set a desired state and the deployment controller gradually converts the current state to the desired state. Take a look at the deployment file below deployment. The above deployment file is like a declarative template for Pods and Replicas.

The above deployment named myapp in {metadata.name}, creates a replica set to display two pods of myapp.

What are ReplicaSets?

Creating a K8s deployment kubectl apply -f deploy. Kubernetes Services: The SPOC team that routes relevant external communications to developer pods are ephemeral resources. In Kubernetes, a service is an abstraction that defines a logical set of pods and a policy for accessing them. Kubernetes services provide addresses through which associated pods can be accessed. Create a Kubernetes service kubectl apply -f service. The minikube tunnel command can be used to expose LoadBalancer services. The Minikube tunnel runs as a process on the host and creates a network route to the cluster CIDR service using the cluster IP address as a gateway. You can now use this IP address to open the service in the browser. The section on services is incomplete without an analogy with the life of developers. Imagine an external team uncertain or confused about the use of a feature developed by the development team. With that, we come to the end of the article on K8s and the Adventures of the Freshest Day One.

https://betterprogramming.pub/relating-with-docker-and-kubernetes-as-developers-an-analogue-5e662b1f817b

From the blog CS@Worcester – The Dive by gonzalezwsu22 and used with permission of the author. All other rights reserved by the author.

Microservices and their Pro’s and Con’s

Microservice Architecture is a strategy for designing software in which each part of software exists separately from the others in what is called a microservice. These microservices have their own CPU’s, exist in their own runtime environment, and are designed to do one specific job. Microservices communicate with each other through Application Program Interfaces (APIs) to form the whole of the product.

In their blog “What Is Microservice Architecture? Microservices Explained”, Johnathan Johnson and Laura Schiff discuss in detail the difference between Microservice Architecture and Monolith Architecture, a system in which the entire application exists as a single unit, and how Microservice Architecture is implemented and used. Today I want to discuss the pro’s and con’s of this architecture listed in the blog, and how I plan on using it in the future. I selected this post specifically because it goes into detail about the benefits and drawbacks of Microservice Architecture. If you would like to learn more about the specifics of the implementation, please visit the blog post linked above.

There are many pro’s to using microservices. The main reason it is implemented is because it promotes feature independence. This feature independence has many benefits, such as developer independence, isolation, resilience, and scalability. Personally I think that developer independence is the most beneficial since developers will become very competent with their microservice and will be experts at their specific job.

When a microservice wants to interact with another it makes a call to that service’s API. Since microservices exist in their own runtime environment they will continue to function even if that API call is not executed. This means that if a part of an application goes down the rest of the program continues to run, albeit at a loss of functionality. In my opinion this is the one of the best reasons to use microservices since it makes applications very resilient.

The final pro I would like to discuss is scalability. Since each service has its own dedicated CPU, its usage can be scaled to meet demand. I think this is a great byproduct of microservices, but do not believe this should be the main reason for using them.

The issues related to microservices are real, but manageable. Microservice Architecture adds complexity to a project, but this can be mitigated with training. Microservices also cost more since they use more processing power and require experienced engineers, but I believe the benefits are worth the cost. Finally microservices adds a security risk since each microservice can be attacked individually. Given an experienced team of engineers and good oversight, this risk can be lessened.

In conclusion, I believe Microservice Architecture to be a very good design choice and plan on using it in my future work. Reading the blog post was worth the few minutes it took, and I can say that I understand microservices much better now than I had before. The benefits far outweigh the risks and I can imagine many employers would already be using this architecture.

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