Tag: tips

FAQ: Starting Your Career in Software Development Pt2

Applying for Software Development Jobs

How do I stand out on an application?

I think this is largely going to depend on where you’re applying. Something to consider is that especially with large tech companies, they’re getting thousands and thousands of resumes all the time. It can be really competitive to be able to even land an interview so sometimes if the caliber of other applicants is high, it can make it difficult to stand out.

That’s okay. We don’t have control over others, but we do have control over ourselves! We can try a few different things to stand out and help you get started on your software development journey professionally. The following are things I personally would suggest and may not reflect the exact views of my employers (past, present, or future) and may not reflect those exact views of recruiters/screeners at other companies. There’s my disclaimer!

  • Understand what the minimum requirements are and exceed them when you can. It’ll be hard initially, especially when job positions ask for a minimum amount of time as a professional. If you checked out this post and you had several internships, you’re actually already on your way to listing out necessary work experience! If you couldn’t land internships, or this is your first internship you might not have that luxury (and that’s okay!). Do the job description list other skills or experiences that are required? Can you get examples of that on your resume? Remember, if there’s many other candidates, it’s easy for screeners to filter out applications that don’t seem to meet the minimum requirements (even if you’re totally awesome!) just because there’s so much volume for them to get through.
  • Side projects are your best friend. Think about it though. If 1000 people apply for a job and all have similar work and school experience, how would you stand out? Well, if you’ve been working on some cool stuff outside of work and demonstrating that you have a genuine interest in different areas of software development, that could be huge! Are you going to be working with SQL in your new role? Maybe mention that cool tinder-for-restaurants app you made. Oh, that also demonstrates you know some cross-platform development tools. Awesome! What about that fun web app you made? AND you can put a link to it for them to try out? That could be a huge win if it’s a smaller org that has time to dig a bit deeper on applicants.

    For me, side projects are one of the most important pieces to consider. I get it though. Not everyone has time or the interest to work on stuff outside of their 9-5. And I’m not suggesting this is a requirement or the only way to land a job. I just think this is one of the best and easiest ways to stand out because it shows passion for creating, learning, and interest in your field on top of your work experience (that may or may not look like a majority of other applicants).
  • Your school grades matter… Until they don’t. I don’t want to give people the wrong advice here, so I’ll try to be clear. Especially during internships and at companies that get a lot of applications, grades are likely going to be a factor. It’s just another super easy way for a company to set the bar high and filter out a large amount of applicant volume. I don’t necessarily feel it’s the best way to filter candidates, but I also don’t blame companies for doing this if there’s overwhelming volume. If two people have identical applications but one received a 5% higher average in all of their courses, if you only have time to interview one you’ll likely pick the one with the higher average. Again, I’m not suggesting this implies the other candidate is not worthy or this will always net a company the best employees, I’m just saying that they need to filter down candidates and it’s an easy way to do it.

    With that said, my personal opinion is that I don’t care about grades. Not much, anyway. For interns, I’d probably expect someone to do well in their programming courses, but if your calculus and physics marks were super low I really don’t care. Not unless I’m hiring you to do physics and calculus. But generally (and I hope this comment ages well!) I’m not. I’m hiring you to be a productive member of an awesome software development team.

    Once it comes time for full-time employment I don’t really care about grades at all. I want to know about interesting experiences that are relatable to what you’re applying for. This will give me fuel for engaging interview questions as well, which is our next question!

What types of interview questions should I expect?

I’ll just throw out another reminder here that this is fully my own opinion and not necessarily the opinion of my past, current or future employers. When I’m interviewing people for software development positions, there’s certainly a minimum expectation I have with respect to programming abilities. It might not be what is popularized on the Internet though.

First off, I need evidence that you have actually programmed before. Ideally this is done in a pre-screen (online, over the phone, etc…) before I’m sitting down with you for a lengthy hour (or more) long interview. I have sat in interviews with people that have claimed multiple years of professional programming experience but could not answer FizzBuzz. What’s not make-or-break for me is your knowledge in a specific programming language. Sure, if you’re an expert in the language(s) we’re using heavily in our stack that’s great for ramp up time. However, I feel that great programmers can learn other languages and be effective with them, and I’m seeking great programmers.

Next, I want to see you problem solve. I’m not impressed by you being able to answer an algorithm-based question immediately or jumping right to coding up a heavily optimized solution perfectly the first time around. Why? I’ve known people to memorize these sorts of things. Sure, the pool of questions to pick from feels infinitely large but it certainly does happen where someone lucks out on an interview and they see a question they know an optimized answer for. My interview directly out of university was actually exactly like this, where I was asked one single question and I knew the optimized answer for it in detail (which I disclosed to the interviewers). But as an interviewer, I have no interest in picking candidates based on their memorization abilities. I want you to explain your thought process. I like adjusting the question on the fly with different constraints and have you explain why you might change your design or approach. Why? Because in the real world of software development this kind of thing happens all the time. What doesn’t happen all the time are really contrived theoretical algorithm questions popping up regularly. And just to wrap up thoughts on this point, there are absolutely real situations where applying knowledge and understanding from these algorithm questions is critical, but I don’t feel memorized solutions to these help in the real world.

If you plan on working in big tech companies, especially ones with services running in the cloud, you’ll probably be asked system design questions. I won’t write much here because my thoughts on this are essentially the same as the previous paragraph. Don’t memorize. Understand, explain trade-offs, be able to work through different constraints in your systems! There are plenty of sites online that offer examples to go through, and great examples on YouTube, so I’d just take the time to go learn and understand (not memorize).

Finally, I love seeing how people work together on teams. This is something I’m trying to understand throughout the entire interview process. I want to make sure you’re collaborative and that you’ll work well with others. In the real world of software development, you’re almost always working with others. Being the most amazing programmer but not being collaborative doesn’t work well in any environment that I’ve worked in over the last 10+ years.

How do I stand out in an interview?

