Nov 23 2019

Apple’s Pricing Genius

Laptops are designed to travel with. We taken home, to the coffee shop, to the library, when we travel, everywhere. It is not uncommon to misplace your power adapter when travel, or equally as bad forget it at home after you left for a trip. And of course, the cable used by the power adapter does wear and tear and would need to be replaced.
I must have been about 3 years when I last needed to replace the power adapter to a MacBook Pro. I remember the sticker shock when I picked up a replacement power adapter and found it cost $69, but I needed it so I paid the Apple tax and bought it.
Recently I had left behind at the office the power adapter for current MacBook Pro, 2016 model. I haven’t been in the office since and I needed charge my laptop. Luckily, so I thought, I have an Apple Store two blocks away from home. This time around, the full cost of a power adapter was $79, but Thunderbolt cable or batteries not included, I needed to shell out an additional $39 for a 0.8M USB-C cable.

Apple Store Receipt for MBP Power Adapter
Apple Store Receipt for MBP Power Adapter

This is truly Apple’s genius. To take a technology, like electricity, that was invented over a hundred years ago. A commodity technology that is found in products priced at $10 and below, like power cords. Change the connectors in such a way that others can’t legally copy your design. Break a product down to their essential components, the actual power adapter from the cable. Charge as much as possible for each component that is sold as a product.

Oct 18 2011

Common Causes for Memory Leaks

You’ll always have to deal with memory issues, no matter the programming language. Even with the Java programming language, if the right precautions are not taken, you will have some sort of memory leaks, memory issue, out of memory exception, or heap size problem. I’ve seen two common types of memory issues in every application I’ve worked on.

A common source of memory leaks is global static singleton god object that collects or manages a lot of data, maybe a system cache, object lookup table, service locator, etc. This type of singleton pattern will require other objects to register with it, add themselves to the global pool of objects, but if they are not properly removed, unregistered, when they are no longer needed you will see your memory usage increase over time. I’ve seen this issue when using the callback or listener pattern and the listener object itself holds a lot of other data. This sort of problem is usually relatively easy to identify with a profiler, it will usually be one of the largest objects in your system.

The other, more difficult memory leak to identify, is when you have hundreds of thousands of objects each taking up a reasonable amount of memory. In this case, a single object instance will not take a lot of memory but collectedly the hundreds of thousands of objects can eat up a lot of memory. Here are a few things you can think about when dealing with a small class that spawns thousand of objects…

If you have int types, see if you can change them to short or byte types. Try subclassing if you have any number of properties that most often than not set or are null. Think about lazy loading arrays, lists, and other objects references. If there are many object instances of this class, and any portion of these instances are logically equivalent, think of using the flyweight pattern.

Mar 18 2011

Chipotle Online Order System

I love me a good burrito, and although Chipotle is not my favorite burrito joint, they do have an online order system that makes ordering lunch for a team of hungry, and picky, developers simple. But while scheduling a pick up order for the entire team I felt more like a tester than a customer.

Right on the first page after login in, I encountered infinite navigation loops. At page where I was to order, there is a big red button that read “ORDER NOW.” If you click this button, it reloads the current page you are already on. After trying that trick for a few times I realized I had to select one of the four order methods: online, app, fax, or burritos by the box.

Order Now

Order Now

I then had ‘issues’ adding invitees to my order. Adding invitees is a three step process. You have to add a list of email addresses in the text area, click ‘Add To Invitees’, this then does some AJAX magic and creates a set of check boxes for each invitee and you have to select all before they are actually invited. I can honestly say that I had to this this step a few times to get it right. If done right, each invitee receives an email with a link to order their own meal.

Add Invitees

Add Invitees

One large problem that a few folks had was that they didn’t order what they actually wanted. Unbeknownst to several team members, Chipotle wants users to be explicit about each ingredient in a burrito. A lot of team members just clicked on Chicken and didn’t realize that Chipotle would just give you a piece of tortilla with some chicken. The burrito looked like it had some stunted growth issue, but worst was the faces of the folks that ordered such a mini-burrito. One problem here is that the UI for ordering what goes inside the burrito is cluttered and goes against conventions of ordering a burrito in most taquerias. This mistake happened to three developers, so I can deduce that it is a common error when ordering online from the Chipotle.

Burrito Builder

Burrito Builder

One final issue I encountered was with the pick up of the online order. I didn’t realize or received a message from Chipotle that I had to log into the system after everyone had made their order and check out. When the time came, I just showed up at my local Chipotle to pick up the food but to my surprised they had not received it because I forgot to check out. Of course, I logged onto their website from my phone there was no way for me to see the recent history or pending order. Lucky for me, I was able to reach an hungry developer in the office and asked him to log into their website from my computer and he was able to finalize the order.

In the end, a few folks didn’t get what they expected, the food was late, and I learned a valuable lesson. Next time I’ll just fax the order in.

Aug 19 2008

Database Best Practices

