Translate

Showing posts with label design. Show all posts
Showing posts with label design. Show all posts

Tuesday, May 12, 2015

Why You Should Avoid Dynamic Array Keys

Be extremely careful when assigning array keys dynamically, as you can get data overwrites if two items happen to have the same dynamically assigned value.

While this should probably go without saying, I found myself in this situation recently. I spent a good half hour scratching my head, trying to figure out why the value was correct, but the name was completely wrong. Finally, I realized that two items shared the same value, so the first was being overwritten. I felt I should document the problem on here so that other developers may hopefully keep it in mind when developing dynamic arrays.


Take for example the following array in PHP:

$list = array(
  $item1 => 'Breakfast',
  $item2 => 'Lunch',
  $item3 => 'Dinner'
);


All is good assuming you eat different things for each meal. For example, if you have the following variables:

$item1 = "Cereal";
$item2 = "Salad";
$item3 = "Steak";

Your array will look as such:


array (size=3)
  'Cereal' => string 'Breakfast' (length=9)
  'Salad' => string 'Lunch' (length=5)
  'Steak' => string 'Dinner' (length=6)


But what happens if you are on a budget that month, and have cereal for dinner, too?

$item1 = "Cereal";
$item2 = "Salad";
$item3 = "Cereal";


You end up with:


array (size=2)
  'Cereal' => string 'Dinner' (length=6)
  'Salad' => string 'Lunch' (length=5)


Uh oh. That's no good. 


It's really best to not use dynamic keys, as much as possible. This array can easily be changed to the following without causing any significant changes in the way your code would need to access it.

$list = array(
  'Breakfast' => $item1,
  'Lunch' => $item2,
  'Dinner' => $item3
);

Monday, April 28, 2014

Podcasts

I have been tuning in to a lot of podcasts as of late in order to aggregate a better knowledge about what is going on in the web development and design community. In my travels, I have run across a collections of excellent podcast series. In fact, my two favorites are The Web Ahead hosted by Jen Simmons, The Changelog hosted by Adam Stacoviak, and Up Up Down Down hosted by Allen Pike and Nigel Brooke. They have guests on weekly, and spend about an hour discussing a particular topic in in detail. The Web Ahead and The Changelog focus exclusively on web development, and open-source libraries and projects respectively, while Up Up Down Down focuses on video game trends as well as some other more technical aspects of the industry.

You can check them out on their web sites, or subscribe to them on iTunes in order to receive updates when new episodes come out. They also have individual RSS Feeds which will alert you when there is a new episode. Coincidentally, The Web Ahead and The Changelog are actually hosted on the same site, which is 5by5, They have a ton of other podcasts, but I have not checked the other ones out yet.

These podcasts have a plethora of relevant and interesting information, which I find to be not only entertaining but highly informative. For example, in Episode 67 of The Web Ahead, Jen invited Doug Schepers onto the show to discuss SVG, which I'm sure many of us in the web development/design field have heard of, but not necessarily looked into for one reason or another. After hearing Doug, who has been working with SVG for a decade or more, talk about it so passionately, and in such great detail, I am highly tempted to implement it into one of my personal side-projects in the very near future.

The Changelog is fascinating in it's own right, because although The Web Ahead focuses on free web technologies, the The Changelog sets its sights entirely on the open-source side of things, where users can contribute to the project on GitHub in many cases. Open-Source software of all types has always been an intriguing topic for me, so I find myself tuning into this podcast regularly.

Up Up Down Down is hosted by game developers who are currently working in the industry. They have a guest on, and all debate a topic together. For example, I recently listened to Episode 8, in which they invite Ken Wong, one of the designers of  the new Monument Valley, which is available on the Apple App Store. They discussed and debated the ways in which video games can or can not be considered art, and attempted to define how one thing can be considered art while another is not. Although I am not personally involved in the video game industry, I feel as though the host Allen Pike summed it up perfectly in one of their earlier episodes when he expressed his opinion that even people who do not work on video games can enjoy the show if they have any interest in programming in general.

There are a couple of other excellent podcasts, which I have tuned into for an episode or two and plan on going back to. I feel that one I should mention is CodePen Radio hosted by the founders of Codepen.io, Chris Coyier, Alex Vazquez, and Tim Sabat. I have only listened to one episode from these folks, however, I found it extremely entertaining and am going to download the rest of their episodes to listen to soon.

I would love to hear from anyone who may be reading this to find out what kind of podcasts you listen to. And if you don't listen to podcasts, what sort of content do you subscribe to in order to stay in the loop? For example, weekly shows, screencasts, YouTube channels, etc.

As always, feel free to comment about anything that may be on your mind after having read this. Even if you didn't read a word of this, and you just want to plug your favorite podcast, I would love to hear from you.

Sunday, April 6, 2014

Mobile First Design vs Desktop Design