If you’ve nailed down the stuff in the previous points, you’re probably doing great. But beyond that, I want to see and hear about your cool work experiences. I want to hear how you problem solved and developed creative solutions. Tell me your favorite project. Explain how you learned from one of your failed projects and what you’d do differently going forward. Tell me more details about how you work well with others, even when there were difficulties between team members. Tell me about unique challenges you worked through with your team and how you contributed to the success.

I love seeing people get pumped up about their hobby projects they work on outside of work. It helps to demonstrate that you’re constantly learning, challenging yourself, and that you’re passionate about software. As I said towards the start of this post, I understand that not everyone has time for this kind of thing so it’s not a make-or-break item on an interview. But we’re talking about standing out, and for me, this is something that becomes memorable.

Should I reach out to (hiring) managers directly?

This can largely depend on the organization and how they approach hiring. So my suggestion here is hopefully a good-enough general approach to answer this.

First off, I think you should start by going through the normal HR/recruiting channels that a company has to offer. Get into the system. Get your application/resume in and get queued up so that the right processes can get underway. If you’re already interested in the job, I think this is your first starting point. When people reach out to me and ask about hiring, this is exactly where my mind goes.

Next, if you’re reaching out to managers, I think there’s some do’s and don’ts to consider.

  • DON’T assume that every manager on LinkedIn is currently hiring or directly involved in the hiring process. The conversation generally won’t go too much further if you’re asking person for a job and they’re not in a position to be hiring. Chances are they’ll recommend you do what I suggested above and go through normal recruitment channels.
  • DO reach out with a specific posted position if you think it’s relevant or know it’s specific to their team. Structure your conversation around expressing interest in this role and ask your clarifying questions about it.
  • DON’T ask for referrals if you’ve never worked with the person. I personally don’t know why people expect this to be successful. If I’m recommending someone, it’s my name going along with that referral. Instead of asking for a referral, consider asking if they’re aware of other roles or information about where you can find additional posted roles.
  • DO be personable and respectful. Express interest in the area this manager is hiring for (after you’ve confirmed your assumptions, right?) and ask about the best way to get visibility for applying. If they suggest the best way is truly going through the HR/recruitment pipeline, being more pressing beyond this likely won’t be beneficial. Some managers do more hiring directly and other times this is largely through these other channels.
  • DON’T reach out with expectations that by doing so you will guarantee that you’ll be considered for a role or that the manager has an obligation to set you up for this. This goes back to being respectful. Generally people will try to help if they can, but it’s unfair to set expectations that they’ll drop what they’re doing to help you get a position.

This series of FAQ posts was actually inspired by an individual reaching out with some very specific questions that I could answer. Many of these were asked by others over time, but this individual was polite, patient, and concise in what he wanted information on. There were no demands of me or expectations I’d secure him a job. I think his approach was spot on.


FAQ: Starting Your Career in Software Development Pt1

Navigating Post Secondary Education for Software Development

Do you have any advice regarding university applications?

For university, it’s been so long since I’ve had to go through applications that I’m not sure I have really specific advice. I think it’s important to know what schools have for prerequisites and really ensure you nail those down. In terms of which school to pick, that’s certainly a personal choice. You’ll have so many factors to consider including cost, what programs are offered, relocation, proximity to loved ones, etc…

As a hiring manager, personally, I am less concerned with WHERE someone went to school versus what they could showcase about what they have learned. I’d also personally suggest checking out schools that offer internships since it’s an excellent way to get real experience! This is something that worked really well for me since I didn’t really enjoy classes but my co-op positions proved to me that I was in the right line of work.

Software engineering or computer science?

Great question! I opted for computer engineering. Couple of things to touch on here including the “computer” part meant both electrical and software as a blend. I loved to program but I wanted to learn about hardware. Once I learned about hardware, I realized I wanted nothing to do with it ūüôā

The engineering vs science part… My understanding is that if you want to pursue being a licensed professional engineer, you must go to a school with an accredited engineering program. For me, this is something that I wanted personally. Funny enough, in software, it doesn’t seem to be too common that folks go for their P.Eng. As a result, it makes it harder for someone like me to work under a P.Eng to get that experience.

How do you navigate scholarships?

I’m not sure I received much of anything for scholarships/grants when I was going for school, but if I could go back in time I would kick my own butt… DO THIS. If you can get free money to fund your education, do it. Do the research. Write the essays. Invest time into this because it will pay off by subsidizing your school. You’ll be so thankful you did it later.

If someone would potentially pay me to write an essay now, I’d do it even 9+ years after graduating from university. You bet I would ūüôā I don’t think I could motivate myself at the time, but if you’re reading this then please do better at this than I did!

Any general tips for going into college/university?

Beyond what’s already been mentioned, I think that’s mostly it. Take it seriously to make sure you can meet the requirements of the schools you want to go to. It’s easier said than done, because I can remember I just wanted to be a kid, be with my friends, play video games, etc… But it’s a huge step in your life. Take it seriously.

People used to make fun of me for getting high grades in high school. It’s natural to want to fit in so it would be embarrassing to do well on tests. It would make me want to slack off. But remember, you need to put in the work to get in. And once you’re in, you need to KEEP working to stay in.

Another critical point is that you need to take the time to understand how you learn. I went from getting 95+ in all my courses to barely passing things. And a pass was more than just getting 50% for my average to be in an honors program, so it went from being a super laid back approach to feeling pretty scary. For me personally, I learned nothing in my lectures. I’d sleep half the time. So I stopped going into class (aside from tutorials and labs) and would force myself to do work at home. This doesn’t work for everyone, but it was critical for me to not be wasting my time sleeping in lecture halls. This took me a long time to realize. I also had to teach myself how to study effectively. I had to learn to take mini breaks. You learn a lot about yourself, but I think you need to have some awareness that your high school learning might look VERY different than post-secondary learning.

Once you have a good understanding of how you can learn and study, you’ll be on the right track.

What are your thoughts on internships?

Do them if you can. I can’t stress this enough. I disliked almost all aspects of my time in school (like the IN class part!) but my internships saved me. They were a constant reminder that as long as I finished I’d be doing what I loved.

