Monday, November 13, 2017

Building Beautiful RESTful APIs in .Net Core - Adnug November Meeting

Nate Barbettini talked to 26 developers at the Austin .Net Users Group.



Here's my notes from his talk:
RPC (Remote Procedure Call) vs. REST (REpresentational State Transfer)
RPC endpoints are verbs (api.example.io/getUrser), in REST endpoints are resources (/User)

HATEOAS - hypermmedia as the engine of application state
Data exchange should be treated as if the client were a web browser
No documentation or out-of-band info needed

Use RPC when dealing with a simple object, like the Slack API
Use REST when dealing with lots of different objects with CRUD operations possible on all of them
GraphQL is useful when trying to traverse a graph of REST calls

REST + JSON is popular but hard because no schema is available for the data.
HAL and JSONSchema try to solve that.  Also Ion trys to give structure to JSON data.
The Ion content type is application/ion+json
Ion data is embedded in JSON with fields, like "href","rel", and "value".

ASP.NET Core is a full rewrite of .Net to be portable, faster and cleaner.
Dependency Injection is now in the framework, don't have to download StructureMap

Nate has a free eBook about starting with .Net Core at https://www.recaffeinate.co/
Demo to create new .Net Core API with Web API template.  No diff between MVC or API controllers.

Nate used package Entityframework inmemory to do development of demo.  inmemory just gives an inmemory

ASP.NET Core is friendly to async/await pattern.  async first philosophy.

@nbarbettini
 https://www.recaffeinate.co/

Nate has a Lynda.com course on this.
https://github.com/nbarbettini/BeautifulRestApi is the result of his 4 hour Lynda course.

Nate has done a great job of learning .NET Core and sharing his knowledge with the community free of charge.



Wednesday, November 01, 2017

Just Switched Electrical Providers to Our Energy LLC Using GeekYourRate.com

In Texas we can choose our electrical provider.  PowerToChoose.org is a website to help consumers pick a provider, but it's very difficult to find which provider is the cheapest for me, since providers have a complex rate structure.  I did a previous blog post on choosing an electric provider.

I've found a great website, GeekYourRate.com, which cuts through all the weird pricing structures and shows the best rate for your usage.  The service costs $10, but it saved me $150 for the next year.
GeekYourRate.com said my cheapest option was Our Energy LLC, so I switched.   I had not heard of them before,  but will let you know how they work out.

Be careful not to just continue with your "current" provider when your time is up.  I think they are tempted to offer you a decent plan, but not the best, since it's such a hassle to change.  When I called my provider, and said that I had found a better rate, they offered me a better rate plan than what was mailed to me to renew. 

Here's my results from GeekYourRate.com:

 

Saturday, October 28, 2017

Saving for Retirement

The Basics of Saving for Retirement

I know, I know, I've waited to long to have "the talk" with my daughter who is a Junior in college. But something else always came up. The time never seemed right and I felt awkward, but I finally sat down with her and told her what I wish I'd known at her age about finances. I would be much further along in retirement savings if I'd just known these facts.

You can work hard all your life, put lots of money into your savings, but can still end up with a poor retirement if you don't save well.  Save wisely and you can enjoy a wonderful retirement.

How much money do you need to retire? 
The Four Percent Rule. The typical rule of thumb is that you can take out 4% of your money every year for your retirement.  So if you need $40,000 dollars a year from your savings, you will have to save one million dollars by retirement age.  That's a lot of money and it doesn't just happen.

General Tips
1. Don't buy toys on credit.   Credit cards carry a huge interest rate and you will be losing money every time you have a balance at the end of the month.  Pay your credit cards off at the end of the month.  Buy clothes at Goodwill, eat frugally, take local vacations, drive an old car, use a Windows computer - do what you must, but never carry a balance on your credit cards.

Your home and cars are the only things you should buy on credit.  Save up your money so you don't have to buy cars on credit.

