David Shifflet's Snippets

Mindset + Skillset + Toolkit = Success




Creating Docker Containers for Legacy Windows Console Applications

In this example we are going to create an image for starting a container in Docker. This container will provide a http post endpoint to take a file and provide back some converted result from a "legacy" application. If you read this post it will show you how to automate the legacy application installs and that provides a good start for containerizing a legacy windows application.

The use case for this example is wanting to run a legacy windows console application and post files to it to be ran and then receive the output. If all you want to run is a .net core WebApi or MVC application there are easier ways to do this.

In this example we are going to use:

...
Read More

Automating the Installs for Ancient (Legacy) Windows Applications

Friday, the end of the week. Your manager comes over to you at three in the afternoon with a simple request, "Can you bring up this old windows application on a new machine?"

"Sure", you reply then ask, "I was wondering if you have the install documentation for it?"

He grimaces and sternly states, "I have a word document from 1998 that is woefully out of date. By the way, we need this up by Monday."

Now your weekend is ruined or is it?

...
Read More

Getting Started with NDepend

Recently Patrick Smacchia reached out to me to suggest I take a look at a code analysis tool NDepend. He gave me a license and I started to use it.

I am a big fan of Resharper. I love it. I will follow Resharper's suggestions blindly. My goal in life is to make the upper right hand corner icon become a green check mark. Resharper's biggest strength is that it gives you almost immediate feedback as you write code.

...
Read More


Microsoft Certified Software Developer

I recently got certified as a Microsoft Certified Software Developer and I wanted to document the books I read and the process I used. I did this very fast over 8 weeks. It involved a number of tests and a lot of reading. I do have over twenty years of software development experience so keep that in mind. Exams are listed in the order I took them.

I did this to learn things. I wanted to become more familiar with the latest version of Microsoft products as they relate to software development.

My Microsoft Certifications

What You Need to Do

You will need to be a Microsoft Certified Software Associate and take one elective exam to become a Microsoft Certified Software Developer. No exam used to get the MCSA can be used as the MCSD elective. You cannot take 70-480, 70-486 and 70-483 to get the MCSD.

MCSA: Web Applications
MCSA: Universal Windows Platform

I decided to get the MCSA Web Applications. The Universal Windows Platform seemed less relevant to me.

...
Read More

C# XmlSerializer and Versioning

The C# XmlSerializer let's you easily create an instance of an object and save it to XML. Usually this is a file. To use it you do something like:

public class SampleFile
{
	public string Name { get; set; }
	public List<string> Warnings { get; set; }
}

...

	// Write it to a file		
	var serializer = new XmlSerializer(typeof(SampleFile));
	using (var sw = new StreamWriter(TestFiles[0].Create()))
	{		
		var file = new SampleFileV1()
		{
			Name = "Dave",
			Warnings = new List() { "A", "B", "C" }
		};
		serializer.Serialize(sw, file);
	}
	
...

	// Read from a file
	var serializer = new XmlSerializer(typeof(SampleFile));
	using (var sr = new StreamReader(TestFiles[0].OpenRead()))
	{
		var file = (SampleFile) serializer.Deserialize(sr);
	}			
And the serialized XML will look like:
<?xml version="1.0" encoding="utf-8"?>
<SampleFile xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <Name>Dave</Name>
  <Warnings>
    <string>A</string>
    <string>B</string>
    <string>C</string>
  </Warnings>
</SampleFile>

...
Read More

Entity Relationship Diagram Visualizer

Demo

Code

An Entity Relationship Diagram (ERD) is a drawing that represents objects in a database, usually tables, and their relationships. It's a very useful thing to have when developing software that communicates with a database. It's also a great thing to create before actually creating a database.

There are a lot of commercial tools out there that let you create and work with ERDs. Probably the best one in my opinion is ERwin. Beware ERwin is very expensive. There used to be a community edition but CA sold the division and the new people got rid of it.

