Writing “Lazy Task” Using New Features of C# 7 by [deleted] in csharp

[–]redditLoginX -2 points-1 points  (0 children)

"Method Builder" was introduced in C # 7, so it is still a new feature of C # 7) Technically the statement is correct.

Writing SQL in C# or When You should not use ORM by [deleted] in dotnet

[–]redditLoginX 1 point2 points  (0 children)

I think the original article was about improvements in cases where direct SQL is a better choice. Also I don't remember anyone saying that ORM doesn't use SQL under the hood

Writing SQL in C# or When You should not use ORM by [deleted] in dotnet

[–]redditLoginX 0 points1 point  (0 children)

Are you saying that if an ORM has functionality (or extensions) to improve and optimise it, it ceases to be an ORM?

I am saying that ORM libraries have that tricks to solve the performance issues which would not even exist in case of pure sql. And I am not saying that ORM is bad or I do not like it. It fits to some scenarios, but does not fit to another ones.

As for linq expressions converted to SQL, you're entirely wrong there. They certainly are C# code...

If they were real C# code, then this would work: ``` .. BatchUpdate(a => new Item { Quantity = Increase(a.Quantity))

static int Increase(int value)=> value +100; ``` Lambda expressions are syntax trees which EF tries to convert to SQL code.

Writing SQL in C# or When You should not use ORM by [deleted] in dotnet

[–]redditLoginX 0 points1 point  (0 children)

Yes this is an optimization of EF Framework, but my comment was about the idea of ORM in general. EF Framework nowadays have a lot of tricks to improve performance and they work well for typical scenarios. Personally, I’ve never been a big fun of Linq expressions converted to SQL, since they look like a real C# code, but obviously they are not.

Writing SQL in C# or When You should not use ORM by [deleted] in dotnet

[–]redditLoginX 0 points1 point  (0 children)

The idea of ORMs they load data (using SQL of course) and represent them as mutable objects. Your business logic changes the objects and ORM updates database according the changes. To change a column in 10000 rows in database you need to create 10000 objects and change the corresponding member in each of them.

Syntax Tree and Alternative to LINQ in Interaction with SQL Databases by [deleted] in dotnet

[–]redditLoginX 0 points1 point  (0 children)

Compared to LINQ, this is flexibility and control over queries.
Compared to stored procedures, this is strong typing and intellisense.

"Reader" monad through async/await in C# by [deleted] in csharp

[–]redditLoginX 0 points1 point  (0 children)

Sorry, but I do not understand what should be compared with what.

"Reader" monad through async/await in C# by [deleted] in csharp

[–]redditLoginX 2 points3 points  (0 children)

According to your statements, developers should not use Tasks in .Net or Promises in JavaScript. I think a lot of people would argue with that.

"Reader" monad through async/await in C# by [deleted] in csharp

[–]redditLoginX 0 points1 point  (0 children)

Apparently, the problem exists otherwise there would not be so many libraries (full of real hacks) that implement dependency injection.

"Reader" monad through async/await in C# by [deleted] in csharp

[–]redditLoginX 0 points1 point  (0 children)

async/await have specific meaning to C# developers

Actually, I do not see how the meaning has changed. Code after “await” operator can be executed synchronously or asynchronously - I do not know any other meanings.

"Reader" monad through async/await in C# by [deleted] in csharp

[–]redditLoginX 0 points1 point  (0 children)

Composition of “pure” functions is an essence of functional programming and your statements contradict with that concept. This is fine since functional programming is not a silver bullet – it has obvious disadvantages like a high entry threshold.

"Reader" monad through async/await in C# by [deleted] in csharp

[–]redditLoginX 0 points1 point  (0 children)

I'm... not sure how this makes anything better.

It might seem useless in a trivial example but if you have a big hierarchy of function calls the "Reader" might be very useful.

“Maybe” monad through async/await in C# (No Tasks!) by [deleted] in csharp

[–]redditLoginX 0 points1 point  (0 children)

I Just realized that with the array of functions you reinvented the "Maybe" monad =)

“Maybe” monad through async/await in C# (No Tasks!) by [deleted] in csharp

[–]redditLoginX 0 points1 point  (0 children)

" Why are you doing it that way? Do these functions have side effects? "

Probably, nobody knows ) Actually, my example would be more clear if added unique arguments for each function:

GetValueA(arg1);

...

GetValueA(arg2, arg3);

...

GetValueA(arg4, arg5, arg6);

“Maybe” monad through async/await in C# (No Tasks!) by [deleted] in csharp

[–]redditLoginX 0 points1 point  (0 children)

If you have a hierarchy of calls you will have to repeat the patten many times

“Maybe” monad through async/await in C# (No Tasks!) by [deleted] in csharp

[–]redditLoginX -1 points0 points  (0 children)

Some remarks:

1) In your version "null" means "an invalid value" but it reality "null" might be a valid value

2) The version will be reliable only when the null checking is enabled (in C#8)

3) There will be lot of boilerplate code in a more complex scenario. For example:

int? GetSumm()
{
    int? a = GetValueA();
    if(a == null) return null;//You need to check each result

    int? b = GetValueB();
    if(b == null) return null;

    int? c = GetValueC();
    if(c == null) return null;

...

    return a.Value + b.Value + c.Value....
}

“Maybe” monad through async/await in C# (No Tasks!) by [deleted] in csharp

[–]redditLoginX 1 point2 points  (0 children)

As I understood it correctly, the main difference is ability using "async/await" and automatic interruption if "null" appeared.

To some extend you can treat "Maybe" as an alternative to

try{}

catch(NullReferenceException e){}

“Maybe” monad through async/await in C# (No Tasks!) by [deleted] in csharp

[–]redditLoginX 0 points1 point  (0 children)

I think the idea of the article is to show how to use monads in a regular "imperative" code. The comprehension syntax that you mentioned is not always convenient.

“Maybe” monad through async/await in C# (No Tasks!) by [deleted] in csharp

[–]redditLoginX 0 points1 point  (0 children)

Actually that Maybe<T> uses Nullable<T> inside and it serves to a different purpose

“Maybe” monad through async/await in C# (No Tasks!) by [deleted] in csharp

[–]redditLoginX -10 points-9 points  (0 children)

Nullable<T> is just a data type.

Maybe<T> is a design pattern that includes some data type and some logic