Book Review: Thinking in C++, Section Edition, Volume One

Posted by Brian R Cline | Book Review,Programming | Wednesday 1 September 2010 10:30 am

“Thinking in C++, Section Edition, Volume One” (ISBN:978-0139798092) was written by Bruce Eckel. The book is quite large coming in around 800 pages and focus on making the transition from C to C++, and focusing on practical programming. I believe the book could be much shorter if Bruce had a lot less repetitive, and long winded sort of writing. Bruce’s writing style does not really equate well with using the book for future reference later: thankfully, I don’t anticipate using C++ much as I focus almost entirely on creating and designing web sites.

The typography and presentation of the book need significant work: the font selection and size are annoying and incredibly difficult to read for long periods of time. The printer should have used a smaller size font and reduced the size of the headings slightly as well to decrease the number of pages, and to allow easier reading. The quality of the binding of my paperback edition of the book is absolutely terrible: the cover barely survived 1/2 a day of travel in my briefcase.

Each chapter ends with a lot of different exercises: unfortunately, the author does not include the exercises for free. “Thinking in C++, Volume 1 Solution Guide” must be purchased to see the answers to only some of the exercises. Exercises generally aren’t too bad, or too complex, but for the most part there’s always two or three that could almost be copied directly from the text.

Bruce covers a wide selection of C++, but doesn’t really cover the C++ Standard Template Library until another volume which of course must be purchased separately. I really believe that I learned more about object oriented programming from his introductory text than I have practicing OOP for the last three years: I really feel more confident about when to use composition vs inheritance. I was extremely disappointed to not see a mention of lint or any of the other automated testing and syntax sort of checkers; Bruce covered the compiler and how it generates assembler pretty well, so I would have liked to have seen a little bit about using lint or other software to check for memory leaks.

Bruce’s order of some of the topics should really be reconsidered as I often found myself flipping forward to read more about something especially in Chapter 15 there was a lot of flipping to read about something in Chapter 16. I find the forward references to be extremely frustrating and sometimes this can make studying more difficult.

Over all, I think Bruce has written perhaps one of the best textbooks I have ever used and has some issues with printing, his writing style, and making his text more reference friendly. I hate to say it, but I think that sometimes a box with important things that should be remembered or some tips is something that could be used to make referencing more friendly. (Dietel and Dietel produce many textbooks that make good use of boxes for emphasizing or summarizing something important.)

Learning jquery

Posted by Brian R Cline | JavaScript,Programming,jQuery | Tuesday 24 August 2010 7:22 pm

I’ve been using jQuery since mid 2008 and have to say that I just love how much easier things are and not having to generally deal with the crossbrowser issues in Internet Explorer, Safari,Chrome, and Firefox.

In the roughly two years that I have worked with jQuery, I have refered to a couple of things to learn jQuery and improve my web based applications.

Rebecca Murphy wrote an excellent electronic book called jQuery Fundamentals that she gives away for free from her website. jQuery itself also has many video tutorials, and a fairly well written and maintained web based manual that works similar to a Wiki.

Hope this helps!

Handling Programming Errors

Posted by Brian R Cline | Experience,Programming | Tuesday 24 August 2010 6:12 pm

Handling errors, sometimes called defensive programming, isn’t really something I have been taught very well at Athabasca or Niagara College. Over the last few years, while handling customer support and internal user support I have come to realize that what the dialog box says and the frequency of errors is probably the single biggest user experience issue.

I use the following guidelines for developing and when to show error messages.

Visual Attributes The error message should immediately grab the user’s attention: on a web application it should be exactly in the middle of the screen using some sort of popup, in regular desktop applications it should be in the middle of the screen in a log box. For text, I usually use a bold and red coloured font.

Message The error message must be clear to your average user: if the printer is out of paper tell them that! Don’t give your user just an error code, because they won’t know what that means and they won’t want to read your manual or contact support.

Where? Your user wants to know where it occurred, and how to fix the error. If possible some sort of visual attribute should also be set if the error occurred on a data entry screen. Set the border of the element reg, set it bold if the text is invalid, or even use some sort of icon.

Always make sure your error messages are clear: users don’t want to have to search through some user manual for software they bought, or have to pick up the phone and call for technical support. Apple has really shown us that users just want things to work, and it should of course look pretty. :)

MODx How To Properly Link To a Page

Posted by Brian R Cline | MODx,Programming | Thursday 19 August 2010 10:08 pm

In MODx, it is always preferable to link to another page using the document id instead of using the friendly alias because sometimes MODx Evolution has a package that is appearantly capable of using the alias instead of the document id to provide a working link to another page.

The reason you shouldn’t use the alias instead of the document id is because it isn’t unheard of to have google or other search engines incorrectly access another page perhaps one that isn’t even available.

Using the document id is done in the following manner for Evolution:

>a href = "[˜77˜]"<Link to document 77>/a<