If your school allows for different placements, take advantage of this. I had 6 internships at the University of Waterloo. I did a repeat of my first job, a repeat of my second job, and then tried two different companies after that. I gravitated towards startups, but I also tried working in a larger company as well. Get. Diverse. Experience. Learn about all the different fields you can get into. Software is such a cool industry because… It’s in every industry!

Another benefit to internships is potentially securing a position for right out of school. Cool huh? If you’re really liking where your internships take you, then why not take advantage of companies looking to take you on full time right out of school? Many companies are happy to invest in you, especially if you’re going to be sticking with them after you graduate!


Timeboxing: TODO List 2.0!

I recently wrote about TODO lists and how they can help with focus now that many of us are working from home. I had a former colleague on LinkedIn mention this concept of “timeboxing” (which I think many people are familiar with the general idea) and how that can improve the effectiveness of a TODO list.

Here’s the post I made on LinkedIn sharing my blog article:

And the comment that came in right away from Graeme Harvey:

Graeme Harvey - Timeboxing

This obviously got me thinking because sure, Elon Musk is a pretty smart dude, but I also have a lot of respect for Graeme and his perspective on things. So I decided I’d try something out!

TODO Lists v1.0

My original TODO lists didn’t factor in any timeboxing techniques, but they had some benefits. The engineering mind in me says this is a great opportunity to do a little bit of a pros & cons analysis, so if you didn’t think I was nerdy before… Buckle up!

Pros:

  • Generally written out in the order I want (or need) to get things done. Acts a bit like a schedule in that regard.
  • Can have big and small items on the list.
  • Making progress on small items can help build momentum.
  • Let’s me record all the things I want (or need) to get done in the day and track if I did that or not

Cons:

  • No concept of how many things are too many or too few for an entire day’s worth of activity… There’s no timeboxing!
  • No concept of relative time spent on things (If I wrote “eat breakfast” and “Write a novel”, do they each get equal amount of time?)

TODO Lists v1.1

Okay we’re not quite yet at version 2.0 for these, but I took some of the concepts Graeme was referring to and I’ve implemented them every day since he made the comment. I’ve been trying to gauge how things have been going in terms of productivity and I’m already impressed. In fact, writing this blog post is part of my TODO list with timeboxing constraints (so meta, right?).

So the changes I made were very subtle but I’ll list them below:

  • I dropped the concept of putting in order what has to get done. Much of what I’m working on right now doesn’t have true dependencies, so trying to come up with an order for things doesn’t make sense (right now).
  • Every item I write down I put a time estimate on in minutes or hours. Literally everything. Remember I said little things like “Eat breakfast” can still be a TODO item that can help you feel like there’s momentum? Right. Breakfast, 10 minutes. Lunch, 15 minutes. Everything gets a time!
  • I tally up the total time my TODO list should take with timeboxing and do a gut check. I’m at least awake for 16 hours (typically people sleep like 8 hours, right?), but it’s probably closer to 18 hours. Because I’m starting off and don’t have great estimates, I’m ensuring I’m around the 12 hour mark for filling up my day.
  • I’m purposefully leaving some wiggle room in my schedule so that I can try incrementally building this out to be more accurate.

Nothing groundbreaking to implement, but what have I noticed so far?

  • Having a (relatively) small list of things I need to get done and getting to pick the next thing I want to tackle is kind of nice. A bit of flexibility is great!
  • The timeboxing really helps me make sure I’m focused on what I set out to do. 1 hour to review interview questions? Better not scroll on Instagram. 30 minutes to research a topic? Better not be on YouTube.
  • Some estimates for things are way off and some are very accurate! That’s okay though, because the following day I can adjust my estimates accordingly.
  • The overall feeling of being productive and making progress, for me at least, is even higher than it was before.

I’ve really enjoyed this small tweak and I’m hoping to get this to v2.0 status really soon ūüôā Thanks Graeme!


TODO Lists: Keeping focused when you feel lost

TODO List - Photo by Tirachard Kumtanom from Pexels

It’s more relevant for more people now than it probably has been in other times in their professional careers, but COVID-19 means remote work for a lot of people. It also means no work for a lot of people too. I’ve found that a simple tool for me to keep focused is leveraging a TODO list. It’s so simple that I think people often overlook the power of a TODO list when you’re feeling like you’re a bit lost or not making progress.

With your TODO list, the first thing I’d suggest is thinking about a daily routine. Now that you’re working remote, or in the unfortunate case out of work, I think it’s really important that you keep some sort of daily routine to help give you some guard rails. Think about what things you usually do in the morning. What does your lunch look like? How about the later afternoon and into the evening? What does before bed look like? Thinking through your routine will give you an idea of the things you want to focus on and then give you an idea of how much time you’ll need for regular things and how much time you’ll have remaining for stuff that can pop up.

The next thing I’d suggest with your TODO list is to get granular. This is especially important in my opinion if you’re struggling to feel like you’re making progress on anything. You can even write things down like “brush your teeth”. It doesn’t have to be specific to work and it doesn’t have to be anything groundbreaking. You’ll find that as you start making progress by checking off small items that suddenly you’re accomplishing a lot and a day might have gone from feeling like nothing getting done to fulfilling, or from insurmountable to progress being made! The small steps you can take while working through your TODO list are a great way to remind yourself that you’re making progress.

It’s also a good opportunity to remind yourself that these are very strange times for many of us. If you’re working from home or at home and out of work, these could be very new circumstances for you and not at all like your normal routine. That’s okay! Remember the rest of the world is in this together with you.

You should be affording yourself the time to do little things here and there around the house even if you’re working remotely. For example, if you hear your washer/dryer go off in the middle of the day, instead of letting that be something that’s nagging you in the back of your mind consciously go make the time to take a few minute break and change loads of laundry! There are plenty of unique distractions to be had while working from home, but instead of letting them distract you take control and consciously spend the time on the appropriate things.

