What&#39s Clean Coding &#38 Not

If your are a programmer, then I guess you know, there had been some debate over “What’s the clean code mean?” or simply “How to write clean codes?”. What I have learned from my experience (not just from work, but doing independent programming: that means programming for college project to some free-lancing) and reading, coding is not just about writing big – big lines of code, fill them with algorithms and jargons. Developing software means life time maintainability and support. The life of a software depends upon how it was develop? How maintainable it is? Software isn’t one time created product to be forgotten.

Now question arises “What clean code has to do with software life?”. It has many thing to do.

Many view “clean coding” as they want to perceive the meaning. It goes as there is saying “The beauty is in the eye of the beholder.” So the meaning and in the manner the clean coding is understood, entirely depends upon the person to person. Personally I believe, there is a common ground where at some point, some programmers always agree. This agreement comes, if the two different programmers are of same levels. The level is just term to refer the experience of person.

I was struck with lighting bolt(not actually) when in a particular forum, I had to discuss about “What’s clean coding is?” for long. Everyone expressed there views, from beginners to experts. It was tense discussion for me as I was lil shy about such activity. But everyone silently agreed to a point, there are many things that contribute to clean code. It’s not just about efficiency or beautifully written code.

//code to be added

Look, at the code above and think which code listing is cleaner? I would say example 1 is better. It may look more complex but it is more efficient, as avoidable use of conditions have been removed. Example 2 might be the choice for beginners (that’s what I did as beginner), as it is easier to understand each line. Conditions are break down into simplest and tiniest part. But hey, do you really believe it is better. It is what many experience programmer would call cluttered and waste of time.

Why dirty code?

“Why we get dirty code?” that’s a million dollars question with various answers. Or the question can be “How?”. Let us divide the reasons and try to explore it briefly.

Training! Training!! and again Training!!!

You may have learned coding from college or school, chances are you really don’t learn how to write clean code. I did it from college and I never learn how to write clean codes! Part of this is time pressure on the educational institution. There is only so much that can be taught in a period of time, and coding style, readability, and other things that typically contribute to clean code get dropped from the instruction process, just as process gets dropped when the deadline approaches on a project.
If you look at the syllabi from programming courses at various educational institutions, you will find several that list programming style as one of the course topics or goals. For most that I’ve looked at more deeply, however, it seems that instructors seldom follow through on this goal. Assignments and grading criteria don’t mention any penalty or reward for clear, readable, well-written code. Commercial offerings of programming courses are even worse than the academic ones. They usually have less time for the course and are focused on giving you the bare essentials to enable you to go back to your office and start being productive in the language du jour.

The author hopes to continue the subject matter in future with more deep assesment and analysis.

System Tray Example

When I started Java, I always wondered how do I gonna create system tray for my program. It took some time for me to figure it out. In java, we can create system tray with the help of AWT package. Currently, swing package don’t support the system tray.

The main class named ‘MainFrame’ with main method that will create window & initialize the Utility(system tray) class.
Full source code below :

package tray.ui;

import javax.swing.JFrame;

/**
 *
 * @author PJ
 */
public class MainFrame {

    Utility utility;
    JFrame frame;

    public MainFrame() {
        initComponent();
    }

    public void initComponent() {
        frame = new JFrame("|| System Tray Example ||");
        frame.pack();
        utility = new Utility(this);
        frame.setSize(400, 300);
        frame.setVisible(true);
    }

    public static void main(String args[]) {
        new MainFrame();
    }
}

Now, we have JFrame as window, it’s time to declare a class named ‘Utility’.

package tray.ui;

import java.awt.AWTException;
import java.awt.Image;
import java.awt.Menu;
import java.awt.MenuItem;
import java.awt.PopupMenu;
import java.awt.SystemTray;
import java.awt.TrayIcon;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.net.URL;
import javax.swing.ImageIcon;

/**
 *
 * @author PJ
 */
public class Utility {

    SystemTray systemTray;
    TrayIcon trayIcon;
    MainFrame mainFrame;

