Posts

Showing posts from February, 2019

Exceptional Exception Handlers

Image
As a budding developer, I quickly discovered that there's nothing quite as satisfying as debugging a frustrating error after hacking away at it for what seems to be an eternity. But sometimes error messages aren't very clear and it can make the debugging process especially difficult. Enter exception handlers ! Before we dive into just what an exception handler is and does, we need to take a look at a key question - what is an error and how are errors raised?  In Ruby, an error is an instance of the predefined class Exception  that is raised (or thrown) when something has gone wrong. By default, Ruby programs terminate when an exception occurs, unless you have an exception handler  - a block of code that is executed when an exception occurs. To handle exceptions, we can enclose the code that could throw an exception in a begin-end block and use one or more rescue clauses to tell Ruby the types of exceptions to handle. Note that the body of a method d

Drag and Drop It Like It's Hot

Image
The ability to drag and drop items and elements was first created by Jef Raskin, best known for starting the Macintosh project for Apple in the 1970's. Originally named the "click-and-drag" paradigm, drag and drop is a cornerstone of the user experience when interfacing with computers and smartphones. I recently discovered how to implement this fundamental aspect of designing and developing a program, using Atlassian's React Beautiful DnD Library . This library helps to simplify and more importantly, beautiful and naturalize the movement of items within an app. There are three main parts to keep in mind when designing a drag and drop feature: 1. The Draggable component, which is the item that will actually be dropped. 2. The Droppable component, which contains the Draggable components. 3. The DragDropContext component where the other components live. To test and see how to utilize the tools provided by the library in a project I'm working on, I went