Quick programming style question. If you have two boolean values and want to have a different outcome for each alternative and the case where both are true, how do you do it?
Here are the two options I have come up with.
First, a straight if-else if-else block like this:
Update: I have updated this first option to reflect Dave’s comment below.
if(foo && bar){
//do foo&bar stuff
} else if(foo){
// do foo-only stuff
} else if(bar){
// do bar-only stuff
}
//perform final computations
Second, nesting if clauses like this:
if(foo || bar){
//set up assuming foo && bar
if(!foo){
//remove foo-specific stuff
}
if(!bar){
//remove bar-specific stuff
}
//perform final computations
}
Or perhaps there’s a better way that I haven’t considered. I’d be interested to see how you handle this. Let me know in the comments or a post on your own blog.
Tags:
Recently, I realized how much power the Internet gives to consumers. I had two experiences yesterday that bring this point home.
The fall semester begins in a little more than a week. I went to the book store at school to find out what the required texts were. The software engineering book was $121.60 new and the database systems book was $118.00. I popped my iPhone out of my pocket and browsed to Amazon.com. In less than five minutes, I had located the books and purchased them. Grand total: $140. Victory number one.
Victory number two began when I found out I was going to C4 on a student scholarship. I started making travel arrangements. I checked Expedia and Travelocity first. Travelocity was by far cheaper than Expedia and the price was good, so I decided to book the trip. But every time I clicked through to what I suppose should have been the final page, it redirected me to a fresh search. I tried several times over the course of two hours until finally, I called Travelocity. (”Your call may be recorded.” Please, God, tell me it was.) I got someone on the phone who was obviously located a couple continents away. I explained to him that the website was not functioning properly and that I needed assistance booking the travel. He said, “I can help you with that, but there will be a $25 charge for booking over the phone rather than through the website.” I explained to him that I shouldn’t have to pay that fee because the website was malfunctioning. Otherwise, I wouldn’t have called. He maintained that the fee was non-refundable. So, I asked to speak with his supervisor. “Sure, you can speak to the supervisor, but he will tell you the same thing.” He put me on hold.
While on hold, I brought up Orbitz.com. I found the exact same flights and hotel accommodations for $6 more than Travelocity’s price before the $25 fee. “That’s fine,” I thought to myself.
When the supervisor came on the line, I reiterated the situation. “Website borked. Please waive fee.” The supervisor rattled off some script about prices changing constantly and that the fee could not be waived. When he said that, I clicked submit to book the travel on Orbitz.
I explained to him that since he (or Travelocity, it doesn’t matter which really) was not willing to waive a $25 charge that I should not have to pay anyway, they were foregoing the entire $830 sale. (Ann Margaret is going as well to do some shopping and such.) Not only that, but the bureaucratic (The archives show how I feel about bureaucracy.) attitude of Travelocity’s representatives means I will never do business with them again. Marketing research tells us that it is much cheaper to keep an existing customer than it is to acquire a new customer. Something tells me that for Travelocity, acquiring a customer to replace me will be much more expensive than $25. I wonder if Travelocity thinks the loss of a customer for life is worth $25. I seriously doubt it.
What is interesting about this is that if it weren’t for the Internet as we have it today, I would have had nearly no leverage. If I were sitting in a travel agency office and they tried to foist some fee on me, I could threaten to go to another agency. I could. But unless it’s particularly egregious, I know (and they probably do too) that I’m not going to waste my time going to another agency. But what if I had the other travel agent in the same room saying, “Oh, we won’t charge you some stupid fee.”
In both cases, I was able to “visit the competitor” without any real effort. I was able to retrieve competing offers in both cases without physically changing venue. Moreover, I was able to make good on the usual threat to go with another company immediately. The Internet affords consumers leverage that was simply not available in the past.
Tags:
This review was originally published at The Satchelist. Visit there for more bag reviews.
Introduction
I recently purchased the Bomber Jacket Laptop Messenger bag from Levenger. I have been eyeing this bag for quite a while and when Levenger gave me a 20% off coupon with a recent order, I finally pulled the trigger. But I have some fairly exacting standards when it comes to bags. Can the Levenger Bomber Jacket Laptop Messenger measure up?
Background
Before beginning with the review, it’ll probably be helpful if I give some background about myself and my use case. I am a nomadic programmer. I work a full-time day job; I run a freelance web design and technical consulting business; I am starting out in independent Mac software development; and I switch contexts frequently among the day job, home, school, and assorted mobile locations like Starbucks. So, I have to be able to carry with me a pretty significant amount of kit in order to be ready to work wherever I find myself with a spare half hour. As a result, I have an ongoing, near-obsessive quest for a great bag. For the past year or so, I have been carrying a Wenger backpack that I liked well enough. But something feels just a little bit out of sorts showing up to work or client meetings with a backpack. This is the color of my crystal when evaluating any bag.
Appearance and Aesthetics
Holy cow does this bag look great! The folks from Levenger certainly know how to use quality materials. The leather is soft and supple and smells great. The twill lining is soft as well. The zippers and other hardware are sturdy and made with high quality materials. The magnetic closure is cleanly hidden and keeps the flap from flying all over while I am walking. The strap is gorgeous as well. Whereas many bag makers treat the strap as an afterthought, Levenger has given the strap quality leather accents. The strap material is also found on the side ends of the bag to give the strap a sense of connectedness to the rest of the bag. As an accessory, this bag is near perfect.
Design and Functionality
For my money, I find the design and functionality of the Laptop Messenger to be the place where Levenger cut the corners. This is most unfortunate for a product as beautiful as this one.
The first thing I noticed was that the laptop pocket is the outermost pocket. This is the exact opposite of what a functional bag should do. The laptop will be one of the least frequently accessed items in the bag, particularly when on the move. The laptop pocket should have been placed next to the body instead. This would allow for faster, easier access to files or smaller items in the accessory pockets. Strike one.
The second thing I notice is that the accessory pockets are placed on the far side of the interior pocket. Again, this should be nearer to the body and ideally in the outermost pocket. Simply standing up with the bag over my shoulder reveals this clear design flaw. My accessory pockets contain a 3 X 5 Leather Rope Case (also from Levenger) that is pretty full of index cards, a Moleskine ruled pocket notebook, a brush, a pen, a pencil, a highlighter, and an eraser. When I stand with the bag over my shoulder and move the flap to get access to my items, the weight of them on the outside of the pocket makes the pocket collapse on itself. This means it is near impossible to interact with this bag without looking at it. My litmus test for a bag is how fast I can get to whatever it is I need at any given time. (My Wenger bag fails this test miserably.) For a messenger bag in particular, this is crucial, and this bag returns blue instead of pink.
Laptop-y-ness
I am giving special attention to this particular aspect of the bag since it bills itself specifically as a laptop messenger. For me and many others, laptop does not mean just the computer. If you are anything like me, then you need a variety of plugs, accessories, adapters, and other kit to work effectively with your laptop. The bare minimum requirement is to carry a power cable. There is no good place to store anything other than the computer itself with this bag. If I decide to keep this bag, I will end up purchasing a gear bag (likely of the WaterField variety) to lug around my kit. Not the kind of solution I expect to land on with Levenger.
Conclusion
In the end, the issue of reviewing this bag becomes whether you value form or function. If it’s the form and style that you are after, then save yourself $50 and buy the regular messenger bag. If you value function, then skip the Bomber Jacket Laptop Messenger. The gorgeous materials and craftsmanship save this bag a 2/5 rating. From my perspective, this bag should be sold as a messenger bag with a note that it is large enough to hold a laptop computer. But a Laptop Messenger it is definitely not.
Tags:bags·levenger·Reviews
I have posted about this on the Twitter several times, but I think some folks have missed it.
If you follow me on Twitter, you might know I injured my knee almost a month ago. I was playing basketball (with kids two thirds my age) and stepped out to pick up the ball handler off a pick and when I planted my left leg, I heard a loud pop. My knee oscillated laterally maybe four times. Then, I think I blacked out for a moment because the next thing I remember is being on the floor screaming and weaving a tapestry of profanity. (Bonus points if you name the movie reference there.)
I knew this was serious. I couldn’t walk. I went to the health center at school the next day (because my insurance sucks and if you go anywhere else first they won’t pay) and they wrote me a prescription for hydrocodone and a referral to Dr. James Bothwell. I saw him two days later, and he poked at me a little bit and confirmed what I already suspected: I tore my ACL. He ordered an MRI to see what else I had done.
I had the MRI that evening. The results revealed the torn ACL and a slight tear to the lateral meniscus.
That brings us up to date. I have been doing rehab exercises to strengthen my left leg in preparation for surgery, which is scheduled for May 22. I scheduled it for then so I’ll only miss two days of work. I’ll miss the day of the surgery and the next day. Then, I have the weekend and then a paid holiday on Monday for Memorial Day. Then, I’ll be working from home. Depending on whether he has to stitch my meniscus, that could be another ten days or three weeks.
I’m looking forward to getting back on my feet. Dr. Bothwell says I can play golf in about three months and can start getting back into basketball in nine months to a year.
Thanks for all your warm thoughts and well wishes.
Tags:acl·injury·knee
This Computer Information Technology degree has been interesting. Of course, the coursework has been interesting, but it’s also been fascinating (dumbfounding at times) to watch the functioning of such a large institution as TCU is.
When I first transferred into this B.S. degree from my Th.M. program in 2006, there was some question about my transfer credits. Almost everything counted and I ended up with about 108 credited hours toward my new program. There were a few general ed courses I had to take because my first program did not require as many courses in the particular area.
I had to take a social science course. Miguel Leatham, a professor of anthropology, had given a talk to one of my graduate classes on ritual, so when I saw that his Anthropology of Religion was on offer, I thought it would be a great class for my social science credit. But, according to the university powers, Anthropology of Religion is not a social science, just a religious studies course. I’ll repeat that: Anthropology of Religion is not a social science course. I ended up taking Health, Illness, and Medicine that semester.
But today, I was registering for Software Engineering for the fall, and I notice that it is listed as being a writing emphasis class. If Anthropology of Religion is not social science, then there’s no way in hell that Software Engineering is a writing emphasis course. Sure, we’re going to do a fair amount of writing (design documents, user manuals, etc.) but that’s not what writing emphasis is for—it’s to get people comfortable and proficient at communicating in written form, preferably in English, so they don’t look like idiots when they venture out into the real world. (I’ll gloss over the fact that most of the real world wouldn’t know proper usage or sentence construction either bit them in the ass.)
This is all a matter of common sense versus bureaucracy. When I petitioned for Anthropology of Religion as a social science credit, some rule monkey looked at the UCR listing and said, “No, because the rules say…” But no one had the commons sense to know that Software Engineering is not a writing emphasis course.
If you’re reading this, please learn to use whatever God was gracious enough to stick between your ears. Don’t be a bureaucratic rule monkey.
Tags:
I got really fed up with Adobe hijacking my PDF viewing with their bloated plug-in. Preview is just flat better for just reading a PDF. In the past, it was a configurable option in Acrobat Professional or Acrobat Reader preferences, but to my chagrin, they’ve now decided that the user can’t be allowed to choose how to view PDF’s as evidenced by this screenshot:

Frustrated, I turned to Twitter for help. Robert Marini (@wisequark) was Johnny-on-the-spot with the solution. Here’s the Twitter discussion in a thread for your easy following: So, it turns out that Adobe not only hijacks my PDF viewing, but any time I update any of my Adobe software (I have CS3 Master Collection.) They’re going to reinstall the thing. “Bullshit,” says I, so I fired up Hazel to fix it for good.
Read on for my solution using Hazel.
[Read more →]
Tags:adobe·Applescript·hazel·noodlesoft
Over on Twitter, Brett Kelly (@inkedmn) mentioned that he’s tired of most of his music collection. This was a problem for me a while back, but I have two suggestions that can help. If you’re in need of a breath of fresh musical air, read on. [Read more →]
Tags:iPod·music·pandora