    public Utility(MainFrame mf) {
        mainFrame = mf;
        try {
            initSystemTray();
        } catch (AWTException awt) {
            System.out.println("Cannot initialize the system tray.");
            awt.printStackTrace();
        }
    }

    public void initSystemTray() throws AWTException {
        if (!SystemTray.isSupported()) {
            System.out.println("...system tray is not supported...");
            return;
        }

        String toolTip = "By : Prajin Maharjan";
        PopupMenu popup = new PopupMenu();
        trayIcon = new TrayIcon(createTrayIcon("/tray/ui/icon.png"));
        trayIcon.setImageAutoSize(true);
        trayIcon.setToolTip(toolTip);
        systemTray = SystemTray.getSystemTray();

        //--system tray items
        Menu table = new Menu(" Show Table ");
        MenuItem table1 = new MenuItem(" Table 1 ");
        MenuItem table2 = new MenuItem(" Table 2 ");
        MenuItem list1 = new MenuItem(" List 1");
        MenuItem list2 = new MenuItem(" List 2 ");
        MenuItem helpContentMenu = new MenuItem(" Help Content ");
        MenuItem exitMenu = new MenuItem(" Exit! ");
        
        table.add(table1);
        table.add(table2);

        popup.add(table);
        popup.addSeparator();
        popup.add(list1);
        popup.add(list2);
        popup.addSeparator();
        popup.add(helpContentMenu);
        popup.addSeparator();
        popup.add(exitMenu);

        trayIcon.setPopupMenu(popup);
        try {
            systemTray.add(trayIcon);
        } catch (AWTException awte) {
            System.out.println("System tray icon could not be added.");
            return;
        }

        table1.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
            }
        });

        table2.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
            }
        });
    }

    public static Image createTrayIcon(String path) {
        URL imageURL = null;
        try {
            imageURL = Utility.class.getResource(path);
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (imageURL == null) {
            System.err.println("Resource not found " + path);
            return null;
        } else {
            return (new ImageIcon(imageURL).getImage());
        }
    }

    public void isClose() {
        systemTray.remove(trayIcon);
    }
}

The output should look like :

System Tray Example Image
System Tray Example

Swing PopUp Menu

We have seen popup menu at desktop based user interface for programs. The popup menu acts like shortcut links. They are generally setup for the performing actions, that user might need often, like ‘Refresh’, ‘New’ for operation system. Popup menu are easy to access (just by right click of mouse) and delivers most commonly needed features to user. Mostly every program now a days have there own popup menu. Today, we will create a simple popup menu based on java swing with some menu items and see how it looks.


        MouseListener popupListener = new PopupListener(popup);
        popupMenuEx.centerJPanel.addMouseListener(popupListener);
        // Add more according to requirements
        . . .

Assign popup menu.

Below is the full code for creating popup menu class :

package swing.ui;

import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.JSeparator;

/**
 *
 * @author prajin
 */
public class Popup implements ActionListener, ItemListener {

    private PopupMenuEx popupMenuEx;

    public Popup(PopupMenuEx mf) {
        popupMenuEx = mf;
        try {
            createAndShowPopupMenu();
        } catch (Exception e) {
        }
    }

    public void createAndShowPopupMenu() {
        JPopupMenu popup = new JPopupMenu(title);

        JMenuItem newMenu = new JMenuItem(" New ");
        JMenuItem deleteMenu = new JMenuItem(" Delete ");
        JMenuItem saveMenu = new JMenuItem(" Save ");
        JMenuItem searchMenu = new JMenuItem(" Search ");
        JMenuItem resetMenu = new JMenuItem(" Exit ");
        JSeparator separator1 = new JSeparator();
        JSeparator separator2 = new JSeparator();

        JMenu optionMenu = new JMenu("Option");
        optionMenu.add(deleteMenu);
        optionMenu.add(searchMenu);

        popup.add(newMenu);
        popup.add(saveMenu);
        popup.add(separator1);
        popup.add(optionMenu);
        popup.add(separator2);
        popup.add(resetMenu);

        MouseListener popupListener = new PopupListener(popup);
        popupMenuEx.centerJPanel.addMouseListener(popupListener);

        newMenu.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
            }
        });
    }

    public void actionPerformed(ActionEvent e) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void itemStateChanged(ItemEvent e) {
        throw new UnsupportedOperationException("Not supported yet.");
    }
}

