The Buck Stops Here

Shortly after becoming a manager, most managers realize that one of the advantages in this new situation is that you don’t have to do everything by yourself. Some realize sooner or later that you actually cannot do everything by yourself (others somehow reach the conclusion that you don’t need to do anything by yourself, but that’s a different story). At this point you get to ‘choose’ which kind of a manger you want to be, I guess the scale can be set between micro-management and what I refer to as management by context.

micromanager

I had a manager once who said that his entire job is to give us context (obviously, in the managing-down direction only. Managers do sideways and upwards management work too, but I’ll concentrate on the down part). This also meant that conflicts and questions in his group shouldn’t reach him, as he, in principle, do not want to give concrete guidance – the solutions should be reached within the group’s scope, relying on and following the provided context. This may sound nice in theory, but practically this meant that it was very hard to reach any decision, mainly because there was no single point in the hierarchy who could and/or would take the responsibility for hard decisions.

It seems to me that this notion of providing context (and effectively nothing more) is the most extreme case of delegation, which got me thinking about the fine line between delegating tasks to achieve more and create synergy, to de-facto delegate core management responsibilities (like, for example, avoiding decision making when decision making is due).

Delegating stuff to your subordinates requires you to trust them in more than one way. You need to believe they are competent, you need to believe they will come to ask for help when they get stuck, but you also need to believe that they will learn and grow from this experience. That last point seems important to me, as delegation is not about the day-to-day tasks of your team, it’s about the day-to-day task you have, which are inherently of the, well, managerial type. So, sharing your tasks with a person reporting to you gives him a chance to prove himself in an area he doesn’t get to experience every day, usually out of his comfort zone and gives you both a chance to increase this assurance that he can take on bigger and bigger roles. However, I tend to think that not every managerial task should be delegated.

Delegation

I tried to think of a definition for the kind of tasks you should avoid delegating on regular basis (there are cases, of course, where you would make an exception for that, more on this in a moment..), and I think an analogy could be outsourcing. A rule of thumb for outsourcing I learned is that you don’t outsource your core business (one good reason for that is that your core business should hold your competitive advantage), and if we apply this for the manager role – this will mean you generally don’t delegate core management functions. Some of those would probably be more obvious like performance reviews, salary related issues, and in general personal/private issues between you and your reports (by the way, there are organizations and positions which use the ‘second in command’ position to take care of some of the administrative stuff related to personal issues, but I think that’s a spacial case). There are tasks which should be quite easy to delegate (and managers many times do) like departmental budget (internally), daily status reports, etc.

The exception for that rule would probably be in the case of ‘growing’ a replacement. During the initiation time, the person replacing the manager should ideally have the chance to experience all the aspects of the new position while the current manager serves as his mentor/backup/ghost. There could be a longer period before the actual initiation where a couple of candidates get to experience significant parts of the manager’s role as a kind of a long examination of their capabilities (many organizations choose this approach officially).

the buck stops here

I, personally, like delegating. One of the main reasons I wanted to become a manager was to be able to create something bigger than I could create by myself. I also like making decisions as a manager since I believe when it comes to your responsibilities you should envision the sign on Harry S. Truman’s desk: “The Buck Stops Here”.

  

iPhone development – continued..

So, last time I wrote about what you need to get started with iPhone development. I thought now would be a good time to talk about stuff I encountered along the way, which I guess almost anyone developing for iPhone would encounter eventually.

This time, let me focus on memory management. Objective-C uses reference counting for its memory management, and the version running on the iPhone does not have garbage collection (yes, this is so 90s..). Anyway, this forces the developer to actually think about what is being allocated, when and where. Apple has a guide about Objective-C memory management in its developers’ resources, begin by reading it.. Assuming it’s clear enough, the next thing to do is to actually check your program for leaks (if you’re a beginner, there are leaks – trust me..). Luckily, Apple provides a tool along with its SDK called Leaks (here’s one place where they didn’t think they need to be original..), which tracks your program in runtime (on the actual device, actually, which is pretty cool and also recommended, as the device behaves differently than the simulator in some aspects, and memory is one of those..) and marks places with leaks. The tool is very nice, but in my opinion not the friendliest tool for beginners. One downside is – it can only detect flows you actually went through (obviously), and it’s sometimes hard to determine what’s the actual source of the leak. Still, if there’s a leak during runtime and yo u passed through the leaking flow, this is your best chance to catch it.

