Month: March 2009

  • Virtually Speaking

    The word virtually is overused. In many cases using the word virtually simply means not. For example:

    I have finished virtually all of my homework.

    This new surgical procedure is virtually pain-free.

    In Modern American Usage, Bryan A. Garner counts virtually as a weasel-word. Weasel-words are so named because of the habit of weasels to attack birds’ nests, and eat their eggs by sucking the meat out, leaving an empty shell.” Likewise, words such as virtually “have the effect of rendering uncertain or hollow the statements in which they appear.”

    So be careful using virtually, or other words that similarly diminish the words around them. Other weasel-words commonly used by writers today include significantly, obviously, very, and quite.

  • Hello EclipseCon 2009

    No, I am not attending EclipseCon — but my smiling face apparently was on Tuesday. StackOverflow founder and CodingHorror blogger Jeff Atwood emailed me to let me know he displayed my StackOverflow user profile page during his keynote at EclipseCon.

    I don’t know what the context was in which he showed my profile. Maybe he just needed an example of an SQL geek who has too much time on his hands.

    I hope a video of the keynote will be made available. If I do find one, I’ll link to it in this blog.

  • Parrot Web Framework?

    Wondering if the following idea could be feasible:

    • Architect a web framework that emphasizes Inversion of Control.
    • Implement core web framework in Parrot (now that this dynamic language platform has released its 1.0).
    • Voila! A web framework that supports any language implemented for Parrot platform.
    • Developers write plugins in any language: Python, Ruby, PHP, Perl6, Lua, C, or any other language supported on Parrot.

    Although the Parrot platform is now 1.0, specific language implementations are still in various stages of development. Realistically, I would guess that it’ll be some years before the architecture above is ready for production.

  • How do the Proxy, Decorator, Adaptor, and Bridge Patterns differ?

    A user recently asked:

    I was looking at the Proxy Pattern, and to me it seems an awful lot like the Decorator, Adaptor, and Bridge Patterns. Am I misunderstanding something? What’s the difference? Why would I use the proxy pattern veses the others? How have you used them in the past in real world projects?

    Proxy, Decorator, Adapter, and Bridge are all variations on “wrapping” a class. But their uses are different.

    • Proxy could be used when you want to lazy-instantiate an object, or hide the fact that you’re calling a remote service, or control access to the object.
    • Decorator is also called “Smart Proxy.” This is used when you want to add functionality to an object, but not by extending that object’s type. This allows you to do so at runtime.
    • Adapter is used when you have an abstract interface, and you want to map that interface to another object which has similar functional role, but a different interface.
    • Bridge is very similar to Adapter, but we call it Bridge when you define both the abstract interface and the underlying implementation. I.e. you’re not adapting to some legacy or third-party code, you’re the designer of all the code but you need to be able to swap out different implementations.

    I’m posting to my blog the questions I’ve answered on StackOverflow, which earned the “Good Answer” badge. This was my answer to “How do the Proxy, Decorator, Adaptor, and Bridge Patterns differ?

  • Can I Use Example Code from Internet Q&A Sites?

    A user recently asked:

    Scenario:

    • A developer is working on a project and encounters a problem.
    • They ask a question on the internet somewhere (ie stackoverflow.com)
    • Someone answers their question and provides a nice code snippet that just about does what they want.

    Where does one legally stand if the developer includes the code verbatim in their project’s code?

    I know I’ve done this before…and I’m sure others have too…but I’d really like to know what the legal or ethical answer is to this question.

    Note: never make business decisions based on legal advice you read on the internet — including mine! Confirm this with a qualified legal professional.

    StackOverflow seems to offer its content under the Creative Commons Attribution-Share Alike 2.5 license. See the logo and link at the bottom of the page.

    This means you are free to copy, distribute, and transmit any content you see here, or to remix or adapt the content.

    However, you must attribute the work in the manner specified by the author (though I can’t find where this is specified on StackOverflow), and if you alter or build upon the content, you may distribute it only under a compatible license. So it’s similar to LGPL, in that respect.

    I would recommend that you do not copy code or other content from StackOverflow verbatim, if you need to use it in a commercial project.

    • Should one use the example code and move on?

      No. You need to be aware of the license and comply with it, or in theory you could get your project into trouble. Realistically, this is very unlikely. But it is still possible to cause problems.

    • Should one use the example code and provide a comment referencing its origin?

      Yes, attribution is required by the Creative Commons license used by StackOverflow.

    • Should one inform the provider of the example code that they’ve used their code?

      You are not obligated to do so, so it would be a courtesy and that’s up to you.

    • Should one not use the example code at all and use the basic idea to create your own code?

      Yes, this would be a conservative and safe policy. Plus, it’s always better to understand how the code works, which you would have to in order to write code with similar functionality.

    • Is it ok to use said example code in proprietary closed-source projects?

      No. The license would require you to make your project available under the same Creative Commons Share Alike (or compatible) license.

    • Is it ok to use said example code in proprietary but internal-use-only projects?

      Technically, yes, because like GPL & LGPL, the licensing requirement only activates when you distribute a derived work. But how can you be sure that code from the internal-use-only project will never be duplicated into a product that gets distributed? Do you plan to annotate code fragments within your internal projects? I would not recommend relying on this.

    • Are the legal implications currently undefined?

      No, they are spelled out in the Creative Commons license mentioned above.

    I’m posting to my blog the questions I’ve answered on StackOverflow, which earned the “Good Answer” badge. This was my answer to “What legal issues can I run into if I use example code (say from stackoverflow) in my projects?

  • Quantity Over Quality

    Alex Netkachov recently reported a list of micro-optimizations for PHP. Several other bloggers (Sebastian, Maggie, Pádraic) responded with appropriate messages, reminding people that proper application design usually counts more than micro-optimizations.

    They are all correct.

    When I was an intern, I emailed a C compiler developer, to ask a question that had occurred to me regarding optimization: which is faster, ++i or i++? Assuming either form will work in my case, as in the increment expression in a for() loop. His response (paraphrased):

    “By emailing me this question, you have already wasted more computing resources than you will ever save by choosing one form over the other during your entire programming career.”

    (I’m still not sure if he meant to emphasize that the performance difference between the two expressions was extremely small, or that he didn’t think very highly of my career prospects. I’ll prefer to assume the former.)

    A list of performance factoids like those listed by Alex are missing the guidance and wisdom that software developers need to judge their importance. All of the responses from other bloggers are similarly qualitative, instead of quantitative.

    I know that it’s hard to make quantitative statements with regards to optimization.

    • How much benefit can I get by replacing print with echo? It depends on how much printing you do in a given application — and also what else you’re doing in that application.
    • Can I benefit from caching page output or results of resource-consuming functions? Probably, but not if the content is 100% dynamic and must be re-calculated for each request.
    • Which of these micro-optimizations should I employ with greater priority? Which is the best use of my development time?

    These micro-optimization tips are interesting and worth knowing, but they should also be taken with a grain of salt. Their importance varies, depending on the nature of your application. There are no magic words that are guaranteed to double performance in every application.

    Finding the best way to optimize your code is your job as a software developer. You must use scientific measurement, as well as good judgment, experience, and intuition to get your job done most effectively.

  • Accepting a job that failed The Joel Test

    A user recently asked:

    I’m about to accept a job offer for a company that has failed The Joel Test with flying colors.

    Now, my question is how do I improve the conditions there. I am positive that within a few months I will be able to make a difference.

    But where do I start? And how?

    Don’t view yourself as the “new sheriff in town” who’s here to clean it all up in one year. The habits they have settled into have been a long time forming.

    Watch and listen, and ask questions about the most severe and recurring pain points. Find out what bad habits have actually caused loss of work, late nights, quality problems, or lost customers. Try to quantify the cost of these bad habits.

    Then at some point talk to your boss in a one-on-one meeting and make a proposal for how you could mitigate one specific risk that seems to be their biggest problem. It could be almost anything on the Joel Test, but I’d guess it’s most likely to be one of:

    • No source code control means the code is a mess, with lots of “commented out” sections. Can’t track which code changes were made for a given bug. It’s hard to do major features in parallel with ongoing maintenance. No way to roll back changes. No way to track which developer did what changes.

    • No build process means some code changes exist only on the live server. Developers are constantly pushing and pulling code to and from the live server. No one has a development environment that’s in sync with the live code, so it’s hard to reproduce bugs.

    • No bug database means some tasks “fall through the cracks” from time to time. Customers report bugs that fall into a black hole. Managers don’t know what’s being worked on. Employees have no record of their work when it comes time for annual reviews.

    When presenting the solutions, don’t try to justify them with abstract concepts like “best practices” or “it’s the industry standard way” or anything so intangible. If those were enough to motivate this company, they would have done it by now.

    Instead, focus on what is their deciding factor. I’d guess it’s probably related to how much time and money it costs the business to use best practices, versus how much it can save them. But you should find out if this is really their reason. It’ll take some setup work to establish these tools and practices, but you can explain the recurring benefits for quality, productivity, and predictability of the development work. All those can contribute to the business’ bottom line.

    In one year, you’ll be doing extremely well if you can make just one change to help them. It’ll take a lot of patience to overcome a development culture that has been building for so long. Keep in mind that the rest of the team isn’t there by coincidence — they may actually be compatible with that level of disorganization.

    I’m posting to my blog the questions I’ve answered on StackOverflow, which earned the “Good Answer” badge. This was my answer to “Accepting a job that failed The Joel Test