Toastr

toastr_example

https://www.nuget.org/packages/toastr/

Toastr is one of those GUI items everybody is familiar with. It is the standard in feedback on webpages. Adding this to your solution is almost mandatory.

After installation of the nuget you’ll need to include the js and css files in the _layout.cshtml razor page. Now add some helper classes like the MVC Wrapper for Toastr from Johan Ohlin. This makes creating and showing the Toastr messages really easy by extending the Controller.

Posted in Development, Tooling | Tagged , , | Leave a comment

Common.Logging

Image courtesy of Ales Krivec / unsplash.com
Image courtesy of Ales Krivec / unsplash.com

https://www.nuget.org/packages/Common.Logging/

Common.logging provides an abstraction for the logging framework of choice. For IoC the common.logging offers an interface. NoOpLogger is a fake implementation used for unit testing.

I prefer to use the nuget from log4net with the Common.Logging implementation. https://www.nuget.org/packages/Common.Logging.Log4Net1211/ With log4net I log to a database table for easy access to the logging and to a file for fallback if the database is unavailable.

Posted in Development, Tooling | Tagged , , , , , | Leave a comment

Ajaxload

http://ajaxload.infoJust a tip for creating that loading image everybody uses or your custom version of it. Goto http://ajaxload.info

Posted in Tooling | Tagged , | Leave a comment

AutoMapper

Image courtesy of Mike Enerio / unsplash.com
Image courtesy of Mike Enerio / unsplash.com

https://www.nuget.org/packages/AutoMapper/

Mapping two objects using convention and coded/configurerd mappings. This comes in handy when moving through the layers of a solution (data > business > viewmodel) Every property with the same name is automatically mapper – hence the name.

The newest version of AutoMapper offers an Interface for use with IoC. Save the MapperConfiguration and use it every time to construct the IMapper impementation (config.CreateMapper())

Posted in Development, Tooling | Tagged , , , | Leave a comment

Unity

Image courtesy of Tim Gouw / unsplash.com
Image courtesy of Tim Gouw / unsplash.com

https://www.nuget.org/packages/Unity/

Dependency Inversion is one of the SOLID principles. An IoC container is a must for me when developing. Unity is my goto framework for the last year.

I prefer Unity for it’s lifetime control options. Do I need a new object every time, singleton or per thread? With Unity I can specify this in the configuration.

Posted in Development, Tooling | Tagged , , , | Leave a comment

SDN event June 2017

The SDN – Software Development Network – is a special interest group for dutch developers. Four times a year they organise an event where people present and talk about their passion.

As a member of the SDN you are aware of the latest developments. You are part of a network of professional developers who assist each other in word and deed. This means there is a technical helpdesk at your fingertips so you can book considerable time savings in solving problems.
sdn.nl with Google translate

Here are the talks I attended.

Keynote: The Development Platform Landscape in 2017

Developers have been used to write some code and run some code. This was easy when the devices of developers were the same devices the customer would run the product on. Today the diversity of devices is huge. We don’t write code on the same machine as the product would run (eg tablet, mobile) This makes the write some code and run some code cycle take longer.

The diversity of platforms has been the standard. Microsoft’s monopoly was the abnormally. Today we again have multiple platforms. But devices have more compute power and can afford the write-once run everywhere principle (which is slower than native) without being surpassed bij Lotus 1-2-3.

With the discovery of greyball in Uber apps the developers have the responsibility: are we going to allow this to happen or do we choose the right thing to do?

Image courtesy of patryk gradys / unsplash.com
Image courtesy of patryk gradys / unsplash.com

Blockchain concepts and experiments

Rob Koelman of De Nederlandsche Bank has made the transition from Enterprise Architect to the Business. They needed to have someone with deep knowledge of blockchain (bitcoin) to help them advise other companies. This was two years ago.

On the bitcoin.org site you can download the root paper (bitcoin: a peer-to-peer electronic cash system) The main thing they tried to solve was the double spending problem: paper money (or coins) can only be spend once, but what about virtual money?

Bitcoin_logo.svg

Rob explains the concept of Distributed Ledger Technology and the implementation in the Bitcoin arena such a double spending, mining and forks. Then he talks about his experiment with the DnBcoin where he downloaded the code from BitCoin from github and changed it. He discovered a lot of asserts and checks in the code that made his experiment not as trivial.

At the end of the talk Roel Hans showed us the Microsoft (Azure) template for creating your own implementation based on Ethereum.

Convergence: How Mobile, Cloud and Open Source Come Together to Save the World

richardcampbell-htbox.jpg

Richard Campbell talks about his role in htbox.org where developers code for humanitarian organizations. Why? Because when money is off the table you want:

  1. Autonomy: choose where you participate in, do what you like
  2. Mastery: become skilled, learn new things
  3. Purpose: because it matters

Microsoft graph: a way to build secure and smart apps

Sjoukje Zaal showed the v1 and the beta of microsoft graph. Access all Microsoft products (Azure Ad, Intune, Office365) from graph.microsoft.com.

Conclusion

Nice to hear something about blockchain from someone with first hand experience. No sales pitches but ready to use tips-and-tricks. Again a very good meeting.

Some links:

Posted in Conference | Tagged , , , , , , , | Leave a comment

EF query optimisation

We have a view that is very slow when you don’t use a filter on the name field. Everywhere in our stored procedures and (sub)queries we have this applied.

In our web applicatie we use Entity Framework. The business layer required the name filter, but the result always times out. The query looks like below.

-- simplified for clarity
SELECT [Extent1].[Name] as [Name]
FROM view as [Extent1]
WHERE [Extent1].[Name] = @p__linq__0

This is case of bad parameter sniffing. More about this in the References at the end of this post.

Reading this answer on stackoverflow made me look into the custom query execution against the Database object of your Context. And that solved the puzzle with a custom method instead of the generated IDbSet properties.

public IQueryable<viewRecordType> GetViewRecordsWhereNameIs(
string name) {
   // Danger! Sql injection possible
   var query = string.Format(
      "SELECT * FROM view WHERE name = '{0}'",
      name);
   return Database.SqlQuery<viewRecordType>(query).AsQueryable();
}

Please note the warning. Sql injection is possible when you don’t use parameters!

References

Entity Framework Performance and What You Can Do About It
How to Confuse the SQL Server Query Optimizer

Posted in Development | Tagged , , , | Leave a comment