Pull to refresh

Development

Show first
  • New
  • Top
Rating limit
  • All
  • ≥0
  • ≥10
  • ≥25
  • ≥50
  • ≥100

The architecture of an exceptional situation: pt.2 of 4

Seminars by Stanislav Sidristy corporate blog Programming *.NET *C# *

I guess one of the most important issues in this topic is building an exception handling architecture in your application. This is interesting for many reasons. And the main reason, I think, is an apparent simplicity, which you don’t always know what to do with. All the basic constructs such as IEnumerable, IDisposable, IObservable, etc. have this property and use it everywhere. On the one hand, their simplicity tempts to use these constructs in different situations. On the other hand, they are full of traps which you might not get out. It is possible that looking at the amount of information we will cover you’ve got a question: what is so special about exceptional situations?


However, to make conclusions about building the architecture of exception classes we should learn some details about their classification. Because before building a system of types that would be clear for the user of code, a programmer should determine when to choose the type of error and when to catch or skip exceptions. So, let’s classify the exceptional situations (not the types of exceptions) based on various features.

Read more →
Total votes 10: ↑9 and ↓1 +8
Views 1.1K
Comments 0

WAF through the eyes of hackers

Digital Security corporate blog Information Security *
Today we’re going to talk about one of the modern security mechanism for web applications, namely Web Application Firewall (WAF). We’ll discuss modern WAFs and what they are based on, as well as bypass techniques, how to use them, and why you should never entirely rely on WAF. We’re speaking from the pentesters’ perspective; we’ve never developed WAFs and only collected data from open sources. Thus, we can only refer to our own experience and may be unaware of some peculiarities of WAFs.
Read more →
Total votes 13: ↑9 and ↓4 +5
Views 25K
Comments 0

Let's help QueryProvider deal with interpolated strings

Website development *Programming *.NET *Designing and refactoring *C# *
Translation

Specifics of QueryProvider


QueryProvider can’t deal with this:


var result = _context.Humans
                      .Select(x => $"Name: {x.Name}  Age: {x.Age}")
                      .Where(x => x != "")
                      .ToList();

It can’t deal with any sentence using an interpolated string, but it’ll easily deal with this:


var result = _context.Humans
                      .Select(x => "Name " +  x.Name + " Age " + x.Age)
                      .Where(x => x != "")
                      .ToList();

The most painful thing is to fix bugs after turning on ClientEvaluation (exception for client-side calculation), since all Automapper profiles should be strictly analyzed for interpolation. Let’s find out what’s what and propose our solution to the problem.

Read more →
Total votes 12: ↑11 and ↓1 +10
Views 1.2K
Comments 0

Support of Visual Studio 2019 in PVS-Studio

PVS-Studio corporate blog .NET *Visual Studio *C# *Development for Windows *


Support of Visual Studio 2019 in PVS-Studio affected a number of components: the plugin itself, the command-line analyzer, the cores of the C++ and C# analyzers, and a few utilities. In this article, I will briefly explain what problems we encountered when implementing support of the IDE and how we addressed them.
Read more →
Total votes 31: ↑30 and ↓1 +29
Views 824
Comments 0

Various things in MetaPost

LaTeX *
Translation
What is the best tool to use for drawing vector pictures? For me and probably for many others, the answer is pretty obvious: Illustrator, or, maybe, Inkscape. At least that's what I thought when I was asked to draw about eight hundred diagrams for a physics textbook. Nothing exceptional, just a bunch of black and white illustrations with spheres, springs, pulleys, lenses and so on. By that time it was already known that the book was going to be made in LaTeX and I was given a number of MS Word documents with embedded images. Some of them were scanned pictures from other books, some were pencil drawings. Picturing days and nights of inkscaping this stuff made me feel dizzy, so soon I found myself fantasizing about a more automated solution. For some reason MetaPost became the focus of these fantasies.



Read more →
Total votes 16: ↑15 and ↓1 +14
Views 9.2K
Comments 0

Exceptional situations: part 1 of 4

Seminars by Stanislav Sidristy corporate blog Programming *.NET *C# *


Introduction


