Tuesday, October 13, 2015

Photos from Austin .Net Users Group October 12, 2015 - What's New in C# 6.0



Jimmy Bogard addressed 35 people at the Austin .Net Users Group on C# 6.0 and the new C# compiler.  The original C# compiler was written in 2000 in C++.  Roslyn, a completely rewritten compiler coded in C# is currently available.
Roslyn is only usable from VS 2015.

Roslyn being developed in the open at github.com by Microsoft.

It is multi-threaded.

Roslyn makes implementing new language features much easier.
Jimmy showed how C# 6.0 is used in his project AutoMapper.

Here are my unedited random notes on new features in C# 6.0:


0. private setter:
public Type SourceType {get; } //implies setting only in constructor

1. auto-initialize
public string FirstName { get; set; } = "Joe";
public string CreationDate {get;set;} = DateTime.Now;

field or property?  if using variable outside a class use property

2. Expression Body Function Members:
public string FullName { get { return FirstName + " " + LastName; }
replaced with 
public string FullName => FirstName + " " + LastName;
Can be used for methods as well:
public string GetFullName() => FirstName + " " + LastName;

3. Using Static - pulls in all possible methods from class to be used in class
using static System.Console;
WriteLine("....");
 using static system.math;
Round()
using System.Linq.Enumerable

4. Null Propagating Operator (The Elvis Operator) ?.
var x = source?.GetType() ?? sourceType;

5. String Interpolation - use instead of string.Format()
return $"Trying to map {SourceType.Name} to {DestinationType.Name}";

6. nameof()
throw new ArgumentNulException(nameof(context));

7. Index Initializer
static Customer() {
Dictionary customers = new {
[0] = new Customer(),
[10] = new Customer()
}
 }

8. Exception Filter

catch(Exception ex) when System.Threading.Thread.CurrentPrincipal.Indent.Name != "asdf"


9. await/catch/finally



Saturday, October 10, 2015

PersonalCapital.com as a replacement for Quicken

With Windows XP retiring, I looked for a replacement for my Quicken financial software which ran on my soon-to-be-obsolete XP computer.  I never liked Quicken, but it worked and was barely adequate.
 
After evaluating many software programs and web sites I settled on PersonalCapital.com.
I was queasy about uploading sensitive data to their site, but realized my home computer can be hacked as easily as their site - no place is safe anymore.

I love PersonalCapital.com.  It's one easy place to consolidate all my finances.
The best part is their asset allocation function which looks across all my accounts to determine if I  have the right mix of stocks and bonds, foreign and domestic investments. 

Their charts are simple but effective in showing trends in my finances.

I update my check categories and PC shows  how much I am spending each month on food, gas, entertainment and other things.

The coolest thing happened this last week.  PersonalCapital sent me a notification that one of my investment funds had a higher than expected fee.  Sure enough I researched recent changes in my retirement account, and our company had re-allocated our previous funds at Vanguard into new funds.  One of the new funds had a much higher fee than the previous fund.  Now I know I need to switch funds.

Thank you Personal Capital.


Friday, September 04, 2015

Remote Editing of Files with Emacs Through a Proxy on Windows 7

I've always loved emacs for editing files on remote machines.  I started with Ange-ftp, then tramp,  and then plink.  Now with blocked ports and a proxy to navigate, I've upgrade to plinkx.
With plinkx you can fiddle with the setting in PuTTY to get everything perfect and then use the PuTTY saved session in Emacs.
This is much easier than trying to set all the communication protocols in lisp.
Here's some setup code from my .emacs file.  The tricky part is that the tramp-default-host is the name of your saved session.


    (progn  
             (require 'tramp)
             (setq tramp-default-method "plinkx")
             (setq tramp-default-user "myUserName")
             (setq tramp-default-host "f");;the Saved Session from PuTTY.  See below.
             (setq tramp-verbose 10)
             (setq tramp-debug-buffer t)
             (setq password-cache-expiry nil)
    )




Now it works great!

Thursday, July 23, 2015

WebDAV error "HTTP Error 405.0 - Method Not Allowed" using WebAPI

This morning I ran into this error on our .Net WebAPI project:

 "HTTP Error 405.0 - Method Not Allowed. The page you are looking for cannot be displayed because an invalid method (HTTP verb) is being used."
"This error means that the request sent to the Web server contained an HTTP verb that is not allowed by the configured module handler for the request."

This is after we did the excellent fix suggested at http://evolutionarydeveloper.blogspot.com/2012/07/method-not-allowed-405-on-iis7-website.html.

The problem turned out not to be that the handler was not configured to handle a GET, but that my routing was ambiguous. I edited WebApiConfig.cs and modified the routing to be more specific. Now it works like magic.

(Note to Microsoft: Not to be whiny, but would it be so hard to give us an error like, "ambiguous route"?).

Monday, July 13, 2015

Photos from Austin .Net Users Group July 13, 2015

David McCarter talked to 55 people about 10 things to do to improve your code. David has many years of experience so it was interesting to hear his thoughts.
His contacts:: website: dotNetTips.com, email: dotNetDave@live.com, twitter: @realdonetdave

His tips for writing good code:
* Layer your code. Typical layers: Data, Business, Communications, UI
* Design for occasional internet connection. Why can't I post on Facebook when I don't have a connection?
* Make your app faster. Cache long running reports, use cloud based region data centers. Make "chunky not chatty" calls over the net. (Visual Studio 2015 will make performance issue better)
* Most of your code should be in portable dlls. Only code in client app loads data and interacts with the user.
* Check out IntelliTests in VS 2015.
* 3 Pillars of Object Oriented Programming: Encapsulation, Inheritance, Polymorphism
* Only application should log errors, not the dlls.
* Exceptions and Event Logging. His open source logging utility to fix the problems in .Net's trace logging: dotNetTips.Utility.Logging. Log Severity, Category, CLR version, free physical memory, virtual, OS.
* Internationalization string birthDate = p1.BirthDate.ToString(CultureInfo.CurrentCulture);
* Introduction to Localization and Globalization in .NET by Jeremy Clark on pluralsight.com
* Store format string in Properties.Resources.UserInfoFormat "birthday:{0}, name: {1}"
* Use Strong Naming to prevent spoofing
* David Recommends CodeItRight which finds and fixes errors.
* Use code obsfication, but not the free microsoft one, but buy a commercial obsficator.
* Stop the copy and paste nightmare
* Use code analysis e.g., FXCop
* Use application profiling for memory and performance