Thinking About Verbs

In my last post, I said you should model verbs, not nouns. I probably exaggerated a bit (I tend to do that) – you shouldn’t completely forget about the nouns. Your verbs wouldn’t have much to do without them. Instead, you should be focused on the verbs and the details of the interactions, not the details of the nouns and adjectives (those will take care of themselves).

Your users want to use your application to get work done. As a I said, gone are the days of simple data entry applications (well, not completely, but certainly anyone building new products isn’t working on solving data entry problems). They want to perform tasks using your application – ordering a book is a task, not a data entry activity. Dispensing a medication, verifying the number of 2x4s in stock, checking a book out of a library – tasks, all.

This is not a new concept. Microsoft published an article about Inductive User Interfaces back in February, 2001 (Inductive was their term for task-based). Tasks have been the focus of various writings about Domain Driven Design, CQRS, and Event Sourcing. Another similar approach is the DCI Architecture, which is a little more formal but also acknowledges the importance of the verbs (or interactions, as they are called).

Which of these approaches, architectures, or techniques you use isn’t overly important. What is important is that you consider the verbs, the events, and the interactions. My last post came from a meeting we had at my company talking about how best to handle data transfer objects. We came to the realization that it was better to have a different DTO for every context, even if they contained the same properties, because as time went on, each of these objects would have their own reasons to change.

This led to trying to determine how best to name these things. How do you differentiate between 6 different OrderDTO classes? The answer is, you don’t – the order isn’t the important part. You focus on what the consumer of the DTO is trying to achieve and use that for the name. This is of course a fairly contrived starting point for a discussion of verbs – I still am starting from nouns (orders are nouns). But it led to further discussion about the way we needed to think about things – in terms of the interactions. If we had started there, we would have had an easier time of things. Fortunately the system under discussion still has a ways to go and we have plenty of time to make use of the lesson.

Special thanks to Matt Otto, who reminded me of DCI Architecture, as well as linked me to this very amusing article that basically makes the same points, although much better.

Posted in Architecture, Distributed Systems, General Coding, Improvement, Techniques | Tagged , , , ,

Model the Verbs, Not the Nouns

For most of my career, the “best practice” has been to build applications from the data up. You model the database and then everything will be happy. Its just the way you do it. There is no other way.

So what’s the problem? You end up building applications around what data you need to display and what data you will update. So you show the user all of the data they might need, because you don’t know what they need. You ask for all sorts of data, because you might need it for some scenario. You build screens that they can use to enter any changes that might occur with this data, no matter why those changes are required.

The problem with this approach is there is no “why?”. Why are you showing the user this data? Why are they updating it? What is it that they are really trying to do? You end up with a lot of very obtuse code that is hard to follow, because its only concern is pushing data to the screen from the database, or vice versa. It flows through a lot of logic that you might need in case of various scenarios, but its impossible to know what rules apply to what scenarios, because there is nothing about your code to imply intent.

Back when I started in this field, I was building applications to allow users to put paper forms into databases. There really wasn’t much more logic than that. I was not alone in this – its what most applications did back in the early 90′s. We were trying to build the paperless office, after all.

We can do so much more now. In fact, our users expect it. In order to do so, though, we need to think about the behavior that is expected. What is the user trying to accomplish? Why? What is the intent?

If we examined the behavior, the verbs of the system, instead of just the data (the nouns), we’d have a better understanding of what it was we are trying to build. Our code would be more obvious. The user’s intent would become clear. And then we could build the system the users actually want to use, the one that helps them get their work done in a more efficient fashion. The one that they don’t constantly complain about (OK, that might be a stretch…).

Model behavior by thinking about the verbs. The nouns will follow.

Posted in Architecture, Distributed Systems, General Coding, Improvement, Techniques | Tagged , , , , | 2 Comments

The Wild Goose Chases of 2011

I spent a lot of time last year trying to learn a lot about everything I could in terms of the latest development fads (other than Agile – I think I’ve flogged that horse to pieces). I figured I needed to learn Ruby, Rails, JavaScript, Node, jQuery, Backbone,… Part of the department is rebuilding a PowerBuilder application that needs to stay a thick client using WPF, so I learned a bit about Caliburn Micro. I found a little time to dabble in CQRS, MicroORMs, RabbitMQ, and MassTransit as well, but I didn’t focus on them too much.

