Tag: Programming

How to be a more Efficient Debugger

How to be a More Efficient Debugger

For the last 10+ years or so, I’ve been programming professionally. Even with ten years of practice, I still am unable to write a bug free applications. In this blog post, I have put together some tips on how to be a more efficient debugger and how to actually resolve the issue. A lot of my bugs aren’t as obvious as they used to be, but they are definitely still there. In the book Code Complete, Uncle Bob Martin, suggests that every error is an opportunity to learn. Continue reading

How to Improve as a Developer

How to Improve as a Software Developer

As a software developer, it’s really important to take time and improve your programming skills by learning new technologies and techniques. By constantly trying to improve as a developer there’s potential to become a highly sought after developer. Continue reading

Apex: Converting Lists to Sets, and Sets To Lists

As many Salesforce Apex programmers know, in Salesforce it’s pretty much an unchallenged best practice that all code should be able to handle bulk inserts, updates, etc. When adhering to this best practice, it’s really common to use sets, or lists as parameters in functions. Sometimes, there’s a need to convert between lists, or sets, or maybe even maps. Continue reading

Book Review: Practical Salesforce.com Development Without Code

Practical Salesforce.com Development Without Code

Practical Salesforce.com Development Without Code written by Phil Weinmeister has been recently released. I think the book really targets those new to the Salesforce platform and does a wonderful job of providing examples and providing a reference that will be useful in the future.

Phil Weinmeister has done a phenomenal job putting together some different scenarios where it makes absolute sense to make use of the declarative functionality that Salesforce provides. As a developer I’ve struggled quite a bit when to use “clicks not code” and feel that Phil has great examples that would be useful to most Salesforce Admins and developers to learn from.

Some of the topics covered include workflows, approvals, process builder, validation rules, and more.

The chapter on object and field level permissions in Salesforce is really well written. I really wish this book had existed when I was first starting to use Salesforce.

Overall, I recommend using the book to learn the declarative features of Salesforce.

How I became A Developer

Computers have interested me virtually my entire life. I don’t remember when I got my 1st computer, I remember my dad and mom taking about how my dad would play computer games or use a bbs and have me sitting in his lap. Around the time I was six my dad was given a computer by one of his friends that apparently wasn’t working, I remember it briefly it was a 286 and the case was a very rugged metal, but what I remember most was that my dad got the computer going again and eventually put it in my bedroom.

There were many days and nights I read out of an old beat up DOS manual. Eventually, my dad got a 486 and I inherited his old 386 that could run Windows 95 and HotDog! I made my first website with HotDog and eventually decided to move onto Homesite 1.0 which was extremely awesome and allowed me to learn HTML 3. I started doing chores and using birthday money to buy books, and better computer equipment.

I continued on and eventually went to Niagara College for Computer Engineering, but eventually switched to Computer Programming because that’s where my passion truly exists.

What first attracted you to this field?
The constantly changing and evolving web and computers has always piqued my interest. I’m lazy, I don’t like repetitive work, I couldn’t imagine working in a factory on an assembly line or working somewhere where I don’t get to learn every day.

What keeps you going
I love learning, experimenting and figuring out how to accomplish a goal as long as I’m still able to tinker I’m sure I’ll develop.

Clean Code: Compiler Warnings

It’s no secret that I work as a freelance software/web developer and often jump around between languages. I, continually, run into projects where the developers are ignoring warnings produced by the compiler which can lead to some very sloppy code along with some very interesting situations that occur as the code runs in production.

In my experience, warnings are almost always a bug in waiting especially warnings for assignment operators used in an if statement instead of the equality operator (very common in C variants.) Spend those extra few hours when you develop and try to ensure that you keep the compiler warnings to a minimum, so your code is clean and doesn’t appear to be sloppy.

Warnings also destroy your credibility as a developer, because they make your code look sloppy and suspect whenever a problem occurs. If you’re an employer, do your developers compile with warnings on and if they compile with warnings on do they take the time to resolve them?

Book Review: jQuery in Action

jQuery in Action, First Edition is written by Bear Bibeault and Yehuda Katz and is probably the simplest and easiest to understand programming book available. Target reader is somebody that already is using javascript in projects and is looking to push the limits of their web applications by using jQuery and many of it’s great plugins.