One downside I didn’t mention about the Leaks tool and which is not that obvious, is that even when you find a leak, it’s not always obvious why are things behaving the way they are. It so happens that I found a great tool which does static analysis for Objective-C code, and the best thing about it is that when it finds bugs (memory leaks are bugs, duh..), it also explains why is that a bug. The tool is called Clang Static Analyzer and it’s pretty straight forward to use – you download it, extract it, and then use two simple commands:

/path/to/clang/installation/scan-build xcodebuild

(This should be executed in your program’s home directory).

Then, once this is done, a report will be generated and the last line in the verbose output of the build will have the report name, then simply execute>

/path/to/clang/installation/scan-view <report name>

Which will open a browser window with your report, links to the source files and cool embedded explanations. Once you do the fixes, execute the scan again and check there are no more errors.. note that the default behavior if there are no errors is not to generate a report at all..

So, that’s it for now. More on the fun in iPhone development next time..

iPhone development – the beginning

A while back, I assumed responsibility for an initiative which includes iPhone development. Having had to bootstrap the project, I went through the various stages of learning, technology choices, getting the right material and establishing the basic methodologies for developing mobile applications, specifically on iPhone, in a company. I will try to describe in this post some of the more interesting issues I encountered during the beginning of the development, hopefully it would save someone some time.

Let’s begin – just to make it clear, you better have a Mac to develop for iPhone. There are Hackintosh solutions with questionable legality, there are Terminal Server solutions (like Aqua Connect), and if your iPhone is jail-broken, you can even use it as the development platform (again, not an Apple legitimate method), but the best experience for the developer and probably the only Apple approved way of doing iPhone development.

So, after having a Mac around, the first thing someone beginning to develop on the iPhone platform should probably do is to register with the Apple Developer Connection. In addition to the basic resources you need, and assuming you plan to publish your stuff on the App Store (there are other, at the moment not ‘legitimate’, options to publish your application, I will not discuss them here), this is where you’ll get you certificates and keys to test your application on your device. Developing using the iPhone simulator is free, but deploying on an actual device will require you to pay, currently it’s $99 yearly subscription. If you plan to have a team of developers, choose the Team option (costs the same..), and if you’re a company, note that you’ll have to prove it (by sending Apple the relevant documents), this, too, will cost $99 per developer. The Enterprise registration is for development of Enterprise applications (not to be published on the App Store).

Once you’re done with that, you can start reading the relevant manuals, there’s a pretty good Objective-C (the language you use to develop on iPhone..) guide there, there are some other guides online (line here), and I personally recommend having a physical book around (Programming in Objective-C 2.0 is the one we’re using, and I think it’s very good). Having done most of my programming in other languages, I found some ‘weird’ aspects in Objective-C, but that’ll probably have to wait for another post.

Now that the basics are established, I found a great way to get acquainted with iPhone development is the Stanford online course. Although it doesn’t cover iPhone OS 3.0, in my opinion it’s a great starting point. I think it’s important to get to know the tools and the environment, maybe create a simple app (or try to) before going through the course (it’s probably the equivalent of doing the exercises given throughout the semester), but it really allows the beginner developer to close some holes which are hard to close when you’re just going through documents and online tutorials which, in many cases, have varying levels of assumptions on the knowledge of the reader. This course aims for beginners and tries to makes sure everyone knows their stuff by the end of it, regardless of their original background.

In addition to the Stanford course, again I found a physical book very helpful, and the best one I found is Beginning iPhone 3 Development, which both includes changes from iPhone OS 3.0 (complementing the Stanford stuff), and has some very common and good examples for iPhone applications.

