Combating Impostor Syndrome

Impostor Syndrome, or feelings of self-doubt, is a common occurrence in just about every field and career. Software developers might experience it more frequently due to the constant and rapid changes in technology we are faced with, but we are not alone. Doctors, professors, attorneys, actors, authors, movie producers, and many, many more all at one time or another seem to suffer from self-doubt or Impostor Syndrome.

Tom Hanks has Impostor Syndrome?

Tom Hanks, for example, has had a rather impressive acting career by most standards. With movies like Apollo 13, Sleepless in Seattle, and Saving Private Ryan. Five Academy Award nominations with two wins, eight Golden Globe Award nominations with four wins, in fact, he has accumulated 17 major award wins in his career. Over a 50% “win” ratio. I’m not an expert on acting award ratios, but winning more often than losing has to be a good standard.

Certainly, someone who has the acting resume, awards, and career that Mr. Hanks has must not experience Impostor Syndrome and self-doubt, right? Here’s a recent quote of his:

“I still feel sometimes that I’d like to be as good as so-and-so actor. I see some other actors’ work, and I think I’ll never get there. I wish I could.” – Tom Hanks

Clearly, if Mr. Hanks has doubts about his acting abilities in comparison to others, we shouldn’t be shocked when we encounter feelings of being an impostor in our own roles.

Can you relate?

I would venture to guess that we have all had people we look up to in our jobs or industry. People that we believe have knowledge, experience, or talent that we will never be able to achieve. Remember back to when you were first starting out in your current career. I know, for some that is much more recent than others, but think back. Recall a time when you were watching your mentor fly through some project code or teach a difficult subject. Did you feel like “Wow, Trina is amazing! I’ll never be as good as her?” Or maybe you were struggling on a project and after hours of trying to figure out a solution Travis walks by, points out your mistake and just walks away shaking his head after spending seconds on the project?

Both scenarios start that feeling of self-doubt. That feeling of being an impostor in our chosen field. That feeling that someone is going to find out that we are frauds and should be doing something different.

Fighting a dragon

But how can we combat that feeling? How can we prevent it from taking over our thoughts and stifling our work flow and creativity?

I like to think of combating impostor syndrome in a metaphorical way of a knight fighting a dragon. Prior to going off to battle the dragon that is Impostor Syndrome we need to get our mental armor on. As with a suit of armor and tools that a knight would wear and use, we need to put on mental armor when we start on a new task or project to prevent our struggles with learning from overwhelming us. Things like a helmet, breast plate, leggings, boots, sword, and shield are all needed to fight our evil dragon.

Our Armor


I think of the helmet as protecting bad thoughts from entering and good thoughts from exiting my brain. We all have knowledge and skills to bring to the table, it is often a matter of being humble enough to admit that we do know things and restructure what we think others know.As we can see, we do know things about our tasks, and how to implement them. Keeping our thoughts protected can help us remember that.

Breast Plate

Our breast plate (which will for the sake of argument include arm and hand protection) I think of as protecting us from negative feedback. Let’s face it, not everyone is as nice or tolerant of others as we would like. Often when we are working with someone who we highly respect in our careers, they can do or say something that enhances our impostor feelings. “How long have you been staring at that code, Joe? Of course, it isn’t working, that line isn’t indented correctly. Duh!” Huge blow when that happens to us, right? Keeping a breast plate on us to allow those comments to not have as large of an impact is important to prevent the impostor dragon from causing overwhelming damage.


The leggings are important as well. Obviously without our legs walking, running, and moving about to engage in combat would be a challenge. To combat our dragon we need to engage in community, realize that we are not alone in feeling like an impostor. Everyone has something to contribute to a project, and to the battle to fight our dragon.


Boots, or in the language of armor sabatons, protect our feet, which we need to make steps along our journey. Keep a journal of the steps we take as we walk along our journey. Write down successes and, yes, failures. It provides retrospective insights about both conditions and revisiting them allows us to remember both equally as well.

The shield

Thus far everything has been something we would actually wear. A shield is something we carry with us, right? In this metaphor, a shield represents an idea to shield us. That idea is that knowing that no one is perfect. No one. There is no perfect actor, doctor, author, professors, and there certainly isn’t a perfect developer. Knowing that even the most seasoned developer on your team likely suffers from impostor syndrome from time to time as well will help shield you from your own thoughts of being an impostor and will help fight off that evil dragon.

Armor recap

These are the basics of our armor: a helmet to protect our thoughts, a breast plate to protect us from negative feedback, leggings to remember that we are not alone out there, boots as a reminder to keep a log of our journey, and a shield to protect against the idea that the perfect developer exists. Now we get to our weapon, the sword. Imagine going into battle against a dragon without an offense?

Our sword is used to represent knowledge. That is what ultimately will slay our dragon, right? When we feel confident in a certain task, we no longer feel like an impostor in that one area. Remember that even the most experienced people continue to fight and search for answers and gain knowledge in the process.

