Practices: Object Oriented Development
January 17, 2010 Category: Blog, Technical 11 Comments »
I’m starting off this series talking about Object Oriented Programming. It’s amazing how many people write C# or VB (.NET) with long, procedural methods with really no understanding of the true fundamentals of OO design.
I know, I know – it’s not you, and know what? I’m not talking about you.. but check out the code from the person next to you. See what I mean?
Just because you’re writing in an OO language, doesn’t mean that you’re writing OO code, or taking advantage of the Object Oriented benefits. An Object Oriented language is more than classes with methods, properties and events (even VB 6 had that!).
Learn the Fundamentals.
Get to know Interfaces, abstract classes, structs. I’m not picking on the thousands and thousands of extremely talented .NET developers that came from VB6 (I’m one of them), but I am acknowledging the fact the there are OO tools and strategies at your disposal now that never were before. Dig in to the delegates and the various eventing models, chained constructors, virtual and overridden methods. Go beyond if statements, while loops and language syntax similarities and embrace your new polymorphic self.
Perhaps, you’ve been a very successful developer for a very long time, I’m not saying that you have to change how you write all of your code. I am however, suggesting that you should realize that you have more tools in your toolbox than you might be aware of, and that if you learn how to use those tools, you will be more successful using the right tool for the right job.
Go beyond the fundamentals. A friend of mine teaches Object Oriented Analysis and Design for SMU, he once told me that if you have to use an if statement in your code then you’re not doing OO – it’s now procedural. I think he meant his statement in jest, (Although, he actually doesn’t allow his students to use if statements past the third section in his course) but the point was well taken. Beyond language semantics lie’s a whole world of patterns, approaches, and ways of doing OO that can make your life much, much simpler.
Pragmatic – Make new friends, but keep the old ones..
I’m not that much of an OO purist. I actually do feel that sometimes a well laid our “procedural” method can be easier to read, and communicate the intent of the code, but it’s a balancing act. Every time you write an if/switch statement you fork the flow of your code and increase it’s complexity, reducing your ability to maintain and test it. An OO purest might create a polymorphic object at this point and hop over to it instead of writing that if statement. I’m not saying that one way is better than the other. Like I said, writing readable/maintainable/testable code is a balancing act.
Beware of being “too” OO. It’s easy to get too pure on your OO. I’ve worked on systems where I had to fight through 7 to 8 levels of inheritance debugging and fighting all the way to figure out what in the world the system was doing. I’ve seen developers take 30 lines of procedural code and convert them in to 60 or 70 unique classes spread out over 6 projects. You can have too much of a good thing!
Is it OK to be “procedural” sometimes… can you be too OO?
The truth is, you want to use the right tool for the right job. The code on top is probably pretty readable and is fine… *right now* it won’t be too long and you’re going to want to start moving it closer to something like on the bottom. Why? With every scenario, and rule that gets applied to shipping orders, this code becomes less readable and harder to test. It won’t be long until you’re going to want to start validating (unit testing) your various order processes independent of each other. You’re going to want to break apart the coordination of an order, determination (the factory) of an order, from how it is actually handled… as you do that, your code will start to become more SOLID… but we’ll save that for the next post.
Interview Question Alert
Some of the related questions that I often ask:
Q:What’s the difference between an Interface and an Abstract class? When would you use one over the other? What implications does that have?
A: Interfaces define the contract with zero implementation, Abstract classes can have some implementation, but for the most part don’t. You can inherit from one base class, but implement as many Interfaces as you’d like to. Abstract classes can be versioned (if you’re going to strongly name them) but Interfaces cannot be versioned. Bonus Answer: Whenever you create an abstract class, you should always have an Interface to go with it, then code your dependencies to the Interface, not the abstract class.
Q: “Polymorphic” is a big OO word that developers like to throw around. Give a practical example of when you’ve used polymorphic behaviors in your code.
A: Anytime you use an abstract factory you’re implementing polymorphic principals. So the “processor.Process()” method above would be an example of Polymorphism, so would most Interface based development.
Further Reading
I hope this post has inspired you at some level to keep honing your development skills. I know that it was heavier on the “why” and low on the “how” specifics… I think that’s part of the point. You’ve got to go tackle some of this yourself. So go on, get out there.
Wikipedia – http://en.wikipedia.org/wiki/Object_oriented
Book: Object Thinking – MS Press
What are the resources that have helped you the most in your software development?
Photo Credit: http://www.flickr.com/photos/wwworks/sets/72157594328095699/
Introduction – 10 Development Practices
January 16, 2010 Category: Blog, Technical 3 Comments »
If you are going to read through my “10 practices that every developer should start right now” series, then you probably want to know where these 10 practices came from, why I chose these 10 – really, what so important about secure coding anyway?
– I think that it’s important to know that these aren’t just 10 random items to fill a couple of blog posts. These are all practices that have been thoroughly thought out. This list is something that I started to formulate over a year ago based on my experience as a consultant, working as a technical editor, and discussions with countless MVPs, other consultants and in my interviews with potential consultants…
Experience. First, these 10 practices have come from over 15 years of professional development work, working with countless customers when I was at Microsoft, as well as the numerous development shops and enterprise customers that I’ve been a consultant for over the last many years. These are, what I consider, to be the biggest bang for your buck, the low hanging fruit that you can quickly implement and the practices that will yield the greatest value in the shortest time.
Writing a Book. I once had the privilege of working as a Technical Editor on a C# 3.0 book. That experience was both rewarding and frustrating. It was rewarding to go through the process, engage with the executive editors, author and see the whose process of writing a technical book move forward. It was also frustrating to know that – while everything in the book was technically accurate – it often was not the content that I would have wanted to cover. These are the things that I want to talk about.
Hiring. Over the years, but especially during my time as a Principal consultant for Improving Enterprises and now as the Senior Software Architect for Six Flags, I’ve spent countless hours interviewing various – really smart people – that often fell short. (I’m a nice guy – but apparently a pretty heavy handed interviewer). I’ve discovered that the things that matter in software development – are often not taught, even in the best schools. These are the topics that I wish every CIS/ MIS department would start covering to some extent. I sometimes wished that I had a “quick read” book that I could hand to people on their way out and say “here, read this. This is what you should know before you try to work here.”
Scope – Obviously any one of these topics could be a whole book in and of itself. So none of these posts are going to be intended as a “complete” reference or anything like that. More like “Caleb’s thoughts on the matter.”… and hopefully some useful insights, and enough information to let you, Dear Reader, move forward and know where to go from here.
So that’s my introduction. I hope that you’ll join me as we dig in to all 10 practices.
photo credit: flickr
10 practices that every developer needs to start right now
January 6, 2010 Category: Blog, Technical 8 Comments »
Update: Since technically a DI Container could be considered part of SOLID, I’ve swapped it out for Secure Coding… more on this soon!
If I ever right a book on becoming a .NET Ninja, these are the things that I want to cover.
Introduction
OO
SOLID
Use a Container (DI)
Secure Coding 101
Patterns
Automated Tests
Source Control
Continuous Integration
Agile | Lean | Scrum | XP
Team Dynamics
Never Stop Learning
Eventually, I’d like to write a book and dedicate at least a chapter to each of these (although any one of these topics could be a book in and of itself) In the mean time, I think that I’ll start with a blog post on each one, and maybe make it a goal to eventually do a User Group talk covering each topic? I’m looking forward to flushing these out as posts. I hope that you will enjoy them too!
What sort of things would you add to the list?
“draft whurley” Featured on Linux.com
September 16, 2009 Category: Blog, Thoughts 2 Comments »
Last Thursday I posted my thoughts about Microsoft’s OSS announcements (go digg it: 3 Reasons Microsoft Needs an Open Source Officer), namely the formation of the CodePlex Foundation (awesome) and the departure of Sam Ramji (bummer). My take is that this is a great opportunity for Microsoft to take open source projects at Microsoft up a notch and raise the stakes with a big bold move by bringing in someone like my friend whurley (William Hurley – currently the chief architect of open source strategy at BMC).
This morning I turned on my computer to see that Todd Weiss and the folks at Linux.com had featured this idea on their home page. Go check it out the full article!
Related Reading
- Be sure to check out ars techica’s article on the Codeplex Foundation and Jeremy’s Post as well.
- Scott Bellware just chimed in on how the Codeplex Foundation is a “watershed moment, a turning point for the Microsoft platform and .NET community” – I couldn’t agree more. Go check out his complete article.
- Phil Haack is shedding some more light on Codeplex Foundation
- Red Monk’s Q&A on the CodePlex Foundation
- Featured on Linux .com! Who Will Fill Sam Ramji’s Role as Microsoft’s Open Source Leader?
3 Reasons Microsoft Needs an Open Source Officer
September 10, 2009 Category: Blog, Thoughts 2 Comments »
Today there were two big announcements from Microsoft regarding their involvement with the Open Source communities. First, was the formation of the CodePlex foundation, an open source foundation for the
Enabling the exchange of code and understanding among software companies and open source communities
Awesome. Great. Fantastic. This is the natural progression of a lot of the open source work that’s been happening at CodePlex, in the ASP.NET MVC stack and a lot of the other OSS projects that Microsoft has been initiating and contributing to lately.
The other announcement was more disappointing, Bill Hilf, the general manager of Windows, announced that Sam Ramji would be leaving his post at Microsoft to be the interim president of the CodePlex Foundation (cool – but why interim?) and then he would be pursuing some other opportunity.
Sam’s primary focus is to drive Microsoft’s Linux and Open Source Strategy, working together with Microsoft technology development teams and open source communities to build interoperable solutions
Horrible. Tragic. What a loss. At least, that’s what I thought at first. The truth is that Sam is leaving a much different Microsoft than the one he joined three years ago. A better, more open Microsoft. I agree with Bill’s assessment,
Microsoft’s open source strategy is no longer just locked in a single ‘lab’ on campus – now OSS is an important part of many product groups and strategies across the company
Sam’s role seems to be that of an OSS advocate, working to build OSS awareness and acceptance from group to group within Microsoft. Well done. Mission *mostly* accomplished.
So where does that leave us? I believe that at certain times in history a company like Microsoft will be faced with opportunities. Opportunities to move boldly forward or slink back in to the status quo, and (to quote that great philosopher and social commentator Dr. Horrible) the status, is not quo. I believe that now is the time for Microsoft to up the ante.
Rather than replace Sam, with yet another “Senior Director” – how many of those are at Microsoft? – I believe it’s Microsoft’s time to embrace an OSS strategy that moves beyond the director level. They need to show the world a bold move, similar to what BMC did over 2 years ago. Microsoft needs an Open Source advocate with teeth.
Three reasons Microsoft needs an Open Source Officer
- The Timing is Right – The Momentum is there.
Change is in the air. Sam is moving on. The Codeplex foundation has launched, there’s a new Chief Architect in town, and Microsoft has embraced many aspects of OSS is so many areas of their business because they have realized that – when it makes sense and in the right environment, OSS is good for business and good for your customers. - It’s a different world out there.
Not only has the world inside of Microsoft changed, so has the competition. Microsoft is increasingly competing in an open web world, with open standards against open platforms. More and more, these competitors also become their partners and customers. - Go big or go home.
I believe that it is the spirit of Microsoft to take on new challenges, to put there money where there mouth is, and to embrace a big future with a strong vision.
Who should they hire? Well, I’m sure there are a lot of qualified people in this space, and I’m not going to mention anyone specific by name here… but if you follow my twitter feed then you might have seen something that I posted earlier today.
… and hey Microsoft, if you’re listening, I wasn’t the only one that thought that…
… I’m just sayin.
Updates:
- Be sure to check out ars techica’s article on the Codeplex Foundation and Jeremy’s Post as well.
- Scott Bellware just chimed in on how the Codeplex Foundation is a “watershed moment, a turning point for the Microsoft platform and .NET community” – I couldn’t agree more. Go check out his complete article.
- Phil Haack is shedding some more light on Codeplex Foundation
- Red Monk’s Q&A on the CodePlex Foundation
- Featured on Linux .com! Who Will Fill Sam Ramji’s Role as Microsoft’s Open Source Leader?
5 Steps to becoming a Silverlight Expert
July 4, 2009 Category: Blog, Technical 5 Comments »
Recently I noticed something interesting on google searches and especially on bing. If you search for “Silverlight Expert” I show up near the top! Well… when google thinks that you are a Silverlight expert, then it’s time to start blogging more I guess. So here are my top 5 steps to becoming a Silverlight Expert. These are some of the most valuable steps that I’ve used as an Expert Silverlight Consultant and Trainer. We try to introduce as many of these resources in our Training and Consulting.
5. UX Skillzes
Sorry for the haxx0r lingo… but I’ve been liking it a lot lately. So, what are UX Skills? In short, this has nothing to do with Silverlight. Silverlight (or Flash, or WPF) are technologies that make it easier to create a better User Experience. At the end of the day though, it is the developer / designer that has the responsibility of creating the experience. the platform just makes it easier to realize that designers vision. No tool can completely make up for a lack of skill.
User Experience (UX) is made up of multiple areas and disciplines. Including concepts like Information Architecture (IA), Interaction Design (ID), Visual Design, Human-Computer Interaction studies, Human Interaction Psychology, etc…
Source: http://www.flickr.com/photos/surfaceappeal/3085503904/
Some of the resources that I use to hone UX principles and concepts:
- Jared Spool’s UIE Podcasts
- Silverlight Team Blog
- Microsoft Expression Community
- Chris Bernard’s Design Thinking Blog
- Mix Design Articles
- Stephen P. Anderson’s Poet Painter blog and Slideshare Presentations
- My Delicious UX Bookmarks
4. .NET Voodoo
My favorite feature of Silverlight 2 and beyond is that it has the .NET CLR built in to it. That means that .NET developers are able to leverage their existing skills while creating amazing applications in Silverlight. This has also opened up the door to a number of .NET libraries and resources being ported to Silverlight. Some of my favorites, Ninject, Rhino Mocks, Dynamic Proxy, SL Unity from Microsoft, WPF Pixel Shaders. To become a Silverlight Expert, be prepared to flex some .NET muscle.
3. The Way of the Web
While Silverlight is more like WPF and WinForm development than ASP.NET development it’s still important to realize that you are building for the Web. That means that learning technologies like REST (ADO.NET Data Services), JavaScript, the browser’s document object model (DOM), browser sandboxing and using tools like Fiddler are going to be important to you.
2. Blend / Visual Studio Combo
Aside from .NET being in Silverlight, the other awesome feature of Silverlight is that the UI is built with XAML, the same UI platform that WPF uses. That means that Microsoft’s design tool, Expression Blend, is what you use to design UI in Silverlight. This provides the most amazing workflow between designers and developers. Blend 3 is amazing. While Blend 2 is great for mocking a single screen, Blend 3 is awesome at quickly creating mocks for an entire applications. Including features like SketchFlow, mock application data and many more incredible features.
1. Get Started with Silverlight -
So there you go… my last step is to go get started! I find that many people avoid the first step of working with Silverlight because they are intimidated by the newness of it all. I also find that once people do get started, they are usually surprised by how familiar development in Silverlight actually is. Enjoy!
- Silverlight.net – the official Microsoft site for developers and Silverlight designers. Specifically, make sure to check out the getting started section and the how to videos!
- SilverZine – Silverlight designer / developer, Alex Knight, started this great collection of links and tutorials for Silverlight designers. I found out about the site through a Silverlight insiders email list that I’m on, and I’m glad I did! There are some great insights and resources here!
- http://twitter.com/silverlightshow – this actually is a great collection of links and pointers to some really nice Silverlight content.
OK, so those are my top 5 steps. What are yours? Did I miss anything important? Add yours to the comments.
3 Things That Win 7 Should Steal from Apple.
May 20, 2009 Category: Blog, Thoughts No Comments »
For the last 2 months I’ve working on one of the @improving macs almost exclusively. While that’s definitely had it’s annoyances, it’s also been very eye opening in a couple of areas.
Last month Microsoft released the Release Canidate1 of Windows 7. For what it’s worth I will say that I like it, more importantly, my wife likes it too. Just like Vista has nicer features than XP (no seriously, I actually like Vista!), there are features in Win7 that I really like over Vista. That being said, after spending two months on a Mac, here are the things that I wish Microsoft would “barrow” from Apple before Windows 7 RTMs.
Apple’s “Show Desktop” Implementation
I like Win7’s Desktop Peak. But let’s be real. When I want to look at my desktop, it’s probably because I want to do something on my desktop. If I click on the “Show Desktop” button, then everything get minimized and I loose my place when I’m done with the desktop (I have to go restore all of my Windows manually). Macs have this great feature that let’s me, in a single motion, push everything to the side, lets me see and work with my desktop, then with a single click anywhere on the edge of the screen and I’m back to where I was before. Awesome. Dear Microsoft, I know what they’ll say, you stole it. Mac had it first. it doesn’t matter. Go ahead, take it. It’s a better implementation. thx.
Apples “Widget” View
I like Widgets, I like Gadgets. I’m not talking about Apple’s widget “zoom in” and “zoom out” views (although those are nice!), nor am I talking about how Windows 7’s Gadgets can go anywhere on the desktop and are always on your desktop (although I like that too!) I am specifically talking about the scenarios when you have a bunch of windows open and your in the middle of working and you need to take a quick look at your widgets/gadgets. On a mac you set your Expose’s hot spots to bring up your “dashboard”, in Windows 7 you either “peak” at your desktop, or you press the Win+G keys.Here’s the thing, on a mac when you do that, they do a dark overlay on the rest of your desktop. It makes it really easy to to focus in on your widgets and see them quickly. it sounds like a small thing, but you already know how busy your screen can get when you’re working on various projects and then you try to see your gadgets and they just don’t stand out very well.Dear Microsoft, please fade out the background when I push Win+G. kthx.
Apple’s Colors.
Not all of their colors. I like some of the rich look of Vista and Windows 7, but here’s something that I noticed while working on the mac. The “system tray” (or whatever you call it) is boring. Everything is the same color. Compare that to the spectrum of color that the average Windows user is used to. It’s not that color is bad… but I’m starting to think that business is. Business and clutter compete for your attention, and let’s face it… the reason that it’s in the system tray is because it’s important.. it’s just not that important. I know that I’m focusing on the system tray, but really I’m talking an over all effort to make the things that I want to focus on, visually focusable (is that a word?). Reduce noise, increase signal.
So what does Windows 7 have going for it?
A lot. But here’s the thing that it soooo much better on Win7. The Taskbar – so much better than the dock or expose for moving between applications – especially tabbed windows. On one hand, I really like the pop and slide of exposes, and I really like the fish eye affect in the mac dock… but here’s the deal, the dock is great for launching applications, but it’s lousy for moving between open applications. The new Win 7 dock does an amazing job of organizing all of your open tabs regardless of which window their in. It really creates a nice, unified way to move between the things that you are working on and to close the things that you don’t care about. I know that it sounds trivial, but think about where you spend your time – it makes a difference.
What about you? What are you love / hates with Windows 7 or teh mac?
BTW – Travis promised to teach me some mac foo… I’ll have to post again after that!
Silverlight Databinding: Acme Insurance Demo
January 19, 2009 Category: Blog, Technical 1 Comment »
I just posted this on my new health blog. I’m re-posting it here because there is a definite overlap to this contest between getting healthy and the developers audience here.
Wednesday night I spoke at the North Dallas .NET User Group where I announced this for the first time publically… unless you count twitter (some good twitter feed back as well)
So Here’s the deal…. if you’ve seen my new health blog you’ll know that I’ve been having a lot a success lately getting back in shape with an eating plan. I feel great and I’d like to keep the momentum going and help “spread the love”. Too many developers are out of shape (including me).
To help keep this going I’m going to run a contest on my health blog in February: I don’t have all of the details worked out yet, but I do know that I’m going to give out a free subscription to MSDN Team Suit to the winner (approx $10,000 retail value!).
so, tune in, subscribe, or follow me on twitter and look for the final details to get announced here on my health blog before February. Also, if you have any suggestions on how we could do this fairly and accurately on line, leave a comment over there!
(I turned off comments on this post… so that they could go over here.)
Dependency Injection with Silverlight
December 18, 2008 Category: Blog, Technical 2 Comments »
This is one of my favorite talks that I’ve been doing lately. I like the concepts here because they don’t just apply to Silverlight applications, but all of your software development. I also like that fact that most people don’t think about some of the more advanced software approaches that you can take with Silverlight.
Download my demo code from SkyDrive.
Enjoy!