A sample TODO list might look like the following:

  • AM
    • Get the dog outside!
    • Feed the dog
    • Eat breakfast
    • Hygiene routine
    • Coffee + read news
    • Answer emails
    • Work on Project A
    • Video meeting 1
    • Continue Project A
  • Afternoon
    • Eat lunch
    • Get the dog outside!
    • Do the dishes
    • Answer emails
    • Video meeting 2
    • Work on Project B
    • Get work schedule planned for tomorrow
  • Evening
    • Eat dinner
    • Get the dog outside!
    • Get some exercise!
    • Hygiene routine
    • Pick-a-chore around the house
    • Watch TV/Movie or play a game
  • Before Bed
    • Hygiene routine
    • Read your current book
    • Write out your TODO list for tomorrow

You might have read through that and thought that it feels silly to have a line item for something as simple as brushing your teeth or eating a meal. And that’s totally normal for some people! You might have adapted really well to your change of environment and you’ve got little to no issues adjusting. For others, that won’t be the case. If you’re struggling to feel like you’re making progress, staying on track, or if that the day seems like you’ll never accomplish everything you need to… Take the little wins with very simple things. You’ll notice that you’ll build momentum for yourself.

A friendly reminder to make sure you take the time to get your TODO list together before the next day! I like doing it right before bed so I can run through what I think my following day will look like.


Autofac Modules and Code Organization

Organizing Code With Autofac Modules

What are Autofac Modules?

I’ve been writing a little bit about Autofac and why it’s rad, but today I want to talk about Autofac modules. In my previous post on this, I talk about one of drawbacks to the constructor dependency pattern is that at some point in your application, generally in the entry point, you get allllll of this spaghetti code that is the setup for your code base.

Essentially, we’ve balanced having nice clean testable classes with having a really messy spot in the code. But it’s only ONE spot and the rest of your code is nice. So it’s a decent trade off. But we can do better than that, can’t we?

Autofac modules!

We can use Autofac modules to organize some of the code that we have in our entry point into logical groupings. So an Autofac module is an implementation of a class that registers types to our dependency container to be resolved at a later time. You could do this all in one big module, but like many things in programming, having some giant monolothic thing that does ALLLL the work usually isn’t the best.

An Example of Converting to Autofac Modules

Let’s create a simple application as an example. I’ll describe it in words, and then I’ll toss up some code to show a simple representation if it. We’ll assume we’re using dependencies passed as interfaces via constructors as one of our best practices, which makes this conversion much easier!

So our app will have a main window with a main content area and a header area. These will be represented by three objects. Our application will also have a logger instance that we pass around so classes that need logging abilities can take an ILogger in their constructor. But our logger will have some simple configuration that we need to do before we use it.

Let’s assume to start our Program.cs file looks like this:

internal sealed class Program
{
    private static void Main(string[] args)
    {
        var logger = new FileLogger();
        logger.LogLevel = LogLevel.Debug;
        logger.FilePath = "log.txt";

        var header = new FancyHeader(logger);
        var content = BoringMainContent();
        var window = new MainWindow(header, content);
        window.Show();
    }
}

Before getting comfortable with Autofac, my initial first step would be to logically group things in the main method. In this particular case, we have something simple and surprise… it’s all grouped. But my next step would usually be to pull these things out into their own methods. I do this because it helps me identify if my groupings make sense and where my dependencies are. Let’s try it!

internal sealed class Program
{
    private static void Main(string[] args)
    {
        var logger = InitializeLogging();
        var window = InitializeGui(logger);
        window.Show();
    }

    // no params passed in, so no dependencies
    // return value is an ILogger, so we have a
    // logical grouping that will provide us a logger
    private static ILogger InitializeLogging()
    {
        var logger = new FileLogger();
        logger.LogLevel = LogLevel.Debug;
        logger.FilePath = "log.txt";
        return logger;
    }

    // only parameter is a logger, so that's our dependency
    // return value is a window, so this grouping provides
    // a window for us
    private IWindow InitializeGui(ILogger logger)
    {
        var header = new FancyHeader(logger);
        var content = BoringMainContent();
        var window = new MainWindow(header, content);
        return window;
    }
}

Alright cool. So yes, this is a bit of extra code compared to the initial example, but I promise you grouping these things out into separate methods as a starting point when you have a LOT of initialization logic will help a ton. Once they are in methods, you can pull them out into their own classes. Refactoring 101 for single responsibility principle going on here ūüėČ BUT, we’re interested in Autofac. So what’s the next step?

We have two logical groupings going on here in our example. One is logging and the other is for the GUI. So we can actually go ahead and make two Autofac modules that do this work for us.

public sealed class LoggingModule : Module
{
    protected override void Load(ContainerBuilder builder)
    {
        builder
            .RegisterType<FileLogger>()
            .AsImplementedInterfaces() // FileLogger will be resolved as an ILogger
            .SingleInstance() // we only ever need to use one logger instance for our app
            .OnActivated(x =>
            {
                // this handles our extra setup we had for this object
                x.Instance.LogLevel = LogLevel.Debug;
                x.Instance.FilePath = "log.txt";
            });
    }
}

public sealed class GuiModule : Module
{
    protected override void Load(ContainerBuilder builder)
    {
        builder
            .RegisterType<FancyHeader>() // this has a dependency on ILogger, but autofac will figure it out for us
            .AsImplementedInterfaces() // FancyHeader will be resolved as IHeader
            .SingleInstance(); // we only ever need to use one instance for our app
        builder
            .RegisterType<BoringMainContent>()
            .AsImplementedInterfaces() // BoringMainContent will be resolved as IContent
            .SingleInstance(); // we only ever need to use one instance for our app
        builder
            .RegisterType<MainWindow>() // Autofac will resolve our IHeader and IContent dependencies for us
            .AsImplementedInterfaces() // MainWindow will be resolved as IWindow
            .SingleInstance(); // we only ever need to use one instance for our app
    }
}

And those are our two logical groupings for modules! So, how do we use this and what does our Main() method look like now? I’ll demonstrate with one way that works for a couple modules, but I want to follow up with another post that talks about dynamically loading modules. If you can imagine this scenario blown out across MANY modules, you’ll understand why it might be helpful.

The idea for our Main() method is that we just want to resolve the one main dependency manually and let Autofac do the rest. So in this case, it’s our MainWindow.

