Tech Talk #1: “Fatal Error – Highway to Hell” Part 1

Despite this dull September weather DA-14 conference room was flooded with light and joy. We conducted our first tech talk and this time we talked about fatal errors and specifically their types, reasons, solutions and exceptions. Our speaker, Roman Sachenko, shared his hand-on experience and relevant knowledge.

Fatal Error Tech Talk pic

So what do you mean by saying “error” in real life?

  • Something goes wrong;
  • Something takes an unexpected turn;
  • Something comes with things you don’t even know how to handle;
  • You do something wrong so, consequently, you face all the above;

Definition of “Error” in software engineering:

  • Error appears as a result of bad software code in some programs that are involved in producing erroneous results;
  • Unexpected behavior or conditions that are not a part of normal software execution;
  • Bug in software that causes program malfunction, but no abnormal termination or crash;

While writing a computer program even the most experienced programmers can make mistakes, thus it is essential to feel up to finding these mistakes and to be able to debug an application. To make it easier to find and fix errors, determine the cause, we divided them into two main categories:

Operational Errors

Programmer Errors

Runtime problems that are encountered by correctly-written applications;
Program bugs;
These aren’t bugs in computer programs;
Issues that can be prevented by engineering change;
Problems that are caused by external factors like:
  • system
  • configuration
  • server hardware
  • network
By definition, they can never be processed properly;

The core difference between these two kinds of errors is that operational ones can happen anytime and even in fault-free programs. Operational errors are failure situations that correctly-written programs have to deal with and their error message doesn’t always indicate a serious problem or a bug.

As a comparison, programmer errors are bugs. These are the cases where developer made a mistake like mistyping a variable identifier, failing to validate user input and so on.

Where it comes from:

  • Typo

Description:

function sayHello(name) {
    var messageHello = 'Hello, ' + name;
    console.log(messageEhllo);
}

sayHello('James Heatfield');
//ReferenceError: messageEhllo is not defined

Solution:

  1. configure IDE to handle typos (ex. ' strict mode' in JavaScript)
  2. develop and follow naming convention
  3. be careful and practise
  • Invalidated data

Description: missing data validators

function displayName(personObject) {
    console.log(personObject.full_name);
}

displayName({}); //undefined
displayName();   //TypeError: Cannot read property 'full_name' of undefined

Solution: validate incoming data

function displayName(personObject) {
    if(personObject && personObject.full_name) {
	console.log(personObject.full_name);	
    }
}

displayName({});        //
displayName();          //
displayName({full_name: 'James Heatfield'}); //James Heatfield
  • Incompetence

Description:

  1. junior developer
  2. new technology
  3. you are engaged in already existing project

Solution:

  1. involving team lead
  2. project documentation
  3. always think before you do something
  • Carelessness

Description:

  1. bad code format/style
  2. missing comments
  3. incomprehensible variable and functional declaration
  4. missing application structure
  5. etc.

Solution:

  1. create a “blueprint” before you start
  2. follow code convention
  3. comment your code / create self-commented code
  • Unsuitable system (OS, language, database, module, etc.)

Description:

  1. slow server
  2. selected database is not compatible with requested tasks
  3. applied OS is not compatible with application

Solution:

  1. don’t hesitate to apply new technologies
  2. work on requirements and require full project description
  • Overconfidence

Description:

  1. “that’s not my bad”
  2. “I am pretty sure that my code works fine”
  3. “you better check your computer as everything works fine on my side”

Solution:

  1. trust your team
  2. work with your team
  3. be a bit prejudiced against your code
  • Superstition

Description:

  1. “that’s not my code, there is something in the system”
  2. “my compiler does this wrong”

Solution:

  1. compiler is your friend
  2. be a bit prejudiced against your code
  • Corrupted library/service/module

Description:

  1. module contains corrupted code
  2. library is out of date
  3. service is not suitable with current environment

Solution:

  1. think and check library before you use it
  2. check module requirements
  3. check if service is still supported
  • External system problems

Description:

  1. out of memory
  2. power off
  3. disk corruption
  4. etc.

Solution:

  1. choose suitable service
  2. high-level server configuration
  3. correct error handling

To learn more about error handling patterns please read “Fatal Error – Highway to Hell, Part 2”.

↑ Go up

Similar post