@manhng

Welcome to my blog!

Asynchronous Programming Best Practies

April 23, 2021 13:44

Asynchronous Programming (edit)

Async/Await - Best Practices in Asynchronous Programming | Microsoft Docs (HAY HAY HAY)

Best practices in .Net asynchronous programming | InfoWorld (HAY HAY HAY)

Devops best practices: How to drive agility and operational excellence | InfoWorld

AppVeyor & Azure DevOps

AppVeyor: Tích hợp liên tục cho các nhà phát triển bận rộn

AppVeyor tự động hóa việc xây dựng, thử nghiệm và triển khai các ứng dụng .NET giúp nhóm của bạn tập trung vào việc cung cấp các ứng dụng tuyệt vời.

Login - AppVeyor

Các tính năng chính:

  • Không cần thiết lập hoặc bảo trì
  • Cấu hình xây dựng thân thiện với nhà phát triển bằng UI hoặc YAML
  • Xây dựng nhanh trên phần cứng chuyên dụng với ổ SSD
  • Xây dựng nhiều chi nhánh
  • Nhân viên và hỗ trợ cộng đồng
  • Trả giá khi bạn đi

Các phần mềm tương tự AppVeyor:

GitHub - ariya/karma-appveyor: Karma AppVeyor integration demo

BenchmarkDotNet

Powerful .NET library for benchmarking

GitHub - dotnet/BenchmarkDotNet: Powerful .NET library for benchmarking

Generate PDF Files

How to Generate PDF Files in Python with Xhtml2pdf, WeasyPrint or Unoconv - Gearheart

Creating PDF Reports with Pandas, Jinja and WeasyPrint - Practical Business Python (pbpython.com)

6 Things to Do Before You Outsource Web Development - Gearheart

Azure DevOps

Dịch vụ cho các nhóm chia sẻ mã, theo dõi công việc và gửi phần mềm cho bất kỳ ngôn ngữ nào. Đó là sự bổ sung hoàn hảo cho IDE của bạn.

Công cụ triển khai phần mềm hàng đầu: 25 công cụ hữu ích để hợp lý hóa việc phân phối cài đặt phần mềm - Danh Võ (danhvo.net)

CSS

  • Typography

  • Blueprint CSS

Avoid mixing asynchronous and synchronous code

You should never have a mix of synchronous and asynchronous code. It is a bad programming practice to block on async code by making calls to Task.Wait or Task.Result. I would recommend using async code end to end – it is the safest way to avoid errors from creeping in.

You can avoid deadlocks by using .ConfigureAwait(continueOnCapturedContext: false) whenever you make a call to await. If you don't use this, the async method would block at the point where await has been called. In this case you are just informing the awaiter not to capture the current context. I would say that it is a good practice to use .ConfigureAwait(false) unless you have a specific reason to not use it.

I would discuss more on asynchronous programming in my future blog posts here. For more information on best practices in asynchronous programming, you can refer to Stephen Cleary's great article at MSDN.

Code Coverage:

Visualize unit test code coverage easily for free in Visual Studio Community Edition (and other editions too)

GitHub - FortuneN/FineCodeCoverage: Visualize unit test code coverage easily for free in Visual Studio Community Edition (and other editions too)

FineCodeCoverage 1.1.144 - AppVeyor

Best Practices:

How to use SortedDictionary, SortedList, and SortedSet in C# | InfoWorld

How to benchmark C# code using BenchmarkDotNet | InfoWorld

How to work with Quartz.Net in C# | InfoWorld

How to use Moq to ease unit testing in C# | InfoWorld

How to perform lazy initialization in C# | InfoWorld

How to work with reflection in C# | InfoWorld

How to avoid temporal coupling in C# | InfoWorld

7 best practices for remote development teams | InfoWorld

You can explore a demo ASP.NET Core application that illustrates several ways to benchmark the code. You can get the application from the ASP.NET repo on GitHub. 

How to do more in C#: 

HttpContext vs HttpContextBase vs HttpContextWrapper

May 1, 2019 01:05

HttpContext vs HttpContextBase vs HttpContextWrapper (edit)

Http Context is handled a little differently in C# 3.5 onwards, its a little hard to get the full picture by looking at the msdn docs ("whats with these 2 new context classes???" is what i thought) so here's my take on it.