Mobile design has been a hotly debated subject for the last couple years, and finally, I feel as though we have come to a point where making our desktop sites more mobile friendly isn't the daunting and confusing task it once was. In fact, most sites that I personally end up on have some sort of mobile optimization. Be it the removal of processor-heavy objects or the reorganization of content to accommodate for the smaller screen real-estate. We have come to the point where redesigning your site for mobile is kind of a piece of cake. Just make your site as you always have, then use CSS media queries to remove the features that would bother mobile users. Right?

However, I was shocked to find a study by PhoCusWright Inc., which investigated the statistics of how users react to slow loading times on mobile adapted sites. All of that content which is loaded for desktop versions of your site, and then hidden away on mobile versions may slow your site's loading time down to the point where your users will go elsewhere. A quote from Akamai.com stated:

  • Three second rule - 57 percent of online shoppers will wait three seconds or less before abandoning the site
  • Younger travelers are less patient – Generation Y and younger travelers are less patient than older travelers when it comes to page load times. 65 percent of 18-24 year olds expect a site to load in two seconds or less
  • Prevention is key - A third of travelers would be less likely to visit a site after experiencing technical problems like slowness or errors on the page. Business travelers are slightly more likely to have a negative reaction
  • Loyalty is not forgiveness - Active loyalty program members are more likely than other travelers to indicate that they would not likely be influenced at all by technical glitches at 34 percent. However, the remaining 66 percent are actually more likely than others to have strong negative reactions.
  • Travelers tend to be multi-taskers - 59 percent of consumers do something else when waiting for a travel website to load. Nearly one in five (19 percent) open another travel site in a new window when made to wait.
  • Hidden fees may cost you - 43 percent of online shoppers have abandoned a booking because the final product price and/or fees were higher than they were willing to pay

Some of these findings should not be very surprising, but the exact statistics are a little bit staggering. If you site is loading videos and flash animations and jQuery galleries, loads of text, and CSS effects, then hiding them on mobile platforms, your users could be leaving faster than they came.

So many people access the web from their mobile devices these days. In fact, the Pew Research Internet Project web site has published that 63% of adults who own cell phones use those cell phones to access the web. Presumably on a semi-regular basis.

This information may be a bit sobering for some. I know it certainly is for me. For me, these statistics are enough to start really getting hard-nosed about mobile-first development. Making sure that the site works completely without flashy effects and the like is already a best-practice standard which I adhere to as best I can, so mobile first development should not be too much of a change in the work-flow.

What do you all think about mobile-first development? Are these statistics enough to sway you in your work-flow, or do you think that if someone wants a real web experience, they should just go on a desktop PC? What are your thoughts about sites linking to a mobile version of the site, instead of using media queries? Do the excess HTTP requests justify the better adaptation of your site for your mobile users?

Friday, February 28, 2014

Starting Things Off...

Hello, and welcome to anyone who may be reading this. You might be here because you are interested in the same things I am, or you may be here because you randomly stumbled across this blog while browsing the depths of the net. Regardless of how you landed in this particular part of the internet; Welcome!

I suppose I should begin with a little bit of background about myself. I am an aspiring web developer with my sights set on doing freelance web programming jobs for clients. I have been working with languages such as PHP and JavaScript for roughly 2 years now, and I enjoy it to a great degree. I used to have a web site (one of those free sites you get from your ISP, hah) and write some blog content when I was a youngster. None of that ever got anywhere and it lacked any sort of visual or functional spark that would draw anyone in. I would mostly just go on sites to get free JavaScript snippets and paste them into my site to see what would happen.

Fast forward by a little less than a decade, and I had forgotten I even enjoyed web things. I went into college with no particular direction, knowing only that I didn't want to live the rest of my life on minimum wage. I took a music class my first semester, thinking that I wanted to be a music producer, but ended up not enjoying it at all. Next semester, I took a few classes in the Graphics program, because I thought I wanted to be a 3D Artist. Long story short; I didn't want to be one after all.

However, one of the requirements to become a 3D Artist was a Web Design class, which I soon discovered that I had an actual interest in, and now here I am today. I spend a good part of my spare time learning and expanding my knowledge with these programming languages and techniques, and when I run into a problem, I gravitate toward writing a program to accomplish the task. I consider PHP to be my "language of choice", because that is what I would call the first real programming language I learned; after HTML and CSS of course, but those are required to do anything on the web anyway, so I don't count them in this situation. 

But anyway, this has gone on long enough. I hope that this blog can get off the ground, or at least function as a place where I can keep a running log of things that I learn, or technologies I find interesting, and so on. 

After writing that out, I am actually quite curious to hear how other folks in the industry found out that they were interested in working with web. Regardless of if it is web programming, or design or UX, or anything else, I would love to hear it. 

Even if you are not interested in any of this stuff, and you somehow stumbled upon this by accident, I would love to hear how you got your start in whatever it is that you do!