2. Use a Credit Union.  Banks are made to provide profits for their owners, the stock holders.  Banks try to wring every last cent from you.  Credit Unions belong to the depositors and hence try to serve you, the depositor.  That being said, sometimes banks can provide services like ATMs everywhere that make them worth a second look, but remember banks live to make other people money.

Bankers circling to figure out ways to charge more fees
Basics of Investing
1.  You get paid for risk.  Since inflation runs about 2% a year, if you put your money in the bank in a risk-free FDIC insured account at 0.05% interest, you are losing money every year.  You need to take more risk to earn more money.

2. What is the stock market?  When you own a stock, you own a little piece of the company.  When the company makes a profit for the year they will pay you a tiny part of that profit which is called a dividend.  If a company has a million stock shares, and you own one stock, you will get one-millionth of their profits for the year.  Although some companies don't pay dividends, but let their stock price rise instead.  Either way you can make money.

3. Stocks are risky. If the company goes bankrupt you can lose all the value of your stock.  But with greater risk comes greater reward.  The stock market averages about 8% returns a year.

4. What are stock funds?  Stock funds are composed of a group of other stocks.  It's like a basket of baskets; when you buy a stock fund (big basket), you buy a small piece of multiple stocks (little baskets).  Two types of funds exist, managed and indexed.  Managed funds buy stocks based on the opinion of a highly paid stock picker.  Index funds buy stocks based on an list, like the 500 biggest companies in the stock market (the S&P 500 list) or the 1000 biggest companies (the Schwab 1000).

Index funds will almost always beat managed funds because managed funds have a higher expense, like 1-2% of all your money, while index funds may only charge you .03% of your money invested in them.  Over the decades this tiny difference can amount to over a hundred thousand dollars.





Don't invest in individual stocks, buy index stock funds. Individual stocks are fun to play with, but they're not stable enough to warrant high-stake investments.

You can buy stocks and bonds at a company like Vanguard or Schwab.  You create an account and send them money and they will buy and hold the stocks and bonds for you.

4. What are bonds?  Companies borrow money from investors by selling bonds. They are like government savings bonds - you buy them now and can redeem them later with interest. While bonds earn interest and are safer than stocks, they don't earn as much potential profit.  When a company goes bankrupt the bond holders get their money before stock owners, less risk so less reward.  Government bonds are the safest investment, but only pay about 1.5 - 2% returns.

6. Diversify.  You should own a mix of stock index funds and bonds in case the stock market goes way down.

What percentage in stocks?  One rule of thumb is to have the percentage of stocks the same as (120-your age), so at age 50 you should have 70% of your savings in stocks, both domestic and foreign.  When you are 20 you should be 100% in stocks, since you have a lot of time to ride out the ups and downs in the market.
You should also diversify over countries.  Have some stock and bonds from other countries.
 John Bogle, founder of the Vanguard Group which champions low cost index funds recommends this set of funds:
40% in the Vanguard Total U.S. Stock Market Index Fund
20% in the Vanguard Total International Stock Market Index Fund
40% in the Vanguard Total Bond Market Index Fund

7. Dollar cost averaging and beating the market.  Trying to invest money in the stock market when you think it is low, and selling when you think it is high almost never works.  Instead, invest every month when its going up and down and just ride out the storms.

The S&P 500 in 2008 was around 1500 and dropped to 700.   Many of my friends sold their stocks and lost half their investments.  If they would have been patient, they would have made all that money back and then some since the market has recovered to 2500.

8.  Real Estate.  You can invest in real estate, but it takes time to manage.  Your own home is typically, but not always, a good investment.  Another way to invent in real estate is a Real Estate Investment Trust (REIT), which is like a stock, but it invests in real estate like apartments, shopping malls, office buildings, and homes.  This is the simplest way to own real estate.

9.  Invest in ways that minimize your taxes.  Your work will typically have a Retirement 401(K) plan that will allow you to invest money without it first being taxed.  They will typically match a part of your investment, like the first 4% of your salary.  You get to deduct the amount you invest from your income so you don't have to pay taxes on it, yet.  When you retire you will pay taxes when you pull money out, but the money has grown for 30 years without paying taxes.