With our armor, shield, and sword set and ready to fight our dragon, we should likely have a battle plan. Fortunately, if we keep our protection in place it simplifies our battle quite considerably.

Wrapping it up

For new developers (and by “new” I am talking not only about new to the industry, but also new to a given subject or technology), remember that everyone in a development role is in a constant learning state. Find a good mentor as part of your game plan, it will help in sharpening your sword (knowledge) to fight our dragon.

If you are a seasoned developer, you can help in our battle plan as well. While you might not be struggling with writing a “Hello world” app in Java 7, remember that there are things to learn in Java 9 that might cause you to resharpen your sword. Use your experience to mentor junior developers and put yourself in their shoes. Remember what it was like to push your first repo to GitHub, to make your first pull request to an Open Source library, or your first venture into using a new Python library.

Let’s all try to keep our helmet, breast plate, leggings, boots, and shields in tact to protect ourselves during those times in which we are facing our dragon named Impostor Syndrome. And keep up on our learning and mentoring as well, to keep our sword sharp to battle and defeat the dragon.


MongoDB and Java CRUD operations

MongoDB has been out for quite a while now and with it’s 3.2 release out in Dec 2015 many of the online tutorials have become outdated as the syntax and language drivers have evolved. Let’s take a look at an introduction to the 3.2 MongoDB driver in Java. We’ll cover some real basic implementation but showcase the driver syntax and some basic MongoDB documents.

I am building this project using IntelliJ 15.0.2 and utilizing Maven for dependency management. The code is available on GitHub: here. You will want to add the following dependency to your Maven project:


We also will need a running MongoDB server. I will assume that you have MongoDB downloaded and installed on your local machine for the purposes of this tutorial. Our Java class will be accessing the MongoDB server on localhost, on the default port of 27017. It is also assumed that authentication for the MongoDB server is not implemented. For information on implementing access control on a MongoDB server, take a look here.

For this introductory walk-through, we are going to be doing everything inside of our main method in our Java class. In a later post we’ll see how the project can be refactored to create methods for doing our activities.

I want to show how to do a few important tasks with MongoDB. Namely,

  • Connect to a database
  • Insert individual documents into the database
  • Insert multiple documents into the database
  • Find and print documents from the database
  • Update a document.
  • Drop (delete) documents from the collection.
  • Show how to drop an entire collection.

Connect to a Database

We need to connect to specify the name of the database to use and, if the database does not exist, MongoDB creates it for us.

import com.mongodb.MongoClient;
import com.mongodb.MongoClientURI;
import com.mongodb.client.MongoDatabase;

public class MongoJava {