private static void Main(string[] args)
{
    // create an autofac container builder
    var containerBuilder = new ContainerBuilder();

    // manually register our two new modules we made
    containerBuilder.RegisterModule<LoggingModule>();
    containerBuilder.RegisterModule<GuiModule >();

    // create the dependency container
    var container = containerBuilder.Build();

    // resolve and use our main dependency by it's interface
    // (because we shouldn't care what the implementation is...
    // that was up to the configuration via modules!)
    var window = container.Resolve<IWindow>();
    window.Show();
}

In Summary…

This example showed us how to group your main initialization logic out into groups that would play nice as Autofac modules. In a really simple example, having modules might look like bloated extra code, but it already illustrated that your entry point is very simple and follows a pattern to extend (just register another module for more dependencies… and I’ll add more on this later). There’s also an obvious way to group more new logic into your application for dependencies! So discussed logging and GUI initialization, but you could extend this to:

  • User Settings
  • Analytics/Telemetry
  • Error Reporting
  • Database Configuration
  • Etc… Just add more modules!

Sometimes the pain of having a really hectic entry point isn’t realized until you’ve had to work on teams where people are modifying the same beast of an entry point all the time:

  • Simple merge conflicts in your “using” statements… Because there’s hundreds of lines of using statements at the top of the file
  • Visual studio actually CANNOT use intellisense properly when the file gets too unwieldly
  • The debugger cannot resolve variables properly when the main entry point gets too big
  • Merging and auto-conflict resolution sometimes results in code just getting blown away in the entry point… And good luck finding what went wrong in your thousands of lines of initilization

So what’s next? Well, if you keep building out your app you might notice you have tons of modules now. Your single GUI module might have to get broken out into modules for certain parts of the GUI, for example, just to keep them more manageable. Maybe you want plugins to extend the application dynamically, which is really powerful! Our method for registering modules just isn’t really extensible at that point, but it’s very explicit. I’ll be sharing some information about automatic Autofac module discovery and registration next!


What Makes Good Code? – Should Every Class Have An Interface? Pt 1

What Makes Good Code? - Should Every Class Have An Interface?

What’s An Interface?

I mentioned in the first post of this series that I’ll likely be referring to C# in most of these posts. I think the concept of an interface in C# extends to other languages–sometimes by a different name–so the discussion here may still be applicable. Some examples in C++, Java,¬†and Python to get you going for comparisons.

From MSDN:

An interface contains definitions for a group of related functionalities that a class or a struct can implement.
By using interfaces, you can, for example, include behavior from multiple sources in a class. That capability is important in C# because the language doesn’t support multiple inheritance of classes. In addition, you must use an interface if you want to simulate inheritance for structs, because they can’t actually inherit from another struct or class.

It’s also important to note that an interface¬†decouples the definition of something from its implementation. Decoupled code is, in general, something that programmers are always after. If we refer back to the¬†points I defined for what makes good code (again, in my opinion), we can see how interfaces should help with that.

  • Extensibility: Referring to interfaces in code instead of concrete classes allows a developer to swap out the implementation easier (i.e. extend support for different data providers in your data layer). They provide a specification to be met should a developer want to extend the code base with new concrete implementations.
  • Maintainability:¬†Interfaces make refactoring an easier job (when the interface signature doesn’t have to change). A developer can get the flexibility of modifying the implementation that already exists or creating a new one provided that it meets the interface.
  • Testability: Referring to interfaces in code instead of concrete classes allows mocking frameworks to leverage mocked objects so that true unit tests are easier to write.
  • Readability: I’m neutral on this. I don’t think interfaces are overly helpful for making code more readable, but I don’t think they inherently make code harder to read.

I’m only trying to focus on¬†some of the pro’s here, and we’ll use this sub-series to explore if these hold true across the board. So… should¬†every class have a backing¬†interface?

An Example

Let’s walk through a little example. In this example, we’ll look at an object that “does stuff”, but it requires something that can do a string lookup to “do stuff” with. We’ll look at how using an interface can make this type of code extensible!

First, here is our interface that we’ll use for looking up strings:

[csharp]
public interface IStringLookup
{
string GetString(string name);
}
[/csharp]

And here is our first implementation of something that can lookup strings for us. It’ll just lookup an XML node and pull a value from it. (How it actually does this stuff isn’t really important for the example, which is why I’m glossing over it):

[csharp]
public sealed class XmlStringLookup : IStringLookup
{
private readonly XmlDocument _xmlDocument;

public XmlStringLookup(XmlDocument xmlDocument)
{
_xmlDocument = xmlDocument;
}

public string GetString(string name)
{
return _xmlDocument
.GetElementsByTagName(name)
.Cast<XmlElement>()
.First()
.Value;
}
}

[/csharp]

This will be used to plug into the rest of the code:

[csharp]
private static int Main(string[] args)
{
    var obj = CreateObj();
    var stringLookup = CreateStringLookup();
    
    obj.DoStuff(stringLookup);

    return 0;
}

private static IMyObject CreateObj()
{
    return new MyObject();
}

private static IStringLookup CreateStringLookup()
{
    return new XmlStringLookup(new XmlDocument());
}

public interface IMyObject
{
    void DoStuff(IStringLookup stringLookup);
}

public class MyObject : IMyObject
{
    public void DoStuff(IStringLookup stringLookup)
    {
        var theFancyString = stringLookup.GetString("FancyString");
        
        // TODO: do stuff with this string
    }
}

[/csharp]

In the code snippet above, you’ll see our Main() method creating an instance of “MyObject” which is the thing that’s going to “DoStuff” with our XML string lookup. The important thing to note is that the DoStuff method takes in the interface IStringLookup that our XML class implements.

Now, XML string lookups are great, but let’s show why interfaces make this code extensible. Let’s swap out an XML lookup for an overly simplified CSV string lookup! Here’s the implementation:

[csharp]
public sealed class CsvStringLookup : IStringLookup
{
    private readonly StreamReader _reader;

    public CsvStringLookup(StreamReader reader)
    {
        _reader = reader;
    }