If your company doesn't offer a 401K, you can invest in an IRA, or a ROTH account. If you invest in an IRA, it is untaxed going in, allowing for compounding interest on the full amount you put in, but taxed when you withdraw money from the account. If you invest in a ROTH account, money is taxed going in, but considered non-taxable income when withdrawn.

10.  How much to save?

As a general rule you should try to 15% of your salary for retirement. The following table shows how far along you should be at a particular age to be on track.

Age Save this multiple of your salary
30 1x
40 3x
50 6x
60 8x
67 10x

In Summary
Save 15% of your salary for retirement every month in a mix of domestic and international stock index funds and bond funds into your company 401K or a ROTH account.


Planning and saving for your future is hard work, but your 65 year old self will thank you.


Friday, October 20, 2017

Agile Austin Lunch Session - How Microsoft VSTS went from 18 mo Releases to Three Week Sprints

Clementino de Mendonça presented to 20 Agile Austiners on the topic "Agile at Scale SIG - Agile Transformation at Microsoft TFS/VSTS team".

Microsoft uses 3 week sprints with releases to different test environments named  Ring 0 to Ring 6.
Releases every 3 months, could be more frequent, but customers don't want it more frequently.

Microsoft's internal release notes for VS are available at https://www.visualstudio.com/team-services/release-notes/

How did they go from 18 month release cycle to daily?

In the old days it took 3 months of planning to organised details for the next release.  Developers coded in two week sprints, with stand ups.
The lower levels were Agile, but the upper level planning was not.

Before and After Microsoft Transformations:
4-6 month milestones to 3 week sprints
Personal offices to Team rooms
Long planning cycles to Continual Planning and Learning
Feature Branches to everyone in master branch with tags
Secret road map to publicly shared road map on the web
100 page specs to specs in PPT
Private repos to open source publicly available
Deep hierarchy to flat hierarchy

"Culture eats strategy for breakfast", Peter Drucker

Microsoft at one time was cutting edge on Agile (Ken Schwaber studied them for the creation of Scrum), but then lost it.

Microsoft looked at Pink's book "Drive". People want Autonomy, Master, and Purpose.
Youtube video summary here,

Alignment and Autonomy balance.  Too much alignment and the autonomy falters.

MS changed Roles.  In the old days developer testers were considered lower quality.
Used to have Program Management, Dev, and Testing.  Now only PM and Engineering.  Everybody writes tests - no separate testers.

Full list of roles:  UX / User Experience / Program Management / Engineering / Service Delivery.

PM is responsible for What and Why building.  Engineering is responsible for How.

Teams are cross discipline, 10-12 people, self managing, clear goals, lasts for 12-18 months, work in physical team rooms.
The team owns the features in production and own deployment.  So if problems occur, that team fixes the problem.

Instead of doing horizontal layers: teams doing UI other team doing API, others doing business logic.
Now, one team does all of those things in a vertical slice.

Autonomy - let teams choose what they want to work on.  They must train successors.  aka.selfformingteams

800 people working on VS.  Teams stay in contact with each other using "Sprint Mails" detailing what they did, and what they plan to do next sprint.  This is instead of big meetings.


Lightweight Planning: Sprints in 3 weeks, Plan in 3 sprints, Season is 6 months, and Strategy in 12 months.

Strategy / Features / Stories / Tasks.  Strategy comes from top down.

Backlog is taken from UserVoice, community requests and voted on.

Stabilization sprint used to happen.  Devs would push bug fixes to stabilization sprint instead of fixing immediately.

Bug Cap is total number of bugs to have, it's five times number of devs.

Takeways
1. Get good a science, but don't be overly prescriptive.
2. Stop celebrating activity, start celebrating results.
3. Embrace the new normal.  Delivery continuously.
4. You can't cheat shipping.  Putting into production.
5. Build the culture you want ... and you'll get the behavior you're after.





Wednesday, October 11, 2017