HttpContext

This is the vintage asp.net context. The problem with this is that it has no base class and isn't virtual, and hence is unusable for testing (cannot mock it). It's recommended to not pass it around as function arguments, instead pass around variables of type HttpContextBase.

HttpContextBase

This is the (new to c# 3.5) replacement to HttpContext. Since it is abstract, it is now mockable. The idea is that your functions that expect to be passed a context should expect to receive one of these. It is concretely implemented by HttpContextWrapper

HttpContextWrapper

Also new in C# 3.5 - this is the concrete implementation of HttpContextBase. To create one of these in a normal webpage, use new HttpContextWrapper(HttpContext.Current).

The idea is that to make your code unit-testable, you declare all your variables and function parameters to be of type HttpContextBase, and use an IOC framework eg Castle Windsor to get it injected. In normal code, castle is to inject the equivalent of 'new HttpContextWrapper(HttpContext.Current)', whereas in test code you're to be given a mock of HttpContextBase.

http://www.splinter.com.au/httpcontext-vs-httpcontextbase-vs-httpcontext/

Google Search: MVC 5

tip-of-the-day site:ittecture.wordpress.com

https://www.codingame.com/playgrounds/10771/asp-net-mvc-dos-and-dontsbest-practices

https://www.pluralsight.com/paths/mvc5 (HAY)

Integrate Google Oauth 2.O OpenId without Owin in sitecore asp.net mvc

http://santoshpoojari.blogspot.com/

Radio Button for Enum (C#)

https://stackoverflow.com/questions/5621013/pass-enum-to-html-radiobuttonfor-mvc3

UmbracoCMS

https://github.com/leekelleher

ParseQueryString in ASP.NET

https://leekelleher.com/2008/06/06/how-to-convert-namevaluecollection-to-a-query-string/

https://weblog.west-wind.com/posts/2014/Sep/08/A-NET-QueryString-and-Form-Data-Parser

https://stackoverflow.com/questions/68624/how-to-parse-a-query-string-into-a-namevaluecollection-in-net

http://burnignorance.com/asp-net-developer-tips/parse-query-string-using-httputility-parsequerystring/

https://www.hanselman.com/blog/ASPNETParamsCollectionVsQueryStringFormsVsRequestindexAndDoubleDecoding.aspx

http://densom.blogspot.com/2009/08/how-to-parse-query-string-without-using.html

http://www.codedigest.com/Articles/ASPNET/402_HttpUtility_Methods_in_AspNet.aspx

https://www.c-sharpcorner.com/blogs/add-remove-or-modify-the-query-string-value-in-url-in-asp-net1

http://www.dylanbeattie.net/2008/12/mocking-querystring-collection-in.html

https://www.ryadel.com/en/asp-net-c-sharp-parse-query-string-get-parameter-arrays-square-bracket-notation-http/ (HAY)

Google Search: MVC 6

https://code-maze.com/aspnetcore-webapi-best-practices/ (HAY)

Simple Asp.net Identity Core Without Entity Framework

https://code.msdn.microsoft.com/Simple-Aspnet-Identiy-Core-7475a961/view/Discussions

ASP.NET Web API Processing Architecture

https://blog.pedrofelix.org/2012/03/05/asp-net-web-api-processing-architecture/

Processing.Architecture

Web Performance Tips: 10 JavaScript Best Practices

July 21, 2017 13:30

Best Practices

To highlight the presentation, I have talked about the following JavaScript best practices tips:

  1. Put stylesheets at the top (css)
  2. Move scripts to the bottom (javascript)
  3. Provide a clean separation of content, CSS, and JavaScript
  4. De-reference unused objects
  5. Think Asynchronous
  6. Working with Objects
  7. Defer Loading Resources
  8. Use JSLint -- Code Quality Tool
  9. Reduce the size of JavaScript file
    • gzip
  10. General JavaScript Coding Best Practices
    • Use === Instead of ==
    • Eval = Bad
    • Don’t Use Short-Hand
    • Reduce Globals: Namespace
    • Don't Pass a String to "SetInterval" or "SetTimeOut"
    • Use {} Instead of New Object()
    • Use [] Instead of New Array()

Categories

Recent posts