The net result, come the holidays in December, I was feeling quite burnt out. So much so that I pretty much ignored software for a bit. January started and I felt better, and then I went to CodeMash, and that helped a bit. But the thing that really snapped me out of my funk was the realization last week that while I should know the basics about everything I can, I can’t know everything in any real depth. I have to have something I specialize in.

I’ve always been a fan of the generalizing specialist theory espoused by Scott Ambler. The problem was, I was spending all of my time generalizing. Part of that was an occupational hazard – I am tasked with figuring out the general direction for the technology and architecture of our product suite going forward. In order to do that, I needed to evaluate the suitability of some of these things. But I certainly didn’t need to dive into all of the shiny tools and toys I did – some of it didn’t matter at all. Some of it could have been delegated to someone else.

So now, as I step away from the fire hose that I’ve spent the last year trying to drink from, I realize what I need to do. I need to focus on the things that I know well, that have gotten me to where I am today. Sure, I still need to occasionally play with other technologies. But that can’t be the focus of my software development life. By diluting myself across these things, I haven’t really helped anyone, especially myself.

Now that I have that sense of clarity, I think this year will go much better…

Posted in Improvement | Tagged , , | 1 Comment

Don’t take any wooden nickels, part 3

So don’t trust consultants and don’t trust Microsoft (and by Microsoft, I really meant any vendor’s guidance). And it’s more a case of trust, but verify. But I digress…

Open source software can be a great solution to a problem you need to solve. Finding the right tool or library can cut precious time off of your schedule and greatly decrease your maintenance costs. Of course, if you aren’t careful an OSS solution can be the anchor that drags your project down to a watery grave.

As I said about consultants and vendors in the other posts in this series – it’s your responsibility to explore the in’s and out’s of the open source solution. Will the license work for your business model? Is it well supported? Is it a fairly good match to the way you and your team build software? Lastly make sure it really is better than the alternatives.

The alternatives you have to consider are commercial solutions and building it yourself. If you need to figure out how best to carry out that evaluation, there are plenty of sources out there to guide you. But that’s another show. If you can’t wait and need some pointers I use, feel free to email me.

The point of this series is that software is a tricky game. There is no one best solution that will apply to all problems, not even for a small related subset. Carefully consider the options. Learn from multiple sources. Read articles and books about things outside of your stack of choice. Heck, read about things not directly related to software at all (I’m a sucker for pop econ and statistics books – Freakonomics and Drunkard’s Walk are very good books).

Don’t blindly follow.

Posted in Improvement, Techniques | Tagged , , , ,

Don’t take any wooden nickels, part 2

Microsoft Patterns and Practices is an extreme case of my theory about consultants. These guys appear to have never shipped anything that will be used by real users. That wasn’t always true. Early versions of the Data Access Block were quite useful. But then they started building examples that showed every possible facet and feature they could think of. And people started using these examples as guidance. Probably because P&P told them to.

The problem was, these things were too complicated for any real use and too complicated for a mere mortal (or even one of those rockstars. or was it ninjas?) to be able to extract just the little bits that could help them. And so people just started using these things whole hog, even if they only really needed 10% of the functionality. And don’t get me started on how big consulting firms (like the Big 6, or however many are left these days) love to use them as a basis for their lowest bidder projects that overrun schedule and budget…

What’s even worse is that typically these things do not follow sound software development principles. To them, OO is a typo where someone forgot to include the "W" (WOO!). People use these things as guidance to learn from. There’s an idea that there is nothing worse than to lead an innocent to sin. I’m not calling them evil or anything, but this guidance isn’t doing anybody who’s learning how to code in .Net any favors.

And of course, most sample code has this problem. In the sample code accompanying an article or a presentation, sometimes it is necessary to leave out the parameter checking and error handling code so that your point is clear. Its not the greatest thing, but its usually worth the tradeoff. It might be nice if maybe we started including the "well written" version in our sample code downloads.

The problem is, P&P ships these things as guidance. They implicitly say – if you write your code like this, everything will be great. And that’s probably true for version one but the omissions and issues of version one tend to live a long time. Not following good OO and development practices makes it hard to maintain and improve the application and that’s no fun.

Don’t take any one source as the guide for how you build software. Microsoft has provided a lot of very good tools and some very good guidance about how best to use those tools. But that guidance does not apply to every situation and some of it really doesn’t apply to any. Make sure you look at all sample code (or even open source project code) with open eyes. The author probably has a viable solution to a problem and it might even be your problem. But don’t assume it is the best solution for your needs.

Posted in Improvement, Techniques | Tagged , ,