Using the document id is done in the following manner for Revolution:

>a href = "[[˜77]]"<Link to document 77>/a<

The documentation for MODx Revolution is really geat and should be used to learn additional things.

Hope this helps!

MODx Revolution – Dynamically Generating Google SiteMap XML

Posted by Brian R Cline | MODx | Thursday 19 August 2010 6:13 am

Google SiteMap and the other web tools provides a way for the owner or webmaster of a site to easily submit all of the pages to Google and keep track of which ones are crawled and indexed. Wikipedia provides a much more detailed description which goes beyond the scope of this post.

I didn’t want to have to manually try and figure out which links are children of other links for my own site (which again only has 5 pages anyway!) or other things like that, so I was looking for an automatic way to generate the google sitemap and then be able to provide it to google.

MODx Revolution has a plugin called GoogleSiteMap which uses a snippet called GoogleSiteMap I created a page, set the template to empty, and called the snippet directly on the page and then took the xml it created and pasted it into an xml file to submit. The XML it generates even correctly does the last modified date.

Hope this helps!

Centering a DIV Horizontally

Posted by Brian R Cline | CSS,Programming | Wednesday 18 August 2010 10:45 am

Assuming you have a basic knowledge of css and html putting a div in the horizontal center of a containing block isn’t too difficult. I’m going to center a div with only text, but the exact same css may be used for a div containing images,inputs, etc. I’m going to assume you are using html or xhtml strict and have a div that has the following code:


<div id="toBeCentered">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat</div>

All new web designers and developers assume that the css can simply be text-align:center; , but this isn’t correct because this centers the contents of the box instead of the box itself.

#toBeCentered {
text-align:center;
}

To make the div center horizontally we need to ensure we do two things:

      Set a width to the div
      Set the left & right margins to auto. Web browsers are required to give the margins equal width which will set the div exactly in the center. works width.

We must instead change the css to auto the left and right margins and must set a size to the div. Setting a size to the div

#toBeCentered {
width: 200px;
margin-left: auto;
margin-right:auto;
}

Hope this helps!

Wayfinder in MODx Revolution

Posted by Brian R Cline | MODx | Monday 16 August 2010 6:57 am

When I first tried MODx Revolution (which I did try before MODx Evolution) I found the documentation to be pretty good except about snippet syntax. The tag syntax has changed from MODx Evolution to MODx Revolution.


[Wayfinder? &startId=`0`]

has to changed to

[[Wayfinder? &startId=`0`]]

More information can now be found here for all of the tag syntax changes.

Setting Focus to 1st Text Field in jQuery

Posted by Brian R Cline | JavaScript,Programming,Uncategorized,jQuery | Saturday 14 August 2010 10:48 am

Setting focus to the 1st field in jQuery is actually really simple: there are some plugins that also can do it automatically on each reload of a form.

I usually just use the following code on any pages where there is a form.


<script type="text/javascript">
$(document).ready(function() {
$("input:text:visible:first").focus();
});
</script>

Hope this helps.

How to Center a Div in the Middle of the Screen

Posted by Brian R Cline | Programming,jQuery | Friday 13 August 2010 3:35 pm

David Tang has written a very simple, but great plugin for jQuery that allows the casual JavaScript/jQuery programmer to easily place a div in the middle of the page. In fact, I am now using it on several of the sites I work on to alert users in an unobtrusive way to any errors in a form.

I don’t feel it is necessary to write any sample code or display how the plugin works, because David has done a decent job documenting and creating demos.

MODx – Evolution – 1st Impressions

Posted by Brian R Cline | MODx,PHP,Programming | Thursday 12 August 2010 1:09 pm

I haven’t been using MODx for very long, but I have worked with several other content management systems previously and experienced both the good and the bad with them. MODx appears to be a fairly simple MVC style content management system with a bit of a pluggable architecture. I haven’t written any plugins for MODx, but it appears that hooks are used just like WordPress does.

I have found MODx to be very easy for creating fully tableless XHTML compliant sites and creating very search engine friendly websites. Very easily, it is also possible to hide what cms is running the site by using the easily created pretty urls. (There’s just a couple of simple settings and a file renaming.)

I found the templating system to be extremely frustrating because the template is actually stored in the database instead of in the file system like done in most traditional CMS. I really find editing the templates, snippets, and larger chunks extremely frustrating to edit in the manager because of the lack of syntax highlighting, and issues with formatting.

Of course, the manager does offer the advantage of being able to edit content and site structure from pretty much anything that can access the internet and doesn’t mind some fairly heavy javascript use. MODx’s requirements for webhosting aren’t exactly hard to find either although there is a forum of reviews and suggestions.

Overall, MODx doesn’t appear to be too bad for smaller boutique websites which are a large chunk of my current business. I believe I would recommend it to fellow freelancers for smaller websites that don’t have much need for plugins or high amounts of customization.

Next Page »