    public string GetString(string name)
    {
        string line;
        while ((line = _reader.ReadLine()) != null)
        {
¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†var¬†split¬†=¬†line.Split(‘,’);
            if (split[0] != name)
            {
                continue;
            }

            return split[1];
        }

        throw new InvalidOperationException("Not found.");
    }
}
[/csharp]

Now to leverage this class, we only need to modify ONE line of code from the original posting! Just modify CreateStringLookup() to be:

[csharp]
private static IStringLookup CreateStringLookup()
{
    return new CsvStringLookup(new StreamReader(File.OpenRead(@"pathtosomefile.txt")));
}
[/csharp]

And voila! We’ve been able to extend our code to use a COMPLETELY different implementation of a string lookup with relatively no code change. You could make the argument that if you needed to modify the implementation for a buggy class that as long as you were adhering to the interface, you wouldn’t need to modify much surrounding code (just like this example). This would be a point towards improved maintainability in code.

“But wait!” you shout, “I could have done the EXACT same thing with an abstract class instead of the IStringLookup interface you big dummy! Interfaces are garbage!”

And you wouldn’t be wrong about the abstract class part! It’s totally true that IStringLookup could instead have been an abstract class like StringLookupBase (or something…) and¬†the benefits would still apply! That’s a really interesting point, so let’s keep that in mind as we continue on through out this whole series. The little lesson here? It’s not the interface that gives us this bonus, it’s the API boundary and level of abstraction we introduced (something that does string lookups). Both an interface and abstract class happen to help us a lot here.

Continue to Part 2


Staying Productive

Staying Productive

Background

I wrote a post a long while back about how I started to use Google Keep to get myself organized. Google Keep has been a go-to app for me on my phone for a long time now. I love using it to make lists of things, and I find it much more convenient than a paper notebook.

Don’t get me wrong–I think a paper notebook still has plenty of uses! I love my notebook for long running meetings with open-ended discussions or brain storming sessions. It’s great to be able to take a pen/pencil and doodle down any idea that comes to mind. When I’m having a free-form conversation, I need a free-form way to take notes.

However, my phone is something I almost always have with me–and my paper notebook isn’t. My phone allows me to take my Google Keep notes and email them to myself. It allows me to have a reminder right on my homescreen every time I unlock my phone. It’s just more convenient.

But something happened since the last time I wrote about using Google Keep. I use it more and more, and at some point I felt like I was getting less and less done. This is less about in the office and more about how productive I feel at home. So how can I be getting less done (or at least feeling that way) if I’m taking my own advice and using Google Keep to hack my TODO list?

I have tons of lists and no actions.

I think that’s the big take away. I list all the things I’m thinking about, and I keep making more lists. There’s no time frame around actioning things with the lists I’m making! So, in the spirit of continuous improvement, I set out to make some changes.

Inspiration

I know I wanted to make some changes with this part of my life because it was starting to weigh down on me; I didn’t feel productive. But I knew this wasn’t going to be something I’d answer over night. I kept my eyes and ears open for ideas for a little while before I thought up some tweaks.

The first thing I came across while living my alter ego was an Instagram post by Big J. Big J is this¬†guy that’s incredibly big and incredibly strong. He’s lived the bodybuilding life and has a lot to show for it… And because being successful in the bodybuilding and strength world means being extremely motivated and hardworking, it’s no surprise I picked up this little bit from Big J:

Simple idea, right? Put some time into planning your schedule for the upcoming days. It almost seems to obvious to not be doing. I mean, don’t I do this already? I have meeting invites and stuff in my calendar for work… But, that’s right! I don’t have anything in my calendar for my own personal things that I like to do outside of work. Hmmm…

The next little tip to push me along was after a conversation with a teammate of mine at work. Our conversation was mostly about work-life balance, but my colleague was telling me about something he was trying out around forming habits. Essentially, over a period of time he’s been recording his success at keeping on top of good habits and identifying reasons why he’s sometimes missing them. Definitely right up the continuous improvement alley! Another great point he brought up was that good habits need to be introduced one at a time and only once you’ve been consistent with your other habits. By adding too much at once, you can derail the whole good habit process.

The “Staying Productive” Hack

This is the hack I’ve been implementing for a bit over a week now, and it’s helped tremendously with feeling productive!

Every night when I’m laying in bed, I spend about 5-15 minutes with my phone and I schedule personal activities in my calendar for the following day.

There it is. It’s not rocket science or something Earth shattering, but it’s definitely helping. Taking a page out of Big J’s book and a tip from my colleague, I’ve modified my schedule to introduce a very brief planning period every day. And it’s just one change that I think is helping introduce a good habit into my life.

This has helped me:

  • Stay on top of prepping food (which is a big part of the lifestyle I try to live)
  • Schedule time to relax (yes, I even schedule time for things like video games!)
  • Schedule time to blog (I run three blogs, and sometimes finding time to write feels like a chore)
  • Work on personal projects
  • … Feel like I’m being productive.

And no, I didn’t drop Google Keep–It actually helps feed into my scheduling! It’s great to look over my lists of things and try to create actions for them.

Next Steps

This simple hack¬†is not only nothing particularly fancy, it’s also not bullet proof! But that’s okay when you’re always trying to continuously improve. Some snags I’ve run into or things I’ve thought about are:

  • How do I¬†adjust my planned schedule when unexpected things come up? If someone drops in for a visit out of nowhere, or my car breaks down, or my dog decides to tear up the furniture, how do I make sure I can continue on with my planned schedule? Right now some things drop off the schedule or I push other things off to compensate. This hasn’t been too big of a problem so far, but sometimes this has a bit of a landslide effect and it makes the rest of the day feel unproductive. A little bit of dirt in the cogs seems to throw the whole thing off for me! This is something I’ll be thinking about as I encounter it and I’ll try to thing of some easy solutions.
  • How can I be more like Big J?! Aside from being bigger and stronger, how can I plan for more days? Big J plans every Sunday but I plan every night for the next day. Is there a happy medium? Planning every Sunday would potentially amplify the landslide effect I previously mentioned, but it would be a convenient single planning session for the whole week. Perhaps I’ll continue with the advice of my colleague and modify one part of my new habit at a time and look at planning for an extra day at a time and see how that goes!

