Sunday, September 11, 2016

OBJECT-ORIENTED PROGRAMMING

Last month I finished The C# Player's Guide. My boss plopped it down on my desk one morning in July. "You'll have to get through this book before you'll start pair testing with the other automation engineers." Challenge accepted, hefe. In about a month I got through each short chapter and came out the other end with a heck of a lot of C# smarts. 

 The first half of the book has a C# syntax flow where everything makes sense and has a clear progression where the last subject builds on the next one. Then thing start getting crazy. What I was surprised from the book was how abstract the concepts were getting. The simple explanations of C# syntax such as variables, classes, methods, and loops gave way to subjects such as inheritance, method and class overloading, aggregation and composition, and interfaces. There was a clear tonal shift and I was having a difficult time imagining the situations I would use the concepts that I was learning without more context.

Part of my issue in reviewing these things is that at the time I though thy were specific to the C# syntax. Boy was I wrong. It turns out that half of this book was reviewing OBJECT ORIENTED PROGRAMMING PRINCIPLES. The examples they gave for each principle was written in C# but could have easily been written in VB.NET, Python, Ruby, C++, Objective-C, ect. Have you ever heard the notion that it's easy to pick up a new programming language after learning your first? It always blew my mind that developers claimed to be applying and accepting offers for positions that required them to write in a language they had no experience in. Now it is starting to click.

I'm kind of embarrassed to admit that I didn't truly understand what object oriented programming meant until a couple weeks ago. I've been familiar with the term for quite some time but I just kind of told myself I had a basic idea of what it means. Boy was I wrong again. 

OOP vs. FP

There are two major methods to programming - object-oriented and functional programming. My little experience has shown that the trend is strongly going in the direction of OOP. Major languages such as Ruby, Python, C++, Java, C#, VB.NET, Swift, Objective-C, are all OOP. Other languages that you may have heard of such as Haskell, Perl, Lisp, and Clojure are used in FP. 

Object-oriented programming is based on "objects" which work as data structures that hold data  in the form of "attributes" and perform actions through code known as "methods". The idea is that users use common parts of the program, however they often work various "instances" of these common parts. Each bank account, user profile, game save, and food order hold common functionality but different data. An object can be created and maintained for each particular situation the user requires. You can begin to see how this  dynamic form of programming can be powerful in the hands of developers.

Functional programming is a different animal but in the end strives to accomplish a lot of the same things as OOP. My understanding of FP at the moment is only what the internet tells me- I've never been hands on with it. Using FP is designing and building the structures and elements of the program by evaluating mathematical functions. FP typically avoids changing-state and mutable data. An example of mutable data is something that can be changed after it is created, such as a password for an online profile or a heart rate tracher on a smart watch. Many consider FP to be a much more procedural and cumbersome coding process.

My bias and lack of knowledge/experience are painfully present in this article. But isn't that beauty of starting out? You'll see me write plenty more about OOP as I continue learning how to make awesome shit with Python, C#, and soon Javascript. Six months from now I'll look back at this post and laugh and I wouldn't fault you for doing the same now.




No comments:

Post a Comment