Ok.. That’s the beginning. Right after that comes the part where you actually do stuff and hit some walls. I’ll try to describe some of the walls I hit and how I got around, over, under or through them in future posts (promises, promises..).

Update: I found this list of online resources from StackOverflow which looks very helpful..

Why are you following me?

I’ve been playing around with Twitter lately, and found the social aspects of it quite intriguing. In other social networks I participate in (like Facebook or LinkedIn), connections usually denotes there’s some kind of personal relationship (‘friendship’ based in Facebook or professional based in LinkedIn) between two individuals. In Twitter the most visible connection is the ‘follower’ notion, and at first I treated it with a similar approach as I do in other networks (meaning – being very selective as to who I follow and expecting only familiar faces in my followers).

Then (quite quickly, actually) I got the first unfamiliar person following me, and that got me thinking – cool, I’m interesting (that was my main motivation to following someone – I was actually interested in what they were saying..). I guess I thought it would be interesting to know this person who decided to follow me, so I followed back (and he did have a couple of thousands followers, so he must  be an interesting person, right?).

A couple of days later two other people started following me (and I followed them in response), and then this little flow of followers started, and I was thinking to myself – why is this happening? I know I’m interesting :-), but how do this people know? Do they actually read what I’m writing? I know I couldn’t possibly keep following dozens of people, how could someone follow hundreds or thousands of people? What’s the point of all that?

Then I heard of someone proposing a prize for followers (something like that, there are others..), and it occurred to me that some (hopefully only some) of my followers are actually only following me because they expected me to follow back.. Not that I mind, but I figured if I follow that many people sooner or later (probably sooner) my incoming twitter stream will be a big haystack, and finding the needles will become increasingly hard..

So, I got to thinking, how can I maintain a large number of followed people while still noticing the interesting information? There are some tools out there like Twitter search or Filttr , there are #hashtags and Tweeter trends, but it’s not exactly what I’m looking for.. Here are some of my thoughts, I’m not sure if some or all of them are already implemented somehow, I’ll be happy to here:

I’d like a way to distinguish between ‘information’ tweets (something happened somewhere), ‘status tweets’ (I’m going to sleep..), ‘reference tweets’ (hey, look at this site..) and so on. I’m not sure if there’s a tool that does that, and obviously it requires cooperation from the tweeter himself (you need to mark your outgoing tweet under some category, and maybe it misses the point of quick updates..), although to some extent this could probably be done in the receiving end using some sort of a learning client (bayesian based?).

In addition, if I’m already following someone, I don’t really want to see retweets of that person in my list (in fact, I don’t want to see double retweets at all..). This should be easier to implement, I guess, though maybe what I actually want is add some client side learning here as well – mark tweets as ‘not interesting’ automatically?

Another thing is – it seems to me like ‘all tweets are created equal’, and that seems to work out well, but maybe you could have the ability to highlight/promote a tweet? I guess you’d have to limit the amount of promotions (per day? charge for them? charge over a threshold?), but if I know that someone (who I already follow) consciously marked something as more important, maybe I’ll give it more attention..

Java Language Change

I’ve been to JavaEdge 2008 last week, and while many of the sessions were interesting, I found the one about the Java Language Change particularly intriguing.

During the session 10 proposed changes were introduced, all of them minor by definition (as stated by Sun in the JavaOne 2008 TS-5881 presentation), and everyone got to (anonymously) vote.

Here is the list of proposed changes, and even if you don’t get to vote, I think it’s interesting and thought provoking:

1. Map-for-each:


for (String key, Integer value : map) {
...
}

2. For-each iteration control:

for (String str : list : it) {
if (str.length() > 100) {
it.remove();
}
it.set(...);
it.index();
it.isFirst();
it.isLast();

}

3. List/map access:


List<String> list = ...
Map<String, Job> map = ...
Map<String, Map<String, Task>> combined = ...

