Wednesday, May 27, 2015

Software Engineer in search of a specialty

Arguments for specialization -

T-shaped skill sets -

I have been reading recently about specializing more as a software engineer. At this time I don't have a specialty at all.  For all of my career I have been a Java full stack engineer working mostly on web applications doing basically what is needed to get the job done.  Being able debug and speak to all areas of the application is valuable but having a focus/specialty would be even more so.  It would feel good to be more than a jack of all trades master of none engineer.  The time in my career I felt the most valuable to the organization was when I technical domain expert for a really complex feature of the flagship product.  With the pace that technological options are growing it is seemingly impossible task to truly know enough. The desire to specialize is there but the opportunity to isn't apparent to me at the moment so I need to steps to make it happen.

Step One:  Pick a specialty

This is where I get stuck and have been stuck for a couple years now.  I have areas of interest but nothing that stands out as something I can dig deep on within my current position so it would be purely on the side. So TBD...  still stuck at step one.  I should send out messages in a bottle  or smoke signals or something.

Step Two:  Obsess over learning the specialty

Step Three:  I don't know yet...

Tuesday, May 26, 2015

Programming excerise - Alternating loops

This is a fairly easy challenge.  I could see this as a warm up question in a job interview.  The solution I provided assumes the lists are the same length.  In an interview it would often start this way and then be asked to expand upon the solution to account for the variation in list sizes.

Write a function that combines two lists by alternatingly taking elements. For example: given the two lists [a, b, c] and [1, 2, 3], the function should return [a, 1, b, 2, c, 3].

List<String> result = new ArrayList<>();
List<String> letters = new ArrayList<>(Arrays.asList("a","b","c"));
List<String> numbers = new ArrayList<>(Arrays.asList("1","2","3"));

Iterator<String> letterIterator = letters.iterator();
Iterator<String> numberIterator = numbers.iterator();