The problem with ERwin is there is a steep learning curve and it requires a lot of clicking. Creating an ERD can take some time. If you have an existing database it's not so bad, but creating a new ERD from scratch... takes some time.

I looked around at a couple projects on github and there were several that were using a markdown like language to describe the database and create an ERD. The best one I found was BurntSushi/erd. This can be ran locally but I wanted something that was web based.

...
Read More

C# Yield and the Hidden Dangers

C# has a yield keyword the best description I could find is available here. Basically it allows you to write a custom iterator. ...
Read More


End to End Tests for HttpClient

A lot of applications have something like this in them:


    public class SomeBusinessService
    {
        public void DoTheBusiness(object o)
        {
            DoBusiness();

            using (var httpClient = new HttpClient())
            using (var response = httpClient.GetAsync(Settings.Default.SomeUrl).Result)
            using (var content = response.Content)
            {
                //Call out and based on the return do something
                DoMoreBusiness(content.ReadAsStringAsync().Result);
            }
        }
    }

So what is the problem with that code? First I can't inject a mock for the HttpClient it is concrete. I can't really change the setting for the "SomeUrl" property, and nine times out of 10 that is an ApplicationSettings (You can change user settings easily but not application settings).

What to do when we are faced with this problem?

...
Read More

End to End Tests for SmtpClient

I deal with sending emails a lot. For most of the tests they are pretty simple such as making sure the mail is formatted properly. In some cases I have to actually confirm that the mail client can deliver to a server and confirm that I can read it from that server. An End to End (E2E) test.

There's a lot of ways to approach this like bringing up a test mail server and POP3ing to it. Maybe use PaperCut and eyeball the results. What if there was a way your test could bring up an Smtp Server and you could use that?

...
Read More

Socket.IO and Planning Poker

Demo Here
Example Code Here

So I had created a Planning Poker game for Sprint Story estimation in the past. It's available here.