class PopupListener extends MouseAdapter {

    JPopupMenu popup;

    PopupListener(JPopupMenu popupMenu) {
        popup = popupMenu;
    }

    public void mousePressed(MouseEvent e) {
        maybeShowPopup(e);
    }

    public void mouseReleased(MouseEvent e) {
        maybeShowPopup(e);
    }

    private void maybeShowPopup(MouseEvent e) {
        if (e.isPopupTrigger()) {
            popup.show(e.getComponent(),
                    e.getX(), e.getY());
        }
    }
}


Below is the code for using popup menu :

package swing.ui;

import java.awt.BorderLayout;
import java.awt.Color;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.LineBorder;

/**
 *
 * @author prajin
 */
public class PopupMenuEx {

    public JFrame jFrame;
    public JPanel centerJPanel;
    Popup popup;

    public PopupMenuEx() {
        initUIComponents();
    }

    public void initUIComponents() {
        jFrame = new JFrame("Popup Menu Ex");
        jFrame.pack();
        centerJPanel = new JPanel();
        centerJPanel.setBorder(new LineBorder(Color.DARK_GRAY, 4));

        jFrame.add(centerJPanel, BorderLayout.CENTER);
        jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        jFrame.setSize(300, 250);
        popup = new Popup(this);
        jFrame.setVisible(true);
    }

    public static void main(String args[]) {
        new PopupMenuEx();
    }
}

The output looks like this :

Swing based JPopup Menu

Swing Menu Bar

Swing is simple yet elegant way to create desktop based friendly user interface(UI). The desktop UI contain lot’s of different details. But today, we will create a simple menu bar that will just look like menu bar, we see daily while using different apps. The menu bar are important part of any program. It’s a way to navigate through the program, perform different actions, software customization and ease for usage. Menu bar contains lots of program features, options and distinct actions like ‘Save’, ‘New’ etc.
Note : Menu Bar by default always appear at the top of the window frame.


        KeyStroke keyNew = KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.CTRL_MASK);
        newMenuItem.setAccelerator(keyNew);

Assign key ‘CTRL + N’ series to Menu Item.


     newMenuItem.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                // CODE TO BE EXECUTED WHEN NEW MENU IS CLICKED
            }
        });

Add Action listener to the menu item. Code to be executed or method to be called will be placed inside here, which only will be triggered when user will click the menu item.


            menuFile.add(newMenuItem);
            ...
            menuBarTop.add(menuFile);

Menu item added to menu and that menu is added to the menu bar.

Below is the full code on how to create a simple menu bar with menu items for swing based window frame.

package swing.ui;

import javax.swing.BorderFactory.*;
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JSeparator;
import javax.swing.KeyStroke;

/**
 *
 * @author prajin
 */
public class MenuBarExample {

    JFrame frame;
    Font font1;

    public MenuBarExample() {
        initUIComponents();
    }

