Category Archives: CS-343

YAGNI – It could be a matter of life or death (or profits)

YAGNI – You aren’t going to need it. In the simplest terms, the principle (initially created by Ron Jefferies) means don’t overengineer before it is necessary. It means to find the solution that works for what is needed today without engineering for POTENTIAL future scenarios. Outside of software engineering, this principle is applicable to everyday […]

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

The Backend Communication Necessity: REST APIs

Introduction

APIs are the most important piece of communication between software applications. REST APIs, in particular, have emerged as the standard for building web services due to their simplicity and scalability. This blog by John Au-Yeung explores best practices for efficient REST APIs, a topic that is essential for modern software development.

Summary Of The Source

  1. Accept and Respond with JSON: JSON is the standard format for APIs due to its readability and compatibility with most programming languages.
  2. Use Nouns Instead of Verbs in Endpoint Paths: Resources should be represented as nouns in endpoint paths, such as /users or /orders, for clarity and consistency.
  3. Handle Errors Gracefully and Return Standard Error Codes: APIs should provide clear error messages and use appropriate status codes, like 404 for not found or 500 for server errors.
  4. Maintain Good Security Practices: Implement authentication methods such as OAuth, encrypt sensitive data, and use rate limiting to prevent abuse.
  5. Versioning Our APIs: Proper versioning, such as including the version in the URL (/v1/users), allows APIs to evolve without disrupting existing integrations.

Why I Chose This Blog

I selected this blog because REST APIs are integral to modern software development, and understanding their design is essential for building scalable and maintainable systems. The blog provides a good understanding of REST APIs for developers at all levels.

Reflection On The Blog

The blog went over the standards when designing REST APIs. One aspect that resonated with me was the emphasis on clarity and simplicity in API structure. For instance, using nouns like /users instead of verbs like /getUsers for endpoint paths. Another valuable takeaway was the focus on error handling and standard status codes. Before reading this, I hadn’t fully appreciated how critical it is to provide meaningful error responses to help developers debug issues. I now recognize how returning clear messages and consistent codes can improve the user experience and reduce confusion for developers. The section on API versioning was also particularly insightful, as I hadn’t previously considered how unversioned APIs could lead to breaking changes when updates are made. This made me realize the importance of planning for future iterations during the initial API design process.

Future Application

By adopting JSON as the default format and carefully designing resource-based endpoints, I aim to create APIs that are in line with all that standards laid out in this blog. I will also make sure to maintain good security practices, such as implementing authentication. Additionally, I will incorporate API versioning to ensure compatibility with older clients as updates are introduced.

Citation

Best practices for REST API design by John Au-Yeung

From the blog CS@Worcester – The Science of Computation by Adam Jacher and used with permission of the author. All other rights reserved by the author.

Whats that smell

Writing good clean code is a work of art that takes a lot of practice and understanding. One of the first practices you should use is what’s called design smells. Design smells are indicators of possible poor design principles that will eventually impact the quality of your project.

We’ve all had that point when we first started learning how to write code where we wrote some pretty ugly “spaghetti”  code. To start, the names of these smells are rigidity, fragility, immobility, viscosity, needless complexity, needless repetition and opacity. Most of these tend to go hand in hand or could stand alone. 

It’s good to know their meanings before talking about their importance.

Rigidity: when your software is difficult to change in even the simplest ways. 

Fragility: having a tendency for your program to break in other places when you make a change.

Immobility: having useful code that could be used in other systems, but can’t be integrated very easily

Viscosity: when it’s not easy to make only one change.

Needless complexity: containing things that don’t really have any use yet.

Needless repetition: repeated code that could be abstracted instead or written over and over.

Opacity: not visually clear.

While the use of being able to identify these design smells may be obvious to some. We will start with some examples before ending with why identifying these smells will be helpful in the long run.

When first starting a project sometimes it’s hard to know where to really start. That is why developers have tools such as class diagrams, but that is for another blog. Starting off with no real design in mind it’s easy to have needless repetition pop up. Once you’ve identified you can break certain things off and turn them into their own methods, you may also realize it has caused rigidity and fragility. Moving those lines might be much harder than you think. Those problems also lead into viscosity if you end up with a big enough mess (speaking from experience).

