Pete On Software

RSS Feed

Podcast Episode 23 – Apple Pay, Apple Watch, and New iPhones – Oh My!

iPhone 6 and 6 PlusThis time, in Episode 23, I recap the September 2014 Apple Launch Event. During this event, Apple launched iPhone 6 and 6 Plus, along with Apple Pay and Apple Watch. I wasn’t really enthusiastic for this event going in because I don’t like big phones, I couldn’t care less about NFC payments, and I’m not excited about wearables. However, by the end of the presentation, I was excited for 2/4 of the products. Either I’m a sucker for marketing, or some of this stuff might actually be pretty good. Listen and find out which it is.

Links Mentioned in this Show:
The OK Go Story
Samsung’s Ad

Scarf Guy

Tommy the Scarf Guy

You can also subscribe to the podcast at any of these places:
iTunes Link RSS Feed Listen on Stitcher
In addition, my podcast is available on DoubleTwist and the Windows Marketplace.
Thanks to all the people who listen, and a special thanks to those who have rated me. I really appreciate it.
Listen here:

My First Dimecast is Up!

I’ve been a fan of Dimecasts.Net for some time. In fact, four and half years ago I mentioned the site in a post on this very blog. Unfortunately, the site hadn’t been updated with a new video in almost two and a half years.

I kept checking in with it periodically, but never saw updates. One day, my curiosity got the better of me and I started looking around the Internet and I found that Dave Schinkel was planning to take the site over from Derik Whittaker. I reached out to see if I could help and Dave was gracious enough to let me play along.

The site is still going to be undergoing a redesign (to be casted, of course), but for now, Dave has re-encoded all of the old videos to MP4 from WMV, boosted the volume, and added a modern player.

All of that being said, I am proud to announce the first new Dimecast in 2.5 years, Episode 206 – Learning Objective-C – Part 1.

Author Screen from my Learning Objective-C Part 1 Dimecast
(A Screenshot of the Author Screen)

Sample Action Screen from my Learning Objective-C Part 1 Dimecast
(A Screenshot of me in action ;) )

The goal is to roll out a lot of new episodes about a lot of different topics soon and get the site back into a vibrant place to help developers learn new skills.

I’m very excited for what’s to come and I hope that you go check out the episode.

Think Outside the Box

Entrepreneur on Fire Podcast Logo
I was listening to episode 682 of the Entrepreneur on Fire Podcast, where John Lee Dumas was interviewing Shane Snow. Shane has written a book called Smartcuts: How Hackers, Innovators, and Icons Accelerate Success. An abbreviated description from Amazon reads:

Entrepreneur and journalist Shane Snow analyzes the lives of people and companies that do incredible things in implausibly short time… One way or another, they do it like computer hackers. They employ what psychologists call “lateral thinking” to rethink convention and break “rules” that aren’t rules.

Shane Snow
During the show, Shane gave a small story to illustrate the general idea of the kind of lateral thinking that he is espousing.

Pretend that you are driving a car on a rainy night and you’re kind of in the middle of nowhere and windshield wipers are going like crazy and you see on the side of the road three people that are standing out there miserable in the rain. You slow down and the first one you notice is a friend of yours that saved your life one time. Next to him is a little old lady with a cane who definitely can’t make it back to town on her own. And next to them is the man or woman of your dreams and this is your only shot to ever meet them. You only have one seat in your car (meaning a car with a total of two seats), who do you pick up?

John Lee Dumas suggested that he would pick up the little old lady. That is just the “military man” in him. Shane’s point was that lateral thinking “hacks” the question and finds the answer by thinking outside the box. In Shane’s solution, you give the seat to the old lady, give your keys to your friend, and stay with the love of your life.

I love that illustration. Yes, it is contrived, but it is a perfect word picture of how creative problem solvers think. The problem that most people have with the problem is that they make assumptions. In this case, you’ve assumed that you must stay with your car and that you must only save one of the three people in distress. Lateral thinking throws out those assumptions and looks for a way for “everyone to win”. In real life, 100% satisfaction certainly isn’t always possible, but you will get a lot closer by throwing out assumptions and “hacking the question”.

