Monthly Archives: February 2015

RE:Does It Get Boring To Be A Programmer?

This is in response to the post written by Bozhidar Bozhanov, “Does It Get Boring To Be A Programmer?” hosted on Java Coding Geeks. It really reminds me of my career path and how I changed it.

I really programming when I was in elementary school on a TRS-80. Let us not get into the “I had to use tape” discussions please. In any case, the need program carried me on through collage and I graduated with a degree in Computer Engineering. Not only was I a programmer, I was an engineer. I had a license to get paid to do what I enjoy doing was how I saw it.

I am goal oriented so I knew if I wanted to get anywhere I was going to have to develop some goals. I was married by that time so one of my goals was to make sure my work did not get in the way of my marriage. Another goal I set was my career goal. It had to be general enough to fit a number of situations but specific enough to keep on path. The goals I had set kept me in the direction I was aiming but a snag hit along the way.

I had built a set routine in my life of going to work and coming home, going to work and coming home, etc. As the pattern was set, I did something that really threw everything off the tracks, I forgot my goals. Looking back at it, the routine that I had set was really about earning a paycheck and not about what really motivated me. I got my hours so I could pay the bills. That was about the extent of my reasons for going to work. This attitude led me to get bored, really bored. That boredom put me on the path of getting my hours to pay my bills. As one can see, it became a cycle.

The wheels started getting back on track after I got laid off. One of the contracts I was on ran out and no new money was coming so cutbacks were next. I had just blew a deadline so one of the logical choices was me. I really struggled personally as I was looking for work. My goals seemed a long way off now. I was in survival mode and nothing else. The goal of finding work to pay the bills was all consuming. I could never find a position that I was fully qualified for. I got two interviews in four months. That is not a good return on time. I did land a job that paid well under what I was earning in the last job but I had bills. I took the job and started the search again for a job that could pay all the bills.

I developed a habit of following up with every company that I had contact with. This was to keep me fresh in their minds. This habit did land me a job with a company that really has the customer and their employees first. I was getting the bills paid, goal accomplished and more, so why did my career still suck?

The reason my career still sucked was me. I started digging around in my memory to find out why I was fired up when I was just starting and not now. I remembered my career goal, “Solving interesting problems by technical means.” That started the ball rolling from sucky career to a fantastic career. My circumstances had not changed but I started to change.  I started to research different technologies, like Hazelcast, Spring and others.  I wrote my experiences down for everyone to share(blog). This research lead me to do a webinar presentation. I shared my knowledge with the team I was working with and discussed if we could incorporate it anywhere.  In my new job, I am using my knowledge of computer security to meet security requirements set by the customer.  All of this is fueled by my renewed commitment to my career goal.  This commitment has turned into a love of computers that I had back in elementary school with an old TRS-80.  My creativity has soared and with my new found love and professional experience I can design creative solutions to meet customer needs that are practical and sometimes even elegant.

So in direct response to the article, I have found that a programmer can be bored only if they let themselves be bored and loose track of what brought them into computers to begin with.  As for me and my career, I am a born-again programmer.

Advertisement

Beginner’s Guide to Hazelcast Part 6

This is the sixth post in a series of posts about Hazelcast.  If one has not read the last five, please go to the table of contents post I have created to catch up.

Native Clients

After the last post I decided that I am going to go native.  Yep, I am going to demonstrate Hazelcast’s own Java client.  Java is not the only language native clients come in, C++ and C# flavors are available for the enterprise version.

Why Go Native?

It is a good question.  Native clients can keep one fixed into a product line without chance to escape.  Hazelcast rewards the one going native with the following:

  • The client is part of the cluster.  That means one can create places to stash data and listen for events going on in the cluster.  It also means that all of the tricks that have been discussed in my earlier posts can be used as a client.  This advantage cannot be underestimated.
  • The configuration file is similar.  This means that one doesn’t have to translate from the Hazelcast configuration file to client configuration file.  One can copy the file over and like magic it works.  The less translating one has to do, the less that gets lost.

The Any Client Rule of Thumb

Hazelcast clients are the easiest I have ever had the pleasure to set up and use.

Example

This simple example is a continuation of a theme started by the last post, caching expensive operations.

Pom File

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.darylmathison</groupId>
    <artifactId>HazelcastJavaClient</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.7</maven.compiler.source>
        <maven.compiler.target>1.7</maven.compiler.target>
    </properties>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <showDeprecation>true</showDeprecation>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.3.2</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>java</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <mainClass>com.darylmathison.hazelcastjavaclient.Main</mainClass>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <dependencies>
        <dependency>
            <groupId>com.hazelcast</groupId>
            <artifactId>hazelcast-client</artifactId>
            <version>3.3.2</version>
        </dependency>
    </dependencies>

</project>

Client

This client becomes part of the cluster creates a IMap named “fibmap”. The fibonacci result is stored in the map if it hasn’t been calculated before. If one runs the client once, the results are stored in fibmap. The second time the client is run, the cached values are displayed.

package com.darylmathison.hazelcastjavaclient;

import com.hazelcast.client.HazelcastClient;
import com.hazelcast.core.HazelcastInstance;
import java.util.Map;

/**
 *
 * @author Daryl
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        HazelcastInstance instance = HazelcastClient.newHazelcastClient();
        Map<Long, Long> cacheMap = instance.getMap("fibmap");
        
        for(long i = 1; i <= 10L; i++) {
            System.out.println("value is " + fibonacci(i, cacheMap));
        }
        instance.shutdown();
    }
    
    private static long fibonacci(long rounds, Map<Long, Long> cacheMap) {
        Long cached = cacheMap.get(rounds);
        if(cached != null) {
            System.out.print("cached ");
            return cached;
        }
        
        long[] lastTwo = new long[] {1, 1};
        
        for(int i = 0; i < rounds; i++) {
            long last = lastTwo[1];
            lastTwo[1] = lastTwo[0] + lastTwo[1];
            lastTwo[0] = last;
        }
        
        cacheMap.put(rounds, lastTwo[1]);
        return lastTwo[1];
     }

}

Conclusion

In this post I discussed reasons to use Hazelcast’s native Java client. I also showed a quick example of how to use one. The code can be found here.

Reference

When it comes to Beginner’s Guide to Hazelcast. I always am looking at www.hazelcast.com and www.hazelcast.org.