Ideal Workspace for Developers

Before becoming a software developer, I had no clue what this job required or what did a developer did through the day. Many years later, I have a pretty good idea about the workload and can share some advice on what the ideal workspace for someone that writes code is.

First of all, let’s get something clear, software developers do not write code all day, it isn’t the same as writing a blog post or anything else. Working as a software developer is something like 20% code writing and 80 problem-solving. This 80% involves thinking about a problem or a new feature. Sometimes this is a back and forth exercise where the input of other developers or other collaborators might be needed. It isn’t until you have a pretty good understanding that what can be done that you actually get to write software. And because of this, a quiet place with little or no distractions is needed to be productive.

A quiet and distraction-free place

Image credit: https://stackoverflow.blog/

A quiet place is preferred and often required if you want to focus on a problem and a solution. Many companies have resourced to open office spaces with the idea that this sparks collaboration and communication between employees. I can tell you from experience working for years at an open plan office, it doesn’t work for thinking, focusing, or getting things done. When you walk into an open plan office the first time you’ll notice is people wearing headphones, and if you look closely, many of them will be wearing noise-canceling headphones. Software developers need a quiet place to work, private offices, a spacious cubicle, or a desk at home are ideal places for this type of work.

A distraction-free work area is also important, this isn’t to minimize or avoid collaboration, the idea is to not let co-workers or other people or situations have access to a software developer unless there are a clear need and an intention to do it. And don’t worry, people can still just chat or hang out at times when walking on a hallway or via an electronic communication channel.

A comfortable chair and a good size desk

Image credit: Autonomous.ai

While it is OK to use any coffee shop chair or your couch at home, any longer-term seating setup needs to include an ergonomic chair and a stand-up desk preferably. Anyone who spent hours in front of a computer screen will benefit from a good ergonomic chair and a stand-up desk. The right size desk should fit at least two large computer monitors and a laptop, this is a very common setup for software developers.

If you are looking for a good quality desk and chair at a reasonable price I recommend the Autonomous.ai standing desk and chair. I’ve owned both for a while, and I’m pleased with it.

When working from home

If you are a remote worker, having a quiet and distraction-free place is also necessary. This isn’t difficult to achieve, most people working from home will enjoy from a quiet home during working hours as kids go to school and spouses will be at an office, or working at home and focus on their own tasks.

If you work from home and don’t have a spare room or office to work from, find a quiet corner away from the front door and the kitchen (which tends to be a place for families to hang out). Your bedroom might be the perfect place for it, that is if your partner allows it and you are disciplined about working and non-working hours.

When working from a coffee shop or other public space

Ideally, you’ll find a place with comfortable seats, good internet connection, and great coffee and reasonably priced snacks. This isn’t always possible, but if you spend enough time to find the right place(s), you’ll be surprised at how accommodating public spaces can be for you to get stuff done. You’ll need to be prepared to work at these places and to do it successfully I recommend you read this blog post which includes tips and advice about working successfully at coffee shops, etc.

Conclusion

The ideal workspace for software developers continue to be a private office and having the option to work remotely whenever needed. This gives the software developer both a quiet place and a chance to work the hours that are more convenient for her/him. The private office can only help so much avoiding distractions, the best thing to avoid distractions is to form a culture of independence where people collaborate when necessary, without interrupting a co-worker, especially if it isn’t without a purpose

The advice above is by no means a recommendation to isolate software developers. However, to do their job and do it well, software developers need the time and space to focus and work on hard problems and to create solutions. Software developers will always be able to interact with others whether in person or online when needed to collaborate or just to socialize. What’s important here is to have that quiet place when you need it.

 

Parallelism. Using Parallel.For and ConcurrentBag.

Parallelism refers to the technique of running multiple calculations at the same time to speed up a computer program. Historically, this has been a complicated thing to write requiring a developer to do complicated coding including low-level manipulation of threads and locks.

A program will generally run faster if you allow it to execute multiple calculations at the same time. For example, you might have a program where you need check how many orders a customer has, and instead of looping through each customer to check on their orders, you could check on multiple customers at the same time by using something like Parallel.For.

Code example:

