Category Archives: CS-343

API Types Explained: REST, SOAP, and RPC

After class I spent some time researching what are the different types of REST API. Then I found more information about the different types of API architecture out there currently. There are currently three different types of API architecture. They are REST, SOAP, and RPC API each used differently depending on the task, data and specifications needed. 

First let me explain REST API architecture. REST API uses front end and back end servers to communicate to complete tasks. Which can let this architecture be very flexible due to how you want to scale or other specifications. Another benefit to REST is that it does not store any data or status between requests. In addition it is resource oriented which lets URI’s (uniform resource identifier) to identify certain resources within the server.

The data format uses JSON, XML, HTML and plain text. As a result of using JSON as a data format it uses less storage and is a lot faster instead of resolving requests. Moving on in order to communicate with the server it uses HTTP methods and commands so that we can manipulate resources within the server. Lastly, how the architecture handles errors is through the application level. It is how the application handles errors and exceptions made by the individual or company. 

Another architecture used is SOAP API. SOAP uses strict protocols that use XML and WSDL instead of HTTP methods. In addition, it uses message oriented instead of resource oriented messages. Let me explain further, is a program communicates with the server using messages to transfer data or receive data using a message queue. The data format  uses only XML, as a result it increases sizes of data being transferred over a connection. SOAP is an architecture that is stateless and stateful allows users to maintain session information over the server and still receive information from the server.

In order to protect information SOAP uses a WS-Security to encrypt messages and maintain the message. To clarify, SOAP uses XML as a data format but it causes it to be a lot slower due to increased data sizes being transferred and more complex the XML has to be to make sure everything works as intended. Within the XML code has built in error handling that are defined by the user to catch bad requests or other errors. One of the benefits of SOAP is a software architecture that can scale due to being able to add new features and define a stricter contract. 

Lastly, let’s talk about RPC (remote procedural call) architecture. The architecture has a client and server connection to send information back and forth. Also it is written in JSON, XML, and Protocol formats. The RPC communication layer uses protocol IP/TCP to send the data between the server and the user. In addition, it has error handling to manage network and server problems. Plus the user can add in features to authentication actions and encrypt messages. Lastly, RPC uses IDL to call return types, parameters remotely.

From the blog CS@Worcester – Site Title by Ben Santos and used with permission of the author. All other rights reserved by the author.

Refactoring “Bloaters”

I decided to read Pavan Kumar S’s blog, “Refactoring 101: Code Smells – Bloaters.” This post explains a specific code smell called “bloaters,” which starts when parts of your code grow too large and become difficult to maintain. The topic of this blog connects to our course work and topics on design principles, going over code smells and refactoring just like we’ve done in our lectures and homework.

Pavan Kumar describes bloaters as a sign that a program has become overcomplicated and cluttered. He picks out examples such as long methods, large classes, and long parameter lists. Each of these examples show a situation where code tries to handle too many responsibilities at once, causing poor readability and maintainability. Kumar suggests several refactoring techniques to combat these problems, including Extract Method, Extract Class, and Introduce Parameter Object. These techniques can be used to simplify your code by breaking large structures into smaller, specialized units. The blog explains that the goal of refactoring is not to change the external behavior or output of the program but to improve its internal structure so that it remains easier to understand, test, and extend in the future.

This blog appealed to me because it provides a clear explanation of a problem I often run into in my own programming projects. When writing assignments or personal code, I tend to write long methods that handle multiple tasks without modularity or specialized methods in mind. I’m aware of this bad habit because I mostly do it as I usually work with smaller projects that don’t require too much. Although it works initially, the code quickly becomes messy and difficult to modify or expand. Reading this blog was helpful for me since I recognized I recognized my bad habit when writing code.

What stood out most to me was how important refactoring can be in design principles. This was showcased in the duck homework where we have to refactor bad code. This only reinforced the idea and helped me better digest that concept of refactoring. A bloated method or class commonly goes against these ideas by combining too many responsibilities in one place. If you refactor and divide functionality into smaller pieces, each part of the code is more manageable and much cleaner. This short concept reinforced the idea that refactoring is not simply about cleaning up code, it’s good design habit.

From this reading, I picked up on the idea that refactoring does not have to be a massive rewrite or a stressful task. Small improvements like breaking large classes into manageable ones can prevent the slow build up that often happens in growing projects. Hopefully, I can incorporate regularly reviewing my code for signs of bloat and make refactoring part of my skillset.