Next is the problem of needless complexity. Without having a class diagram you might find yourself jumping ahead to try and fix a problem or do something you don’t have a need for yet. The problem is exacerbated if you don’t end up needing it at all. No one likes useless code. This can lead to opacity when your code is making the goals and intents of your work unclear.

With the previously discussed class diagrams (see previous blog) to guide you. Along with an understanding of poor design principles it’s easy to see how being able to identify these smells can keep your work in much better shape for yourself and others. We have stuck with the design process for now, a future blog topic will cover how to make the code itself “cleaner”.

From the blog Mikes CS 343 by Michael St. Germain and used with permission of the author. All other rights reserved by the author.

API Endpoints, just so you know.

If you’re studying or working with Rest APIs, the chances of you running into endpoints are extremely high. I struggled a bit to wrap my head around them, so here’s a casual breakdown. It’s not as scary as it sounds.

What Are API Endpoints?

Let’s start with the basics. An API (Application Programming Interface) is like a menu at a restaurant(HOW MANY TIMES MUST I SAY THIS?). It tells you what’s available (services or data) and how to ask for it (requests). Endpoints are specific URLs on that menu where you go to get what you need.

Imagine you’re at a pizza place. You want to order a pizza with extra cheese and pepperoni. The endpoint is like the part of the menu that says, “Build Your Own Pizza.” It’s where your request (extra cheese, pepperoni) is processed and sent to the kitchen (server), and then your pizza (data) comes back to you.

In tech terms, an endpoint is a specific location on a server where an app interacts with the API to get or send information. For example:

https://api.pizzaplace.com/orders

Here, /orders is the endpoint where you place or check your pizza order.

How Do They Work?

Endpoints use URLs and HTTP methods to define what action you’re taking. These methods are the “verbs” of APIs:

  • GET: Asking, “What’s on the menu?” You’re retrieving information.
  • POST: Placing your pizza order. You’re creating something new.
  • PUT or PATCH: Updating your order, like adding mushrooms.
  • DELETE: Canceling your order. Sad day.

When your request hits the endpoint, the server processes it and sends back a response, often in JSON (an easy-to-read data format).

Why Do They Matter?

Endpoints make modern apps and websites possible. For instance, when you check Instagram, there’s an API endpoint fetching your posts. When you order on Amazon, there’s an endpoint processing your purchase. They’re everywhere!

Endpoints keep things organized. Instead of exposing a server’s entire functionality, APIs provide specific endpoints for specific actions. It’s like keeping the kitchen off-limits in a restaurant—you just see the front counter.

Real-World Example

Let’s say you’re building a library app. You might have API endpoints like these:

  • GET /books: Retrieve a list of all books.
  • GET /books/42: Get details about book #42.
  • POST /books: Add a new book.
  • DELETE /books/42: Remove book #42.

Each endpoint serves a purpose, and together they make the app functional.

Wrapping It Up

API endpoints are the way apps and servers talk to each other. They’re like doorways leading to the data and services you need. Understanding endpoints is crucial because they’re the foundation of so much of what we build. Whether you’re connecting a frontend to a backend or building your own API, endpoints are the unsung heroes of the digital world.

Next time someone mentions an “endpoint,” you’ll know it’s just a fancy name for a digital doorway.

References
https://www.geeksforgeeks.org/what-is-an-api-endpoint/
https://www.ibm.com/topics/api-endpoint

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

Best Practices of REST API Design

I chose the blog post, “Best Practices for REST API Design” by John Au-Yeung because it addresses the best practices developers should be following when it comes to utilizing REST API. The blog shows us strategies that we can use so we can create items to the best of our abilities. In class, we have been using the REST API since Thea’s Pantry utilizes it. Due to this, while we have been learning a lot about it due to classwork and homework, it was interesting to be able to read other perspectives such as this blog. This is really our first introduction in our computer science classes on design like this so the more we can read and learn the better.