If you’ve been making checklists and find that you’re unable to action items, try this approach! It takes only a few minutes every day, and so far I’ve been having great success in feeling productive. It’s not difficult, so it’s worth a try!


One on One Evolution

Background

I’m a “middle manager” where I work, but that means a whole bunch of things. My everyday tasks primarily consist of programming, but I do a bunch of work to interface with other departments and teams, and I play a role in managing people on… well, the “people” side of things. For the latter part, I refer to that as people leadership.

I think it’s pretty easy to look at some of the aspects of people leadership and dismiss them as “fluffy” or needless… I consider myself a logical/technical thinker, so I have that frame of mind¬†sometimes. However, I do see the value in¬†actually being able to support my¬†team so that they can operate at the best of their abilities. I try to find ways to do that without it seeming to them like I’m doing “fluffy leadership things”, and in turn, I don’t feel that way about it either. With that in mind, I had previously set out with ways to accommodate team feedback in a way that works best for them.

One on Ones: The Early Days

I worked with my HR manager a couple of years back to establish a one on one template that I could use with the developers on my team. The goal was to be able to identify points of conversation since the last time we met, the individual’s current situation (both positive and concerns), and then identify goals. Ideally, the individual is able to fill this out on the form in as much detail as necessary for us to be able to have a conversation about it later.

I didn’t want this to seem like a chore for people so I’ve tried to identify why this is useful for the individual and for myself. For the individual, it gives them an avenue to discuss anything that’s becoming a problem over the period of a few weeks (i.e. something not obvious all at once) or be able to identify successes in their work. It also allows them to reflect on their goals that they want to set in their career, current projects, or even things outside of work (because¬†improving your abilities outside of work is a good thing too). For me, it provides¬†better insight into the¬†trend of problems people are experiencing, their contributions to their current projects, and even helps me see where people are at with their career goals. Both parties are able to benefit from these!

I’ve left it open in the past as to how people submit them. Written? Sure. Digital? Sure. Whatever is easiest for the individual provided I can get it a couple of¬†days before we meet. I’ve also left it open ended as to how much of the form they fill in. Based on the trends, I think people see value in having more content but sometimes the goal setting is a bit of a grey area. People might be between setting different goals and want to wait to discuss those things. The best part is, I don’t need to hassle the team to fill in more… They just do a great job of providing information for me!

One on Ones: Continuous Improvement

I’m all for continuous improvement in our development¬†processes that we have as well as our management processes. With that said, we’ve made a few tweaks to the one on ones recently that I think have had a great positive impact.

  • Digitized: I’ve got everyone on board with digitizing their one on ones. This is incredibly handy for being able to search for content later on (instead of sifting through paper), so I get a huge benefit from it. Each individual can probably benefit from this too if their ever looking for things we discussed. Archiving digital documents¬†has so many benefits over the paper counterparts that it’s hard to imagine going back to these mostly being paper-based. I can easily print off copies for the individual if they lose them (or if I lose them) and it makes life easier for me at year end. I can quickly scan over documents on my computer to get a good overview of a person’s year right on my laptop.
  • Nick’s Notes: A little tweak to the one on one process is that with the digital copies, I can put in highlighted notes. This allows me to get down my feedback to the individuals before we meet. In the past, I requested documents a couple of days before we meet so I can try to action what I can ahead of time. However, adding my notes and getting it back to the individual before we meet let’s them know things I want to dive deeper on. It gives them an opportunity to prepare their thoughts, and from what I’ve heard, this is really beneficial for them. The other positive thing is that it let’s me provide them kudos on certain things that I don’t necessarily need to spend a lot of time talking about them with one on one. It’s improved the efficiency of our meetings, and I think it benefits both sides.

What’s Next?

I’ll be honest in that I don’t have any next steps planned for these one on ones. But that’s okay! I’m going to let a few more rounds of these go through before I try to tweak the process. This let’s me get a feel for how the changes are playing out and then from there I can see where I might need to make some improvements.

If you don’t have a semi-structured system in place for your one on ones, I highly recommend it! Make it something you can at least get a feel for how successful they are. If you can gauge their effectiveness, then you can try to tweak the process over time to improve¬†it! You’ll benefit from the information, and your team will benefit from you providing support for them.


Code Smells ‚Äď Issue Number 2

