Aspect Oriented Programming (AOP) is a very powerful approach to avoid boilerplate code and archive better modularity. The main idea is to add behavior (advice) to the existing code without making any changes in the code itself. AOP provides a way of weaving an aspect into the code. An aspect is supposed to be generic so it can be applied to any object and an object should not have to know anything about advice. AOP allows the developer to separate cross-cutting concerns and makes it easier to follow the Single Responsibility Principle (one of the SOLID principles). Logging, security, transactions, and exception handling are the most common examples of using AOP. If you are not familiar with this programming technique you can read this or this. Don’t be scared if you still do not understand what it’s all about. After looking at several examples, it becomes much easier to understand.
In Java, AOP is implemented in the AspectJ and Spring frameworks. There are PostSharp (not free), NConcern, and some other frameworks (not very popular or easy to use) to do almost the same stuff in.NET.
It has always been fun to play with C#. In this post, we will see that how we can create a list of objects with a different approach. So the scenario is, for one of my MVC applications I need to bind the 5 empty rows (a list of 5 objects) to the kendo grid for a bulk insert of the records. So whenever I open that page, kendo grid renders 5 empty rows in editable mode.
In this post, for a better illustration, I have used the example of “Book." Let’s say I want to add multiple books to one library management software. First, let’s create one basic POCO class – Book – with some properties, which looks like the following:
1. Safe Navigation Operator ( ? Operator):
The ? operator was introduced with .NET 2.0, with the nullable types that allow variables to have null as a value or to not have one at all. We can test it with the HasValue property.In C# 6, Microsoft added a new feature to this operator (?) called safe navigation operator.
It’s so simple and so useful, let me explain it with an example. We access a child property or method via the navigation operator “." but if you try to navigate into a null variable you will have the famous NullReferenceException. So we must test before accessing or calling any method on this object like this :
Microsoft .NET Core is a cross-platform, open source software development framework that can be used to build applications for mobile, Windows, and the web. You can learn more about .NET Core here, but in this blog post, we’ll walk you through how to create and publish a .NET Core application for Windows.
To work with .NET Core, first, you need to install it from here. While you can use any IDE to create a .NET Core application, I am going to use the Visual Studio 2017 Enterprise version. If you do not have Visual Studio installed, you may want to try the community edition, which can be found for free here. Once the environment is set, launch Visual Studio and create a new project by selecting File->New Project-> Visual C#-> .NET Core-> Console App. Besides C#, a .NET Core application can be used in other languages, like Visual Basic.
It is a common situation that complex objects need to be compared. Sometimes objects can contain nested elements, or some members should be excluded from the comparison (auto-generated identifiers, create/update date etc.), or some members can have custom comparison rules (same data in different formats, like phone numbers). This small framework was developed to solve these kinds of problems.
Briefly, Objects Comparer is an object-to-object comparer, which allows the developer to compare objects recursively, member-by-member, and define custom comparison rules for certain properties, fields, or types.
Most of my articles are about WebDriver. Today, I am going to write about a common problem that people usually hit. Have you experienced this? Your tests finish and then all of a sudden, the browser is still opened? The next time you try to clean the build folder, you cannot because the current driver’s EXE is still in use. Such a pity. From now on, your builds start failing. Many people complain about the flakiness of WebDriver, and this is one of the reasons. Here, I am going to propose to you a solution: As they say in Mortal Kombat, “Finish Him!" (kill all of the processes).
Test C# Code
Once again, I will use one of my favorite test pages: Bing. Below, you can find the page object that we will use in the tests.
Every Wednesday, new courses and workshops are added to the growing Treehouse Library! Read more about the two new courses added this week and get the scoop on what’s coming later this month. Start learning to code today with your free trial on…
The post What’s New at Treehouse: Bootstrap 4 & ASP.NET appeared first on Treehouse Blog.
If you are a developer in the Microsoft environment and if you’re developing desktop apps, it’s likely that you’ve read something about Prism. If you don’t, then this is what Prism is about:
Prism is a framework for building loosely coupled, maintainable, and testable XAML applications in WPF, Windows 10 UWP, and Xamarin Forms. (from the Prism’s Official GitHub description)
Every Wednesday, new courses and workshops are added to the growing Treehouse Library! Here’s a quick list of what’s been added this week, what’s coming soon, and our weekly video update on What’s New at Treehouse. COURSES Introduction to Xamarin – Heath Hodgert (110 minutes)…
The post New & Upcoming Course Highlights: Introduction to Xamarin & CSS Grid Layout appeared first on Treehouse Blog.