    public void initUIComponents() {
        frame = new JFrame("| MENU BAR EXAMPLE |");
        font1 = new Font("Batang", 0, 14);
        JMenuItem newMenuItem = new JMenuItem(" New  ");
        newMenuItem.setFont(font1);
        //--- mnemonic settings -----------
        newMenuItem.setMnemonic(KeyEvent.VK_N);
        KeyStroke keyNew = KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.CTRL_MASK);
        newMenuItem.setAccelerator(keyNew);
        newMenuItem.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                // CODE TO BE EXECUTED WHEN NEW MENU IS CLICKED
            }
        });

        JMenuItem exitMenuItem = new JMenuItem(" Exit  ");
        exitMenuItem.setFont(font1);
        exitMenuItem.setForeground(Color.RED);
        exitMenuItem.setMnemonic(KeyEvent.VK_Q);
        exitMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, InputEvent.ALT_MASK));

        JSeparator separator1 = new JSeparator();

        JMenuItem helpContentMenuItem = new JMenuItem(" Help Contents  ");
        helpContentMenuItem.setFont(font1);
        helpContentMenuItem.setMnemonic(KeyEvent.VK_F1);
        helpContentMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, InputEvent.SHIFT_MASK));

        JMenuBar menuBarTop = new JMenuBar();
        JMenu menuFile = new JMenu(" File ");
        JMenu menuHelp = new JMenu(" Help ");

        menuFile.setFont(font1);
        menuHelp.setFont(font1);

        menuFile.add(newMenuItem);
        menuFile.add(separator1);
        menuFile.add(exitMenuItem);
        menuHelp.add(helpContentMenuItem);

        menuBarTop.add(menuFile);
        menuBarTop.add(menuHelp);

        frame.setJMenuBar(menuBarTop);
        frame.pack();
        frame.setExtendedState(frame.getExtendedState() | JFrame.MAXIMIZED_BOTH);
        frame.setResizable(true);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setVisible(true);
    }

    public static void main(String args[]) {
        new MenuBarExample();
    }
}

The output should look like this :

Swing based Menu Bar

User Interface Design

When I started programming, I started from doing “C”. Programs used to be very simple with some algorithms, logic and sometime lots of maths, and they were console based. It was fun. The fun part became more fun, when I started doing “user interface” based programs. The option to develop a wide range of software suddenly came in front. The UI programming is quite easy, fun and essential, as it won’t require any algorithms. It’s straightforward because when we make a mistake, we immediately see it and can correct it.

For some, UI programming may be quite dull, boring and non-productive part. They think that UI design is like graphics design. What they aren’t seeing here is, how important it is to have a good UI for each program. UI are created for user convenience, they are the one who will use the software. Users are that being, that either have few or no knowledge at all (mostly). First thing a user will see is a program UI, not how it works or what are it’s features.

1. Having Control over your UI will make you happy

Whatever I say or you yell,it’s true, when you look at your UI, you will always feel good. UI serves the purposes of program objectives. The coding is the process that will provide results. While UI is the surface layer that will display the results. UI are the main source of getting inputs from users with minimal errors. UI makes easier for user to understand what they are supposed to do, where they are supposed to click etc. UI is important because it affects the feelings, the emotions, and the mood of your users. If the UI is wrong and the user feels like they can’t control your software, they literally won’t be happy and they’ll blame it on your software. If the UI is smart and things work the way the user expected them to work, they will be cheerful as they manage to accomplish small goals. The point is, does the UI respond to the user in the way in which the user expected it to respond? To make people happy, you have to let them feel like they are in control of their environment. To do this, you need to correctly interpret their actions. The interface needs to behave in the way they are expecting it to behave.

2. What user wants?

When user sit in front of their PC, mostly they won’t have a clean, clear mind state. They tends to be ambiguous. They have some expectations of how they think the program is going to work and they expect it to work as they expected. When user talk about any office package, then they expect it to be just like ‘Microsoft Office Package’. It’s not bad, if they compare your product with one of Microsoft. Isn’t menu bar at top of window cool? Isn’t status bar at bottom of window does help? Yes they do and these idea came from not us but big software developer company. Big company spend lots of time and money in researches, so we can always learn from there hard worked researches. They give high priority to ‘What user have to say?‘, ‘What user response was?‘ etc. They have probably one of biggest user data, filled up with our responses, which they use for future product release enhancements.

So, gathering user requirements effectively as possibly, help for better product at other end. We can’t build program, that provides form like interface with some inputs and button, which when pushed display the inputs we just entered. That button is supposed to do more than just display. It could save the user inputs to database or send it over internet. What it mean is, UI should always be meaningful.

UI
Swing based User Interface Frame / Window

Log4j

