Code Reviewing
I wrote this a few months ago when I was doing a lot of code reviewing. There are a number of criticisms of the Code Review, and certainly, a number of review mechanisms that can and should be used in conjunction with some type of human review, such as static code analysis and performance analysis. In this post, I won’t be comparing or contrasting the Code Review to any of these.
Strategies, Questions to Ask and Things to look for
Some code review questions…- Is it relatively clear what the code does from reading it?
- Is the code in a reasonable location and named appropriately?
- Is this same functionality duplicated elsewhere?
- Are there any unnecessary calls, methods, variables?
- Do any of the url params have the potential to conflict?
- Has all text been pulled out into properties files?
- Would it be useful if this code could be disabled or enabled? If so, has the author provided a means for turning it off?
Tools
My experience with code reviewing tools is limited. The Jupiter eclipse plugin seemed to require too much work on the developers part—generating the request for review, checking in the .jupiter file and review files slowed development down. Monitoring svn check-ins seemed to work moderately well, although it required more work on the reviewer end.
When to do the code review
Ideally, code reviews shouldn’t uncover any larger architectural issues that need addressing. They should expose overlooking coding mistakes. So, ideally there should be no timing problem, that is, you shouldn’t find some large refactor that needs to be done before the code is released. Code should be reviewed after development is finished, but before the functionality is ready for qa.
Double Time
There are several different ways that code reviews can go: the code reviewer(s) can monitor check-ins, developers can request that code reviews be done on their code or the dev team can get together as a group and go over the code line by line etc etc. One thing that has worked for me is employing more than one of these methods. So, developers submit requests for review and I also monitor check-ins.
10 tools every web developer should know
I know, I know – this title sounds like link bait, but I realized the other day that many of the suggestions I make to my fellow developers on how to troubleshoot/debug “stuff” begins by recommending a tool. The underlying theme among all of these tools is that they help you verify, verify, verify!!
So here are some useful things to know how to do as web developer…
1. how to debug with firebug- Set breakpoints
- Edit html/css on the fly
- Turn off css classes
- View external calls that your browser makes on page load
Knowing how to debug with firebug will help you when you want to verify that some piece of javascript is being executed by the browser, when you need to know if a style is actually being applied to a class or that your browser is actually loading a fresh version of some file every page load.
2. how to use tamper data (or another packet sniffer like charles or wireshark/ethereal) :- install tamper data firefox extension or wireshark
- start tampering or capturing data *load webpage (optionally edit the request)
- stop the capture/tampering
- view calls your browser (ah, er, your computer) is making
Basically, if you are unsure that the request contains some information, you can verify that using tamper data or wireshark.
3. how to create cookies with web developer- install the web developer Firefox extension
- select “Cookies” from the Web Developer menu
- next select “Add Cookies”
- enter the name of the cookie, the value and what domain it applies to
Knowing how to set cookies and verify that a cookie exists and that it has some value and applies to some domain is, of course, essential when working with cookies.
4. how to test for multiple user agents- install the firefox extension
- import any needed user agents
- switch from your default user agent to needed user agent (iphone, IE6) and refresh the page
Sometimes development and test environments are publicly accessible, which can be a real problem for test from a mobile device without access to your companies intranet. And although testing for multiple browsers may best be done in the actual browsers themselves, problems can expose themselves here.
5. how to navigate your way around jQuery, prototype, yui, moo tools or some other javascript frameworks, including “third party” javascript apis (like video, twitter, url shortner apis)
- avoid “rolling your own” or “reinventing the wheel” by using existing methods provided by the framework
- use the right methods and objects for the version of framework you are using
It is important to know how to use documentation from some javascript framework to confirm that you are writing what you think you are writing.
6. how to write or use an automated functional testing suite, such as Selenium, Quick Test Pro or some home-made solution- easily set up functional tests to confirm that changes you’ve made aren’t breaking old functionality
The idea behind all of these tools is to capture some record of page quests and html/css/js on the page and match this up to some pre-recorded (potentially somewhat dynamic) set of html/css/js values.
7. how to configure your ide to help you spot javascript/css/html errors- whether it be a javascript plugin for your favorite IDE or the fact that your IDE provides syntax coloring for javascript, know how to make it easy on yourself to spot errors
The easiest thing you can do for yourself is verify that there aren’t errors in your code before you start testing it.
8. how to test your regexs- again just confirm that what you have written is working for the cases you can identify.
You won’t be able to test every possibility, but if you identify the cases that might occur you can test those out
9. how to put your “stuff” in version control easily- whether it is svn, git, clearcase, cvs or whatever, you’ve got to either know your version control client or know your command line commands very well
- confirm that your commits are successful by browsing them in some web interface provided by the vc service
If you aren’t seeing your changes in an environment, it is always good to check and see if those changes are really there.
10. how to troubleshoot client-side performance problems- determine what is slow and if the slowness is a result of page weight or because your javascript has some runtime inefficiencies.
- use yslow
- for a more in depth look at javascript performance, i suggest javascript rocks
Basically, the end result of these tools from a very high level perspective is to know where the performance problem is (or is not). For instance, if your page weight is small and there is little javascript “action” on your page, it might be plausible to think slowness isn’t “on the front end”, but is being cause by slowness on the server side.
Remembering what you've written
I have folks at work ask me details about code I’ve written and how it works. Almost always, I have to go back and at least look at what I’ve written before I can even say for sure that I wrote or worked on the code. Isn’t that sad?
This forgetfulness with regard to what I have written is annoying. And I’d like to brainstorm some ideas here about how someone with the same problem might move around it.
Wiki- fluid / roll your own
- fits high level and low level documentation
- wikis can be as difficult to navigate as the code if not maintained
- details on specific classes and methods
- auto generated; just document your code and wola!
- harder to get high level overview of what the pieces are and how they fit together
- the code speaks for itself
- if the code is well written, no one should be knocking at your door for an overview
- “document” as needed; no time spent for extra documentation that may never be used
- harder to get high level overview of what the pieces are and how they fit together
What other options have I missed here? What, in your experience, has been the best way to document what you have written?
Devchix Task List Android App
This post is to basically explain how the Devchix to do list android app that Nola and I have been working on works. Currently, we are working on Iteration 1 of our plan. Here’s how I understand what we have working so far: In our app, users can switch between 2 activities using the menu option, “Add Task”.
When our app is first opened the first activity that is rendered is the ViewTasks activity. We first start with some setup steps…. we inflate our layout, create our task database and open a connection to that database. We create a cursor that will just represent all tasks that we have put in our database and we call the startManagingCursor method, so that we do not have to do that ourselves.
We get a ListView from our ListActivity; this ListView will be our list of tasks. In our ViewTask activity, we have a subclass class called TaskAdapter, that will help us get data out of our cursor and into our list view. Lastly, we set our TaskAdapter as an adapter on the ListView we just created.
When the user clicks on the menu button, we will see the two menu options whose names we grabbed out of our strings.xml. And because we have implemented the onMenuItemSelected to detect which option the user selects, we the user selects the Add Task option, our second activity will be started where users can enter the name of the task and save the task to the tasks database.
If there are already Tasks in the task database, then TaskAdapter will inflate a new row from the records we get back from our query and then have the TaskWrapper place the contents of the cursor into a Task object. The task object represents has getters and setters for setting the various task fields, which may be overkill right now because we don’t have many fields but as our application grows and expands to do more complex things with task information this may make our code more modular.
Other than creating the table, I don’t believe the methods we have in the TasksDbAdapter class are currently being used. Depending on how we want to clean the code up, we may be able to refactor this class—either move the db creation into the ViewTask activity or move the other queries out into the TasksDbAdapter.
Here’s the link to the Devchix Task List Android App on Google Code.
Atlanta Linux Fest 2009
I attended the Atlanta Linux Fest last Saturday. I only got to stay for two talks, but what I saw was great!
From the Ubuntu Kernel talk given by Pete Graner of Canonical, I learned a couple of interesting things about Ubuntu…
Canonical has teams that work on things other than the ubuntu kernel, including integration for OEMs like Dell and HP, maintaining LaunchPad, and distributing install cds. They are able to maintain a 6 month release cycle for Ubuntu by deciding to only fix those bugs that are truly critical and focusing on the goals decided at the Ubuntu Developer Summit.
Ubuntu One allows you to back up any number of systems into the cloud.
The folks at Canonical have created a version of android that runs on Ubuntu Notebook Remix. It sounded like android uses some of its own version of libraries so a unique version of android had to be compiled to use those libs.
I also saw Kirrily Robert give her Standing Out in the Crowd talk. If you missed OSCon 2009 or the Atlanta Linux Fest, you can check out her talk here.
What's in your bin directory?