https://medium.com/testvagrant/refactoring-101-code-smells-bloaters-f80984859340

From the blog CS@Worcester – Coding with Tai by Tai Nguyen and used with permission of the author. All other rights reserved by the author.

My Experience Learning REST API

When I first started learning about REST APIs, I thought it was just about how apps talk to each other over the internet. But after reading the REST API Tutorial, I realized that REST is much more than just sending HTTP requests. It’s an entire way of thinking about how systems communicate efficiently and reliably. … Read more

From the blog CS@Worcester – BforBuild by Johnson K and used with permission of the author. All other rights reserved by the author.

Keep the Code Simple.

In software development, simplicity is further required in coding. It is the foundation of how software genuinely works. Every line of code we write in system, from short programs to large systems, teaches us one major lesson: keeping code simple leads to stronger, cleaner, and further reliable software. When code is simple, it becomes easier to understand how each part of a program interacts, how data flows through the system, and how changes can be made without breaking additional components.

Throughout our computer science class, we learn that writing code is not just about making something run, it’s about designing how it runs. Concepts like encapsulation, abstraction, and modularity form the heart of this process. Encapsulation keeps data protected and managed within defined boundaries. Abstraction allows us to hide unnecessary details so that only the important parts are visible to the developer. Modularity divides complex programs into smaller, independent sections that can be developed, tested, and improved separately. These principles not only make programs easier to understand but also reflect how big software plans are built in real-world projects.

Simplicity also plays pivotal role in collaboration. When multiple developers work on the same clear and consistent code, it allows everyone to read, modify, and contribute without confusion. In our group projects, clear code helps everyone understand and contribute easily. Even when we continue working from home, the project feels simple and organized, not stressful. This clarity saves time, reduces errors, and keeps teamwork smooth.

Another reason simplicity matters are maintenance. As we study different programming software models, we see that maintaining complex code can become easy to modify and frustrating. Clean, readable code allows group members to trace logic quickly and identify issues before they cause system failures. This is why experienced programmers often say, “Code is read more often than it is written.” The goal is not to write the most advanced or impressive code, but to write the most understandable and dependable one.

Keeping code simple also encourages better thinking. It forces us to focus on problem-solving rather than decoration. By keeping things simple, we learn to study the requirements carefully, organize the program’s structure wisely, and create efficient code that works effectively without unnecessary lines. Simplicity shows real understanding of how software functions at its core.

As I continue learning software design, I realize that simplicity is not the opposite of intelligence, it is the best outcome of experience and clarity. The coders don’t make code complex; they make it clear. True creativity in programming lies not in how much we write, but in how well it makes as simple—and that always begins with keeping the code simple.

From the blog CS@Worcester – Pre-Learner —> A Blog Introduction by Aksh Patel and used with permission of the author. All other rights reserved by the author.

Week 2-CS 343 blog: SOAP API

During class, I went over the topic of REST API and how amazing it was to understand and analyze how it works. However, there are many types of API, including REST API, GraphQL APIS, RPC APIS, and SOAP APIs. Today, I would like to go through what catches my attention the most is SOAP APIS. I read an article about explaining how SOAP API work, when to use them, and how they compare with modern REST APIS, and I would love to share it with you. The article is posted below, and feel free to check it out for further information (all the information is according to the article) 

https://blog.postman.com/soap-api-definition/

WHAT is SOAP? 

In the late 1900s, SOAP, a messaging protocol that was developed to enable different systems running on multiple operating systems, languages, and networks, with the purpose is to exchanging structured information reliably 

Unlike REST, SOAP focuses on messages rather than resources. 

SOAP messages are formatted in XML and usually contain: 

  • Envelope – defines the start and end of the message 
  • Header – contains optional information like authentication or transaction details 
  • Body – holds the actual request or response data 
  • Fault – handles errors 

How SOAP works?  

A SOAP client sends an XML request to a server, which also responds with another XML message. These communications often occur over HTTP (but sometimes also SMTP, TCP, or UDP) 

  • SOAP messages are defined by the Web Services Description Language (WSDL) to describe the operations, parameters, and return types

Advantages of SOAP

  • Platform independent – works across languages and OS. 
  • Protocol flexible – not limited to HTTPS 
  • Strong security – supports encryption and authentication 
  • Error handling – display clear fault messages 
  • The ideal workplace, where rigid relationships and dependability are essential 