In the blog, the author focuses on creating user-friendly APIs that adhere to widely accepted principles. The foundation of REST API design is using nouns in endpoints to represent resources, such as /users or /orders, rather than actions like /getUser. This approach keeps the API intuitive and aligns with REST conventions. HTTP methods play a vital role, with verbs like GET , POST , PUT , and DELETE defining the operations on these endpoints. The principle of statelessness is key to this design, meaning each request from a client must contain all the necessary information for the server to fulfill it. This avoids maintaining client-specific state on the server, simplifying scaling and debugging. Error handling is another essential practice. APIs should return meaningful and consistent HTTP status codes, such as 404 for “not found” or 400 for “bad request,” paired with descriptive error messages to guide users on fixing issues. For managing large datasets, pagination, filtering, and sorting should be supported. These features enhance performance by limiting the data returned and allowing clients to specify exactly what they need. APIs should adopt JSON as the standard response format, as it’s widely used and easy to parse. Including appropriate content-type headers ensures compatibility across platforms. These practices foster better user experiences, maintainability, and scalability. By following them, developers can create APIs that are reliable, predictable, and efficient, promoting successful integrations across diverse client applications.

From the blog, I was able to learn the best practices when it comes to designing using REST API. Going forward, I plan to incorporate these practices as I continue to learn more about front end work. After reading, I feel like I will be able to increase my learning in this area as well as be able to share these practices with my peers.

https://stackoverflow.blog/2020/03/02/best-practices-for-rest-api-design/

From the blog CS@Worcester – Giovanni Casiano – Software Development by Giovanni Casiano and used with permission of the author. All other rights reserved by the author.

Object Oriented Programming – Abstraction, Encapsulation, Polymorphism, and Inheritance

Within object oriented programming, there are four main pillars. These are known as abstraction, encapsulation, polymorphism, and inheritance. These four are essential in understanding object oriented programming and why it is important. While researching, I found a blog called “Encapsulation, Abstraction, Inheritance, and Polymorphism” by Cole Davis which I believe does a great job at explaining all four of the pillars as well as why they are important. I chose to write about this topic as I use object oriented programming all the time, and I plan to do it in the future. Because of this, I wanted to help share some information that I find to be very useful in understanding how it works in case anyone else wants to do the same.

Abstraction: One of the first major pillars you’ll learn about is known as abstraction. Cole Davis does a great job at explaining this pillar, as shown in a quote from his blog: “Abstraction is the process of combining many functions into one. Think of a thermostat. Typically, a thermostat allows the user to change the target temperature, select different modes such as heating, cooling, or fan, and turn the unit on or off. When we use a thermostat, we are unaware of the intricacies that create these functionalities under the hood. By exposing only the necessary abstracted functions to the user, we make it easier for the user to use our programs.” I really enjoyed reading this example as it relates abstraction to real-life terms instead of just using coding terms, making it a lot easier to understand. Essentially, abstraction does the same thing. It makes our code easier to understand, allowing others to get a high-level understanding of our program.

Encapsulation: The second main pillar is known as encapsulation. Encapsulation is the idea of hiding and restricting access to the implementation details of our objects. Basically, this protects the data and functions of our code from being improperly accessed by things other than our objects. It makes our code more robust and predictable, allowing others to see its purpose more clearly. Another major benefit of encapsulation is it allows us to see precisely where we can change implementation details, allowing us to safely change our program.

Inheritance: The third main pillar is known as inheritance. According to the blog “Inheritance is a technique that involves a child class “inheriting” functionality from a parent or super class.” This increases usability in our code as well as stops it from being redundant.

Polymorphism: The four main pillar is known as polymorphism. Polymorphism is a hard one to explain, but its very easy to show. Essentially, it is when child classes run the same inherited method that returns different values. They use the same method, but can return different values based on what they do. Polymorphism allows us to have a more dynamic inheritance, which enables us to use inheritance more for its values that it provides.

Link: https://medium.com/@colebuildanddevelop/encapsulation-abstraction-inheritance-and-polymorphism-26aa98042d41

From the blog CS@Worcester – One pixel at a time by gizmo10203 and used with permission of the author. All other rights reserved by the author.

Exploring REST API Implementation

