K. Sabbak

Code Princess

More like 'Oops' am I right?

May 25, 2018

I just spent a good chunk of my time in the world of Clojure learning functional programming. It was hard (and fun) and I expected it to be hard (and hoped it would be fun). Now I'm working on learning Java and back in the world of object oriented programming and while I expected Java to be hard and not fun (so far I'm right), what I didn't expect is... what's OOP?

I swear I spent the first week of Java trying to figure out how to test things again. Not because I needed to learn JUnit, but because... how do you test in OOP again? I refactored a class the other day because I realized that I was passing things around that I didn't need to. It was already something the object knew about itself. It's so weird. I figured there'd be some ramp-up. Any time I try to jump back into Ruby I need a little time to fully get back into the swing of it, but this feels a lot more like I felt when I started trying to write FP than it does returning to a language that's been gathering a bit of dust.

This method for example:

      private String pullElement(int elementPosition){
        String[] components = text.split(" ");
        return components[elementPosition];
    }

Was sitting around in my code with text being passed in for some reason and I didn't notice it. For a week. Maybe because it wasn't being called outside the class, so I didn't have to type this. in front of it or explicitly call an instance so it wasn't like, so apparent I was passing around a property I had access to without doing that. I guess. I'm making excuses.

I think this is teaching me that I didn't know OOP as well as I thought I did. Or that it's really easy to forget things when you immerse yourself in a new world. To fix the first possible problem, I'm just going to keep learning - nothing new there. To fix the second possible problem, I'm trying to come up with a side project I can tinker with in Clojure or maybe pick up Elixir. What I learned about FP is still very defined in my mind, but I don't need to have a week of style jet-lag every time I switch contexts.

Plus, I hardly have a comprehensive knowledge FP (or Clojure), so that's a side benefit for sure.

Tags: object-oriented-programming functional-programming