Disadvantages of SOAP 

  • More complex and verbose than REST 
  • Harder to evolve or version 
  • Slower performance due to XML analysis 
  • It is less appropriate for web applications because of its limited catching support. 

Common Use Cases 

SOAP API is commonly used in banking, telecommunications, transportation, and enterprise systems – these cases require reliability, structured data, and strict security. 

  • Examples: 

In banking, SOAP API is used for bank transfers.

In transportation, flight booking systems 

ETC, ….

Shipping and logistics services 

Conclusion 

SOAP API is a great protocol, robust and standardized, but compared to REST, it’s less flexible. REST is better for modern web applications and faster iteration. SOAP API is always needed and valuable for many applications that prioritize security, reliability, and formal structure.

From the blog CS@Worcester – Nguyen Technique by Nguyen Vuong and used with permission of the author. All other rights reserved by the author.

Quarter-2 Blog Post

The blog post I decided to talk about is on “Design Smells” in software development. I chose this topic because we’ve touched on it in class during assignments where we matched the correct design smell to its definition. It’s an important concept to understand since we’ll be working with API designs and need to know how to avoid these issues. In the post written by Keith Casey, he compares design smells to your car sounding weird or your “Spidey Senses” going off, subtle signs that something is off with your code or design. He focuses on four main design smells: Inconsistent naming, CRUD-only APIs, Customer-specific features, and Per-resource versioning.

He gives a realistic example of inconsistent naming with variables like interest_rate, intRate, and iRate. It might seem like a small problem, but those tiny differences can cause major confusion (Opacity). While it may look like just a style issue, it often shows that team members have different understandings of the same concept. I’ve seen this happen in class, where one student uses userName and another uses username. It makes the code harder to read and maintain. In the future, I think it’s important for teams or individuals to agree on consistent variable names early, so the code stays clean and easy to follow.

The next design smell discussed is “CRUD over HTTP”. I wasn’t too familiar with this one, so it was interesting to read about. This happens when an API just wraps a database without adding any real logic (Needless Complexity), which the author calls a “glorified database.” Using methods like GET, POST, PUT, and DELETE might seem correct, but if your API only moves data around, it’s not doing much. A good API should validate input, include logic, and make the system useful beyond basic storage. We’ve talked about these HTTP methods in class, learning how each one interacts with data, so this gave me new ideas. Before, I only thought about what each method did; now I’ll think more about what the API is modeling and how it supports the system’s purpose.

For the last two design smells, customer-specific functionality and per-resource versioning, both show how small design changes can turn into big headaches. Customer specific functionality happens when a team adds a feature to please one customer. It sounds harmless, but every tweak adds complexity, more testing, and a higher chance for things to break. The author makes a good point to inspect each request carefully and compare it with the API’s design. The last design smell gives each resource its own version number. It may sound flexible, but it quickly becomes messy and confusing for users. These two examples show that good design means knowing when to say no and keeping things simple within the API.

Overall, this blog post helped me understand how small details can affect the bigger picture in software design. “Design smells” can be avoided with a little attention and ensuring not adding things than can be needlessly complex.

Source: https://caseysoftware.com/blog/api-design-smells

From the blog CS@Worcester – Mike's Byte-sized by mclark141cbd9e67b5 and used with permission of the author. All other rights reserved by the author.

Learning RESTful Designs Principles