It’s time to talk about exceptions or, rather, exceptional situations. Before we start, let’s look at the definition. What is an exceptional situation?


This is a situation that makes the execution of current or subsequent code incorrect. I mean different from how it was designed or intended. Such a situation compromises the integrity of an application or its part, e.g. an object. It brings the application into an extraordinary or exceptional state.


But why do we need to define this terminology? Because it will keep us in some boundaries. If we don’t follow the terminology, we can get too far from a designed concept which may result in many ambiguous situations. Let’s see some practical examples:


 struct Number
 {
     public static Number Parse(string source)
     {
         // ...
         if(!parsed)
         {
             throw new ParsingException();
         }
         // ...
     }

     public static bool TryParse(string source, out Number result)
     {
        // ..
        return parsed;
     }
 }

This example seems a little strange, and it is for a reason. I made this code slightly artificial to show the importance of problems appearing in it. First, let’s look at the Parse method. Why should it throw an exception?

Read more →
Total votes 27: ↑26 and ↓1 +25
Views 1.8K
Comments 2

Indexes in PostgreSQL — 9 (BRIN)

Postgres Professional corporate blog PostgreSQL *SQL *
Translation
In the previous articles we discussed PostgreSQL indexing engine, the interface of access methods, and the following methods: hash indexes, B-trees, GiST, SP-GiST, GIN, and RUM. The topic of this article is BRIN indexes.

BRIN


General concept


Unlike indexes with which we've already got acquainted, the idea of BRIN is to avoid looking through definitely unsuited rows rather than quickly find the matching ones. This is always an inaccurate index: it does not contain TIDs of table rows at all.

Simplistically, BRIN works fine for columns where values correlate with their physical location in the table. In other words, if a query without ORDER BY clause returns the column values virtually in the increasing or decreasing order (and there are no indexes on that column).

This access method was created in scope of Axle, the European project for extremely large analytical databases, with an eye on tables that are several terabyte or dozens of terabytes large. An important feature of BRIN that enables us to create indexes on such tables is a small size and minimal overhead costs of maintenance.

This works as follows. The table is split into ranges that are several pages large (or several blocks large, which is the same) — hence the name: Block Range Index, BRIN. The index stores summary information on the data in each range. As a rule, this is the minimal and maximal values, but it happens to be different, as shown further. Assume that a query is performed that contains the condition for a column; if the sought values do not get into the interval, the whole range can be skipped; but if they do get, all rows in all blocks will have to be looked through to choose the matching ones among them.

It will not be a mistake to treat BRIN not as an index, but as an accelerator of sequential scan. We can regard BRIN as an alternative to partitioning if we consider each range as a «virtual» partition.

Now let's discuss the structure of the index in more detail.
Read more →
Total votes 14: ↑14 and ↓0 +14
Views 6.2K
Comments 0

Should array length be stored into a local variable in C#?

.NET *C# *
Translation
I notice that people often use construction like this:

var length = array.Length;
for (int i = 0; i < length; i++) {
    //do smth
}

They think that having a call to the Array.Length on each iteration will make CLR to take more time to execute the code. To avoid it they store the length value in a local variable.
Let’s find out (once and for all !) if this is a viable thing or using a temporary variable is a waste of time.
Read more →
Total votes 13: ↑13 and ↓0 +13
Views 16K
Comments 0

Artificial neural networks explained in simple words

Machine learning *Popular science Artificial Intelligence Brain
image

When I used to start a conversation about neural networks over a bottle of beer, people were casting glances at me of what seemed to be fear; they grew sad, sometimes with their eyelid twitching. In rare cases, they were even eager to take refuge under the table. Why? These networks are simple and instinctive, actually. Yes, believe me, they are! Just let me prove this is true!


Suppose there are two things I’m aware of about the girl: she looks pretty to my taste or not, and I have lots to talk about with her or I haven’t. True and false will be one and zero respectively. We’ll take similar principle for appearance. The question is: “What girl I’ll fall in love with, and why?”


We also can think it straight and uncompromisingly: “If she looks pretty and there’s plenty to talk about, then I will fall in love. If neither is true, then I quit”.


But what if I like the lady but there’s nothing to talk about with her? Or vice versa?