Every production application I have been involved with has made use of a database. As a programmer, you don’t have to be a DBA, but just as with software development you need to adhere to a core set of database best practices. Below are a few of the best practices I try to follow.

  • Use a database modeling tool that is vendor neutral.
  • Decide upon a database naming convention, standardize it across your organization and be consistent in following through with it. Always be consistent with the use of case and plural vs singular.
  • Have a similar naming between your table columns and object properties.
  • Try not to use system tables directly as they are not SQL standard and may change between releases.
  • Do not use SELECT * in your queries, explicitly write the required columns names in the select statement.
  • Always use a column list in your insert statements. This helps in avoiding problems when the table structure changes, like adding or removing columns.
  • Try to avoid wildcard characters at the beginning of the word while searching using the LIKE keyword.
  • Use the more readable ANSI standard join clause instead of he told style join.
  • If you have a choice, do not store binary files in the database. Instead store the path to the binary file in the database and store the file in the disk, preferably another disk drive.
  • Offload tasks like string manipulations, concatenations, row numbering, case conversions, type conversions, etc to the front-end application.
  • Store computed string manipulations, concatenation, case conversion, type conversions, etc in the database so you don’t have to waste CPU cycles recalculating.
  • Avoid leaking your database design details, such as primary keys.
  • Just like your code, be sure to comment your database design.
  • Use the bulk/multi insert statement.
  • Study the SQL execution plan prior to a major release.

Again, as a software developer you don’t have to be a database tuning expert but you also can’t be excused for not following the above best practices.

Technorati Tags: , , , ,

Jul 9 2008

Microsoft DreamSpark

Even thought I am a Windows user, I am no where near a Microsoft lackey but recently I learned that Microsoft is giving away a ton of professional grade software to students. Through the Microsoft DreamSpark program, students can get access to Visual Studio 2008 Professional, Windows Server 2003 Standard Edition, Microsoft Expression Studio, XNA Studio, XNA Creators Club, SQL Server 2005, as well as other free software such as their express edition software. That is well over $1,500 of free software. I am typically not a Microsoft fanboy but I do have to give credit to Microsoft for making its development tools free of charge to students across the world. Now I wish Adobe would do the same.

Technorati Tags: , , , , , , ,

Dec 3 2007

Favorite Programming Quotes 2007

Here is a list of great programming quotes from my readings over the last year. It is interesting to note that most of my reading material this year has been from blogs. There are just a great amount of programmer bloggers writing a lot of informative tutorials on every programming language, paradigm shift, and framework under the sun.

in my experience, one of the most significant problems in software development is assuming. If you assume a method will passed the right parameter value, the method will fail.
— Paul M. Duvall
Continuous Integration

Programming languages are like girlfriends: The new one is better because *you* are better.
— Derek Sivers
7 reasons I switched back to PHP after 2 years on Rails

The sooner we start coding fewer frameworks and more programs the sooner we’ll become better programmers.
— Warped Java Guy
Elementary Java Solutions

Starting a startup is hard, but having a 9 to 5 job is hard too, and in some ways a worse kind of hard.
— Paul Graham
The Future of Web Startups

In essence, let the market design the product.
— Paul Graham
The Future of Web Startups

A startup now can be just a pair of 22 year old guys. A company like that can move much more easily than one with 10 people, half of whom have kids.
— Paul Graham
The Future of Web Startups

Startups almost never get it right the first time. Much more commonly you launch something, and no one cares. Don’t assume when this happens that you’ve failed. That’s normal for startups. But don’t sit around doing nothing. Iterate.
— Paul Graham
How Not to Die

The key to performance is elegance, not battalions of special cases.
— Jon Bentley and Doug McIlroy

You’ll spend far more time babysitting old technologies than implementing new ones.
— Jason Hiner
IT Dirty Secrets

To Iterate is Human, to Recurse, Divine.
— James O. Coplien

No one hates software more than software developers.
— Jeff Atwood
Hanselminutes Podcast 74

I was a C++ programmer before I started designing Ruby. I programmed in C++ exclusively for two or three years. And after two years of C++ programming, it still surprised me.
— Matz
The Philosophy of Ruby

Good architecture is necessary to give programs enough structure to be able to grow large without collapsing into a puddle of confusion.
— Douglas Crockford
The Elements of JavaScript Style

Programming is difficult. At its core, it is about managing complexity. Computer programs are the most complex things that humans make. Quality is illusive and elusive.
— Douglas Crockford
The Elements of JavaScript Style

Code reuse is the Holy Grail of Software Engineering.
— Douglas Crockford
The Elements of JavaScript Style

The structure of software systems tend to reflect the structure of the organization that produce them.
— Douglas Crockford
The Elements of JavaScript Style

The definition of Hell is working with dates in Java, JDBC, and Oracle. Every single one of them screw it up.
— Dick Wall
CommunityOne 2007: Lunch with the Java Posse

Suppose you went back to Ada Lovelace and asked her the difference between a script and a program. She’d probably look at you funny, then say something like: Well, a script is what you give the actors, but a program is what you give the audience.
— Larry Wall
Programming is Hard, Let’s Go Scripting…

I went to school to learn how to program software applications, which inevitably have bug defects. There was no course at my university on testing, debugging, profiling, or optimization. These things you have to learn on your own, usually in a tight deadline.
— Juixe TechKnow

To most Java developers, Ruby/Rails is like a mistress. Ruby/Rails is young, new, and exciting; but eventually we go back to old faithful, dependable, and employable Java with some new tricks and idioms and we are the better programmer for it.
— Juixe TechKnow

You might as well pay your customers 50K because they are just your QA.
— Juixe TechKnow