Code Smells (Image from http://www.sxc.hu/)

Code Smells

Welcome to the second edition of Code Smells! Periodically I’ll be posting about how to detect code smells and what they mean in terms of the big picture of your code. The previous installment can be found right here.

What’s a code smell? Wikipedia says it perfectly:

In¬†computer programming,¬†code smell¬†is any¬†symptom¬†in the¬†source code¬†of a¬†program¬†that possibly indicates a deeper problem. Code smells are usually not¬†bugs‚ÄĒthey are not technically incorrect and don’t currently prevent the program from functioning. Instead, they indicate weaknesses in design that may be slowing down development or increasing the risk of bugs or failures in the future.

Onto the code smells!

The Stink List

Code Smell #4: (Thanks to reddit user fkaginstrom) You have an large number of parameters being passed in to your function call. Functions that take in a ton of parameters stink for a few reasons. How many is too many though? This is a topic that people have debated all over The Internet. This Stack Overflow answer even quotes an author saying to never have more than three parameters in a function. In my opinion? There’s no fixed number. It’s going to vary from situation to situation, project to project, class to class, and method to method. Putting a fixed number on it is sort of setting up a rule to be broken.

What can you do to avoid this kind of smell? This C#-based Stack Overflow thread has a bunch of great ideas. One simple solution is just to bundle things into logical groupings of data. An example (although, it’s potentially a poor example since it’s only two parameters) is x and y coordinates. You can bundle these into a custom point type and pass this into functions. Now a function that may have taken four pairs of coordinates is reduced from eight parameters down to four. This approach also introduces the dependency on your custom type for your function, but I’m just offering it up as an option. If you’re always passing around the same group of X pieces of data around, it may make sense to bundle them into a single container type.

A side effect of reducing the number of parameters your functions require is readability. It might seem minimal, but having functions with only a handful of parameters keeps them from becoming¬†unwieldy and much easier to understand when scanning through code. Readability is sometimes overlooked by developers, but when you’re in a team (and most developers work in teams), it goes a long way.

Code Smell #5: (Thanks to¬†reddit¬†user¬†fkaginstrom) Your class has a large number of methods. If we keep the Single Responsibility Principle in mind (which states that a class should have one reason to change), it’s a warning sign that we might be creeping in on violating it. How? If more and more methods keep getting added, more responsibilities/capabilities can sneak in. This MSDN blog article also highlights some examples of the Single Responsibility Principle. Essentially, as the methods within your class grow in numbers, your class becomes responsible for more types of things. If you later on want to use ¬†just one of those things in a different context, you’re now required to use one big heavy-weight type. Of course, this heavy-weight type comes with it’s own bundle of dependencies, setup requirements, and so on.

How do you avoid this? You can start by refactoring your monstrous type into multiple types. If your type has 12 methods that it defines, and they fall under three general categories of functionality, consider making three interfaces to group the functionality. Then you might consider adding three classes that stay true to these interfaces. The MSDN article I mentioned before does a good job of explaining  how this kind o approach works.

Code Smell #6: Your single method has grown to hundreds of lines. This is one code smell I find that newer programmers introduce more frequently than experienced programmers. However, when you’re working on an enormous code-base, sometimes this type of thing sneaks right up on you. So what’s the problem with having one method do a ton of things? It’s a convenience, isn’t it? let’s say someone only has to call one method that can launch a rocket, play golf, and invest in the stock market while filming a block-buster movie. That’s power and ease of use, no?

This related to Code Smell #5, in my opinion. The convenience of being able to call a method that does all sorts of fancy things at once is the exact inverse of the problem you face when you want to test the method. If I just want to test that I can successfully start the burners in the rocket, I have no choice but to call the method that does everything. What makes this problem even worse is that once your code has been structured this way, breaking down big methods into smaller methods can prove to be a challenge. When you see how dependencies are passed down the call hierarchy, or where certain classes have knowledge of others, things become scary.

I’ll give one real life example of something I saw recently in a particular code base. A test had to be written to cover a problematic area of code that had been refactored. There needed to be some sort of verification in code that proved this section was behaving as expected under particular conditions. Great stuff. Except the section of code existed inside of a method that did the following:

  • UI interaction
  • Database read
  • Data processing
  • File read
  • Data processing 2
  • Database write
  • External disk operation* (This one was pretty specific to the project I’m describing, but it wasn’t just a simple file read/write)
  • File write
  • UI interaction

Where the highlighted “Data processing 2” is the section of the method that needed testing. How’s that for fun? In order to test this one section properly it required refactoring of all of the encompassing code so that we could test it as a unit.

Have your own code smells? Share them in the comments. Follow Dev Leader on social media outlets to see code smell updates as they come out!

Nick Cosentino – LinkedIn
Nick Cosentino – Twitter
Dev Leader – Facebook
Dev Leader – Google+


Code Smells – Issue Number 1

Code Smells (Image from http://www.sxc.hu/)

Background

I thought this might be kind of fun (fun can also be read as “upsetting”), so I’m giving it a shot. It’s pretty frequent as programmers we go back and revisit some code and find ourselves shaking our heads at what we see. These code smells often don’t show their faces when they’re being created, so don’t beat yourself (or anyone else) up just yet. Common signs you’ve stumbled upon a code smell are when you find yourself saying:

How could that co-op have possibly coded this?! Blast those interns!

Or

What the heck was John thinking when he put this together?! Does he not have a brain?!

Or

No wonder we find so many bugs in this part of code! Look what Jane did!

But it never truly hits home until you get one of these:

What is this crap?! This is by far the worst code I have ever seen. How cou–Oh. Wait. I did that.

Code is always a work in progress. If it’s not, it’s because you’re writing a one off script or your code doesn’t do much of anything. Our skills as programmers are always transforming as are our perspectives. You’re guaranteed to have one of these moments if you’re programming long enough and look back on your code that was once The Pinnacle of Awesome.

With that said, I’m hoping to share some code smells that come up as I see them in my own projects or when talking with friends/colleagues. You might be about to type up one of these code smells, so pay attention! I don’t know how frequently I’ll put one of these posts together, but I might as well start now. Every time I get a handful of code smells I’ll try to push something out to The Interwebz.

The Stink List

Code Smell #1: Your variable is named or prefixed with “temp”, “tmp”, or some variation of “temporary”. This is unnecessary. If you have a variable, by definition it’s something that’s temporary. Nothing in code lasts for forever. You’re just lengthening a variable name or not putting enough thought into a good name.

Code Smell #2: Your variable is one character long. The exception to this is probably for simple loops. You almost always see code that is iterating over a counting variable “i”. Maybe that’s not so bad. If you nest three loops and you have for i, j, and k, things can get messy. If you find you’re using single character names outside of loops… STOP. Just name your variable something that won’t be a puzzle for someone one day from now.

Code Smell #3: You prefix things as “New”, “First”, “Last”, or some other definitive/completely ambiguous position. If you have something that’s “Newest” now and then tomorrow a new one is made, you now have to go change all of your code that used “Newest”, because it’s not the newest now. Same with something like “old” or “new”. It’s the “old” one now, but what happens when your “new” one becomes old because of a third generation? Now you have two olds and a new. What the heck are you going to do? Pick a good name from the start.

Have your own code smells? Share them in the comments. Follow Dev Leader on social media outlets to see code smell updates as they come out!

Nick Cosentino – LinkedIn
Nick Cosentino – Twitter
Dev Leader – Facebook
Dev Leader – Google+


  • Copyright © 1996-2010 Dev Leader. All rights reserved.
    Jarrah theme by Templates Next | Powered by WordPress