Great reminder for the day.

Podcast Episode 22 – In Defense of Stored Procedures

Gavel - Labeled for CC Reuse, From 22 finds me talking about Stored Procedures. Stored Procedures have gotten a bad rap not just recently, but for over a decade. Stored Procedure apologists don’t always help the matter and misinformation abounds. I take a look at stored procedures and why it isn’t the worst thing in the world if you use them.

I haven’t forgotten my last podcast about religious arguments and I try to take an honest look at when stored procedures aren’t terrible, when ORMs are best, and when in-line parameterized SQL might be your best option. Too often, I feel that developers are scared of the database because they don’t know it or only have a limited view of what it could be for. In this episode, I look at it from all angles.

Links Mentioned in this Show:
Rob’s Original Post
Frans Bouma’s Reply
Rob’s Rebuttal
Jeff Atwood’s Post
Ayende’s Compromise
Zip Locate
Listen To This Episode:

You can also subscribe to the podcast at any of these places:
iTunes Link RSS Feed Listen on Stitcher
In addition, my podcast is available on DoubleTwist and the Windows Marketplace.
Thanks to all the people who listen, and a special thanks to those who have rated me. I really appreciate it.

C# MemberwiseClone

Clone Trooper - Creative Commons License from

If you’ve ever needed to make a copy of an object in C#, you might have come across the MemberwiseClone() method. This can save you a lot of hassle of left-hand/right-hand property matching, but it does come with some “gotchas” that might not be readily apparent if you haven’t carefully read the documentation.

Let’s start with a class that looks like this. Notice that it has a ShallowCopy method that just returns a MemberwiseClone of the object.

public class Person
        public string Name { get; set; }
        public Person Boss { get; set; }

        public Person ShallowCopy()
            return (Person)this.MemberwiseClone();

Now, let’s create some objects and make a shallow copy of the worker and see if the objects are the same:

Person bigBoss = new Person() { Name = "Tony", Boss = null };
Person boss = new Person() { Name = "Silvio", Boss = bigBoss };
Person worker = new Person() { Name = "Paulie", Boss = boss };

Person cloneWorker = worker.ShallowCopy();
Console.WriteLine("Are the workers the same? {0}", worker.Equals(cloneWorker));
Console.WriteLine("Are the bosses the same? {0}", worker.Boss.Equals(cloneWorker.Boss));

This gives us the following results:

Are the workers the same? False
Are the bosses the same? True

“So what?” you might ask. Well, what that means is that if I change a property on the Boss of either object, it automatically changes in the other object (since only the reference was copied, and that reference points to the same memory address in both cases).

worker.Boss.Name = "Chuck";
Console.WriteLine("Worker's Boss' Name: {0}.", worker.Boss.Name);
Console.WriteLine("Clone Worker's Boss' Name: {0}.", cloneWorker.Boss.Name);

This gives us the output:

Worker's Boss' Name: Chuck.
Clone Worker's Boss' Name: Chuck.

It is possible that you may be okay with this happening. However, if you don’t want this to happen, you can implement a DeepCopy on your object instead. In the DeepCopy, you take a MemberwiseClone and then you call for a deep copy on every reference type in the object. In our example, I’d add this to our Person class:

public Person DeepCopy()
    Person copy = (Person)this.MemberwiseClone();

    if (this.Boss != null)
        copy.Boss = this.Boss.DeepCopy();

    return copy;

Now, when I check on the objects, they aren’t the same. And, when we change the property on the boss, it doesn’t automatically change in both places because they are completely separate objects.

Are the workers the same? False
Are the bosses the same? False

Worker's Boss' Name: Chuck.
Clone Worker's Boss' Name: Silvio.

That’s all there is to it. I have wrapped up the code for this blog post into a small console project and put it on GitHub. If you have any questions, let me know in the comments.

« Older Entries