So for this second quarter’s professional development activity, i read the Stack Overflow post, “Best practices for REST API design”(https://stackoverflow.blog/2020/03/02/best-practices-for-rest-api-design/), in basics it covers the fundamental guidelines for designing Restful APIs that are both efficient and developer-friendly, covering some key principles like properly structuring URLs, making sure to use nouns instead of verbs when it comes to endpoint naming, implementing HTTP methods accordingly to standards as well as ensuring consistency in API design. The post also talks a little bit about versioning, error handling and security as vital aspects of any production-level API.

I selected this specific resource considering it does relate to what we were doing in class and some of our homework as well, since we’re getting involved on building maintainable, modular systems and REST APIs are just one of the common interfaces used in modern software architecture, for anyone trying to work in backend development you can deepen your understanding of how to design APIs that other developers can easily understand, use and extend to some degree.

From the rest of the article(no pun intended), I learned that REST isn’t just about making the things in question work but having a consistent and predictable interface that makes client-server communication easier. I like how the article broke down best practices for naming conventions, like how using resource-based URIs like /users or /orders/1234 instead of action-based ones like /getUser makes the API more intuitive. I also remembered about the significance of using HTTP status codes, like 201 Created for successful POST requests or 404 Not Found for missing resources. These small details can contribute somewhat to API usability and maintainability.

So i’d say pretty much that the article reinforces the more architectural concepts that we’ve discussed before in class, like abstraction, modularity and encapsulation. An API that is well-designed abstracts away complex backend logic and presents a clean, understandable interface much like how we design modules in general when it comes to software construction. I also like to think that it connects to our work when it comes to some other software design principles like separation of concerns and loose coupling. RESTful Design makes it so that different parts of a system can evolve independently, which is essential for large-scale software projects.

If i had to reflect on this after my reading of the article, i would say that i realize on some occasions i find myself taking shortcuts when designing endpoints for personal projects, mostly just trying to focus on making sure it’s functionality is in suitable position as opposed to focusing on structure, but after my reading i think i’ll try to be more deliberate when it comes to naming conventions, HTTP method uses and documentation.

Overall, this resource gave me a clearer framework for thinking about web service design, and I can already see how it will help me create more scalable and maintainable software in future projects.

From the blog CS@Worcester – CSTips by Jamaal Gedeon and used with permission of the author. All other rights reserved by the author.

Principle of Least Knowledge (AKA Law of Demeter)

Hello everyone, today I will be talking about the Principle of Least Knowledge (AKA Law of Demeter). When first looking into this topic I was unsure of exactly what this was and how it would be applied to programming. When doing my research I found the Khouri College of Computer Sciences at North Eastern University had a page dedicated to this topic, where this law was first introduced.

General Formulation

Illustration of the Law of Demeter, highlighting the principle of limiting interactions between objects.

The LoD is essentially a simple style rule for designing object oriented systems.

“Only talk to your immediate friends” is the motto. 

Professor Leiberherr, the author, states a formulation of “Each unit should have only limited knowledge about other units: only units “closely” related to the current unit.Its main motivation is to control information overload thus helping memory management as each item is closely related.

You can informally summarize the Law with these three formulations:

  • Each method can only send messages to a limited set of objects, namely to the argument objects and to the immediate subparts of the class to which the method is attached.
  • Each method is “dependent” on a limited set of objects (organize dependencies)
  • Each method “collaborates” with a limited set of objects (organize collaborations)

To formulate the Law we can choose from the following independent possibilities:

  • Object/Class
    • Class formulation is intended to be compile-time
    • Object formulation is intended to be followed conceptually
  • Messages/Generic functions/Methods
  • Weak/Strong
    • If we interpret it as all instance variables, including the inherited ones, we get the weak form of the Law. If we exclude the inherited instance variables, we get the strong form of the Law.

Benefits

In a paper written by Leiberherr, there are a couple facts stated for the benefits:

  • If the weak or strong LoD is followed and if class A’s protocol is renamed, then at most the preferred client methods of A and A’s subclasses require modification.
  • If the weak or strong LoD is followed and if the protocol of class A changes, then only preferred client methods of A and its subclasses need to be modified and only methods in the set of potential preferred clients of A and its subclasses need to be added
  • There’s even more benefits highlighted in the paper pertaining to limiting information overload.

Final Thoughts:

Prior to this webpage I knew nothing about this law/principle, however I now understand that it is a fairly useful rule or its respective use case. The law teaches you a way to program Classes, Inheritance, Abstraction, and a few other techniques. Infact There is so much more depth to this that I cant even fully fit it into this blog post. I would highly recommend you check out this page as It contains all the information you need along with sources to learn this.

From the blog Petraq Mele blog posts by Petraq Mele and used with permission of the author. All other rights reserved by the author.

How to become a SOLID software developer.

By Petraq Mele

Hello again to those reading this blog, this time I want to talk about an extremely topic relevant in the programming atmosphere, that being a concept known as SOLID. I managed to find a great section written by Manoj Phandis on these principles.

SOLID is an acronym of five OOP design principles designed to help make it more understandable, flexible, and maintainable.

What are the main 5 design principles?

SINGLE RESPONSIBILITY PRINCIPLE: This principle states a class should have one, and only one, reason to change. Lets take an Animal class example, as opposed to the animal class having a sound and feed parameter, separate those responsibilities into separate classes.

Some benefits include:

  • more readable, that is easier to understand
  • less error prone
  • more robust
  • better testable
  • better maintainable and extendable
  • maximizes the cohesion of classes.

OPEN CLOSED PRINCIPLE: “Open for extension” means the behavior of a module can be extended. “Closed for extension” means when we are adding/extending a modules behavior it should not result in changes to a modules source or binary code.

Demonstration of the Open/Closed Principle in object-oriented programming.

An example Manoj gives is a credit card company wanting to introduce a new preferred credit card product with double reward points. Instead of using conditionals, you create an extension via implementation inheritance or interface abstraction.

LISKOV SUBSTITUTION PRINCIPLE: LSP states functions that use references to base classes must be able to use objects of the derived class without knowing it. For LSP compliance we need to follow some rules that can be categorized into 2 groups:

  • Contract rules
    • Preconditions cannot be strengthened or weakened in a subtype
    • Invariants must be maintained
  • Variance rules
    • There must be contra-variance of the method argument in the subtype & be covariance of the return type in the subtype
    • No new exceptions can be thrown by the subtype unless they are part of the existing exception hierarchy.

INTERFACE SEGREGATION PRINCIPLE: Clients should not be forced to depend on methods they do not use. Interface segregation violations result in classes depending on things they don’t need & an increase of coupling and reduced flexibility/maintainability.

Tips to follow:

  • Prefer small, cohesive interfaces to “fat” interfaces
  • Creating smaller interfaces with just what we need
  • Have the fat interface implement your new interface.
  • Dependency of one class to another should depend on the smallest possible interface.

DEPENDENCY INVERSION PRINCIPLE: This principle has two parts. The first part says high-level modules should not depend on low-level modules. Both should depend on abstractions. The second part says Abstractions should not depend on details. Details should depend on abstractions.

Part one example:

Part two example:

Final thoughts:

Overall these principles are very useful when it comes to object-oriented software development. I learned quite a good amount and I want to thank Manoj Phandis for their amazing outline of the SOLID principles, I would advise you to check them out in his website incase you’re interested in learning more.

From the blog Petraq Mele blog posts by Petraq Mele and used with permission of the author. All other rights reserved by the author.

Application Programming Interfaces

Source: altexsoft

Application Programming Interfaces, or APIs, are the communicating code between a client and server, kind of like a user interface for the computer. They are what receives information from the user interface, sends it to the server to get a result, and sends that result back to the user interface. APIs can be private, partnered, or public. Private is where the API is only available for an organization to use. Partnered is where the API is available to a group of organizations that are in partnership with each other share it. Public is where the API is available to everyone. In our setting, the Thea’s Pantry API is public, mainly used by food pantry volunteers, but the code is openly available on GitLab. 

There are also different types/formats of APIs, like Remote Procedure Call (RPC), Service Object Access Protocol (SOAP), and Representational State Transfer (REST). RPC is when the client requests data from the server and the server sends it. SOAP is a protocol that exchanges data in a decentralized environment, it uses XML messaging between the client and server through HTTP or SMTP. SOAP is known for its high security of data. REST is a protocol where resources are given a URL that can be used to request the data using HTTP methods. REST is simpler and more versatile than SOAP because it requires less complex code writing and uses many formats beyond XML. 

In class and in the homework assignments, we focused on REST API with JSON messaging. We practiced sending requests for GET, POST, PUT, PATCH, and DELETE and some of their different responses like success, entry error, and server error. We also learned how to write our own requests for creating guests, changing a guest’s information, retrieving a guest’s information, and deleting a guest from the system. Some methods, like POST, require arguments as well. To post a new guest, the request needs to have the new UUID and all the information their user will have, like if they are a resident and if they receive financial assistance. To receive a list of users that fit a certain criteria, the GET request needs to have a specific tag in the URL to specify the endpoint. 

Learning APIs will be extremely helpful for the future. In software development, APIs are everywhere. While REST is the most common, it is still useful to know the other kinds as well, like SOAP, and how to use them. Everyone uses APIs: Google, Amazon, Microsoft, Netflix, and many, many more. Getting first hand experience using and building APIs allows me to expand my skillset for real-life applications.

From the blog ALIDA NORDQUIST by alidanordquist and used with permission of the author. All other rights reserved by the author.