Wrestling with large code amounts and winning: multi-line editing

Sometimes on the data processing project, it is needed to work with a large amount of code or other text which is similar but still is different enough. So, it is not viable to extract it into the callable function. For example (yes it is contrived one) you might have a long list of object initializers like this:

Imagine for some reason you decided you wanted to make Student immutable and now you need to replace object initializers with constructor calls. Such a task sounds daunting and extremely boring (unless there is Resharper’s feature that can do exactly what you want). Watch what is possible with Visual Studio Code. It saved me so much time in my last projects where I had to write tones and tones of DSL code to specify domain object definitions:

2

Here is what I did (Windows 10):
1) Ctrl+F to search for };, which is just an anchor for VS Code to know what to highlight;
2) Alt+Enter to give a cursor to each highlighted piece of code;
3) I replace right curly bracket with round one and delete unneeded space;
4) Ctrl+Left Arrow to navigate word by word to the left (in general all shortcuts to navigate text are very useful in this context because cursors may be in different places of the lines);
5) I replace left curly bracket with round one and delete unneeded code Name=.
6) Escape to remove multi-line cursor. Done!

Additionally, to add cursors, you can hold Ctrl+Alt while pressing the up ↑ or down ↓ arrow keys or hold Alt and click left mouse button in desired spots. But using search/Alt+Enter feature can make things even easier for very large files with hundreds of entries.

Enjoy power coding!

Facebooktwittergoogle_pluslinkedinmailFacebooktwittergoogle_pluslinkedinmail

Are soft skills more important than deep technical expertise?

Often I hear the ideas that technical skills are somewhat less important than, for example, communication or other soft skills. Here are some quotes to illustrate what people think:

Dustin Ewers, DeveloperOnFire:

The developer that’s a ninja at whatever the latest JavaScript framework is is great but a developer who is OK at that and also really good communicator is gonna win every day of the week in terms of actually delivering value to people.

John Sonmez, SoftSkills book:

I’d rather hire a developer who knows a little less but knows how to figure out what needs to be done and how to do it, than someone highly skilled who requires constant hand-holding to be productive.

I have seen the most technically competent yet arrogant and unfriendly people lose out on a job to a much less skilled but likable person.

TJ VanToll, DeveloperOnFire:

I don’t consider myself very good software developer necessarely I think I succeeded more in that like learning how to write a good email, learning how to write an opinionated article, can actually take you a lot far ther in many cases than knowing how to write good code for instance.

Now let’s look Pareto principle and we see that roughly 80% of problems we can solve with 20% of features that has a tool we use (like programming language or framework).

Multiply it by diminishing returns law which states that the outcome of our efforts always diminishes. Hence learning 20% of the most used programming language features will provide much more value than learning next 20% of features. But learning that next 20% of features will require more effort because they are more rarely used and therefore it will be harder to remember them.

Add the fact that:

Half of what a programmer knows will be useless in 10 years.

And I would emphasize here that the more detailed and specific the piece of knowledge, the faster it will become useless. This kind of demotivates people to learn new stuff, especially if they are not going to use it immediately.

Finally, add to the equation StackOverflow, YouTube, blogosphere and all other freely and immediately available resources which are capable to solve most of your programming problems in seconds.

What do we get? Well, for most of the jobs very deep and detailed technical knowledge is not as valuable as soft skills – ability to communicate with people via natural as well as via programming languages and ability to solve problems and organize (architect) systems.

At my current project, we hired a guy just because I knew him, I knew he was a good communicator, nice person and loved his craft, that’s it. We did not ask him any questions like what is polymorphism or the sequence of calling of constructors in the inheritance hierarchy. And it really worked great. Do I instead want someone who knows 80% of .NET by heart but with hypertrophied ego or something? No way…

Of course, I just share my thoughts and the fact that these same thoughts appear to other people as well. Interviewers, however, want you to know nitty gritty details as if knowing them proves you will be able to deliver, will keep working on the long demanding project or will be doing well with the team. Many people would disagree and insist that deep tech expertise is the key.

What do you guys think? What is your experience?

Facebooktwittergoogle_pluslinkedinmailFacebooktwittergoogle_pluslinkedinmail

VS Code and Gulp: Solving the “Breakpoint ignored because generated code not found” problem

Recently I have solved a problem which was bugging me for some time. I guess there are many reasons which can cause this problem and also there are many solutions to it, however, I will share my solution here and, hopefully, it will help someone else at least to start digging in the right direction.

So I am using VisualStudio Code for my JS editing, Gulp to automate the build which mainly takes application files from the src folder, passes them through the Babel transpiler and saves them to the .tmp folder. The server serves the application form the .temp folder.

The problem: I want to run my code in the Chrome and debug it right in the VS Code, however, whatever settings I select, putting the breakpoint causes VS Code to complain: “Breakpoint ignored because generated code not found”.

To solve the problem I did the following:

  • Used diagnosticLogging property of the of the configurations property in the launch.js file. Even if the following solution does not help you, this option will help you to debug your problem. This is how I ended up with my solution.

  • Wrote launch configuration like this:

It is very important to start Chrome with remote debugging port 9222 opened. Read official docs for more details. Note that my url ends with /*, this tells VS Code that it should track all files in debugging. More about this read here.

Also, note that webRoot points to the .temp folder, which I alluded to earlier. It is so important that I will repeat. In this folder, I have JS files spat from the Babel and these files are later served to the browser. Hence this is one part of the puzzle: I tell VS Code which exactly files I want to map to those, opened in VS Code (those which are in the src folder).

  • Used correctly setup gulp task to not only transpile JS code but also generate correct source maps. Since I am using Gulp with source maps plugin, I ensured that source maps do not include content on their own, but reference to the root of my application’s sources (from where my transpiler takes the source code, the src folder). Here is how my transpiling Gulp task looks like:

At first, I used this command to write source maps: g.sourcemaps.write('.'). Although it did generate source maps, they were apparently insufficient to VS Code to understand how to match Chrome served files from .tmp and files from src which it was currently browsing. The setting { includeContent: false, sourceRoot: __dirname + '/src/app' } effectively instructed source maps generator to not include source code into source maps itself, but instead point to the source root, where sources can be found. In my case, it is __dirname + '/src/app' which is exactly the folder, which was browsed by VS Code. Hence the second part of the puzzle is found.

However, if src folder is not served by your server to the browser, such code maps will not work in Chrome, because Chrome will not be able to find files on the local disk. This may cause problems in case you still want to debug your code in Chrome from time to time. These problems can be easily solved by disabling JS code maps in the Chrome Dev Tools settings.

Facebooktwittergoogle_pluslinkedinmailFacebooktwittergoogle_pluslinkedinmail