    public static void main(String[] args) {
        try {
            // Connect to MongoDB Server on localhost, port 27017 (default)
            final MongoClient mongoClient = new MongoClient(new MongoClientURI("mongodb://localhost:27017"));
            // Connect to Database "cartoon"
            final MongoDatabase database = mongoClient.getDatabase("cartoon");
            System.out.println("Successful database connection established. \n");

        } catch (Exception exception) {
            System.err.println(exception.getClass().getName() + ": " + exception.getMessage());

Awesome, assuming you have MongoDB up and running when we compile and run the code we will get the expected output of:

Successful database connection established.

Great! Now we need to put some data into our cartoon database. Let’s add a character to a characters collection. We do this by creating a BSON Document object, adding (appending) our data to that object, and then inserting it into the collection with the insertOne() method.

Java Crud Operations

Insert Individual Documents

We’ll create two new documents. One for information about Mickey Mouse and one for Charlie Brown.

Our import additions
import com.mongodb.ErrorCategory;
import com.mongodb.MongoWriteException;
import com.mongodb.client.MongoCollection;

import org.bson.Document;

Adding documents

            //Insert a document into the "characters" collection.
            MongoCollection collection = database.getCollection("characters");

            Document mickeyMouse = new Document();
            Document charlieBrown = new Document();

            mickeyMouse.append("_id", 1)
                    .append("characterName", "Mickey Mouse")
                    .append("creator", new Document("firstName", "Walt").append("lastName", "Disney"))
                    .append("pet", "Goofy");

            charlieBrown.append("_id", 2)
                    .append("characterName", "Charlie Brown")
                    .append("creator", new Document("firstName", "Charles").append("lastName", "Shultz"))
                    .append("pet", "Snoopy");

            try {
                System.out.println("Successfully inserted documents. \n");
            } catch (MongoWriteException mwe) {
                if (mwe.getError().getCategory().equals(ErrorCategory.DUPLICATE_KEY)) {
                    System.out.println("Document with that id already exists");

We should expect the following output:

Successful database connection established.

Successfully inserted documents.

I know what you’re thinking. Are they really in there? We can go to the Mongo Shell by running mongo cartoon from a command prompt we will open a Mongo Shell and be using the cartoon database. We know that our data is in the characters collection so if we do a find() on our collection, and pretty print it with db.characters.find().pretty() we will get back our two documents.

        "_id" : 1,
        "characterName" : "Mickey Mouse",
        "creator" : {
                "firstName" : "Walt",
                "lastName" : "Disney"
        "pet" : "Goofy"
        "_id" : 2,
        "characterName" : "Charlie Brown",
        "creator" : {
                "firstName" : "Charles",
                "lastName" : "Shultz"
        "pet" : "Snoopy"

Notice how we can have documents inside documents like the creator document. Pretty cool, eh? MongoDB allows for a rich schema design in which we can embed information inside other information. Pretty powerful.

Maintenance and Multiple Inserts

This next step we’re going to do a few things. Since we are inserting our documents with specific _id values, we can’t run it again and try to again insert Mickey Mouse into our collection as we’ll generate a Duplicate Key error. So, we’ll do a bit of maintenance at the beginning of our code to delete the current characters collection each time we run our program and yet keep the data in the database at the end.

Let’s get some output about our collection size and also generate multiple documents using the insertMany() method of the driver. We’ll start with inserting documents starting at an _id of 3 (since we already have a 1 and 2) and generate enough so we have 50 documents in our collection.

Our import additions
import java.util.ArrayList;
import java.util.List;

Multiple inserts

            // Delete the collection and start fresh - add before the initial inserts


            // Basic data on collection
            System.out.println("Collection size: " + collection.count() + " documents. \n");

            // Create and insert multiple documents
            List documents = new ArrayList();
            for (int i = 3; i < 51; i++) {
                documents.add(new Document ("_id", i)
                        .append("characterName", "")
                        .append("creator", "")
                        .append("pet", "")

            // Basic data on collection
            System.out.println("Collection size: " + collection.count() + " documents. \n");

Very nice. Now we get some output with data about our growing collection!

Successful database connection established.

Successfully inserted documents. 

Collection size: 2 documents. 

Collection size: 50 documents. 

Updating Documents

We should probably consider learning how to update a document as well. After all, we have 50 documents in the collection but only two of them have any useful data. We use the updateOne() method to update a single document along with the $set operator. We’ll print out the document with the _id of 3, update it, and print it out again to show the change. We can find our document to print using a eq Query Filter, or equals filter.

Our import additions
import com.mongodb.client.model.Filters;

Updates, find with filter

            // Update a document
            // print the third document before update.
            Document third = collection.find(Filters.eq("_id", 3)).first();

            collection.updateOne(new Document("_id", 3),
                    new Document("$set", new Document("characterName", "Dilbert")
                            .append("creator", new Document("firstName", "Scott").append("lastName", "Adams"))
                            .append("pet", "Dogbert"))

            System.out.println("\nUpdated third document:");
            Document dilbert = collection.find(Filters.eq("_id", 3)).first();

Nice work! Our output now is:

Successful database connection established.

Successfully inserted documents. 

Collection size: 2 documents. 

Collection size: 50 documents. 

Original third document:
{ "_id" : 3, "characterName" : "", "creator" : "", "pet" : "" }

Updated third document:
{ "_id" : 3, "characterName" : "Dilbert", "creator" : { "firstName" : "Scott", "lastName" : "Adams" }, "pet" : "Dogbert" }

Whew! Almost there. Let’s print out the entirety of our collection. We do this with a MongoCursor and iterate over all of the documents.

Our import additions
import com.mongodb.client.MongoCursor;

Find all with cursor

            // Find and print ALL documents in the collection
            System.out.println("Print the documents.");

            MongoCursor cursor = collection.find().iterator();
            try {
                while (cursor.hasNext()) {

            } finally {

With all of the new output, and most of it empty, perhaps we should clean up our collection a bit. We currently have 50 documents in there, but only three of them have any pertinent data. Let’s get rid of all documents that don’t have data using the deleteMany() function. We’re going to need another filter here to delete documents whose _id is greater than or equal to 4. Fortunately there is a built in filter, gte that will do just that!

Our final code for this tutorial then is available here as a gist.

            //Delete data
            System.out.println("\nDelete documents with an id greater than or equal to 4.");
            collection.deleteMany(Filters.gte("_id", 4));

            // Find and print ALL documents in the collection
            System.out.println("\nPrint all documents.");

            MongoCursor cursor2 = collection.find().iterator();
            try {
                while (cursor2.hasNext()) {

            } finally {

As we would expect, our collection is now left with only three documents, one each for Mickey Mouse, Charlie Brown, and Dilbert. Our final code for this tutorial then is available here as a gist.


We have learned quite a bit. We have seen how to connect to an active MongoDB server, create new documents, update documents, find documents in our collection, and delete documents. In the database world that is called CRUD, which is an acronym for Create, Read, Update, Delete. Pretty great.

Happy coding!