Or in the directory where you keep all of your scripts?
In my bin directory, I have scripts that…- clean and build projects
- validate xml
- start servers or applications
- executing different build targets
- always executing certain commands with specific arguments (e.g. ls)
- starting servers or applications (ldap, apache)
I’m not terribly creative with my aliases; so, here are some ideas.
Substitution into Intensional Contexts and Web Browsers 1
Let the input into a web browser be A and the composite output of a web browser be B. For instance, the page source of a web page would be A, while the page as the user experiences it would be B.
Consider then the following proposition:Louis believes that man is Clark Kent.
Since we can substitute “that man” with “Superman” using Prototype’s gsub function,
According to A, Louis believes that man is Clark Kent.
<body>
<ol>
<li>
<span id="test2">
Louis believes that man is Clark Kent.
</span>
</li>
</ol>
<script type="text/javascript" language="JavaScript" src="trixie.js" >
</script>
</body>
</html>However, according to B, Louis believes Superman is Clark Kent, which we know from our comic book reading is not true. Uh oh!
Since search engines index A and not B, any substitutions made on the client side may not be captured by a search engine. In other words, it is possible that a site may report that “Louis believes Superman is Clark Kent”, i.e. something false, while the search engine has captured that the site is reporting that “Louis believes that man is Clark Kent”, i.e. something that is true (or vice versa).
This is not the most interesting outcome of this thought experiment. What is interesting is that Javascript (and any similar client side technology with substitution methods similar to prototype’s gsub) gives us a way to expand the scope of the object of the proposition to include multiple intensions of a term.
Android Scripting Environment
Write scripts for Android on the fly with bean shell, python or lua using Android Scripting Environment (ASE).
Install ASE on android.
Install TTS on android.
Write 3 lines of lua for an “app” that can speak whatever crazy explicatives you desire.
require android
name = android.getInput("Enter text to speak","")
android.speak(name.result)