In this blog, I’ll talk about the process of implementing REST APIs, their significance, and the key considerations for building good APIs. REST API implementation involves creating a structured interface for applications to interact with. Using HTTP methods like GET, POST, PUT, DELETE, and PATCH, REST APIs facilitate operations on resources. These resources are typically represented as URLs for example /users, /products, and the interactions follow stateless communication principles where each request is independent and self-contained. A simple example of a REST API might include GET /users: Retrieve a list of users. POST /users: Create a new user. PUT /users/{id}: Update details of a user with a specific ID. DELETE /users/{id}: Remove a user. It’s important to know why REST API implementation is important.Communication. REST APIs provide a consistent framework for systems to interact, regardless of their underlying technologies. This universality enables integration across diverse applications and platforms. Scalability and Performance.REST APIs are designed to scale easily, as their statelessness allows servers to handle multiple requests without maintaining client-specific sessions. This makes REST ideal for cloud-based applications. Business Value
Exposing services through REST APIs enables businesses to monetize their platforms by integrating with third-party applications or creating ecosystems like app marketplaces.

Some key steps in implementing REST APIs include Defining Resources and Endpoints. Identify the data and operations required by the API. For example, a library system might need endpoints like /books, /authors, and /borrowers. Choose the Right Tools
Use frameworks like Express.js (Node.js), Django (Python), or Spring Boot (Java) to streamline development. Ensure Proper Security.Implement authentication and authorization mechanisms like OAuth, API keys, or JWT to protect sensitive data. Document the API. Tools like Swagger can help generate comprehensive, developer-friendly documentation. Test and optimize.
Use automated testing tools to verify functionality, and monitor performance to identify bottlenecks. Some of the best practices for building REST APIs include Designing clean and meaningful resource URLs. Properly utilizing HTTP methods for specific actions. Using status codes to convey response status and errors. Implementing authentication and authorization mechanisms. I chose this topic because it talks about different aspects of implementing REST APIs. In conclusion, by understanding the key principles and specifications of REST APIs, developers can design APIs that facilitate seamless communication between clients and servers.

References.https://medium.com/@zappy_cordovan_shark_864/exploring-restful-apis-building-implementing-and-best-practices-4003a19df798

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

Specifying Rest Api Calls

In the world of modern software development, rest API’s enable seamless communication between systems, services and applications. Specifying REST API calls is equally important for ensuring clarity, functionality, and integration efficiency. Rest APIs provide a way for two applications to communicate, which enables your software to interact efficiently with various other services, thereby enhancing its capabilities and user experience. Rest APIs work by fielding requests for a resource and returning all relevant information about the resource, that is translated into a format that clients can easily interpret. Clients can also modify items on the server and even add new items to the server through a REST API. The six rules of REST APIs include client-server separation. The client sends a request to the server, then the server sends a response back to the client. Servers cannot make requests and clients cannot respond, and all interactions are initiated by the client. The second rule is uniform interface where all requests and all responses must follow a common protocol, or a way of formatting their messages. The third rule is stateless which means that every interaction is independent, and each request provides all the information required to complete the interaction. One important thing we need to understand is why use REST APIs. Rest APIs are flexible where they can handle many types of requests and send data in many different formats. Rest APIs are scalable. They are designed for communication between any two pieces of software, regardless of size.

Benefits of REST APIs help systems and applications communicate with each other. They are simple to use and implement. You can scale REST APIs easily and this is because they are stateless, meaning each request from a client has all the information your server will need to fulfil it. There are a few different types of APIs. One is private APIs.These are internal to an enterprise and only used for connecting systems and data within the business.Public APIs 

These are open to the public and may be used by anyone. There may or not be some authorization and cost associated with these types of APIs. Partner APIs.These are only accessible by authorized external developers to aid business-to-business partnerships. Composite APIs. These combine two or more different APIs to address complex system requirements or behaviors. Some of the steps to create an API are plan the API, build the API, test the API, document the API, and then market the API. I chose these resources because they explain REST APIs in more detail and how they are used in the real world.

References.

https://aws.amazon.com/what-is/api/

https://blog.hubspot.com/website/what-is-rest-api

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

Exploring FrontEnd