Read more →
Total votes 13: ↑11 and ↓2 +9
Views 3.1K
Comments 0

Open source tool for intent-based search quality validation

IT systems testing *Development for e-commerce *Search engine optimization
No matter how cool your search solution is, without a reliable way of testing it you will not be able to do any improvement without breaking something valuable.

Even a tiny increase in overall search result quality might have a noticeable effect on conversion rate. Naturally, you can use exit-rate to judge if your search needs improvements and do required adjustments, but will you be able to make sure those changes are safe? What if improved relevancy for a specific category breaks search for several other categories?

image

Moreover, high exit-rate means no matter what you are going to do, the problem has taken place, so dozens of customers already didn’t manage to find what they were up to. Basically, the only way to proceed is to have a reliable search quality validation approach.
Read more →
Total votes 7: ↑6 and ↓1 +5
Views 543
Comments 0

Microsoft Edge for macOS

Microsoft corporate blog Development for MacOS *Browsers Microsoft Edge

Last month, we announced the first preview builds of the next version of Microsoft Edge for Windows 10. Today, we are pleased to announce the availability of the Microsoft Edge Canary channel for macOS. You can now install preview builds from the Microsoft Edge Insider site for your macOS or Windows 10 PC, with more Windows version support coming soon.


Снимок экрана Microsoft Edge для macOS

Read more →
Total votes 13: ↑11 and ↓2 +9
Views 1.4K
Comments 1

DynamicData: Dynamic Collections, the MVVM Architecture, and Reactive Extensions

Programming *.NET *C# *Development for Windows *
Translation


February 2019 marked the release of ReactiveUI 9 — the cross-platform framework for building GUI applications on the Microsoft .NET platform. ReactiveUI is a tool for tight integration of reactive extensions with the MVVM design pattern. You could familiarize yourself with the framework via a series of videos or the welcome page of the documentation. The ReactiveUI 9 update includes numerous fixes and improvements, but probably the most crucial and interesting one is integration with the DynamicData framework, allowing you to work with dynamic collections in Reactive fashion. Let’s find out what we can use DynamicData for and how this powerful reactive framework works under the hood!

Read more →
Total votes 14: ↑12 and ↓2 +10
Views 11K
Comments 2

Rebuilding an icon: a call for the sharing of open data to help restore Notre-Dame

Microsoft corporate blog Open source *

Since its completion more than 675 years ago, the medieval cathedral of Notre-Dame has captivated millions of people with its incomparable beauty. From its legendary stained glass rose window to its towering spire, it’s widely regarded as one of the most stunning examples of medieval architecture in history.


Read more →
Total votes 10: ↑8 and ↓2 +6
Views 479
Comments 0

Xamarin API Docs: Open Sourced and Available Now

Microsoft corporate blog Development for iOS *Development of mobile applications *API *Xamarin *

Today, we are happy to announce the release of all Xamarin API Documentation as Open Source! API documentation drives the IntelliSense experience while being one of the best ways to help developers achieve their goals.


Xamarin API Docs


Additionally, we have also moved the hosting of the following from their old Xamarin home to docs.microsoft.com:


Read more →
Total votes 8: ↑8 and ↓0 +8
Views 611
Comments 0

Signing into Azure DevOps using your GitHub credentials

Microsoft corporate blog Cloud computing *Microsoft Azure DevOps *Cloud services

Across all of Microsoft, we are focusing on empowering developers to build better apps, faster. One way we are accomplishing that is by providing a range of products and services covering all stages of the software development lifecycle. This includes IDEs and DevOps tools, application and data platforms on the cloud, operating systems, Artificial Intelligence and IoT solutions, and more. All of these are centered around developers, both as individuals working in teams and organizations, and as members of developer communities.


GitHub is one of the largest developer communities, and for millions of developers around the world their GitHub identity has become a critical aspect of their digital life. Recognizing that, we’re excited to announce improvements that will help GitHub users get started more easily with our developer services, including Azure DevOps and Azure.


GitHub sign in button in Microsoft login page
Read more →
Total votes 12: ↑11 and ↓1 +10
Views 465
Comments 0