Egor Nepomnyaschih, Author at Custom Web Development Blog

Author - Egor Nepomnyaschih

async/await syntax encourages frontend developers to develop incorrect code

await operator is an incredible new feature in ECMAScript 2017. There are many articles demonstrating how much you can benefit from it. I agree: asynchronous code was never so brief and clear as when it is written via async/await syntax.

Nevertheless, there is a significant pitfall you should be aware of while developing asynchronous front end code. Backend developers are safe: they can easily copy code from any of the articles above to their NodeJS application, and it will work just fine. Really! However, if you are going to run this code in a browser environment as is, it would be a serious mistake! None of the examples is correctly adjusted for the front end. This is a disaster: in the top 10 Google references on “async await”, I failed to find any examples correctly adjusted for the front end. Junior/middle JS developers and newcomers use these examples as the basis for their work and develop incorrect code that results in unexpected bugs and performance loss all over the place.

Read More

Smart Version Control for Project Managers and Decision Makers

Today I’m going to tell you about Git version control (branching) model that we use widely in ISS Art to effectively manage code base of our projects. The experienced software development teams might know this model as major ideas were found long time ago and posted in the articles:

Here, I’m going to consolidate these ideas in the way that could be easily understood by software project managers, product owners and decision-makers to explain them the technical challenges that can arise due to certain harmful business decisions, and how they can impact development costs and schedule. Examples of harmful business decisions:

  • Task reprioritization after development start
  • Request to include one more feature in release during release testing
  • Too many hotfix requests

Read More

Comprehensive object enumeration in JavaScript

This cool JS snippet implements enumerations for JS:

function makeEnum(idField, indexField) {
  idField = idField || 'id';
  indexField = indexField || 'index';

  var enumeration = [];

  // Standalone object is useful for Underscore collection method usage,
  // for example:
  // _.keys(MyEnum.dict);
  var dict = {};
  enumeration.dict = dict;

  // This method can be used as a callback of map method:
  // var objects = ids.map(MyEnum.get);
  enumeration.get = function(id) {
    return enumeration[id];
  };

  // Registers a new enumeration item.
  enumeration.register = function(instance) {
    instance[indexField] = enumeration.length;
    enumeration[instance[idField]] = instance;
    dict[instance[idField]] = instance;
    enumeration.push(instance);
    return enumeration;
  };

  // Maps enumeration as dictionary:
  // MyEnum.mapDict(function(value, key) { return ...; });
  //
  // This is a shorthand for the next Underscore expression:
  // _.chain(MyEnum.dict).map(function(value, key) {
  //   return [key, ...];
  // }).object().value();
  enumeration.mapDict = function(iteratee, context) {
    var result = {};
    for (var id in dict) {
      if (dict.hasOwnProperty(id)) {
        result[id] = iteratee.call(context || this, dict[id], id, dict);
      }
    }
    return result;
  };

  return enumeration;
}

Read More

How to select a good server-side Web framework

In the previous article I mentioned that we’ve decided to use Jetty+Guice+Servlet combination in our Java Web application. What was it motivated for? Why have we refused to use Jersey? Why have we decided to implement a separate Resource class for every Web action and even for every HTTP method?

When everyone of us selects a tool to work with, we all set some requirements to it, and it should meet all requirements to get a green light. Everyone knows them – these are such obvious things as code readability, ease of debugging/testing, following traditional coding practices (OOD, patterns) etc. But today I’ll tell you what requirements I set specifically for a good server-side Web framework. I’ll be happy to work with any technology stack meeting these key requirements, and Jetty+Guice+Servlet is just one of the options.

Briefly, the requirements are:

  1. Extensibility
  2. Common response format
  3. Automatic exception handling
  4. Transactionality of a request

And let me explain you what do I mean by this.

Read More

Request-scoped resources with Guice and Servlet

Our team was looking for a very simple Java Web framework for one of our projects, and we found the next combination of tools very fascinating:

  • Eclipse Jetty Web server for HTTP request interception
  • Google Guice for dependency injection
  • Java Servlet for request handling

They work together pretty well, and there is a plenty of articles on the Internet covering this topic, so it is easy to get things started. But none of these articles explains how to scope your code in a single HTTP request. By design, servlet is always a singleton. Guice refuses to register servlets as request-scoped objects, so, the whole point of request-scoped object instantiation is being lost. Due to this issue, we’ve almost decided to abandon an idea of using low-level servlets and switch to Jersey framework, which wasn’t very attractive for us as well, for different reasons. But a deeper look to Guice API has saved my day.

Read More

A great feature of PHP – Cookbook for context implementation

This article covers technical details of PHP driven configuration described in a previous article. There are a lot of stones under the water that can drive you crazy when you work with PHP templating engine. I will tell you how to work around some of them. We’ll discuss how to:

  1. Implement script inclusion methods
  2. Prevent vision of context’s private members
  3. Implement graceful error handling
  4. Implement state stack for nested scripts inclusion
  5. Include scripts by relative path
  6. Output JSON arrays/objects in for-loops
  7. Prevent security issues

Read More

A great feature of PHP

I know many Java and .NET developers who often like to make fun of PHP. Honestly, a couple of years ago I was one of them. I used the next arguments to set Java and .NET above PHP (this is my personal opinion):

  • It is not a good idea to use dynamic typization in a server-side language, because server is all about performance and security – static typization supports these two attributes a lot. Also, static typization makes code refactoring much easier.
  • Java and .NET have much better-thought standard libraries. In PHP, you have many different ways to do the same operation – it increases code fragmentation, especially if you work in a large team of PHP developers.
  • Java and .NET have more graceful syntax. $ sign in variable names, -> instead of ., <?php ?> tags make PHP code quite bulky.

Nevertheless, PHP has one great feature that makes it very useful for me. From its very beginning, PHP was designed as HTML code preprocessor. Its syntax serves this purpose perfectly. Ultimately, if you write pure HTML code in your PHP file, PHP interpreter will give you this HTML in output. Only PHP insertions between tags like <?php ?> and <?= ?> will be interpreted as PHP code. It lets you do anything with your HTML output and it is usually more convenient compared to various HTML template engines, because template is just a template – it doesn’t let you write code. Also PHP doesn’t care about what exactly you write into output: HTML, operation progress, or message log. I found it convenient for me to build JSON files with PHP.
Read More

5 things how to make code review easier

Code review has the next main purposes:

  • Improve code quality
  • Share knowledge, improve skills
  • Find some bugs beforehand

To achieve these goals with high efficiency in short time, I follow the next simple principles. For some readers they can appear obvious, but I hope that it still can be helpful for the others.

Read More

ISS Art technology stack in 2015

New technologies appear every day, and we try to stay in step with this tendency. But we don’t jump blindly to every new fashion, because this way we can spend a lot of effort for nothing. For commercial development, it is always better to wait a little bit and make sure that the transition to a new technology will really pay off.

Read More

Aggregation and awareness

We told you about a special way to destroy objects in jWidget framework earlier in a section Problem #1 of the article about Front end optimization. Apparently, the framework introduces an unusual approach for object destruction and memory cleaning which we don’t see in any other frameworks. We call it object aggregation.Read More