Every big applications have some sort of logging facilities or tracing API. Logging is necessity, rather than just another feature. Here I would like to talk about Log4j logger. It is not perfect but good enough for all kind of applications and business scale.

How to install log4j

  • Download stable release from internet.
  • In GUI, just import log4j-x.x.x.jar file to project library.
  • In web, place log4j property file at server domain location or at project source directory
  • In WAR module, include following code at pom.xml file.


Add following lines at pom.xml. Log4j has three other dependencies, so these dependencies can be removed by <exclusions> tag. If you need these dependencies just don’t add all <exclusions> tag part.

<dependency>
<groupid>log4j</groupid>
<artifactid>log4j</artifactid>
<version>1.2.15</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<artifactid>jms</artifactid>
<groupid>javax.jms</groupid>
</exclusion>
<exclusion>
<artifactid >jmxri</artifactId>
<groupid>com.sun.jmx</groupid>
</artifactid></exclusion>
<exclusion>
<artifactid>jmxtools</artifactid>
<groupid>com.sun.jdmk</groupid>
</exclusion>
</exclusions>
</dependency>

How to configure?
Configuring part is important and sometime really troublesome. We can configure log4j in two ways : log4j.xml and log4j.properties.
First for simple start, just create a properties file with name log4j. I will be talking more about log4j.properties here, because it’s simple and easy to pick up with. But that don’t mean log4j.xml isn’t useful. XML format log4j is more suited for complex, big projects and provides better features that properties format. Let’s start –
A simple log4j.properties configuration will look like something this :

# The default root appender
log4j.rootLogger=A1

# A1 is set to be a ConsoleAppender which outputs to System.out.
log4j.appender.A1=org.apache.log4j.FileAppender
log4j.appender.A1.file=app.log
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%-22d{dd/MMM/yyyy HH:mm:ss} %-8p %c [%t] - %m (%l)%n

# An extra category to a log file
log4j.category.AppLogging=A2

# A3 is set to be a FileAppender which will log all actions in the application.
log4j.appender.A3=org.apache.log4j.FileAppender
log4j.appender.A3.layout=org.apache.log4j.PatternLayout
log4j.appender.A3.layout.ConversionPattern=%-22d{dd/MMM/yyyy HH:mm:ss} - %m%n
log4j.appender.A3.file=application.log

log4j.additivity.AppLogging=false

Very-high-bitrate digital subscriber line

Very-high-bitrate DSL (VDSL or VHDSL) is a DSL technology providing faster data transmission (up to 52 Mbit/s downstream and 16 Mbit/s upstream) over a single flat untwisted or twisted pair of copper wires. These fast speeds mean that VDSL is capable of supporting high bandwidth applications such as HDTV, as well as telephone services (voice over IP) and general Internet access, over a single connection. VDSL is deployed over existing wiring used for POTS and lower-speed DSL connections. This standard was approved by ITU in November 2001.

Second-generation systems (VDSL2; ITU-T G.993.2 approved in February 2006) utilize frequencies of up to 30 MHz to provide data rates exceeding 100 Mbit/s simultaneously in both the upstream and downstream directions. The maximum available bit rate is achieved at a range of about 300 meters; performance degrades as the loop attenuation increases.

Currently, the standard VDSL uses up to 7 different frequency bands, which enables customization of data rate between upstream and downstream depending on the service offering and spectrum regulations. First generation VDSL standard specified both quadrature amplitude modulation (QAM) and discrete multi-tone modulation(DMT). In 2006, ITU-T standardized VDSL in recommendation G.993.2 which specified only DMT modulation for VDSL2.


Very-high-speed digital subscriber line 2 (VDSL2) is an access technology that exploits the existing infrastructure of copper wires that were originally deployed forPOTS. It can be deployed from central offices, from fibre-fed cabinets located near the customer premises, or within buildings.

VDSL2 is the newest and most advanced standard of DSL broadband wireline communications. Designed to support the wide deployment of triple play services such as voice, video, data, high definition television (HDTV) and interactive gaming, VDSL2 is purported to enable operators and carriers to gradually, flexibly, and cost-efficiently upgrade existing xDSL infrastructure.