String str = list[0];
list[0] = "Hi";
Integer value = map[str];
map["Hi"] = 56;
Task task = combined["Test"]["Monitor"];

4. Infer generics in declarations:

Instead of
List<String> list = new ArrayList<String>();
use
List<String> list = new ArrayList<>();

5. Multi-catch of Exceptions:


try {
doSomething();
doSomethingElse();
}
catch (IOException, SQLException ex) {
// handle..
}

6. String switch:



String str = ..
switch (str) {
case "name":
processName();
break;
case "surname":
processSurname;
...
}

7. String interpolation:


String name = ...
String Value = ..
String out = $"The value of ${name} is ${value}";

8. Multi-line Strings


String sql =
"""SELECT firstname, lastname, birth_date,
telephone, account
FROM
preson, phone, email
WHERE
..
""";

9. Resource management:



try (FileReader in = new FileReader(file)) {
processFile(in);
} // and resource validation and release is done automatically

10. Null-handling:



Session sess = ..

String code = sess?.preson()?.address()?.postcode(); // if anything preceding ? is null, the result is null

What’s your vote? 😉

Adding AJAX delay/loading indicator using Java Stripes

While exploring the Stripes framework, I spent a while looking at how to add the ‘spinner’ indicator when your server side is processing a long request. Here’s a short summary of what I did to achieve that, hope it could help save someone a little time:

1. Select a spinner image 🙂 I found this cool place where you can generate an image of your choosing at ajaxload.info. Generate whatever you like and save it somewhere, let’s say under ‘images/smallspinner.gif’.

2. In your .jsp file add the following javascript method just before the invoke method you use (again, assuming you’re working with Stripes):


function showSpinner(container) {
var obj = document.getElementById(container);
obj.innerHTML = "<div ID='spinner'>
<img src='images/smallspinner.gif'/></div>";
}


then update your invoke method to call the showSpinner method at the right time:


function invoke(form, event, container) {
if (!form.onsubmit) {
form.onsubmit = function() { return false }
};
showSpinner(container); //This is the new call..
var params = Form.serialize(form, {submit:event});
new Ajax.Updater(container, form.action,
{method:'post', parameters:params});
}


3. Ah, that’s about it.. A short explanation: The target container’s contents is being replaced just before the call invocation with the ‘spinner’ image, so it shows as ‘loading’ until the call returns, and then the server side replaces it with the actual HTML result once it’s ready.

My ninety days

I just stumbled upon this blog entry and the first thought that came to my mind was ‘I wish I would have read it 90 days ago’..

I started working for a new place just about 3 months ago as a software group leader. I kind of knew I’m going to make mistakes and, not surprisingly, I did. The toolbox of an engineering manager, as I see it, is the sum of all his experiences in the past (both technically and personally), and although a lesson learned from a personal experience is invaluable, the ‘tuition fee’ in these cases can be very high. So learning from other people’s experience is usually a much cheaper alternative – but you have to learn to watch, listen and actually learn.

Read that blog entry..

I thought I’d contribute one of my personal observations:

* When you’re joining a new team (especially as a manager), you’re not the only one trying to find his place and show his worth. Many of the team members will ‘overcompensate’ in the first period for various reasons – either they see this change as an opportunity or a threat. Take this into consideration, and take the first impression with a grain of salt. Revisit your impressions after you’ve settled in, and at least from my experience, there are surprises (for the better and worse).

What is Cloneable?

The origin of the name comes from Java’s Cloneable interface which means that, if a class implements the Cloneable interface it is an indication for the Object.clone() method that it is legal to make a field-for-field copy of instances of that class. I won’t get into the details (maybe later..), but basically this blog follows the same rule – copy if you wish to..

I tried to think about what to write in a public Blog (it’s a little intimidating – everything you write is out there for everyone to read and criticize..), I have a few ideas like thoughts on books I read, cool things I find during my work (mostly Java related, but other software engineering stuff may occur) and general thoughts.

Let’s see how it goes..