{"id":13231,"date":"2016-07-27T00:00:00","date_gmt":"2016-07-27T05:00:00","guid":{"rendered":"https:\/\/centricconsulting.com\/post\/miami-advanced-coding-software\/"},"modified":"2021-12-15T00:13:10","modified_gmt":"2021-12-15T05:13:10","slug":"miami-advanced-coding-software","status":"publish","type":"post","link":"https:\/\/centricconsulting.com\/blog\/miami-advanced-coding-software\/","title":{"rendered":"Dive Deeper into the Fundamentals of Coding Software"},"content":{"rendered":"

Resist the temptation to quickly find answers to coding software questions and instead invest the time in keeping those fundamentals sharp!<\/h2>\n

Right now, you\u2019re probably shaking your head thinking, \u201cI don\u2019t ever need to know the complexity of merge sort for the kind of code I write.\u201d That\u2019s certainly true for the vast majority of developers but really misses the point.<\/p>\n

Put it all in Perspective<\/h2>\n

Legend has it that Bill Gates once said, \u201c640K ought to be enough for anybody\u201d when speaking about the memory limitations of the IBM PC. Gates has always denied that he said it. But it is convenient to attribute the quote to him.<\/p>\n

Clearly, 640K of memory was not enough for everybody and memory in modern computers is now measured in Gigabytes instead of Kilobytes, a million-fold increase. I claim that this increase in memory and CPU speed has allowed developers to become lazy and forgo writing efficient code.<\/p>\n

You might respond with, \u201cWho cares if my code has a two nested for loops and declares a new array within the inner loop, the compiler will optimize it!\u201d<\/p>\n

To which I would reply, that\u2019s still lazy and some developers might not even realize that there is even a problem with writing such sub-optimal code, further eroding the fundamental grounds on which computer science was built.<\/p>\n

I won\u2019t bore you with all the details of loop unrolling and memory optimization. You know this. Instead, I created a list of things that I pulled from my old university textbooks that help reinforce fundamentals in the code I write.<\/p>\n

Here\u2019s the Primer<\/h2>\n

The table below \u2013 which can be found in \u201cCracking the Coding Interview\u201d by Gayle Laakmann \u2013 provides a quick reference for topics worth reviewing if it\u2019s been a while since you have cracked open a computer science textbook.\"Primer<\/p>\n

Some Examples<\/h2>\n

My street cred would be severely diminished if I didn\u2019t provide examples of bad fundamentals and their good counterparts. Below are some of the most common I see in my travels.<\/p>\n

The code is written in C; however, many of the concepts also apply to Java, C#, and other modern programming languages. These examples are trivial in nature, but the mistakes are surprisingly not uncommon.<\/p>\n

Loop Unrolling<\/h3>\n

<\/p>\n

Memory Leaks<\/h3>\n
<\/pre>\n

\"Memory<\/h2>\n

Let\u2019s Dive Deeper<\/h2>\n

Granted, the examples above are a bit trivial and don\u2019t represent most of the problems a seasoned developer faces on a daily basic. So let\u2019s explore some tougher issues.<\/p>\n

Java String vs. StringBuilder<\/h3>\n

This one always surprises when I find it in code, since StringBuilder (or StringBuffer) is a pretty basic concept for Java developers.\u00a0 Yet some developers either don\u2019t know about it or have forgotten how expensive String copying can be.\u00a0 The underlying concept here is that String is immutable; whereas, StringBuilder is mutable.\"JavaString<\/p>\n

Iteration vs. Recursion<\/h3>\n

For me, recursion is like an incantation from a wizard: clever, mysterious, and occasionally dangerous.\u00a0 In the right situation, recursion turns ugly code into simple perfection.\u00a0 At other times, recursion is wasteful and serves no purpose.\u00a0 And once in a while, recursion can melt your app and result in the dreaded \u201cstack overflow\u201d when your code gets stuck and can\u2019t escape from itself.\u00a0 The key concept here is to know when to use it, and more importantly, when NOT to use it.\"Iteration<\/p>\n

Hashtable (or Hashmap)<\/h3>\n

Much like recursion, a hashtable is a clever way to solve SOME problems; but not all.\u00a0 Hashtables work well when your data map easily onto a small, finite set of array indices.\u00a0 The hashing function is also key to a good behaving (read efficient) hashtable.\u00a0 If your data is made up of key-value-pairs (KVPs), then you should probably look into using a hashtable.\"Hashtable<\/p>\n

Back to the Basics<\/h2>\n

If you actually cracked open one of your old university textbooks, bravo! You will not be disappointed and this will pay dividends in your everyday coding efforts.<\/p>\n

Here are some books that I keep handy when I\u2019m looking for inspiration:<\/p>\n

    \n
  • The Art of Computer Programming, 1: Fundamental Algorithms \u2013 Donald Knuth<\/li>\n
  • The Art of Computer Programming, 3: Sorting and Searching \u2013 Donald Knuth<\/li>\n
  • Introduction to Algorithms (CLRS) \u2013 Thomas Cormen, Charles Leiserson, Ronald Rivest, and Clifford Stein<\/li>\n<\/ul>\n

    But the best homage you can pay to this blog is to remind your fellow developers about fundamentals and why they still matter. And remember: think INSIDE the box before venturing outside!
    \n<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"

    Resist the temptation to quickly find answers to coding software questions and instead invest the time in keeping those fundamentals sharp!<\/p>\n","protected":false},"author":63,"featured_media":15555,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_oasis_is_in_workflow":0,"_oasis_original":0,"_oasis_task_priority":"","_relevanssi_hide_post":"","_relevanssi_hide_content":"","_relevanssi_pin_for_all":"","_relevanssi_pin_keywords":"","_relevanssi_unpin_keywords":"","_relevanssi_related_keywords":"","_relevanssi_related_include_ids":"","_relevanssi_related_exclude_ids":"","_relevanssi_related_no_append":"","_relevanssi_related_not_related":"","_relevanssi_related_posts":"","_relevanssi_noindex_reason":"","footnotes":""},"categories":[1],"tags":[16613],"coauthors":[15012],"acf":[],"publishpress_future_action":{"enabled":false,"date":"2024-07-21 23:27:28","action":"change-status","newStatus":"draft","terms":[],"taxonomy":"category"},"_links":{"self":[{"href":"https:\/\/centricconsulting.com\/wp-json\/wp\/v2\/posts\/13231"}],"collection":[{"href":"https:\/\/centricconsulting.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/centricconsulting.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/centricconsulting.com\/wp-json\/wp\/v2\/users\/63"}],"replies":[{"embeddable":true,"href":"https:\/\/centricconsulting.com\/wp-json\/wp\/v2\/comments?post=13231"}],"version-history":[{"count":0,"href":"https:\/\/centricconsulting.com\/wp-json\/wp\/v2\/posts\/13231\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/centricconsulting.com\/wp-json\/wp\/v2\/media\/15555"}],"wp:attachment":[{"href":"https:\/\/centricconsulting.com\/wp-json\/wp\/v2\/media?parent=13231"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/centricconsulting.com\/wp-json\/wp\/v2\/categories?post=13231"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/centricconsulting.com\/wp-json\/wp\/v2\/tags?post=13231"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/centricconsulting.com\/wp-json\/wp\/v2\/coauthors?post=13231"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}