Agile Austin, Oct 10, 2017 - Rage, Disorder, and Your Agile Team

At Agile Austin this month Matt McBride from Genesis10 talked about Agile team culture at Kasasa.com headquarters.
He wrote Leadership Patterns for Software and Technology Professionals.


My random notes:
* Rage, Stress, and Its Impact
Rage is one specific behavior that our teams are exposed to in their daily lives.
Rage and anger are types of stress.  Rage and anger are specific instantiations of the "abstract class" named stress.

What is impact of stress?: Health, Behavior, and relationships with our team members.
Stress can be a good thing for short periods.

Cortisol is the chemical produced during stress.  Long-term Cortisol can shrink your brain.
Sources of Anger: disappointment, frustration, judgement, rejection fear.

Anger make people indiscriminately punitive.

* Threat of Architectural Disorder
complexity grows at an exponential pace
Nonfunctional features (security, testing ...) tend to get lost or ignored
Grady Booch on characteristics of successful projects: strong architectural vision and well-managed iterative cycle (scrum).

Major Classes of Program Features to  Think about At the Beginning
1. Significant features for business/customer
   We look for functional features with a high business risk
2. Architecturally significant features
    We look for functional and non-functional features with high technical risk.

From Agile we need to embrace these:  commitment, courage, focus, openness and respect.

Missing in college education is leadership skills.  How to educate non-technical customers.


Leadership:
1. Leaders are avid learners.
Leaders try, fail, learn, and grow.
2. Leadership is a choice.
We have to change the way we think about ourselves, careers, and work.

* Tactics for reducing anger, rage, and stress
Have everyone take one deep breadth
Then followup with a specific goal

Partnership Pattern - moving forward from newbie to Trusted Partner
1. Performance - establish record of success
2. Credibility - be trusted based on performance
3. Trust -
4. Become a Trusted Partner

* The resolute pattern
Recast problems as assumptions to be questioned

Invest in your team and in development of leadership and interaction skills.




Monday, October 09, 2017

Continuous Integration and Delivery with Visual Studio and Azure - Austin .Net Users Group October 9, 2017

Shawn Weisfeld (Shawn is also founder of http://UserGroup.tv) created and deployed a project from scratch at the Austin .Net Users Group. VisualStudio.com gives us a free repository. You can create a project stored in the cloud. Team Services is free for teams under 5 people. Visual Studio online and VS local easily share a repository by default. ms.portal.azure.com will host. You chose how many machines and the size of the machines. Azure will create a load-balancer for the cluster. Azure will automatically collect telemetry. Changing the environmental variables on production is easy - you don't have to create multiple versions of the web.config for each environment. Shawn showed how it really is insanely easy to deploy an app in Azure to cluster using VisualStudio.com, Azure.com and a local copy of Visual Studio 2017.

Saturday, September 23, 2017

How to Embed a JavaScript Script in a Handlebars Template

While working on the next generation of ThePresidentsOftheUnitedStates.com, a site I'm working on with my 10yr old daughter, we needed to add a little bit of JavaScript in the template to add the ordinal suffix to a number (e.g., "3rd President").

It's easy enough to do by registering a Handlebars helper and calling it with "{{{nth number}}}". Here's the code in context:

<header>
<h1>The Presidents Of The United States</h1>
</header>
<script>
Handlebars.registerHelper('nth', function(n) {
  return new Handlebars.SafeString(
    ["st","nd","rd"][((n+90)%100-10)%10-1]||"th"
  );
});
</script>
<script id="entry-template" type="text/x-handlebars-template">
{{#each presidents}}
<div class="row" itemscope itemtype="http://schema.org/Person">
  <div class="col-sm-4 centered" > <!-- left panel -->
  <h2 class="name" itemprop="name">{{fname}} {{mname}} {{lname}}</h2>
  <p class="ordinal">{{number}}{{{nth number}}} President of the United States</p>
Special thanks to Tomas Langkaas from stackoverflow for the "nth" algorithm in JS.