The protocol was standardized as ITU G.993.2 on February 17, 2006.

ITU-T G.993.2 (VDSL2) is an enhancement to G.993.1 (VDSL) that permits the transmission of asymmetric and symmetric aggregate data rates up to 200 Mbit/s downstream and upstream on twisted pairs using a bandwidth up to 30 MHz.

VDSL2 deteriorates quickly from a theoretical maximum of 250 Mbit/s at source to 100 Mbit/s at 0.5 km (1,600 ft) and 50 Mbit/s at 1 km (3,300 ft), but degrades at a much slower rate from there, and still outperforms VDSL. Starting from 1.6 km (1 mi) its performance is equal to ADSL2+.

ADSL-like long reach performance is one of the key advantages of VDSL2. LR-VDSL2 enabled systems are capable of supporting speeds of around 1–4 Mbit/s (downstream) over distances of 4–5 km (2.5–3 miles), gradually increasing the bit rate up to symmetric 100 Mbit/s as loop-length shortens. This means that VDSL2-based systems, unlike VDSL1 systems, are not limited to short local loops or MTU/MDUs only, but can also be used for medium range applications.

Source : wikipedia

Distributed Denial-Of-Service(DOS) Attack

After the wikileaks got all over into news, I was particularly interested in DOS Attack : it’s impact and effectiveness. Among various type of attack, DOS is unique, as its primary objective is to denies the web service to any user requesting service. It’s a attack, rather than break into system. Here, below is article that I found in wikipedia and decided to share.

A denial-of-service attack (DoS attack) or distributed denial-of-service attack (DDoS attack) is an attempt to make a computer resource unavailable to its intended users. Although the means to carry out, motives for, and targets of a DoS attack may vary, it generally consists of the concerted efforts of a person or people to prevent an Internet site or service from functioning efficiently or at all, temporarily or indefinitely. Perpetrators of DoS attacks typically target sites or services hosted on high-profile web servers such as banks, credit card payment gateways, and even root nameservers.

One common method of attack involves saturating the target machine with external communications requests, such that it cannot respond to legitimate traffic, or responds so slowly as to be rendered effectively unavailable. In general terms, DoS attacks are implemented by either forcing the targeted computer(s) to reset, or consuming its resources so that it can no longer provide its intended service or obstructing the communication media between the intended users and the victim so that they can no longer communicate adequately

Denial-of-service attacks can also lead to problems in the network ‘branches’ around the actual computer being attacked. For example, the bandwidth of a router between the Internet and a LAN may be consumed by an attack, compromising not only the intended computer, but also the entire network. If the attack conducted on a sufficiently large scale, entire geographical regions of Internet connectivity can be compromised without the attacker’s knowledge or intent by incorrectly configured or flimsy network infrastructure equipment.

A “denial-of-service” attack is characterized by an explicit attempt by attackers to prevent legitimate users of a service from using that service. There are two general forms of DoS attacks: those that crash services and those that flood services.[4] Attacks can be directed at any network device, including attacks on routing devices and web, electronic mail, or Domain Name System servers.
A DoS attack can be perpetrated in a number of ways. The five basic types of attack are:

  • Consumption of computational resources, such as bandwidth, disk space, or processor time.
  • Disruption of configuration information, such as routing information.
  • Disruption of state information, such as unsolicited resetting of TCP sessions.
  • Disruption of physical network components.
  • Obstructing the communication media between the intended users and the victim so that they can no longer communicate adequately.

A DoS attack may include execution of malware intended to:[citation needed]

  • Max out the processor’s usage, preventing any work from occurring.
  • Trigger errors in the microcode of the machine.
  • Trigger errors in the sequencing of instructions, so as to force the computer into an unstable state or lock-up.
  • Exploit errors in the operating system, causing resource starvation and/or thrashing, i.e. to use up all available facilities so no real work can be accomplished.
  • Crash the operating system itself.