Category: Best Practices

Different Strokes for Different Folks

In my search for new opportunities I have had a couple of interviews so far. The interesting thing has been the varying philosophies I have encountered with regard to development.  Things one firm swears by the other despises.  It has been an interesting exercise in trying to determine what these are and how to navigate the minefield without abandoning your own preferences. Here are just some of the differences I have encountered.

Source Control

First off, believe it or not, there are still quite a few shops that don’t use it.  Over 50% of companies I have talked with so far don’t use it!  To be fair, when I started my current position back in 2012, I had not used source control either.  So I had to quickly learn how to use Subversion (SVN).  Much to my boss’s chagrin, that learning curve was steep and deeply conflicted! But with time and discoveries like “bunny hopping” (for example merging Staging branch into your project branch first, then merging project branch into Staging) things got better.  Then when we decided to finally “Git” with the program things have really hummed along nicely.  I swear by Git for all my home projects. I have even tried to use Git to version my music compositions.

At least in most cases these businesses are saying they plan to move to source control soon.  But which one? Git or Subversion?  In my observation there is a feeling that Subversion is more in align with “corporate” and Git more in line with “startups”. I definitely don’t agree!  But again I am partial to Git so I may be biased.

Object Relational Mapping (ORM)

Watch where you step on this one!  Wow!  I have played with ORM and like it, but also recognize that it is not always appropriate, especially if your business model involves complicated queries.  Yet I assumed going in that you would not be considered a “modern” developer if you weren’t using it. In fact, many job postings include phrases like “MUST HAVE EXPERIENCE WITH OBJECT RELATIONAL MAPPING”.

So imagine my surprise when in one interview I was asked “What experience have you had with ORM and are you comfortable with it?”  and when I finished explaining that I had played around with it and found it to be easy and useful, the interviewer snapped passionately about how much they HATE it. Lesson learned. Need to feel out my audience on this one.

Those opposed to ORM I have generally found to be people who love SQL. I know that when you are sitting elbow deep in a query with 70 joins on 50 different tables it is hard to believe there are people who love it, but trust me there are!  I can see why  people who eat stored procedures for breakfast would hate to use ORM.  It would be like telling classic car nuts who love to cruise around, that they can only legally use Google self-driving cars from now on.

Stored Procedures and Inline SQL

One of my personal pet peeves is seeing a SQL statement written right into a ColdFusion page.  Call me crazy, but I think SQL belongs on the SQL server.  So I do my best to move all inline SQL I find into a stored procedure on the SQL box and just call the stored procedure from CF.  Some places I have met with say “Right Answer!” when I lay that out. Yet others have suggested that they don’t like stored procedures at all and only use them when a query is extremely complicated.  Many said they prefer to put their SQL directly into a  DAO (data access object).  I guess at least this puts it outside of a CFM page and into a CFC.  That is more tolerable to me, but still not my preferred way of working.  But at least on this topic there does not seem to be as much passion.

Frameworks

The biggest differences here are not what you would expect.  I haven’t encountered any heated battles over ColdBox vs. FW/1 vs. Mach II.  The opinions are over whether or not a framework is needed.   To me, if you are doing anything remotely complicated that answer is yes.  But to a certain extent I can see the other side of the argument.  In most cases, those companies I have talked to who don’t use frameworks, admit that they have kind of put one together on their own.  I suspect that is usually the case in instances where no formal one is used as it is just a natural extension of good programming.

Languages 

Since I am a ColdFusion developer most of the opportunities I have explored have been in that realm.  But even in those cases, some companies are looking to migrate away from it.  Here there is a definite split!  Some are leaning toward the wonderful world of PHP. Makes sense. It’s open source, borderline free depending on what you are using it for, and has good solid applications like Magento.

Other companies are leaning toward .Net and C#.  I imagine a lot of it comes down to the same argument had about source control.  .Net for “corporate” feel and PHP for “startups”.  Time will tell I guess.  But I also see me needing to learn both in the near future!

What else?

So what other arguments have you encountered out there in the wild?  What are your thoughts on each of these above.  Leave your comments below and let’s get the discussion rolling!

 

 

Public vs. Private Functions: When is it just redundancy?

A couple of years ago when I first delved into object-oriented programming I was reading a lot of different resources.  One spent a great deal of time describing “public” methods vs. “private” methods.  While I was a little confused at first, I quickly understood that “public” methods were ones that could be accessed from outside of the package (in my case, CFC), and that “private” methods weren’t visible to anything but other methods within the same package (and probably the NSA).  In other words…the actions that take place “behind closed doors”.

This same resource went on to emphasize that best practices dictate that your public methods should contain virtually none of your business logic. In fact, they recommended that your public methods be nothing more than pass-throughs that send the request information on to a similarly named private method.  For example, if your CFC has a method named “login” that is passed the username and password, the only thing that method will do is call a private method named “_login” (note the convention of prefacing private functions with an underscore), and pass it the username and password. Of course, if the private method returns a value the public method will capture the private method’s return value and echo it back to the original caller.

On the whole, this process makes sense to me and indeed is exactly how I have written my CFCs since.  But I am often finding that my CFCs seem to be twice as long as they should be. If I have four public methods, then I have at least four private methods.  And since I love to comment the heck out of everything, this can lead to long CFCs for fairly simple tasks.

So this has left me wondering what you as a developer do.  Is what I am doing “best practice” or is it just bloating my CFCs? Is there a better approach to this that offers the security of private methods without overloading the file with redundant comments and code? I would appreciate comments and suggestions.

As a side note, I have been wanting to employ this same model in the JS files I write. But I think I must be missing something. I can’t figure out how to make “private” methods in JS. Any insight on this would be great as well.

Still playing catch up….and still learning everyday….and loving every minute of it!

© 2018 Script Van Winkle

Theme by Anders NorenUp ↑