Front end development, often described as the face of a web application, plays a crucial role in shaping how users perceive and interact with digital platforms. Front end development basically creates the user interface (how the website looks like) of a website. Users directly see and interact with buttons, menus, text, and images, making it crucial for delivering a positive user experience and influencing how people perceive a digital product. This is important because it directly impacts user engagement, and overall website functionality by ensuring it is visually appealing. Some of the key points about front-end development are focusing on user interface. Developers primarily focus on creating the visual layout and design of the website, including how users interact with them. Another key point is core technologies. The primary languages used in front-end development are HTML (for structuring content), CSS (for styling elements), and JavaScript (for adding interactivity). I think it’s also important to know some key differences between software development in the front end and back end. Backend development is the process of building the components for running the application behind the scenes. Some examples are components for data storage, infrastructure, and code written in one or more programming languages. Users can’t access the back end. Front-end development is the process of building components that interact with users. Examples are the user interface, buttons, user-entered data, websites, and user experience (UX) features. The front end aims at meeting user requirements and delivering a positive user experience.

Pros of front-end development include improved user experience where websites are well crafted, functional, and visually appealing on any device and this attracts more users. Low maintenance cost where you can have websites that work seamlessly across all devices. Faster web pages that optimize your website’s performance, ensuring fast experience across all devices. Some cons of Front-End Developmentare Steep Learning Curve. With numerous tools, frameworks, and libraries available, staying updated can be overwhelming. Browser Compatibility Issues. Ensuring a site works seamlessly across multiple browsers and devices can be tedious. Rapidly Changing Technology. The fast pace of technological advancements requires constant learning, which can be challenging for developers. I chose this article because it goes further into detail about what we talked about in class. It talks about front end development in depth. In conclusion, front end development is an essential aspect of modern web and application development. It’s rewards in terms of user engagement, satisfaction, make it an exciting field.

References.https://cloudinary.com/guides/front-end-development/front-end-development-the-complete-guide

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

Adaptable Web Designs

I chose the blog post, “Designing for the Unexpected” by Cathy Dutton because it addresses how one can create designs that can combat unexpected content changes. The blog shows us strategies that we can use so we don’t get stuck in situations like this. On my own time, I have been learning how to create in the web design space so that was one of the main factors when choosing this blog. This is what led me to choose this blog post, so I can learn how to not make mistakes and so I can follow the strategies laid out to design in the most efficient way possible.

In the blog, Dutton explores strategies for creating adaptable web designs that accommodate unforeseen content changes and evolving device landscapes. She reflected on the evolution from fixed-width designs to responsive layouts, emphasizing the necessity of planning for flexibility from the outset. Dutton recounts her early experiences with web design, and  highlights the challenges of transitioning to responsive design, noting that it requires comprehensive planning during the design phase rather than being an afterthought. To implement responsive designs, Dutton initially utilized percentage-based layouts with native CSS and utility classes, later incorporating Sass for reusable code and more semantic markup. Media queries played a crucial role in this process, allowing designs to adapt at specific breakpoints to maintain readability across different screen sizes. However, she observed that this method often necessitated complex markup, posing challenges for content management, especially for users without extensive HTML knowledge. Dutton introduces the concept of intrinsic design, a term coined by Jen Simmons, which leverages new and existing CSS features to create layouts that respond organically to content and available space. This approach employs the ‘fr’ unit to distribute space flexibly without compromising content legibility, enabling designs to adapt dynamically to varying content and container sizes. Intrinsic design moves beyond predefined breakpoints, fostering components that are inherently responsive. The article also discusses the limitations of relying solely on frameworks like Bootstrap for responsive design. Dutton emphasizes the importance of designing for diverse user contexts, acknowledging that users interact with websites across various environments and devices. By adopting flexible design principles and focusing on content adaptability, designers can create resilient and future-proof web experiences that cater to unforeseen changes and diverse user needs. The blog advocates for a shift towards intrinsic design methodologies that prioritize content flexibility and responsiveness. By embracing CSS advancements and moving beyond rigid frameworks, designers can craft web experiences that gracefully adapt to the unpredictable nature of content and device evolution.

From the blog, I was able to learn the best strategies when it comes to designing an adaptable web interface. Going forward, I plan to incorporate these strategies as I continue to learn more about designing web pages. After reading, I feel like I will be able to increase my learning in this area as well as be able to share these strategies with my peers.

https://alistapart.com/article/designing-for-the-unexpected/

From the blog CS@Worcester – Giovanni Casiano – Software Development by Giovanni Casiano and used with permission of the author. All other rights reserved by the author.