Thursday, July 28, 2016

Technical Skills a Software Developer Needs

Devs,

Here's another great article I read today. I, for the most part, agree with this author.

https://simpleprogrammer.com/2016/07/18/technical-skills-software-developer/

And here's a bonus article: Why SmallTalk is great to know?
http://techbeacon.com/how-learning-smalltalk-can-make-you-better-developer

I can add that it's definitely good to know when having conversations with older techies. I remember one developer from my first job rave about how SmallTalk was THE language and the industries were wrong for jumping into the next "hyped" language.

And another one on the importance of the rising skill of "data analysis":
http://venturebeat.com/2016/07/17/forget-learning-to-code-every-employee-should-know-data-analysis/

Enjoy,
G2

Goodbye OO?

Devs,

I read this great article and had to share. I haven't tried much the proposed development approach (i.e. functional programming), but I am familiar with the challenges of OO.

https://medium.com/@cscalfani/goodbye-object-oriented-programming-a59cda4c0e53#.e1crc9bdt

There are the hybrid development approaches, too.

Of course, it always depends and a developer has to be wise to know which solution works best.

Happy Thinking,
G2

Friday, July 22, 2016

JQuery: Setting Default Date on DatePicker

Devs,

I recently was trying to set the default date of a DatePicker that I added to a input field.

form.find('#expires').datepicker( {defaultDate: 7} );

However, the DatePicker would keep displaying the default date value of "1/1/2020". This was driving me nuts as I was looking through the documentation and searching online (i.e. SO) for solutions to my problem to no avail.

http://api.jqueryui.com/datepicker/#option-defaultDate
http://stackoverflow.com/questions/14580749/jquery-datepicker-set-default-date

Root Cause:

After intense thinking and investigation, I finally found my root cause. I already set the predefined value in the field itself which was overriding my jquery default property.

<input type="text" name="expires" class="expires" id="expires" placeholder="Expires" value="1/1/2020" />


Solution #1:

Remove the attribute value in the input field or replace the value with expected default value before passing field to DatePicker.

I chose to replace the value upon displaying of the input field because without the value attribute the input field displays null by default and the DatePicker would open with a default date. I wanted a default date in the input field AND in the DatePicker.

<input type="text" name="expires" class="expires" id="expires" placeholder="Expires" value="1/1/2020" />

form.find('#expires').val( _getDefaultExpirationDate() );
form.find('#expires').datepicker();

/** 
* Get Default Expiration Date
* @return (string) current date + 1 month in format: MM/DD/YYYY
*/
function _getDefaultExpirationDate()
{
var today = new Date();
return tens(today.getUTCMonth()+ 1) +'/'+ tens(today.getUTCDate()) +'/'+ today.getUTCFullYear();
}

/** 
* Tens 
* - converts an integer that's a single digit into double digits
* - useful for dates and times
* @param (int) integer
* @return (string) single digit with leading '0' or double digit
*/
function _tens (integer)
{
while (integer > 99 )
{
integer = integer - 100;
}
return (integer < 10) ? "0"+integer : integer;
}

Easier Solution:

Change the input type from 'text' to 'date' and set default value.
http://www.w3schools.com/jsref/prop_date_value.asp

<input type="date" name="expires" class="expires" id="expires" placeholder="Expires" value="1/31/2016" />

Happy Coding!,
G2

Wednesday, July 13, 2016

PHP Array indexes are CaSe-SeNsiTIvE

Devs,

Quick note, PHP array indexes are CaSe-SeNsiTIvE.

I ran into an issue with sending a $_POST to the database to insert a record. I was validating the data in the post array and setting required values if a key was not set properly. However, this gave me a database insert error stating I'm using duplicate field (column) names.

Well, ain't that tricky!

Did a quick search to confirm my assumption about PHP array indexes being case-sensitive.
http://stackoverflow.com/questions/1511230/php-array-are-array-indexes-case-sensitive

Yep, added the check for all cases and database insert worked! Yay!!

I wonder what other languages treat array indexes as case-sensitive? Maybe all programming languages? This would only make sense, no? The value of an index is calculated differently based on char value, right?

To be continued...

Happy Coding,
G2

Wednesday, June 29, 2016

The opposite of "last updated" = "least active"

Dev,

Today I found myself absorbed with a co-worker in search of the right term for the opposite of "last updated". I found probable terms like "wane", "stale", and "untouched", but none quite fitting and self-explanatory for users.

We asked a fellow co-worker, an analyst, who came up with "active" and "idle". Of course, why didn't I think of this? In earlier projects and working with former teams, it's common to use the phrase "most active" and "least active" in respect to projects.

So, there we have it and now I have it recorded for my future reference to never waste another couple hours trying to figure this out. I can't believe this isn't already captured in certain websites or online forums like: http://english.stackexchange.com/questions/46976/opposite-of-most-recently

Photo by betaBoston
Happy Thinking,
G2

Tuesday, June 21, 2016

Encoding - A Developer's Knowledge Requirement

Devs,

"It's really simple: Know what encoding a certain piece of text, that is, a certain byte sequence, is in, then interpret it with that encoding. That's all you need to do. If you're writing an app that allows the user to input some text, specify what encoding you accept from the user. For any sort of text field, the programmer can usually decide its encoding. For any sort of file a user may upload or import into a program, there needs to be a specification what encoding that file should be in. Alternatively, the user needs some way to tell the program what encoding the file is in. This information may be part of the file format itself, or it may be a selection the user has make (not that most users would usually know, unless they have read this article)."

http://kunststube.net/encoding/

This was a really good read and I...actually agree. Encoding isn't just a problem with data files, but also with development environments, or specifically IDEs like Eclipse. Unfortunately, just like English is not a universal language, neither is UTF-8. Let's know how we're speaking to each other to understand each other - even in the world of code.

Additional, check out Joel's article:
Cheers,

Monday, June 6, 2016

Why Facebook hasn't migrated away from PHP

Dev Fam,

Sometimes I just don't have time to play with code and simply need to up my learning by reading a *good* article. Today's article is from my question identified by a post in Quora.

https://www.quora.com/Why-hasn-t-Facebook-migrated-away-from-PHP

This is good to know considering how our young generation today of developers can be influenced like fans of an entertainer. In the field of science and technology, we can't just go with the flow of the crowd or get caught in the wave of the current. STEM folk have to evaluate into the depth of what's happening with any new technology or scientific discovery and ensure its proper usage before applying. This is especially true for any large subject matter, product, or system.