In a previous blog, I said

This new code is about classes (FilePath) instead of being about functions (IsUncPath(string) ).  

Pearls of wisdom, for sure.  But what does it mean?  How do you know if you're really writing OO code?

Try this: sit down with someone (pets are fine) and explain to them how your program works.  If you find yourself saying “And then function F1 calls function F2 once for each item, which calls to F3 as needed“, then you're probably doing procedural programming.  If you say “There's this class C1, and it's responsible for blah, and it references one-or-more of class C2, which does blah.“ then you're probably doing Object Oriented Programming.

Procedural programming isn't bad, of course.  But it's pretty fashionable to do OO these last 10 years, so let's try, ok?

switch - not OO.  Can be replaced with polymorphism.  If the divergence is simple but repeats itself in many places, you can use a State or Strategy pattern.  If the divergence is more complex, then splitting up the current class may make more sense.  You can use Extract Method to get a handle on the things that should be moved around.

conditionals - not OO.  (Crazy talk, right?)  Don't go replace all your conditionals with polymorphism, with the comment “Jay said so“.  Deciding when this is the right thing to do is your job.  I'm just trying to get page hits, right?  Anyway, it's the same as switch

string - not OO.  Every string you use has assocated rules about what it can contain & how it works.  Social Security Numbers must be 9 digits, NTFS file paths can't contain '&', etc.  Make a class to hold the string and code in these rules.

all builtin types - not OO.  Same as string, but somewhat less severe.

In C#, throwing Sytem.Exception. - not OO.  Whoa, but I thought exceptions were a good OO practice?  They are, but look at how you use them.  Compare:

if (someCondition)

{

throw new Exception("condition wasn't met");

}

and:

class SomeException : Exception

{

public SomeException() : base ("condition wasn't met") { }

}

...

if (someCondition)

{

throw new SomeException();

}

See how the second example says what it's doing with types?

string is so concerning, I'm going to write a separate post just for it.