I found the book and its appendices to be extremely well written. I found the examples to be superbly written and extremely usable in my projects: there aren’t a lot of examples on basic things like selectors but there are a ton of great examples on much more advanced concepts. An additional feature that I found really helpful was the interactive lab exercises that begin around chapter two.

As a reference, which I don’t think was the primary intent, it would be difficult to use the book as some of the API is randomly spread throughout the book. The random spread does make the book a lot better though, because each chapter definitely builds well upon the previous chapter.

I completely recommend this book and can only imagine that the Second Edition improves upon the First Edition. I haven’t really found much negative about the book other than wishing the API wasn’t spread out so much, but the index is very good.

How To Post Great Freelance Gigs

I have been trolling Craigslist and Kijiji lately in hopes of finding some additional freelance work to add to my portfolio before I become a full time freelancer/consultant. Read the advertisements has proven to be a terribly frustrating experience. Advertisers need to always remember that the more details they provide will lead to a much more realistic budget and a system that better meets their needs.

Advertisements need to be as detailed and as short as possible. If the programmer is expected to modify or write plugins for an existing application or website you need to provide details on how the previous system is implemented. Ideally, you will answer all of the following questions. What programming language? What database is it using? Who is hosting it? Is there any sort of documentation? Do you have programming guidelines?

Regarding the actual project or changes to an existing project require you to answer additional questions. Is it completely new project? Who will own the work (source code, graphics, etc)? What’s the timeline? What should the application do? What is the scope of the project?

Always remember that you also get what you pay for and that if you pay minimum wage or outsource to another country (China,India, Brazil, etc) you will likely get inflexible crap that will have to be redone if your site or application goes through some sort of expansion.

Learning Drupal

For the last couple of weeks, I have began playing around with Drupal because I’m so sick of fighting proprietary CMS. The proprietary CMS suffers from the vendor updating only updating the CMS when convenient for them and this ends up holding the purchaser hostage. Overall, I know that drupal has enough of the functionality that I need in modules and the core to significantly improve the efficiency of my programming and possibly offer a large learning opportunity on software architecture.

Continue reading

Determine if Skype is Installed

The easiest method of checking whether Skype is installed is actually to check for a Registry Key. We, of course, can’t check C:Program Files for a Skype Directory because the user could have installed elsewhere (or maybe if 64 bit the operating system did?)

Skype’s API Document provides us with the following information:

To check if Skype is installed, in regedit check if the following key exists: HKCUSoftwareSkypePhone, SkypePath . This key points to the location of the skype.exe file. If this key does not exist, check if the HKLMSoftwareSkypePhone, SkypePath key exists. If the HKCU key does not exist but the HKLM key is present, Skype has been installed from an administrator account but not been used from the current account.

Generally, I only care if the Current User has configured Skype, so I will ignore the HKEY_LOCAL_Machine information and instead rely entirely on the HKEY_CURRENT_USER information.