private IEnumerable<Orders> MyMethod(List<Orders> orders)
    {
        // Converting the List<Orders> to ConcurrentBag for thread-safe purposes.
        var result = new ConcurrentBag<Orders>();

        Parallel.ForEach(orders, item =>
        {
           // Some data manipulation
           result.Add(new Orders(/* constructor parameters */);
        });

        return result;
    }

The .NET Framework makes writing parallel code a much simpler task than before. A variety of enhancements and additions such as runtime, class library types, and diagnostic tools were introduced with the .NET Framework 4.0 to help developers write safe and efficient parallel code.

Below are some of these tools and enhancements, you can click any of the links for access to Microsoft’s documentation for each one of these:

The benefits

The benefit of using parallel programming is gaining the advantage to execute multiple instructions at the same time. This offers the benefit of making your program faster by reducing the time for the same code to execute sequentially. While this is a great way to speed up your code, you should still consider other ideas as well and not use the framework features around parallelism before knowing more about it. Believe, I know by personal experience, unfortunately.

The disadvantages

The disadvantages of using parallel coding are the increase of use of CPU for it (something to be aware of) and also the potential for issues when using collection objects that aren’t thread-safe. Thread safe means multiple threads can access the common data without any problem. When using something like Parallel.For you want to use a thread-safe object such as ConcurrentBag<T>. Bags are useful for storing objects when ordering doesn’t matter, and unlike sets, bags support duplicates. If you need your collection to be ordered, remember to sort it after converting it to a List<>.

As with everything else, test your code and find out if using the Parallel library or PLINQ in your existing scenario is the right thing for it or not. While it might seem that running things in parallel will always be faster, this isn’t always true. Read more about it here.

Happy coding!

Favorite New Visual Studio Code Features of 2018

Visual Studio is my favorite code editor, and the things I like the best about it is how light and extensible it is. Last week I posted some of my favorite extensions for this code editor, and today I want to show you some of the new features I like the most.

Visual Studio Code is updated frequently, and it is hard to keep up with all the new great stuff they keep adding to this editor. This is my attempt to help you discover some of the coolest features added to it so far this year, in my opinion of course.

I will update this post at the end of the year and include a summary of all the great features and advances of this mighty code editor.

The following features are just some of my favorites and the ones I use often. They are listed in the order they have been released so the most recent one and one of my favorites, the Grid Editor Layout is listed last as it was part of the June release.

Node debugging

Automatically attach debugger to Node.js subprocesses

For node-debug we’ve added a mechanism that tracks all subprocesses of a debuggee and tries to automatically attach to those processes that are launched in debug mode. This feature simplifies debugging of programs that fork or spawn Node.js processes like programs based on the “cluster” node module:

Auto Attach shown with Cluster Example

The feature is enabled by setting the launch config attribute autoAttachChildProcesses to true:

{
  "type": "node",
  "request": "launch",
  "name": "Cluster",
  "program": "${workspaceFolder}/cluster.js",
  "autoAttachChildProcesses": true
}

Auto-imports based on filename

Auto-imports for JavaScript and TypeScript now support importing default exported objects based on filename:

importing a default exported object by filename

Copy/Paste files across windows

We now allow you to copy and paste files between two VS Code File Explorers in different instances. This works for single or multi-selection of files as well as folders.

Copy Paste across Windows

Split terminals (My personal favorite!)

The Integrated Terminal can now be split such that multiple are visible at once, which can enable much easier management of terminals when you need a watch and a run command for example:

Split terminals

Splitting can be done by clicking the split button in the panel, through the context menu or the command Ctrl+\.

Focus can be moved between split terminals using Alt+Right and Alt+Left. The active pane can be resized using the keyboard with:

  • Terminal: Resize Pane Downunassigned
  • Terminal: Resize Pane Upunassigned
  • Terminal: Resize Pane Leftunassigned
  • Terminal: Resize Pane Rightunassigned

Syntax aware folding

Folding ranges in HTML, JSON, Markdown, CSS, LESS and SCSS are now, by default, computed based on the language’s syntax and no longer rely on well-formed indentation.

Syntax folding

Support for TypeScript and JavaScript is also available, and can be enabled by the setting "typescript.experimental.syntaxFolding": true.

If you prefer to switch back to indentation based folding for one (or all) of the languages above, use:

  "[html]": {
    "editor.foldingStrategy": "indentation"
  },

The extension API now supports adding related information to diagnostics and this is shown in all places where diagnostics are shown: on hover, the error Peek window, and Problems Panel.

In the example below, you can see related information pointing out the first location where a twice assigned variable was used:

Related Diagnostics Information

Column selection using middle mouse button

In VS Code, column (box) selection can be added by holding Shift and Alt and then using the left mouse button. Now the middle mouse button can also be used to create a column selection:

Editor column selection

Note: When setting editor.multiCursorModifier to ctrlCmd, the modifiers are Shift and Ctrl on Windows and Shift and Cmd on macOS.

Highlight unused variables and imports

Unused variables, parameters, and imports are now greyed out in JavaScript and TypeScript:

Many greyed out unused variables

Use a Quick Fix to remove them and clean up your code automatically:

Quick fix all action

Grid editor layout

You can now arrange editors both vertically and horizontally and have more than 3 editors side by side:

Grid Editor Layout

To support flexible layouts, you can create empty editor groups. By default, closing the last editor of an editor group will also close the group itself, but you can change this behavior with the new setting workbench.editor.closeEmptyGroups: false.

Grid Empty

There are a predefined set of editor layouts in the new View > Editor Layout menu:

Grid Editor Layout Menu

Editors that open to the side (for example by clicking the editor toolbar Split Editor action) will by default open to the right hand side of the active editor. If you prefer to open editors below the active one, configure the new setting workbench.editor.openSideBySideDirection: down.

Like I said above, it’s hard to keep up with all the great features being released so often, so please feel free to leave a comment with your favorite feature added this year or something that you’d hope they will add in the near future.

For the full list of features released so far this year, click here.

Happy Coding!