Tuesday, December 27, 2022

Peopleware: Part Two - The office environment

Summary of part II of Peopleware: Productive Projects And Teams

So if the managers job is to enable people to work, how does he/she do that?

The first step is acknowledging that the resource that you are managing i.e the peopleware does not come from a factory. They are unique and every individual has their own way of working and choice of keyboard/mouse/screen/desk arrangement etc. You can't have all the desks look the same and all the walls have the same paintings and all the floors look exactly alike. Give the people freedom to mold their environment according to their needs and wants. Once that gets out of the way, people can focus on the work and not fuss about how the silly mouse on their table annoys them. So get out of their way.

The thinking worker also needs to, surprise surprise, think. That requires quiet and focused time. In an office environment with a lot of distractions, this becomes impossible. If people come early or stay late just to get some work done, you should be worried.

Saving money on space is not the smartest move. The company may save a penny on space but will pay a dollar because of the reduced productivity. People are not chickens that can be crammed in tight cages and still lay eggs. You need to provide ppl space and reasonable privacy to do their best work. Office quality is directly proportional to product quality. More noisy offices produces more buggy software. Also quality workers tend to gravitate towards quality offices. So even if everything else was same, if you loose out on quality workers you loose out on quality products. They companies producing quality products all provide their workers quality offices.

You should enable people to have that focused time. People should expect that and no body should be offended if a colleague didn't reply immediately because they were focused on a problem. Asking people to report the number of productive hours each day builds this awareness in the people that this is something that they can expect to have and builds a culture of people letting other people work without distractions. Start measuring the environment factor (e-factor) on regular basis.

e-factor = Uninterrupted hours/Hours in office

If the e-factor is less than 40%, the office environment is not letting the people to get in to flow and get the job done.

Management should make sure that their is enough space, enough quiet and enough privacy so the people can get the work done and then get out of their way.

Peopleware: Part One - The human resource

From now on I am going to use this blog to record learning from the books that I read. To summarize what I have read so I can get back to it when I want/need to. The first book that I am going with is Peopleware: Productive Projects And Teams and here I summarize the first part of this book.

The first part of the book is about understanding the resource that we are managing. Different resources require different style of management. In programming terms memory and processor are two distinct resources and require different management. The resource that is being managed is creative thinking workers and they need to be managed accordingly. Almost all the time when a project fails, the reasons are not technological  but sociological. Understanding this is key. Thinking workers are not created from the same mold and hence can't all be treated the same way. They require freedom to do what they do. They will make mistakes and should be allowed to do so. They are not part of an assembly line where one can be easily replaced with another. Assembly line management of optimizing the pipeline for more throughput will not work. People should be allowed to spend time thinking and not just doing.

The Spanish theory managers try to optimize value produced per hour of paid labor by using unpaid overtime. This will not get your far. Most of us have limited "productive" hours per day and overtime will not increase that number and overtime on one day results in some "undisclosed" or "unreported" downtime the other day. So the net remains the same. But in the long run this kind of management will result in resentment and in good people stopping caring as they realize they sacrificed more important things like their personal lives, their kids birthdays and etc for work. This will harm the company badly. Let the people have normal lives and work life balance. This will do more good and does not result in less actual work.

Creative people take pride in what they create. Pushing them to deliver something faster at the cost of quality hurts that pride and harms the companies bottom line in the long run. The company may deliver the product on time but if the people stopped caring about the product they are creating, the company will hurt. Japanese companies allow the staff to have veto over product delivery if the people creating the product are not satisfied with it.

Parkinson's law says that work expands to fill the time available. This may be true in some cases but not in case of people who like doing what they are doing. People under stress don't work better, just faster. The quality degrades, more bugs are left and they require time to get fixed. So it may feel like the work is happening faster but the productivity actually goes down. The data actually suggests not having any deadlines at all as it results in the most productivity but some people may feel lost in such an environment and in such cases estimates/deadlines by system analysts result in best productivity. One observation though is that the organization busy work does expand to fulfill all the time available i.e meetings and all. We do need to keep that in check.

The manager's role in such an environment is not to make people work. These people care about their craft and want to work. The manager's role is to remove hurdles from peoples way and make it possible for them to work.

Monday, May 8, 2017

Simple Ways to Improve Battery Life on Linux Laptops

  • Set Ubuntu's Built-In Power Settings. 
  • Turn off Bluetooth. 
  • Turn off Wi-Fi. 
  • Lower Screen Brightness. 
  • Quit Apps You're Not Using. 
  • Avoid Adobe Flash (Where Possible) 
  • Install TLP.

Tuesday, March 3, 2015

How to CORRECTLY take a screenshot using Android MediaProjection API

