ProgrammingPro #5: OpenLLaMA, Mojo AI Programming Language, Software Architecture Tutorial
Hi,
Hello and welcome to another issue of the ProgrammingPro! In this newsletter, we detail the most relevant industry insights, actionable tutorials, and useful tools and resources for developers and software engineers.
In today’s issue:
News and Analysis
Secret Knowledge: Articles & Trending Repos
Dev Advice & Inside Stories
Architecture Tutorial: How Does C# Deal with Code Reuse
My promise with this newsletter is to act as your personal assistant and help you navigate and keep up-to-date with what's happening in the world of software development. What did you think of today's newsletter? Please consider taking the short survey below to share your thoughts and you will get a free PDF of the “Flutter Projects” eBook upon completion.
Thanks for reading.
Until next time!
Kartikey Pandey
Editor-in-Chief
Complete the Survey. Get a Packt eBook for Free!
🚀 News and Analysis
Mojo - New Programming Language for AI: Mojo is a new programming language for AI, based on Python, which fixes Python’s performance and deployment problems. Mojo combines the usability of Python with the performance of C. With Mojo, you can unlock programmability of AI hardware and extensibility of AI models.
Angular 16 Now Released: This is Angular’s biggest release since the initial rollout of Angular; making large leaps in reactivity, server-side rendering, and tooling.
GCC 13 Release Supports for C++ 23 and Go 1.18: GCC 13 implements a number of C++ 13 features including labels at the end of compound statements, support for #warning, and delimited escape sequences. GCC 13 offers a complete implementation of Go 1.18 user packages.
Rueidis 1.0 - A Fast Redis Client with Caching: Endorsed to now be in the official Redis GitHub org at least, this is a Redis client focused on performance with auto-pipelining of non blocking commands, client-side caching implemented in the preferred way, and support for Redis’s official extensions. The only tricky part is how to pronounce ‘Rueidis’.
Language Popularity by GitHub Pull Requests: Analysis on GitHub pull requests and ranked by language. Together Python and JavaScript make up nearly 40% of all activity on GitHub.
Python 3.12 - Faster, Leaner, Future-Proof: At PyCon 2023, held in Salt Lake City, Utah, several talks highlighted Python's future as a faster and more efficient language. Python 3.12 will showcase many of those improvements. TL;DR is that improvements to the next (and future) versions of Python are set to speed it up, slim it down, and pave the way toward even better things.
What’s New for Developers in Chrome 113: Chrome 113 introduces WebGPU, which allows for high-performance 3D graphics and data-parallel computation on the web. Devtools can now override network response headers. Chrome 113 also brings an unprefixed image-set type, new media features, and an origin trial for WebGPU WebCodecs integration.
Secret Knowledge: Articles & Trending Repos
OpenLLaMA - An Open Reproduction of LLaMA: OpenLLaMA is a permissively licensed open source reproduction of Meta AI's LLaMA large language model.
wazero 1.1 - Zero Dependency WebAssembly Runtime in Go: Embed wazero in your Go project and extend any app. v1.1 improves debugging, reduces memory usage and adds new APIs for advanced use cases.
griptape: A modular Python framework for LLM workflows, tools, memory, and data. griptape can be used to build sequential LLM pipelines and sprawling DAG workflows, augment LLMs with chain of thought capabilities and external tools, and add memory to AI pipelines.
Tempo: Tempo allows you to easily build & consume low-latency, cross-platform, and fully typesafe APIs.
Graph 0.20 - Generic Library for Creating Graph Data Structures: Graph supports different kinds of graphs such as directed graphs, acyclic graphs, or trees. It’s basically a library for creating generic graph data structures and modifying, analyzing, and visualizing them.
Dev Advice & Inside Stories
Rules of Thumb for Software Development Estimations: Software estimation is the bane of many developers’ existence and the scourge of project managers everywhere. While estimates can never be perfect, the article explains ways to refine estimates to the benefit of the team and stakeholders.
Cohesion in Simple Terms: Modularity is a must for good software design. It helps with extensibility, readability, maintainability, and more. It certainly isn’t easy to make your code modular, but what exactly is modularity, and how do we measure it?
Software Engineering Promotions - How to Increase Your Chances of Getting to the Next Level: Most developers will have their sights set on a promotion. Whether it be that coveted Senior title or the Staff and Principal levels, there is always something to aim for. This article shares a structured approach that you can take to increase your chances of a promotion.
Managing Complex Organizational Change: Guiding your team through organizational change isn’t straightforward. Especially in times of drastic organization changes, it’s important to help your team navigate through the tides. This article examines some of the ways to can employ to streamline the change process.
Software Architecture
Tutorial: How Does C# Deal with Code Reuse
There are many approaches where C# helps us deal with code reuse. The ability to build libraries, as we did in the previous section, is one of them. One of the most important ones is the fact that the language is object-oriented. Besides, it is worth mentioning the facilities that generics brought to the C# language. This tutorial discusses the last two mentioned.
Object-oriented analysis
The object-oriented analysis approach gives us the ability to reuse code in different ways, from the facility of inheritance to the changeability of polymorphism. Complete adoption of object-oriented programming will let you implement abstraction and encapsulation too.
The following diagram shows how using the object-oriented approach makes reuse easier. As you can see, there are different ways to calculate the grades of an evaluation, considering you can be a basic or a prime user of the system:
There are two aspects to be analyzed as code reuse in this design. The first is that there is no need to declare the properties in each child class since inheritance is doing it for you.
The second is the opportunity to use polymorphism, enabling different behaviors for the same method:
public class PrimeUsersEvaluation : Evaluation
{
/// <summary>
/// The business rule implemented here indicates that grades that
/// came from prime users have 20% of increase
/// </summary>
/// <returns>the final grade from a prime user</returns>
public override double CalculateGrade()
{
return Grade * 1.2;
}
}
In the preceding code, you can see the usage of the polymorphism principle, where the calculation of evaluation for prime users will increase by 20%. Now, look at how easy it is to call different objects inherited by the same class. Since the collection content implements the same interface, IContentEvaluated, it can have basic and prime users too:
public class EvaluationService
{
public IContentEvaluated Content { get; set; }
/// <summary>
/// No matter the Evaluation, the calculation will always get
/// values from the method CalculateGrade
/// </summary>
/// <returns>The average of the grade from Evaluations</returns>
public double CalculateEvaluationAverage()
{
return Content.Evaluations
.Select(x => x.CalculateGrade())
.Average();
}
}
Object-oriented adoption can be considered mandatory when using C#. However, more specific usage will need study and practice. You, as a software architect, should always incentivize your team to study object-oriented analysis. The more abstraction abilities they have, the easier code reuse will become.
Generics
Generics were introduced in C# in version 2.0, and it is considered an approach that increases code reuse. It also maximizes type safety and performance.
The basic principle of generics is that you can define in an interface, class, method, property, event, or even a delegate, a placeholder that will be replaced with a specific type later when one of the preceding entities is used. The opportunity you have with this feature is incredible since you can use the same code to run different versions of the type, generically.
The following code is a modification of EvaluationService, which was presented in the previous section. The idea here is to enable the generalization of the service, giving us the opportunity to define the goal of evaluation since its creation:
public class EvaluationService<T> where T: IContentEvaluated, new()
This declaration indicates that any class that implements the IContentEvaluated interface can be used for this service. The new constraint indicates this class must have a public parameter-less default constructor.
Besides, the service will be responsible for creating the evaluated content.
public EvaluationService()
{
var name = GetTypeOfEvaluation();
content = new T();
}
It is worth mentioning that this code will work because all the classes are in the same assembly. The result of this modification can be checked in the instance creation of the service:
var service = new EvaluationService<CityEvaluation>();
The good news is that, now, you have a generic service that will automatically instantiate the list object with the evaluations of the content you need. It’s worth mentioning that generics will obviously need more time dedicated to the first project’s construction. However, once the design is done, you will have good, fast, and easy-to-maintain code. This is what we call reuse!
This tutorial is an extract from the book Software Architecture with C# 10 and .NET 6 - Third Edition written by Gabriel Baptista, Francesco Abbruzzese and published by Packt Publishing in March 2022.