ASE is well suited for playing with Lua or Python on your commute home.
Any functionality native to the phone that isn’t already exposed in the API can be exposed by recompiling the app, which requires that you compile the android os too.
Android Bootcamp 2
- Adb logcat is a command that opens the log of what’s really going on under the hood. Adb stands for android debug bridge. Typing adb logcat at a terminal/command prompt while the emulator is running provides you with a very useful console log.
- Screen layouts are controlled by xml, an android specific xml format.
- Resources classes are compiled from the layout, strings and other xml files in res folder and can be referenced in code by R.layout.name_of_layout_xml. These resources can make little red x’s in Eclipse show up even when there isn’t a real problem with your code because you just need to clean/build.
- Apps aren’t deployed as wars or jars. They are deployed in an apk.
- The activity lifecycle includes a number of methods that you can override, including onCreate and onPause.
- I had done some tutorials, bought some books, and looked over several of sites I had also asked for help, but nothing really got the concepts in my head like the training at the Big Nerd Ranch.
We covered a ton of stuff over the course of the week: Layouts—lists, spinners, radio buttons, Activities (multiple activities), Menus, Saving to Database, Notifications, Toasts, Video, Webkit, Location, Intents, Content Providers, AIDLs, Services, Dailing a number, Maps… (there were more topics, but these are the ones that really stood out).
There were modules on each of these topics complete with code examples and exercises, which has really been helping out now that I am back at home writing Android apps as fast as my little fingers can type.
The time our class spent together eating meals was incredibly instructive—as folks drilled our instructor with Android-related questions. :) Here are some of my notes from class. After the course, I am re-writing the Android Sheep app and am working on my own “to do” list app—original, huh.
Adele Goldberg
Do you remember the scene in Pirates of Silicon Valley where the team at Xerox PARC must give Steve Jobs a tour of their ground-breaking research? A red-headed woman very reluctantly shows Steve the team’s then bleeding-edge work. Take a minute to watch the clip, if you haven’t seen it (beginning around frame 3.14).
This scene is very loosely based on actual events1, and the woman portrayed can refer to none other than Adele Goldberg.
Dr. Goldberg was one of the researchers responsible for the advancement of object-oriented programming concepts and for the development of the Smalltalk language. Smalltalk, the first fully object-oriented language, was used to prototype the features that we associate with modern GUIs—graphical menus, mouse clicks, browsers and windows. The end result of the PARC team’s research was enabling users with little technical knowledge to make simple changes on a microcomputer, such as changing directories, opening files and pasting text.
The research Goldberg and company were conducting wasn’t only making computing more friendly for users; it was also making computing more usable for programmers. At ParcPlace, which she founded, she helped develop tools for corporate customers who want to use OO concepts in their development.
Adele was president of the ACM from 1984 to 1986. Currently, she is the founder of Neometron, Inc.
References- http://www.pbs.org/nerds/part3.html
- http://en.wikipedia.org/wiki/Adele_Goldberg_(computer_scientist)
- http://www.ddj.com/184405043
You can hear Adele talk about browsing, selecting text with a mouse and other innovations in computing in this video.