You must make sure you reference: Microsoft.Win32 for the registry functions or modify the snippet slightly.

        using Microsoft.Win32;

        //Function uses Microsoft.Win32 to check registry value of 
        //HKEY_CURRENT_USERSoftwareSkypePhoneSkypePath and returns false if
        //the key is null
        private bool isSkypeUser()
        {
            RegistryKey skype = Registry.CurrentUser.OpenSubKey(@"SoftwareSkypePhone");

            if (skype != null && skype.GetValue("SkypePath") != null)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

Mouse Overs For ASP.NET

Have you ever wanted to have the ability for the colour of a row to change when your user moves the mouse over top of a particular row, and then change the colour back whenever the cursor is moved back off?

Well, this process isn’t very difficult in fact using some knowledge of JavaScript & the Document Object Model (DOM) we can dynamically change the background colour.

We need to override the Render class and then add some attributes to each GridViewRow before the page is finally output to the browser.

In this example, I have called the gridview we are adding the mouseovers and mouseouts “gvClients” because it displays a list of my fictional company’s clients. Wherever you see gvClients you need to make sure that you change this to your respective gridview’s name.

protected override void Render(System.Web.UI.HtmlTextWriter writer)
{
   /*Using a simple foreach we iterate through the Rows and use the row.Attributes.Add() and pass in the javascript property we want to output as    html, along with the function we will use and then because asp.net usually dynmically creates the names for each item we need to use    the row.ClientID as this will exist only on the client side.
*/
foreach (GridViewRow row in gvClients.Rows)
{
  row.Attributes.Add(“onmouseout”, “ColorGridForMouseOut(‘” + row.ClientID + “‘);”);
  row.Attributes.Add(“onmouseover”, “ColorGridForMouseOver(‘” + row.ClientID + “‘);”);
}

//We finally just pass in the html that’s now been created.
base.Render(writer);
}

— Sample javascript

//Change Color of Gridview on MouseOut
function ColorGridForMouseOver(id) {
var el = document.getElementById(id);

if(el.currentStyle) // for msie
{
if (el.style.backgroundColor !=’orange’)
{
el.style.backgroundColor=’lightblue’;
el.style.cursor=’hand’;
}
}
else // for real browsers 😉
{
if (el.style.backgroundColor != ‘Orange’)
{
el.style.backgroundColor = ‘lightblue’;
el.style.cursor = ‘pointer’;
}
}
}

function ColorGridForMouseOut(id)
{
var el = document.getElementById(id);

if(el.currentStyle) // for msie
{
if (el.style.backgroundColor !=’orange’)
{
el.style.backgroundColor=’White’;
el.style.textDecoration=’none’;
}
}
else // for real browsers 😉
{
if (el.style.backgroundColor != ‘Orange’)
{
el.style.backgroundColor = ‘White’;
el.style.textDecoration=’none’;
}
}
}

Thank you for taking the time to visit.

Creating a Simple RSS Feed

RSS is an acronym for Really Simple Syndication and is an XML specification published by the W3C. RSS became a standardized specification around June 2000. This is meant to be a very simple primer on developing an RSS feed. Please note that this is not meant to replace a detailed book or the specification created by W3C. When I first created an RSS feed for a client the specification was the only way to learn RSS.

There are required elements to meet the specification as well as some optional. Some of the elements that are option really should be included logically.

Each RSS feed begins with a tag describing what XML specification the document meets. For example:

<?xml version=”1.0″?>

After the XML Version, we need to know which version of the RSS specification this document will meet. The rss document will also have a closing </rss> tag at the end.

So far, we have:
<?xml version=”1.0″?>
<rss version=”2.0″>
</rss>

The next tag we have is for a channel. A channel is a reverse-chronological list of links to stories that includes a title, and some sort of description.

The channel has a couple of required elements that are mostly self explanatory. The first one is a title (the name of the channel, usually just the website name), a link (to the website) and a description of the service.

So, we now have:
<?xml version=”1.0″?>
<rss version=”2.0″>
<channel>
<title>Brian R. Cline’s News Feed</title>
<link>http://www.brcline.com</link>

<description>Programming Blog for a Programmer Analyst in Niagara Falls, Ontario, Canada.</description>
</channel>
</rss>

There’s many optional elements to include within the channel, but I don’t feel that most are needed to produce a great and strictly valid RSS feed.

For example, there’s image which lets you specify a GIF,JPEG, or PNG to associate with the channel but not all RSS aggregators can show it.

The bulk of the RSS feed is created by using “items” which represent the story and usually include a title, link, and description. All elements of an item are actually optional, but you should include at least a title and description.

An item is fairly simple, here is an example:

<item>
<title>New Blog Post</title>
<link>http://www.brcline.com/blog/page?=13</link>

<description>Brian R. Cline posted about how to create an RSS feed.</description>
</item>

RSS channel’s usually include more than one item and are updated fairly regularly. I’ve included a couple of different items in the final example.

<?xml version=”1.0″?>
<rss version=”2.0″>
<channel>
<title>Brian R. Cline’s News Feed</title>
<link>http://www.brcline.com</link>

<description>Programming Blog for a Programmer Analyst in Niagara Falls, Ontario, Canada.</description>

<item>

<title>New Blog Post</title>

<link>http://www.brcline.com/blog/page?=13</link>

<description>Brian R. Cline posted about how to create an RSS feed.</description>

</item>

<item>

<title>New Blog Post – Welcome</title>

<link>http://www.brcline.com/blog/page?=1</link>

<description>Brian R. Cline posted a new blog welcoming users to the blog.</description>

</item>

<item>

<title>Blog Created</title>

<link>http://www.brcline.com/blog/ </link>

<description>Brian R. Cline adds wordpress to his website.</description>

</item>
</channel>
</rss>