while (letterIterator.hasNext() || numberIterator.hasNext()) { 
 if (result.size() % 2 == 0) {
 } else {

Related Content:

Saturday, May 23, 2015

Fun with Loops - 7 ways to do loops in Java 8

This is more of a coding stretch than a challenge.

Write functions that compute the sum of the numbers in a given list using a for-loop, for each loop, new Java 8 streams, a while-loop, and recursion.

public class Main {

 public static void main(String[] args) throws Exception {
  List<Integer> numbers = new ArrayList<>(
      Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9));
  int sumJavaStream = sumJavaStream(numbers);
  int sumForLoop = sumForLoop(numbers);
  int sumForEachLoop = sumForEachLoop(numbers);
  int sumDoWhile = sumWhile(numbers);
  int sumRecursion = sumRecursion(numbers);
  if (sumDoWhile == sumForLoop && sumForLoop == sumForEachLoop && 
    sumForEachLoop == sumDoWhile && sumDoWhile == sumRecursion) {

 private static int sumJavaStream(List<Integer> numbers) {
  return -> num.intValue()).sum();
 private static int sumForLoop(List<Integer> numbers) {
  int result = 0;
  for (int i = 0; i < numbers.size(); i++) {
   result += numbers.get(i).intValue();
  return result;
 private static int sumForEachLoop(List<Integer> numbers) {
  int result = 0;
  for (Integer number : numbers) {
   result += number.intValue();
  return result;

 private static int sumWhile(List<Integer> numbers) {
  int result = 0;
  int i = 0;
     while (i < numbers.size()) {
      result += numbers.get(i).intValue();
  return result;  
 private static int sumRecursion(List<Integer>> numbers) {
  return sumRecursion(numbers, 0, 0); 
 private static int sumRecursion(List<Integer> numbers, int index, int sum) {
  int result = sum;
  if (index < numbers.size()) {
   result += numbers.get(index);
   result = sumRecursion(numbers, index + 1, result);
  return result; 

Related Content:

Thursday, May 21, 2015

Soft Skills are so important to Software Engineers

Soft skills are so underrated.  All to often software engineers job themselves on their technical chops but soft skills probably affect your career more. Soft Skills software developers manual by John Sonmez is a book I highly recommend.  (Hopefully a digital copy of it will be available soon.)  Jon also wrote a blog post just after his book came out with a bunch of tips about boosting your career and here are my quick thoughts on each tip.  This author and I are in slightly different places and have different career goals.  My family comes before my career goals by miles

24 quick tips to boost your career as a software engineer

Tip #1: Learn how to learn

Life long learning is huge.

Tip #2: Commit to a reading schedule

Life is too chaotic right now.  I am not sure if I can commit to a reading schedule at this time.  Maybe in the future.  I learn a little better by taking courses and doing tutorials vs reading books.

Tip #3: Improve your health

Sleep and working out are important for optimal brain functionality.  I need to stop using having young children as an excuse for not exercising as much as I should.

Tip #4: Practice interviewing

I agree with this one in a huge way.  Interviewing is a skill and it is often rusty when you need it most.  I also think doing the coding challenges like the ones you often have to do in job interviews is something to be practiced regularly.

Tip #5: Create a blog

You are reading my blog.  So I have one but no one visits it because I don't publicize it or publish anywhere else.  I am still working up the confidence in regards to does my voice matter at all in the software engineering world. A friend of my Daniele Rossi is coaching me how to make it better.

Tip #6: Find a mentor

I need to network more before I can even consider trying to find someone to act as a mentor.  My career goals as a software engineer don't align with my peers so this can be difficult at times to even find people on a similar page as me.

Tip #7: Launch a side project

I never know what to create when ever this comes up.  The most I tend to do is build platforms to play with new tech.

Tip #8: Wake up an hour earlier each morning

Good advice.  I am an early bird by nature and am very productive in the morning.  Once my youngest is a little older I think this may be possible.

Tip #9: Start tracking your time

This seems like a lot of work.  I am not ready to make managing my career a job but maybe one day I will.

Tip #10: Watch less (or no) TV

This is a tough one for me.  My TV watching is already pretty minimal.  The time I do spend doing it often spent sitting with my wife after the kids are asleep.  I suppose since she is a software engineer also we could cut down that some and have some quality time in other ways but we are often drained by the end of the day.

Tip #11: Work on your Soft Skills

Aren't all these tips primarily about soft skills?

Tip #12: Join the community

Easy for single people but hard for parents with young children... but this is something I should really just make time for.  Maybe start with an online community.

Tip #13: Give a talk

I used to be in Toastmasters so public speaking isn't a problem for me despite the fact that I stutter.  Joining a community, being at a company where lightning talks are done, and just making the time to put myself out there is where I should start. However the priority of this tip is a little lower for me because others are a prerequisite.

Tip #14: Be a mentor

I like mentoring. The challenge for me is finding someone to mentor.  Well that and finding the time. See Tip #6.

Tip #15: Plan your year

Building your brand and skill set is something the can and should be planned.  If you don't set goals how will you achieve them?

Tip #16: Learn a new technology

This is our life.  This is our career.  As a software engineer if you are not learning a new skill or mastering one you already are familiar with you are falling behind because things change daily.

Tip #17: Get to know your IDE better

This is a sneaky one but one that can really affect productivity.  Knowing the short cuts and features of your IDE can really speed up development and decrease time spent debugging.

Tip #18: Have your resume professionally written

Wow! No thank you.  I am not going to spend over $500 on having someone write my resume.  I am sure they will do a better job than I can but I have had no issues with recruiters not beating down my door. This seems like a waste to me.  I will stick with just running it by colleagues who see resumes for software engineer candidates and ask I stack up and how I could improve it.

Tip #19: Make connections now, not later

This is basically a repeat but a repeat for a good reason.  Networking can be huge.  I am not very good at it but that is no excuse for not doing it

Tip #20: Utilize a productivity technique

Productivity technique? Runaway!!!!!  Just the very idea of this type of thing turns me off.  Maybe I am not driven enough for it or don't have inspiring goals in mind.

Tip #21: Develop a routine

Good habits are important for sustainability.  Not only that but if you do fall off track due to something unexpected that comes up or you just plain got lazy having a routine to revive and go back to will speed your recovery.

Tip #22: Upgrade your equipment

I don't really code too much for myself on my own gear.  That is where I need to start vs getting a screaming machine.

Tip #23: Create a personal brand

Think of your career has a business.  What is your brand?  What makes you valuable to employers?

Tip #24: Specialize

I have been a full stack Java engineer my whole career.  I have no specialty of particular talent other than I have always been in a position where I need to wear many hats.  The desire to specialize is there but the opportunity to is what has held me back.  Maybe focusing on personal learning and projects could help more here.  Honestly I think I would like to specialize in something that isn't even a recognized strength right now.  Is that strange?

I would love to know your initial thoughts on some of these tips.

more Java 8 Goodies

I did streams yesterday but lets touch on a couple fun points.  Again I am a little late to the party on this stuff but I doubt I am the only one.


      Could this be the end of null pointer exceptions?  This is a lot nicer way to default values and do null checks.  If you follow my blog you know I hate ternary operators due to their poor readable and this does away with that in the case of default values.

    Optional<String> displayText = Optional.ofNullable(null);
        "display text found? " + displayText.isPresent() );
        "display text: " + displayText.orElseGet( () -> "n/a" ) );
    System.out.println( text -> text.toUpperCase() ).orElse(" ") );

Interface Changes

      I am not entirely sure about this one because the line between abstract class and interface is really blurry.

Default Methods:

      This can help with backwards comparability when adding new methods to interfaces.

    public interface MouseTrap {
 // ...
 default void setTrap() {
     // ...

Static Methods:

    private interface MouseTrapFactory {
        // Interfaces now allow static methods
        static MouseTrap createMouseTrap(String bait) {
        return new BetterMouseTrap(bait);

Native JavaScript Support

    Since I haven't used it really yet I don't want to just copy other peoples examples but now with Java 8 the native Javascript engine that can be accessed with in is Nashorn (pr. "nass-horn").  The JavaScript you write can be executed from the command line (which can even call Java classes) or within Java classes.

Related Content

Wednesday, May 20, 2015

Java 8 streams and the drastic impact on loops

Java 8 is a game changer.  There is no question about that.  Java 7 barely made a splash but Java 8 is like Java 5 which introduced generics, annotations, and so on. I may be a little late to the party on Java 8 but in corporate america things become relevant a little slower.  One of the ways Java 8 has changed things is with streams and how it has changed the way we can do loops.

Here is a little code to show you how things can be different with streams.  I will go into more detail but this is just to start the discussion with code.

     public void doStuff() throws Exception {
  List<BlogPost > posts = new ArrayList<>();
  BlogPost post1 = new BlogPost();
  post1.setTags(Arrays.asList("A", "B", "C"));  
  BlogPost post2 = new BlogPost();
  post2.setTags(Arrays.asList("C", "D", "E"));  
  BlogPost result1 = getRelatedPostLoop(posts, "D");
  Optional<BlogPost > result2 = 
                        getRelatedPostStream(posts, "D");
  if (result1 != result2.get()) {
   throw new Exception("error");
  BlogPost result3 = getRelatedPostLoop(posts, "F");
  Optional<Blogpost> result4 = 
                        getRelatedPostStream(posts, "F");
  if (result3 != null || result4.isPresent()) {
   throw new Exception("error");
 //Java 7 way
 private BlogPost getRelatedPostLoop(List<BlogPost> posts, 
                String tag) {
     for (BlogPost post : posts) {
         if (post.getTags().contains(tag)) {
             return post;
     return null;
 //Java 8 way
 private Optional<BlogPost> getRelatedPostStream(
                List<BlogPost > posts, String tag) {

          .filter(post -> post.getTags().contains(tag))
 private class BlogPost {
  private String tile;
  private StringBuffer body;
  private List<String> tags;
  public String getTile() {
   return tile;
  public void setTile(String tile) {
   this.tile = tile;
  public StringBuffer getBody() {
   return body;
  public void setBody(StringBuffer body) {
   this.body = body;
  public List getTags() {
   return tags;
  public void setTags(List<String> tags) {
   this.tags = tags;

Pretty cool right?  Single pass loops can be made a lot simpler with the use of streams.  The list is being used as a stream which does the same as a for loop.  The filter operation does exactly what you would expect; it filters each element in the list by a condition passed in through the argument.  Lastly findFirst pretty clearly from its name again returns the first element from the stream or null if the stream is empty.

Other hidden gems in that code thanks to Java 8:
  • List<BlogPost > posts = new ArrayList<>();

    This is a simple thing but reduces frustration.  How many times have you been frustrated because you had to cut and paste the same generic on both sides of an assignment?  You are writing the assignment inline why does the compiler really need to you specify it twice! Well now you don't have to.
  • Optional<BlogPost>

    Optional is a new class which helps make it clear that a null object response can be returned and adds in some helper methods to work with that possibly null value cleanly. 

More examples of how streams can be done to make the code a little cleaner:

  • Here is a simple way to return the filtered matches as a collection.  There is no need to create the in scope list variable to be used in the response.

 private List<BlogPost> getAllRelatedPosts(
                List<BlogPost > posts, String tag) {
          .filter(post -> post.getTags().contains(tag))

  • Also here is a simple way to return the filtered matches but only the distinct matches. Small change but showing the power here.

 private Set<BlogPost> getAllRelatedPosts(
                List<BlogPost> posts, String tag) {
          .filter(post -> post.getTags().contains(tag))

  • Even performing operations to say get a sum total based upon a loop variable method is easy
     private int getTagCount(List<BlogPost> posts) {
                                         post -> 

  • The magic continues on and on but those are things you really should explore on your own

Potentially helpful links:

Wednesday, May 13, 2015

“Kill the boy and let the man be born.”

“Kill the boy and let the man be born.”  Thank you Game of Thrones for that wonderful quote in last Sunday's episode of Season 5 called "Kill the Boy."  The line was spoken by Aemon Targaryen the 100 year old maester to Jon Snow the young bright eyed new Lord Commander of the Nights Watch.  The advice was meant to tell Jon it is time to grow up and set aside the rose colored glasses of childhood and become the adult/man you need to be. With his new position Jon cannot afford to not be a realist.  He must make all the moves necessary to survive and do what is best for the realm even if at times it is unpleasant.  This same lesson needs to be learned at some point in time when thinking about your career.

For me that lesson was learned very harshly when I was laid off by a company I expected to spend my entire career at.  My father has worked for the company since before I was born and my mother worked there for over ten years until she left after my little sister was born.  So at the time I was let go my immediate family had combined about 50 years tied up with the company.  It was where I always dreamed of working and where I got inspired in my choice of careers when I joined my father when he went into the office on the weekends.  Someone made a call that they could outsource my job along with a third of the IT department and save a few bucks.  It was as simple and as impersonal as that.  Sure they offered me money to stay till then end and with a wink and nudge said if I apply for a spot on this other team I will very likely still have a job after it is done but the bloom was off the rose.  The business arrangement of my employment was no longer favorable to the company so they were terminating said arrangement.  That same mentality is important to have as an employee as well because the only loyalty your employer has is to the business and its success and survival. 

Thinking about your career as a business is important in today's workplace.  Your skill set, your ability to communicate, your employment history, the impressions you make on your coworkers, and even your integrity have value and it is in your best interest to maximize that value.  If your skill set is falling behind in what is popular today today because your current position works with an old tech stack then something needs to be done about that.  Keeping your skill set current requires continuous learning which is your responsibility not your employers.  Ideally your employer sends you to conferences and offers programs to make continually growing your skill set easier but that is not always the case.  There are even aspects of brand management when it comes to your career which is built out of your work history, past professional relationships, networking, and social media.  Your career is a business which you want to do everything you can to thrive so that it meets your professional and personal goals.  It does not necessarily mean chase every penny you can earn because there is a value to a work environment where you are happy in to.  

Decide the direction you want your career/business to go and make the steps necessary to take it there.  "Kill the boy" and let go of the notations that you deserve professional success therefore it should be handed to you.  You have to earn success and take the steps necessary to maximize your chances of achieving that success. 

Friday, May 1, 2015

Turning a riddle/puzzle into code

I stumbled upon a little random coding exercise and I coded it just as a mental stretch if you will.  It is not artistically beautiful code but it works.  I found it difficult to create the logic in such a way that it could apply to something other than just this exact case.

The challenge basically is you have 3 things you are responsible for but two of them are dangerous to something else.  How do you transport them one at a time without having any of them get harmed.  In this case a wolf, goat, and a salad.  The wolf will eat the goat and the goat would eat the salad if you aren't there to stop them.  How do you move them one at time

The original puzzle can be found here.

import java.util.ArrayList;
import java.util.List;

public class Main {

    public static void main(String[] args) throws Exception {

//        Goat-Wolf-Salad
//        A goat, a wolf and a salad are on one side of a river and you need to get them to the other side 
//        using your boat. You can carry one item in your boat to the other side at any given time. 
//        However, when the goat and the wolf are left alone the wolf will eat the goat. 
//        If the goat and the salad are left alone the goat will eat the salad. As long as you 
//        are with them nothing will happen, i.e. the wolf won’t eat the goat and the goat won’t eat the salad.
//        W > G   G > S        
//        Write a program which determines algorithmically an order in which you carry them all to the other side.

         *  Solution: 
               WGSU |    |  ____   
                W S | UG |
                W S |    | UG
                WSU |    | G
                S   | UW | G
                S   |    | UWG
                S   | UG | W
                GSU |    | W
                G   | US | W
                G   |    | UWS                
                UG  |    | WS
                ___ | UG | WS
                    |    | UWGS

        Main thisClass = new Main();
        Traveler you = Traveler("You"null);
        Traveler salad = Traveler("Salad"null);
        Traveler goat = Traveler("Goat", salad);
        Traveler wolf = Traveler("Wolf", goat);
        List leftbank = new ArrayList();

        List rightbank = new ArrayList();
        while(!leftbank.isEmpty()) {
            //determine who to move
            //move passenger
            //check if both sides safe or else throw exception
            transportPassenger(leftbank,rightbank, you);
            System.out.println("left: " + leftbank);
            System.out.println("right: " + rightbank);
            if(!isSafe(leftbank, you) || !isSafe(rightbank, you)) {
                throw new Exception("Someone got eatten");
    private static void transportPassenger(List leftbank, List rightbank,  Traveler you) {
        if (leftbank.contains(you)) {
            Traveler passenger =  nextPassenger(leftbank, you);
            if (passenger == null) {
                //get the most dangerous traveler on the river bank
                for (Traveler traveler: leftbank) {
                    if (traveler.dangerousTo != null) {
                        passenger = traveler;
            if (passenger != null) {
                System.out.println("transporting: " +;
            } else {
                System.out.println("transporting: none");
        } else if (!leftbank.isEmpty()) {                        
            Traveler passenger = null;
            if (rightbank .size() != 2) {
                passenger =  nextPassenger(rightbank, you);
            if (passenger != null) {
                System.out.println("transporting: " +;
            } else {
                System.out.println("transporting: none");
    private static Traveler nextPassenger(List riverbank,  Traveler you) {
        Traveler passenger = null;
        List inDanger = new ArrayList();
        //get the travelers that are in danger
        for (Traveler traveler: riverbank) {
            if (traveler.dangerousTo != null) {
                for (Traveler anotherPassenger : riverbank) {
                    if (traveler != anotherPassenger && traveler.dangerousTo == anotherPassenger) {
                        System.out.println("in Danger: " +;
        if (inDanger.size() == 1) {
            passenger = inDanger.get(0);
        } else if (inDanger.size() > 1){
            //get most dangerous in danger
            for (Traveler traveler: inDanger) {
                if (traveler.dangerousTo != null) {
                    passenger = traveler;
        return passenger;        
    private static boolean isSafe(List group, Traveler you) {
        boolean isSafe = true;
        if (!group.contains(you)) { 
            for (Traveler passenger : group) {
                if (passenger.dangerousTo != null) {
                    for (Traveler anotherPassenger : group) {
                        if (passenger.dangerousTo == anotherPassenger) {
                            isSafe = false;
        return isSafe;        
    private class Traveler {
        public String name;
        public Traveler dangerousTo;
        public Traveler(String name, Traveler dangerousTo) {
   = name;
            this.dangerousTo = dangerousTo;
        public String toString() {
            return name;