Maybe you’re wondering what a “web operating system" is? In order to explain that, we must take a look at a traditional operating system’s primary functions. The main task of an operating system is to provide a uniform way to access the underlying hardware, with the goal of simplifying the creation of applications. Hence, the "kernel" in an operating system, becomes an API which the developer can consume, to transparently access the underlying hardware of the machine. This is often referred to as "HAL," implying "Hardware Abstraction Layer."
An operating system also contains other functions – but the primary goal is to simplify the creation of apps for the end application developer, by abstracting away the "boring stuff," and making everything easier to use from an application development point of view.
Three years ago, I wrote how to create a filter using a Builder design pattern and passing that expression into a query to return results.
This post was production code and is currently providing search results as we speak.
I have previously written about how to, effectively, subclass using NSubstitute; in this post, I’ll cover how to partially mock out that class.
Before I get into the solution, what follows is a workaround to allow badly written or legacy code to be tested without refactoring. If you’re reading this and thinking you need this solution then my suggestion would be to refactor and use some form of dependency injection. However, for various reasons, that’s not always possible (hence this post).
One of the things that is very different when you move to ASP.NET Core is the way that configuration files are treated. This partly comes from the drive to move things that are not configuration out of configuration files. It looks like the days of app.config and web.config are numbered and, in their place, we have AppSettings.Json. Here’s an example of what that new file might look like:
The old files were very flat and, using the configuration manager, you could simply read a setting; something like this:
With the Repository pattern, we can create an abstraction layer between the data access and the business logic layer of an application. By using it, we are promoting a more loosely coupled approach to access our data from the database. Also, the code is cleaner and easier to maintain and reuse. Data access logic is in a separate class, or sets of classes called a repository, with the responsibility of persisting the application’s business model.
Implementing the repository pattern is our topic for this post.
C# 7.0 introduces ref returns and ref locals. The main goal of these new features is to make it easier for developers to pass around references to value types instead of copies of their values. This is important when working with large data structures that are implemented as value types. This blog post shows how to use ref returns and ref locals in C#.
Current Ref and Out Arguments
We can use ref and out arguments to send some variables to the method and let it modify the value of this method. This way we can write methods that “return” more than one value. Ref lets the value type in by reference. Out means that the variable will get a value in the method where it is given as an argument.
As we all know, strings are immutable, because, after a string is stored in the memory, the memory, which is allocated for the string, cannot change.
If the string changed, a new memory location is needed to store the changed string. In these circumstances, we use the StringBuilder class with a string type.
One of the most popular programming languages on the market is getting even better. With every iteration of C#, we get more and more features that are meant to make our lives as developers a lot easier. Support for writing (hopefully) better and more readable asynchronous code, being able to do pattern matching, tuples, deconstruction, and much more. These are just a few of the many additions to C# that we’ve seen lately. In this talk, I go through how C# has changed, as well as focusing on what’s coming in C# 7.1, 7.2, 8.0, and beyond!
If you’re reading this article, you’ve either decided to learn to code this year as a complete beginner or maybe you’re already a programmer and want to expand your skill set. Either way, you’re likely familiar with the reasons why learning…
The post The Top 5 Programming Languages to Learn This Year appeared first on Treehouse Blog.