With the MediaProjection API in Android 5.0 it is possible to: 
capture the contents of the main screen (the default display) into a Surface object, which your app can then send across the network
The process to capture the screen contents is described in MediaProjection API Demo. This demo uses a SurfaceView to show a miniature version of the device's screen creating a Droste effect. But the surface view is not very helpful to actually use the captured screen i.e you can not get the screen capture as an image or a video. If you need to capture the screen as an image you can use and ImageReader object and pass its surface to createVirtualDisplay() method.

The problem is that it is not very straight forward to get the captured screen from ImageReader object either. The image that you get from ImageReader is raw i.e it has stride pixels in the image buffer and you need to take care of them your self. There are many people out there having difficulties getting the image from an ImageReader e.g here, here and here. The solution described in some of these Stackoverflow posts does work but it reduces the image quality significantly and also it is a lot more work and therefore it is slow. 

Below I describe a simpler method to get the image from ImageReader once you have created a virtual display using the ImageReader's surface. For completeness sake I describe the steps for creating a virtual display as well but if you are familiar with them just skip to step 3.

Step 1
To capture the screen contents you need a MediaProjection object. But first you need the user's permission to capture the screen using following code:
MediaProjectionManager projectionManager = (MediaProjectionManager) getSystemService(Context.MEDIA_PROJECTION_SERVICE);startActivityForResult(projectionManager.createScreenCaptureIntent(), PERMISSION_CODE);
This will start a dialog activity to ask user for permission to capture the display contents. 

Step 2
Once user allows screen capture, we can get a MediaProjection object in the onActivityResult() method using the following code.
MediaProjectionManager projectionManager = (MediaProjectionManager) getSystemService(Context.MEDIA_PROJECTION_SERVICE);
mProjection = projectionManager.getMediaProjection(resultCode, data);
The "data" passed to getMediaProjection() call is the intent data passed to onActivityResult() method. 

Step 3
The call to create a virtual display takes width and height of the virtual display and a surface object which will be used to save the device's screen. To the capture the screen as an image or a series of images we use surface of an ImageReader object. Create an ImageReader object as follows:
mImageReader = ImageReader.newInstance(mWidth, mHeight, ImageFormat.RGB_565, 2);
Step 4
Once we have the MediaProjection and ImageReader objects, we can start capturing screen by creating a virtual display using following code:
mProjection.createVirtualDisplay("screen-mirror", mWidth, mHeight, mDensity, flags, mImageReader.getSurface(), null, null);
Step 5
Now we can get the screen capture as image using the following code.
final Image.Plane[] planes = image.getPlanes();
final ByteBuffer buffer = planes[0].getBuffer();
int offset = 0;
int pixelStride = planes[0].getPixelStride();
int rowStride = planes[0].getRowStride();
int rowPadding = rowStride - pixelStride * mWidth;
// create bitmap
Bitmap bmp = Bitmap.createBitmap(mWidth+rowPadding/pixelStride, mHeight, Bitmap.Config.RGB_565);
bmp.copyPixelsFromBuffer(buffer);
image.close();
now the bitmap object bmp has the your screen capture in correct format and you can simply use Bitmap.compress() method to convert it to JPEG, PNG or WEBP format. 
The error that most people make here is that they create bitmap of the wrong size, they create bitmap of same width and height as the virtual display but the problem is that the image you get from ImageReader has some extra pixels in there on each line. So you need to account for those as well when creating the bitmap to copy the pixel data. Therefore when creating bitmap I am passing "mWidth+rowPadding/pixelStride" as width. This is for sake of clarity so it is easy to understand otherwise you can instead pass "rowStride/pixelStride".

Thursday, November 6, 2014

Three parts of a web page

As far as I see there are three components of a web page:

1. HTML
2. CSS
3. Javascript

There are different libraries, frameworks and gems dealing with these three aspects. So far, in each of these three areas, I have identified following things that I need to learn, step by step:

HTML: HTML5
CSS: Sass, bootstrap
Javascript: jquery, coffee script

I will keep adding other stuff to this list as I realize or as I come across them.

Tuesday, November 4, 2014

Re learning RoR

I did web development using RubyOnRails for a year after I graduated in 2006. Back then there was not a lot of documentation about it and we had to learn lot of stuff using trial and error. I havent lot of development in RoR since then but now I want to do some serious web development and RoR seems an obvious choice since it is very popular and because I know it a little. So I have started re-learning it. I am going through Ruby On Rails Tutorial book and I intend to finish it. Many things are new and at times it feels too much to even remember all the different frameworks/libraries that keep poping (Saas, bootstrap, coffee script, jquery and etc) not to mention all these gems being used but hopefully I will get the hang of it soon.