The problem was that Peer.JS uses WebRTC and in the absence of a decent TURN server (which I don't have) doesn't work well with NAT and people behind firewalls.

Solution: Use websockets. So I got Socket.IO, messed around with it and changed the old code to use it. This solves the issues people were having with the firewalls and unable to join games.

To use it go here. Type in a name. Click new game. To invite others copy and paste the share URL near the top.

...
Read More

NORTHWIND for Oracle

Example Code Here

So I do a lot of examples with Oracle. I just realized that not everyone has the Northwind Database in Oracle!

This repo on github has the DDL (Sql Build Script) where you can create it in Oracle. I will write a more detailed post about how I am using Oracle with docker in the future.

Be warned the Northwind database has obnoxiousness, like why are the table names plural and not singular??? PRODUCTS vs PRODUCT? It's not a good example of how to do a database, but it's useful for examples and testing because people are usually familiar with it. It's very approachable.

...
Read More

.NET Core, Oracle and NHibernate

Example Code Here

Introduction

So NHibernate has been released with .NET Core support! NHibernate Announcement

Which means in theory we can use that as an ORM and combined with the .NET Core support from Oracle.ManagedDataAccess we can use it with Oracle Databases!

So in this example, we will use the previous Linq2Db examples and move those over to NHibernate! We will still maintain the Sqlite tests we had before.

This example references and builds off stuff contained in a previous example. When I am referring to Linq2Db I am referring to code in that example.

...
Read More

C#, WebAssembly and Zork



Example Code Here
Demo Here

The Idea

I decided to try out using Ooui which is a framework for creating WebAssemblies using C# and Xamarin Forms. You can learn about it here https://github.com/praeclarum/Ooui and at http://praeclarum.org/post/171899388348/oouiwasm-net-in-the-browser. The general idea is write C# and compile it to WebAssembly and run that in the browser instead of JavaScript. I could have gone the Blazor route, but my internet has been flaky and I didn't want to download the VS2017 preview release.

After going thru the Ooui Getting Started, I needed to make something. WHAT? I decided a text based game like Zork would be nice.

Zork is a text based piece of interactive fiction made by Infocom. Zork is inspired by Collosal Cave a game written in Fortran for DEC computers. Selling games for DEC computers didn't make a lot of sense, so Infocom decided to create a virtual machine called ZMachine. This ZMachine would let them use the same code (image) across multiple platforms. Back in the day these platforms were personal computers like the C64, IBM, Apple II and lots of others.

Zork appears to be abandonware and is freely distributable at a lot of sites. There are a lot of unofficial versions, including this one. ...
Read More


.NET Core, Oracle, Linq2Db, Sqlite and In Memory Database Tests

Introduction

Example Code Here

So in the last example we created a .NET Core project that connected to an Oracle database and displayed a list of products from Northwind. For this example we are going to write some tests to make sure our Linq2Db is working

Our goal here is to:

  • Use an In Memory Database that mirrors our Oracle database so it's fast. We are going to use Sqlite. The queries are agnostic in regards to the database engine, so in theory the ones for Oracle should work with Sqlite and vice versa.
  • Use xUnit
  • Test that the linq queries from Linq2Db actually work

Let's get started!

...
Read More

.NET Core, Alternatives to EntityFramework with Oracle and Linq2DB

Introduction

Example Code Here

.NET Core is great. But if you are looking to use an ORM (Object Relational Mapper) you are kind of out of luck unless you want to use Entity Framework and there happens to be a provider for it. Right now there is no EF Provider from Oracle, so to do true .NET core with Oracle, Entity Framework isn't going to work.

It may be possible to get NHibernate kind of working with the ODP.NET Core drivers, but it's not officially supported. So I wanted to look at what else is out there.

Let's look at Linq2DB. Which is available at Linq2DB on GitHub. What will this do for us?


LINQ to DB is the fastest LINQ database access library offering a simple, light, fast, and type-safe layer between your POCO objects and your database.

Architecturally it is one step above micro-ORMs like Dapper, Massive, or PetaPoco, in that you work with LINQ expressions, not with magic strings, while maintaining a thin abstraction layer between your code and the database. Your queries are checked by the C# compiler and allow for easy refactoring.

However, it's not as heavy as LINQ to SQL or Entity Framework. There is no change-tracking, so you have to manage that yourself, but on the positive side you get more control and faster access to your data.

In other words LINQ to DB is type-safe SQL.

...
Read More

SqlWrangler Has New Features

SqlWrangler is a SQL Client with some amazing features. I added some new features recently and I wanted to give you all the details.

New Features

  • Run some sql like "select * from northwind.products" and export C# models. Now with EntityFramework mapping and Linq2DB mapping model generation!
  • Open Excel Spreadsheets and run SQL against them, like they are a database! (Requires Microsoft Ace)

EntityFramework and Linq2DBMapping Model Generation

So open Sql Wrangler run some sql.

Then click the ... Walk thru the dialogs and you will get code back like:

...
Read More

Oracle ODP.NET and .NET CORE

For this example we are going to:

  • Create a .Net Core Console Application (.NET Core can run on platforms other than Windows, like Linux!)
  • Use the ODP.NET Managed Data Access for .NET core and connect to an oracle database to get some data and display it in the console.

...
Read More

Keep on Top of Things with Post Its

I have noticed that a lot of people I work with they let things fall through the cracks. A person can't do everything and we all depend on other's to do their jobs. And other's depend on you to do your job.

If you tell someone you will do something... DO IT.

On a typical call I hear someone say they are going to do something. They swear up and down they are going to do it. AND THEN THEY DON'T DO IT. OR THEY DO IT LATE.

That makes me sad. Cause that one thing that wasn't done, might have been required by 5 other people to spin off and do their things.

There is a very easy solution to this!

...
Read More

Time Kills Calls - Be Better on the Telephone

I took these notes when I was thinking and researching about how most of my calls go. Some good and some bad. I love talking on the phone, maybe too much? But this is good advice. Most of it came from a Grant Cardone video.

I liked this video so much, I moved the reference up to the top. Click play and read on


WHEN ON THE PHONE TRY TO DO THIS...

1. BE HONEST and TRANSPARENT

2. BE INTERESTING and INTERESTED

3. Believe you can make a sale from every call. (avg sales follow up for calls is 8-12x calls, to get first call is 8x's calls for internet leads. 75% of sales people never call back twice!!!)

...
Read More

Sales Opener / Rebuttal Notes

Customer Stages:

NO -> MAYBE -> YES

NEGOTIATIONS ARE CONTROLLED BY THE PERSON ASKING QUESTIONS AND GETTING ANSWERS!

STAY POSITIVE AND ENTHUSIASTIC!

  • I'M NOT SURE IF IT'S FOR YOU BUT, ...
  • OPEN-MINDED.... How open-minded would you be to...? Would you be open-minded in giving this a chance?
  • WHAT DO YOU KNOW? What do you know about...? (For Expert Customers... Goal: have the person realize their opinion may not be correct and are open to change.)
  • HOW WOULD YOU FEEL IF...? (Have the customer visualize using the product.)
  • JUST IMAGINE (Have the customer visualize using the product.)
  • WHEN WOULD BE A GOOD TIME? (Get the customer to focus and look at the product. Get their attention.)
  • WHAT DO YOU LIKE ABOUT IT? (After a demo lead with this first. NOT: "What is wrong?" nor "Is it ok?")
  • ...
    Read More

Sales Objection Notes

I was reading a lot of objections and sales books when I made these notes, a great deal came from books, youtube videos and websites. References are linked at the bottom.

COMPLAINTS VS OBJECTIONS

OBJECTION: "The price is too high!" COMPLAINT: "The weather is too hot!"

You can negotiate the price, you can't change the weather! That is the difference. You can't counter a complaint, but you can counter an objection.

...
Read More

Convert a DataTable to an Excel Spreadsheet or PDF, Now on GitHub

DataTableToXlsPdf

______      _      _____     _     _    _____    __   ___     ______   _  __ 
|  _  \    | |    |_   _|   | |   | |  |_   _|   \ \ / / |    | ___ \ | |/ _|
| | | |__ _| |_ __ _| | __ _| |__ | | ___| | ___  \ V /| |___ | |_/ /_| | |_ 
| | | / _` | __/ _` | |/ _` | '_ \| |/ _ \ |/ _ \ /   \| / __||  __/ _` |  _|
| |/ / (_| | || (_| | | (_| | |_) | |  __/ | (_) / /^\ \ \__ \| | | (_| | |  
|___/ \__,_|\__\__,_\_/\__,_|_.__/|_|\___\_/\___/\/   \/_|___/\_|  \__,_|_|  

OVERVIEW:

A class library for taking a datatable and converting it to a Microsoft Excel XLSX or a PDF file. The PDF file generated is using the Microsoft Excel export, not PrintToPdf!

* THIS DOES REQUIRE MICROSOFT EXCEL TO BE INSTALLED *

USAGE: Look at the test but basically it's this...

DataTableToXlsPdf.ToFile(dataTable, file);
File is a FileInfo.  If the extension is PDF it will save as PDF...  Something else it will save as an excel file (.XLSX)

Get it from GitHub

...
Read More

SchemaSpider, Now on GitHub

SCHEMA SPIDER

  _________      .__                            _________      .__    .___            
 /   _____/ ____ |  |__   ____   _____ _____   /   _____/_____ |__| __| _/___________ 
 \_____  \_/ ___\|  |  \_/ __ \ /     \\__  \  \_____  \\____ \|  |/ __ |/ __ \_  __ \
 /        \  \___|   Y  \  ___/|  Y Y  \/ __ \_/        \  |_> >  / /_/ \  ___/|  | \/
/_______  /\___  >___|  /\___  >__|_|  (____  /_______  /   __/|__\____ |\___  >__|   
        \/     \/     \/     \/      \/     \/        \/|__|           \/    \/       

OVERVIEW:

This is a tool for generating NHibernate Models and Mappings from an existing database (right now Oracle). This tool can infer the relationships even if you don't have PK and XKs defined.

...
Read More

32 Sales Objections Easily Countered: A Quick and Easy Guide to Countering the Most Common Sales Objections, Stalls, and Pushbacks with Words that Work

32 Sales Objections Easily Countered: A Quick and Easy Guide to Countering the Most Common Sales Objections, Stalls, and Pushbacks with Words that Work

The non-fiction book "32 Sales Objections Easily Countered" by Stepp Stevens Sydnor is a book about countering the most common sales objections and pushbacks. An example of an objections is "Is this the best price I can get?" The book is split into two sections. The first goes over the basics of countering objections, the second part lists the thirty two sales objections. Each example objection has a list of Do's and Don'ts and a tip from the author. I really enjoyed reading this book.

One exercise the author suggests is asking people when you buy things "Is this the best price I can get?" DO THIS. The results are amazing and will show you how most people can't or don't counter objections

...
Read More

The Art of Witty Banter: Be Clever, Be Quick, Be Interesting - Create Captivating Conversation

The Art of Witty Banter: Be Clever, Be Quick, Be Interesting - Create Captivatin

The non-fiction book the "The Art of Witty Banter" by Patrick King is a book that aims to teach you how to have interesting conversations. The book was short and easy to read. The subject is pretty approachable by anyone who has had a conversation, which should be most people on the planet. I didn't think I got a lot out of reading this book. However these are the things I liked and did not like.

...
Read More

Go for No! Yes is the Destination, No is How You Get There

Go for No! Yes is the Destination, No is How You Get There

This is a very short, easy and fun to read book by Richard Fenton and Andrea Waltz. The book has a clear message about the word "NO". The book is written as a story where one man bumps his head and meets his more successful self in an alternate reality.

The premise of the book is that you improve through failure. It also makes it a point to remind the reader that looking to fail can be a successful approach. A good example of this is how most people see "FAILURE - YOU - SUCCESS" being like a needle where you want to avoid failure and keep the needle in the success portion. The authors state that this is a better approach "YOU - FAILURE - SUCCESS", success can only happen through failures. I believe this is true. I learn more from my failures than through my successes.

...
Read More

Working Remotely Like a Pro - The Voice Quality

The problem with working remotely is kind of obvious, you are remote! This poses a number of problems:

  • You aren't in the office.
  • You might not have an office for clients to meet at.

Even if you are in an office and working with remote people, you are kind of remote! So these are good tips for you too!

So the obvious solution is the telephone. Now a days the telephone comes in a lot of different formats, the main ones I use are:

  • Apple iPhone
  • Skype
  • GotoMeeting

The important thing to keep in mind is that 99% of your important communication with others will be over voice. This means it's important to have decent speakers and a decent microphone. Video calls aren't going to help unless you and the other person know sign language. You want to make your voice heard clearly!

You want people to understand you, and you will want to understand people. So first some things that cost nothing, or next to nothing to improve your sound quality...

...
Read More

Code This, Not That - Organizing Your Projects

One of the hardest things in doing anything is getting started! It's the same way for writing software. You open up Visual Studio and you are like, where do I begin? Where do I put things? How do I make my life easier?

Hopefully with this post I can make your life easier, not only for you, but for others that might want to work with your code. Most of these ideas came from discussions with my good friend Vamsee Kamabathula he taught me a lot about how to make writing software brain dead easy by following a fairly formulaic approach. This initial project organization is one of those ideas.

To begin let's talk about some stuff to keep in mind:

  • Organizing your project helps in finding things. Being able to find things is important if you want to read things. This is pretty obvious but it needs to be said. You write code once, but you read code a lot!
  • We write code to be read! First impressions are important. If someone can't figure out your code within 15 minutes (This is probably more like 2 minutes.) they will move on. You might have the greatest code in the world but if no one can read it or understand it quickly... They will move on. The first thing a new reader will look for is an "entry point" into the code. This could be via a tool, or it could be via tests. Ninety percent of the time it won't be via your class libraries. So, don't make the first impression overwhelming!
  • Names should be descriptive, especially assembly names. If I am looking at binaries and I see some DLL names for assemblies, I should be able to back track that to the code that generated those assemblies.
  • An organization should organize their code in a coherent and similar manner. If I can read one thing quickly and understand, I should be able to open something I have never seen and understand the format, and be able to start reading the code.

So in order to show you the way, let's show some wrong ways first.

The First Wrong Way - The Letter Full of Glitter

Imagine if you got a letter in the mail full of glitter. I believe this is called a glitter bomb. You open the thing and glitter goes everywhere. Structuring your project flat like this is really similar.



So if we are looking for an entry point into this project? Where is it? We have somethings called ".Tests" but then we have four things that aren't test? Is one a tool? Obviously the thing has to deal with migrating accounting data. Which one is the tool that actually migrates the data? Chances are that would be a good entry point for us to figure out this code?

...
Read More

Exactly What to Say: The Magic Words for Influence and Impact

Exactly What to Say: The Magic Words for Influence and Impact

This is a short easy to read book written by Phil M Jones . The book is about knowing what to say.

First, you aren't going to learn "magic words" that will let you manipulate people. The words the author goes over will help you work with most of the people, most of the time. The words will not work on all the people all the time. Second, this book isn't about words you can use to take advantage of people. The words will help you to help others make a decision.

The book is formatted in short chapters of 2-3 pages with a word or phrase, a brief explanation of why it's a good idea to use it, and finally followed up with an example. The words may seem simple and obvious, but simple and obvious works! The easiest way to describe this is via an example word.

Have you ever been scared to follow up with someone, because you knew they hadn't done what you wanted them to?

Start the conversation off with:
I'm guessing you haven't got around to... < insert some excuse >

Let's say you were making a call where the other party had to talk to their spouse before making a decision, you would say:

I'm guessing you haven't got around to talking to your spouse.

The other person will be proud they did what they agreed to do "I did talk to them!" or they will make a new promise to speak with them.

What this does is cut them off from making excuses. You have addressed that at the start of the conversation. It also lets the other person save face, because they don't have to make excuses to you why they didn't do something, they either did it or they can offer how they are going to correct the situation. The subsequent conversation you have with the other person will be more direct and more successful.

...
Read More

My Blog Builder, Now on GitHub

So this blog, it isn't WordPress. I didn't want to pay for that. It just a collection of static HTML files.

With a catch! Basically I have template files and I run this thing I call the BlogBuilder and it generates the final HTML files that I then push to the webserver.

It's cheaper and in a way easier.

  • You can find the code for the blog builder here:
    Blog Builder
  • And you can see how I format the content here. This repository is the website content before I run it thru the BlogBuilder.
    Website Content
    (Look at the blog directory if you clone it.)
...
Read More

Mentoring 101

Mentoring 101
Review:
This is a short book written by John C. Maxwell . The book is about helping others. The best part of this book is that it is short, clear and to the point. You can read it in around two hours.

The author tries to make the point that training can help people and individuals. I think this part of the book from page 100 gives an example of that:

  • When it's bad for the individual and bad for the organization -- everyone loses.
  • When it's good for the individual but bad for the organization -- the organization loses.
  • When it's bad for the individual but good for the organization -- the individual loses.
  • When it's good for the individual and good for the organization -- everyone wins.

The author also goes into developing the right mindset to help others learn. From page 76:

  • B elieve in them
  • E ncourage them
  • S hare with them
  • T rust them

It's a short book and was pretty cheap. The format and size of the book makes it feel like a Little Golden Book for adults.
...
Read More

The Art of Unit Testing: with examples in C #

The Art of Unit Testing: with examples in C
Review:
This is not a bad book. If you knew nothing about writing automated tests, this book would OPEN your eyes. You will learn about fakes and mocks. It doesn't go into the Moq framework very much. :(

That said this book has problems.

...
Read More

Outstanding!: 47 Ways to Make Your Organization Exceptional

Outstanding!: 47 Ways to Make Your Organization Exceptional
Review:
This book was written by John G. Miller who is the author of QBQ - The Question Behind the Question.

This book is composed of forty seven short chapters that vary in length between 3 to 10 pages about how to make your organization exceptional. It is a quick read.

HOW NOT TO READ THIS BOOK:
Read it from front to back, then put it down.

HOW TO READ THIS BOOK:
Read it from front to back, then put it somewhere and flip thru it sometimes. If there was a business improvement coffee table book this would be it. Each chapter is small and can be read in about 10 minutes. If you ever get bored instead of picking up the coffee table book of "Point Reyes Pictures" or "Steam Trains" pick this up and flip thru it and start reading.

OVERALL:
This is a pretty good book. Even if you don't read it all, read parts of it. Maybe even read random parts of it. The chapters are pretty self standing and don't reference each other.

...
Read More

The Greatest Salesman in the World

The Greatest Salesman in the World
Review:
This is an old book, but an EXCELLENT book. It was first published in 1968, and written by O.G. Mandino.

The first half of the book is a parable about a manager working for his boss. His boss decides to retire and passes on his knowledge to his younger manager. This knowledge is contained in the form of ancient scrolls in a chest.

The second half contains the content of the ancient scrolls.

The entire books is very Assassin's Creed like. Instead of a secret clan of Assassins there is a secret group of expert sales people.

This book is a quick read at around 100 pages, the reading flows and is entertaining.

The real content starts around the scrolls. The first scroll explains how to read the later scrolls.

I try hard to stay positive and persist at things. When I find myself in trouble or being super negative I read these scrolls and it helps a lot.

...
Read More

Radical Candor: Be a Kick-Ass Boss Without Losing Your Humanity

Radical Candor: Be a Kick-Ass Boss Without Losing Your Humanity

Review:
A friend recommended I should read this. This was a slow read, there was a lot of information to absorb.

The main message of this book is that clear and candid communication allows for better resolutions!

Overall it was really good. It comes with two awesome tools the Get Stuff Done Wheel and the Radical Candor matrix.
...
Read More

Code This, Not That - Use Params

So let's say we had animals and we wanted to write their sounds out to the console.

Let's start with a class like:

public class Animal
{
	public string Sound { get; set; }
}
And let's create a service to make an animal speak:
public class ThatAnimalSpeakingService
{
	public void Speak(Animal animal)
	{
		Console.WriteLine(animal.Sound);
	}
}
And now for a test with multiple animals...
[TestMethod]
public void ThatMakeAnimalsSpeak()
{
	var cat = new Animal() { Sound = "meow"};
	var dog = new Animal() { Sound = "woof" };
	var fish = new Animal() { Sound = "bloop" };
	
	var svc = new ThatAnimalSpeakingService();
	svc.Speak(cat);
	svc.Speak(dog);
	svc.Speak(fish);
}
And that works we get:
meow
woof
bloop
The only problem is the service can only take one animal at a time. What if we wanted to deal with one animal or an array of animals? ...
Read More

Code This, Not That - Use Streams NOT FileInfo

So let's say we want to read a file. And for this example let's say this file contains some text seperated by commas like so...

1,2,3,4,5,6,7

And one might write something along the lines of...

public class ThatReadCsvFile
{
	public string[] ReadFile(FileInfo file)
	{
		using (var sr = new StreamReader(file.OpenRead()))
		{
			var s = sr.ReadLine();
			while (s != null)
			{
				return s.Split(',');
			}
		}
		return new string[] { };
	}        
}
The problem with this code is you can only use it with Files. What if you want to use it with streams? Like maybe in a test using a memory stream? ...
Read More







A RODEO of SAVINGS






And More!