• Activity
  • Votes
  • Comments
  • New
  • All activity
    1. Meta Discussion: Is there interest in topics concerning code quality?

      I've posted a few lengthy topics here outside of programming challenges, and I've noticed that the ones that seem to have spurred the most interest and generated some discussion were ones that...

      I've posted a few lengthy topics here outside of programming challenges, and I've noticed that the ones that seem to have spurred the most interest and generated some discussion were ones that were directly related to code quality. To avoid falling for confirmation bias, though, I thought I would ask directly.

      Is there generally a greater interest in code quality discussions? If so, then what kind of things are you interested in seeing in those discussions? What do you prefer not to see? If not, then what kinds of programming-related discussions would you prefer to see more of? What about non-programming discussions?

      Also, is there any interest in an informal series of topics much like the programming challenges or the a layperson's introduction to... series (i.e. decentralized and available for anyone to participate whenever)? Personally, I'd be interested in seeing more on the subject from others!

      17 votes
    2. Posting old news

      I've tried using search (both by keyword and by tag) but I couldn't find anything about this. What's Tildes opinion about posting old news that haven't been discussed yet? I'm not talking about...

      I've tried using search (both by keyword and by tag) but I couldn't find anything about this. What's Tildes opinion about posting old news that haven't been discussed yet? I'm not talking about your regular news post from a newspaper that is already too late to be discussed about, I'm talking about things such as software releases or old blog posts that have never been posted but would be interesting to discuss about. How would one tag them? Where should we post them if allowed?

      Edit: I'm sorry but I won't be here for discussing this tomorrow or during the weekend. I'm not staying at home, but I hope I can come back to some good responses next week.

      9 votes
    3. ~music Listening Club 22 - Survival

      Welcome to week 22! Here we've got this week's user-voted record: Survival by Bob Marley & The Wailers! Taken from @koan's pitch: Does Bob Marley have gold and platinum records? Definitely....

      Welcome to week 22! Here we've got this week's user-voted record: Survival by Bob Marley & The Wailers!

      Taken from @koan's pitch:

      Does Bob Marley have gold and platinum records? Definitely. Survival is not one of them, but in my opinion it is by far his greatest album -- hands down, no competition. Everybody has an opinion about Bob Marley, whether you've actually given him a shot or not. Reggae can be polarizing. Some love it, some think it's corny. But Survival is not corny. It's Marley's greatest roots reggae record.

      While some Bob Marley songs might make you want to relax on a beach and sip cold cocktails, the songs on Survival make you want to get up and do something about shit. When I was absolutely stewing in dissatisfaction with my corporate job, listening to Survival on my commute in the morning inspired me to change my life. Be careful, because listening to it too much might turn you into a revolutionary.

      If you're unfamiliar with reggae in general, or you think it's silly, give this record a chance. It might change your perspective about a very deep and varied genre of music.

      Here's the place to discuss your thoughts on the record, your history with it or the artist, and basically talk about whatever you want to that goes along with Survival. Remember that this is intended to be a slow moving thing, feel free to take your time and comment at any point in the week!

      If you'd like to stream or buy the album, it can be found on most platforms here.

      7 votes
    4. Code Quality Tip: Wrapping external libraries.

      Preface Occasionally I feel the need to touch on the subject of code quality, particularly because of the importance of its impact on technical debt, especially as I continue to encounter the...

      Preface

      Occasionally I feel the need to touch on the subject of code quality, particularly because of the importance of its impact on technical debt, especially as I continue to encounter the effects of technical debt in my own work and do my best to manage it. It's a subject that is unfortunately not emphasized nearly enough in academia.


      Background

      As a refresher, technical debt is the long-term cost of the design decisions in your code. These costs can manifest in different ways, such as greater difficulty in understanding what your code is doing or making non-breaking changes to it. More generally, these costs manifest as additional time and resources being spent to make some kind of change.

      Sometimes these costs aren't things you think to consider. One such consideration is how difficult it might be to upgrade a specific technology in your stack. For example, what if you've built a back-end system that integrates with AWS and you suddenly need to upgrade your SDK? In a small project this might be easy, but what if you've built a system that you've been maintaining for years and it relies heavily on AWS integrations? If the method names, namespaces, argument orders, or anything else has changed between versions, then suddenly you'll need to update every single reference to an AWS-related tool in your code to reflect those changes. In larger software projects, this could be a daunting and incredibly expensive task, spanning potentially weeks or even months of work and testing.

      That is, unless you keep those references to a minimum.


      A Toy Example

      This is where "wrapping" your external libraries comes into play. The concept of "wrapping" basically means to create some other function or object that takes care of operating the functions or object methods that you really want to target. One example might look like this:

      <?php
      
      class ImportedClass {
          public function methodThatMightBecomeModified($arg1, $arg2) {
              // Do something.
          }
      }
      
      class ImportedClassWrapper {
          private $class_instance = null;
      
          private function getInstance() {
              if(is_null($this->class_instance)) {
                  $this->class_instance = new ImportedClass();
              }
      
              return $this->class_instance;
          }
      
          public function wrappedMethod($arg1, $arg2) {
              return $this->getInstance()->methodThatMightBecomeModified($arg1, $arg2);
          }
      }
      
      ?>
      

      Updating Tools Doesn't Have to Suck

      Imagine that our ImportedClass has some important new features that we need to make use of that are only available in the most recent version, and we're several versions behind. The problem, of course, is that there were a lot of changes that ended up being made between our current version and the new version. For example, ImportedClass is now called NewImportedClass. On top of that, methodThatMightBecomeModified is now called methodThatWasModified, and the argument order ended up getting switched around!

      Now imagine that we were directly calling new ImportedClass() in many different places in our code, as well as directly invoking methodThatMightBecomeModified:

      <?php
      
      $imported_class_instance = new ImportedClass();
      $imported_class_instance->methodThatMightBeModified($val1, $val2);
      
      ?>
      

      For every single instance in our code, we need to perform a replacement. There is a linear or--in terms of Big-O notation--a complexity of O(n) to make these replacements. If we assume that we only ever used this one method, and we used it 100 times, then there are 100 instances of new ImportClass() to update and another 100 instances of the method invocation, equaling 200 lines of code to change. Furthermore, we need to remember each of the replacements that need to be made and carefully avoid making any errors in the process. This is clearly non-ideal.

      Now imagine that we chose instead to use the wrapper object:

      <?php
      
      $imported_class_wrapper = new ImportedClassWrapper();
      $imported_class_wrapper->wrappedMethod($val1, $val2);
      
      ?>
      

      Our updates are now limited only to the wrapper class:

      <?php
      
      class ImportedClassWrapper {
          private $class_instance = null;
      
          private function getInstance() {
              if(is_null($this->class_instance)) {
                  $this->class_instance = new NewImportedClass();
              }
      
              return $this->class_instance;
          }
      
          public function wrappedMethod($arg1, $arg2) {
              return $this->getInstance()->methodThatWasModified($arg2, $arg1);
          }
      }
      
      ?>
      

      Rather than making changes to 200 lines of code, we've now made changes to only 2. What was once an O(n) complexity change has now turned into an O(1) complexity change to make this upgrade. Not bad for a few extra lines of code!


      A Practical Example

      Toy problems are all well and good, but how does this translate to reality?

      Well, I ran into such a problem myself once. Running MongoDB with PHP requires the use of an external driver, and this driver provides an object representing a MongoDB ObjectId. I needed to perform a migration from one hosting provider over to a new cloud hosting provider, with the application and database services, which were originally hosted on the same physical machine, hosted on separate servers. For security reasons, this required an upgrade to a newer version of MongoDB, which in turn required an upgrade to a newer version of the driver.

      This upgrade resulted in many of the calls to new MongoId() failing, because the old version of the driver would accept empty strings and other invalid ID strings and default to generating a new ObjectId, whereas the new version of the driver treated invalid ID strings as failing errors. And there were many, many cases where invalid strings were being passed into the constructor.

      Even after spending hours replacing the (literally) several dozen instances of the constructor calls, there were still some places in the code where invalid strings managed to get passed in. This made for a very costly upgrade.

      The bugs were easy to fix after the initial replacements, though. After wrapping new MongoId() inside of a wrapper function, a few additional conditional statements inside of the new function resolved the bugs without having to dig around the rest of the code base.


      Final Thoughts

      This is one of those lessons that you don't fully appreciate until you've experienced the technical debt of an unwrapped external library first-hand. Code quality is an active effort, but a worthwhile one. It requires you to be willing to throw away potentially hours or even days of work when you realize that something needs to change, because you're thinking about how to keep yourself from banging your head against a wall later down the line instead of thinking only about how to finish up your current task.

      "Work smarter, not harder" means putting in some hard work upfront to keep your technical debt under control.

      That's all for now, and remember: don't be fools, wrap your external tools.

      23 votes
    5. On YouTube and EU Article 13

      If you've been following tech news somewhat recently, you've surely heard about Article 13- the one where the EU essentially requires all content hosts to have extremely strict copyright checking...

      If you've been following tech news somewhat recently, you've surely heard about Article 13- the one where the EU essentially requires all content hosts to have extremely strict copyright checking tools and have automated takedown of any potentially copyrighted works.

      That got put on the backburner for a little bit, but now it's back with a vote being held in early 2019.

      YouTube, being one of, if not the largest content hosts in the world, is greatly affected by this motion. In fact, they have a whole website designed to encourage their creators to talk about A13 in their videos. The page very subtly hints at massive service changes that will happen in the EU if this actually ends up passing.

      The CEO of YouTube, Susan Wojcicki, has also written an op-ed for Financial times (linked to official YT blog since it's free there) about the issues facing YT if A13 passes.

      I haven't heard anything from official sources, but I've heard on the rumor mill that YouTube will completely suspend creators in the EU, not allowing them to upload any content, and potentially even removing their existing content from YouTube.

      What if this passes? YouTube is one of the biggest sources of free knowledge and entertainment we have today, and it's become engrained into the internet as it is today.

      With all this, I simply ask, "what's next?"

      9 votes
    6. What have you been listening to this week?

      Filling in again this week. What have you been listening to this week? You don't need to do a 6000 word review if you don't want to, but please write something! Feel free to give recs or discuss...

      Filling in again this week.

      What have you been listening to this week? You don't need to do a 6000 word review if you don't want to, but please write something!

      Feel free to give recs or discuss anything about each others' listening habits.

      You can make a chart if you use last.fm:

      http://www.tapmusic.net/lastfm/

      Remember that linking directly to your image will update with your future listening, make sure to reupload to somewhere like imgur if you'd like it to remain what you have at the time of posting.

      14 votes