New Project Experiment: browser code 100% independent of the back end

I’ve taken on a new project this month and I decided to try something out that I’ve never done before.  I want to make the browser code to work 100% independent of the back end.

What exactly do I mean by this?

  • The browser code should all be done with AJAX in a way that it does not require any preprocessing done by the server to render HTML Pages.
  • All requests to the back end  are to be done with AJAX.
  • All posting of data to the back end will be done with AJAX.
  • The browser should be able  to communicate to any back-end that provides RESTful services.

Why would I do this?

  • The more and more I look at the presentation layer, we’ve gotten ourselves so deeply entrenched into one specific technology or platform, that it’s been near impossible to get out of it.
  • I want to be able to have a platform that could run on a back end system that is in the best interests of the client, but allow them later to upgrade if needed without having to redo the front end.
  • The front end code should be able to be 100% independent of the back-end development.  I should be able to build the front end for example on OSX and if I wanted to build the back end in Windows with WCF.

The tools and Technology I plan to use for the front end

  • jQuery 1.3
  • jQuery UI 1.6
  • DataTables plugin (v1.4.x) for jQuery by Allan Jardine
  • TextMate IDE for OSX

The tools and technology I plan to use for the back end

  • Visual Studio 2008
  • WCF
  • C#
  • Linq
  • SQL Server 2005
  • IIS 6.0 on Windows 2003 Server

The reason for back end to be Windows is because the client has Windows servers running IIS 6.0.  However I plan on for the experiment to build the back end later as part of the experiment using Google App Engine and Python.  It should be very interesting to see if this can be achieved.   Yes this is a steep order but I believe it can be done.  I plan on posting regular progress on my blog.

.net
OSX
WCF
ajax
jQuery

Comments (0)

Permalink

Check out an article I wrote about the iPhone for Website Magazine!

I wrote an article for WebSite Magazine which is published monthly.  The article was on the Traps to avoid when developing iPhone Apps.

Check it out and if your not already a subscriber, subscribe because it has a ton a great articles each month.

Apple
Objective-C
Technology
cocoa
iPhone

Comments (0)

Permalink

I love to consume Cocoa!

The last three weeks have been an absolute joy!  I’ve been coding like I was 29 again and dreaming of Cocoa!  OK maybe not that part but I’ve found something that I have not felt like in 7 years.  The last time I felt like this was when .NET first came around. However for the first time since I’ve left college, I’m actually coding on a platform that was not created by Microsoft.  

It’s a weird feeling because I’ve been using Visual Studio when it was just Visual C++ and Visual Basic as two packages that looked like the same IDE.  However xCode 3.0 is amazing!  It feels right!  I’ve tried Eclipse and even that did not feel polished compared to VS or xCode.  There are several things in xCode that I don’t think I can do without anymore.

So what have I been doing for the last 3 weeks?  We’ll I’m officially a professional Cocoa developer now.  Sure I’ve played around with it for years and made my own programs but this is the first time I actually getting paid to do it.  Not just one project but I have 3 projects and several more lined up.  I’m making iPhone applications for my clients and it rocks!  I’m about to release the first product to the application store and I’m very proud of what I’ve been able to do in relatively short period of time.

When the product is released and is approved on the iTunes App Store, I’ll make sure to let everyone know about it.  

P.S. Don’t forget to download it when it comes out ;)

Apple
Objective-C
cocoa
iPhone

Comments (0)

Permalink

I bet Steve Jobs completely lost it this week!

Wow! What a horrible week for Apple (at least Weds thru Friday).  I have honestly never seen Apple blow it so bad on a week that could have been another brightest moment to add to the trophy case.  Instead they hired Murphy to run the launch of MobileMe and the new iPhone/2.0 software launch.   

For those who don’t know Murphy, he has a law named after him.  ”Whatever can go wrong will go wrong, and at the worst possible time, in the worst possible way“ - Murphy’s Law.

Seriously, I would not have wanted to be the product Manager for MobileMe on Weds.  Can you imagine the phone calls this guy/gal was getting from Jobs.  Based on what I’ve heard and read, I would have to imagine someone was next to the mobileMe servers in the fetal position.  The servers are up, and then their down. This cycle goes on for well over 24 hours.  No was sleeping for the next 3 days for these guys.

Then comes the launch day of the phone.  Friday you are hearing stories that no one can get their new 3G phones to activate.  Now this one is probably AT&Ts fault.  I can just imagine Steve on the phone ripping a new one at AT&T and telling them they suck and I wish we went with Verizon :).  

Then to make it worse, the release of the iPhone 2.0 upgrade, cause people who did it early had their iPhones bricked because of the same activation problem that plagued the new iPhone subscribers. 

Not only were the people who were getting new phones upset, but now you have your loyal users pissed because their phones don’t work!  Thank goodness I was too busy writing my first iPhone app for a client that I did not have time to upgrade it that day. Later I did it and had no problems. (I think Murphy was finally fired when I got around to doing it.)  I know that one of the guys at work had his phone bricked for about 3 hours before he was able to get it reconfigured again.

Finally you also begin to hear about problems of people with iPod Touch. I’m thinking this one was probably a bit overblown since everything else was going wrong so why not the iPod Touch.

However, in the end it seems everything worked out.  I would have to say part of the problem why this launch was so bad compared to the perfect launch before was that you took your phone home and activated at your time. Not this old school crap of having to get it all done in the store like its 1999.  You can bet that Apple is going to think twice about trying to keep AT&T happy if they can’t get their system working to do it smoothly as possible.

So there was probably a lot of screaming, lost voices, high blood pressure and a few people who either quit or got fired yesterday.  Everyone is entitled to bad day, but this is rarely a day we see from Apple!

 

 

 

 

Apple
Technology
iPhone
mobileMe

Comments (2)

Permalink

How to Change the text Color of a NSButton in Objective-C

One of the things that I need to do is simply change the text of a NSButton (or NSButtonCell) to a different color.  No problem I thought. I can easily do this in any language since I started developing Windows 3.1 Applications.

Boy was I wrong. There is no simple way to do it.   

Before the Apple purist start yelling that I should not do it because the guidelines state not do, I need to do it for the game I am developing.  Normally I would 100% agree and I think that is what makes Apple apps so great is that they look consistent and that is part of the problem with Windows App: plagued by horribly colored apps.  

 

After trying to Google and looking though all the docs from Apple to find a solution with not much help, I was finally able to find a couple of posting that pointed me to the right direction. A little from this post, a little direction from another I was finally able find a solution.  

Here is the code snippet from my test.  It’s not perfect by no means but you get the idea of how to do it.

 

- (IBAction)section1Selected:(id)sender
{
    [section2 deselectAllCells];

    NSLog (@"Selected");
    id cell = [section1 selectedCell];

    if (cell == nil)
        NSLog(@"Nothing Selected");
    else
    {
        NSButtonCell *button = (NSButtonCell *)cell;

        NSString *myString = [button title];

        NSLog(@"The Button Text is %@", myString);

        NSMutableParagraphStyle *pStyle = [[NSMutableParagraphStyle alloc] init];
        [pStyle setAlignment:NSCenterTextAlignment];

        NSDictionary *dict = [NSDictionary  dictionaryWithObjectsAndKeys:[NSColor blueColor],
                              NSForegroundColorAttributeName,
                              [button font],  NSFontAttributeName,
                            pStyle, NSParagraphStyleAttributeName, nil];

        NSAttributedString *atted = [[NSAttributedString alloc] initWithString:myString attributes:dict];
        [button setAttributedTitle: atted];
    }
}

This code has a NSMatrix that contain 9 NSButtonCells.  It finds the one that was selected in the NSMatrix and then I create a NSDictionary where I add 3 value key pairs, the NSForegroundColorAttributeName, the NSFontAttributeName and the NSParagraphStyleAttributeName.

I then create a NSAttributeString and initializde it with the text of the NSButtonCell and the attributesI created from the NSDictionary object.   Finally I set the AttributedTitle to the NSAttributedString.

WHEW! That is a ton of work just to get the color of the text of a button changed.

One thing I did not talk about was the third value key pair I added to the NSDictionary.  Before I added this, the text of the button would change the color, but it would be aligned to the left. Even though I passed in the Font attribute, it seemed to ignore this.  I’m not sure if its a bug or not but its probably not been looked at by Apple because I have to believe this is a hack and not a recommended solution.  Either way I created a NSMutableParagraphStyle object, set it to align in the middle and then added it to the NSDictionary object which was set as the attributes to the button.  WOOT! That worked!  

Hopefully this post will help new Cocoa developers who are looking at changing the text of the button. However its not intended for normal apps and you can’t blame me if all the Mac Apps buttons have changed color. :)

I wanted to show that with a little digging into the API, you’re capable of doing anything!  Even something I’ve taken for granted for 15 years!!

Apple
Objective-C
internet explorer
xCode
xna
youtube

Comments (1)

Permalink

Apple blows it on getting MobileMe up and running on Launch Day!

Wow!  I think this is the first post that I’ve ever done where I’m nailing Apple like their Microsoft.

MobileMemobileMe was supposed to be up and running now but it has had problems all day and its now officially down again.  I guess Apple was not ready for the amount of traffic or maybe they realized all that AJAX may have more load on the servers than they thought ;)  I would not doubt they thought they could just keep the old servers of mac.com and make it run the same. 

Heck it may not even be there fault.  Maybe Microsoft is doing a DOS attack on them….. :)

Hopefully MobileMe will be ready to go because I can’t wait to finally sync everything from all my Macs to my PC and iPhone with one single solution instead of the 3 step hack that I did using Google Apps.

See you Microsoft fan boys, I am not afraid to nail Apple for something they can’t do right.  Enjoy it because this is a rare thing to see this from Apple.

[UPDATE 1:12 AM Friday July 11] - I was able to login and connect for about 5 minutes. It then got really, really slow, then 5 minutes later it was back down and I was redirected back to the http://www.apple.com/mobileme/ site.

[UPDATE 1:15 AM Saturday July 12] - We’ll it looks like the worst is behind us.  This would have to be the worst week in Apple’s 8 year rule of dong it “Just Right”.  What could go wrong what went wrong.  

Apple
Humor
iPhone

Comments (0)

Permalink

The audacity of some Windows Developers

I’ve been reading an excellent blog called Cocoa is my Girlfriend and there is a post about The audacity of [some] Windows Developers.  I have to agree with him.  Windows developers can be a little bit stubborn about their ways.

I fell into the same camp when I started doing some development on the mac. I could not understand why Objective-C and Cocoa had to do things the “Wrong Way”.  However I soon realized that just because it was not the way I did things, did not make it stupid or wrong.  I guess I was used to doing it a certain way I just could not understand it.

After 6 months of playing around with Cocoa,  it now makes me sick to the stomach to have to do it the .net way.  I’ve fallen in love with Cocoa and now have seen the light on why its done the way it is.  It’s truly brilliant!  

Sure, I miss a few things about C# and Visual Studio but with xCode 3.0 I got most of what I was missing and more.  Don’t even get me started on the bloated thing called Visual Studio 2008 and that mess called Team Services.  I can’t for the life of me understand why Microsoft can’t simply adopt some amazing open source tools and integrate them into their products instead of trying to reinvent the wheel.  

I love the fact that I can hook up CVS or SVN right into xCode without having to use another tool.

I’m that guy who is stuck in the middle. I still do Microsoft development on a regular basis, but we did sign our first iPhone application deal and for the next month or 2 I will be all Mac.  To me this is pure joy and reminds me how much I love programming again and this is what it felt like when .net first came out.  

I guess I’m not afraid to admit when there is something else out there that maybe better than my comfort zone and I’m not afraid to give it a shot to see if it can make me more productive.  I would suggest more people on both sides of the fence to do the same!

 

.net
Apple
Software Development
open source
subversion

Comments (1)

Permalink

Why over time, overtime is extremely harmful to your development team!

Today I was using Google Reader and it suggested a new Blog that I’ve not read in a long time.  I checked it out today and it had an excellent post about “The Case Against Overtime“.  This could not come at a more valuable time for me to reflect back on this.  I’ve had the best development team working on our Product at VCG but lately the team, including myself have hit burnout!

I 100% believe that it’s all the overtime and weekends constantly getting ready for a demo, a conference, the launch and more demos!  However, this week I and apparently the team has had enough.  One of the partners for the product wanted everyone to work hard the next couple of weekends to get this great demo ready for a potential client.  I could see (including myself) the energy of the team drop!  Yes, I’m convinced we’ve hit burnout!  

Last month it was another demo where the development team worked a few weekends to get ready. The month before that was a launch, the month before that was a demo, the month before that was a conference!  You see the trend here!  I feel that this has become extremely unhealthy to the team.  So we’re not working this weekend or next weekend.  It’s time to stop burning the midnight oil all the time.  

The guys and I have been working 60 hour weeks for months now and it has to stop!  The team needs a break.  We need time off, we need to spend time with our families and most importantly, we need to fall in love with developing again!

Here is his 7 reasons why not to do Overtime:

Lost Opportunity Costs in Professional Growth 

I could not agree more!  We’ve been so stuck on getting the API working and finding workarounds to PerformancePoint Server, that the team has stopped looking at new technology in their free time to take a different look at things!

Increased Professional Risk from Lack of Diversification

Again because all we’ve done is BI, by working weekends and overtime, has stopped several programmers from doing their own pet projects to diversify their skills.

Decreased Professional Passion

The fire needs to be relit so we can love what we do. I think limiting the overtime hours (to none if possible) going forward will do this!

Lost Productivity and Poor Code Quality

I combined these two together because one totally affects the other. The law of diminishing returns is at work here. I know myself that if I work more than 12 hours, the work I do after that, usually has to be redone because I hit the wall. Instead some additional sleep would have been more helpful to attack the problem.  This would have benefited everyone (not just myself).  

Remember, when you’re working on a team, and the quality goes down, it effects everyone. The spiral continues because you’re tired the next day.  I can always tell when I give the guys off a few days for working overtime (which I probably have upset other managers because I gave my people some time off that does not go towards vacation time), they’re much better and productivity goes way up.

Lost Personal Revenue

When you start hearing comments that they are working for next to nothing and make less than the noobie at the office because they are calculating their overtime hours with their base salary, you know you got problems!  I can almost guarantee when you have this, you’re weeks or maybe a month away from losing key members.  This happened to my team. I tried to make it right but when it gets this far, you’ve lost them!

The Usual Personal Reasons

Family and outside life suffers!  And we forget sometimes who we’re working for to keep happy!  When this suffers and your teams starts to stress and their health begins to go, what the hell good was it?!  I don’t want to get there and I don’t want my team to ever be in that place either!

What to do about?

So as a manager, if you’re starting to see these signs, seriously consider changing your methods because it’s only a matter of time before burnout hits and you’ve lost your good people to someone else! I’ve now seen it and I’m going to do my best to make sure we keep it to a minimum!  This business is extremely hard to find good people and its even harder to find developers that totally understand BI like mine do. I  can’t afford for this to happen!  I’ve seen the signs and its time to fix the problem!

Software Development
agile development

Comments (0)

Permalink

This is why I 100% love Apple!

OK, yes I’ve become a Apple Fan-boy but it’s only because they continue to exceed my expectations.   This week is no exception.  They have gone way beyond my wildest dreams when it comes to making things right!

I just had the company purchase me a new iMac 24 inch, 2.8 GHz a few weeks ago.  I got it all configured as I wanted but when it was delivered to me I had some hard drive issues.  I purchased Disk Warrior and for the most part I was able to get the drive fixed.  However there was some Graphic card issues where the computer would lock up after a few hours of heavy GPU usage.  This was really starting to get on my nerves because I purchased 4 macs over the years I’d never experienced these issues ever before. (I still have my G5 from 2003 and its been my work horse, but that is why I got the iMac to finally replace it).

We’ll I was going to wait and see if the next build of OS X 10.5.3 would fix some of the issues.  However, on Monday I get an email from Apple telling me about their great new iMacs!  Damn it! I just purchased a new iMac, and I’m having issues with it and to rub it in my face they release a new one with a ton of upgrades and it’s only $80 more.

So now I’m really upset!  So I decided to call Apple Care and to see if they can do something about this iMac that’s not running as good as it should.  I’m expecting that I’m going to have a fight on my hands.

Ahh…..nope!  I call Apple Care and I actually get a person in less than 1 minute! (At its 1pm PST) I can’t tell you the last time I got anyone at Dell in under 30 minutes!  I tell the rep the problem I’m having and she tells me “no problem! Let’s see if we can get this resolved for you”.  She puts me on hold for a few minutes and comes back on the phone and tells me that she’s going to redirect my call to the sales department and they will get me a full refund.  So I talk to them and they tell me they are going to email me a fedex return code and when they receive the computer back I will get a full refund!

So that’s not even the best part.  I get the FedEx return code and I’m able to print out the label so that FedEx can come pick up the defective computer.  I then get another email from Apple with a $50 coupon off my next purchase! WOW! I never even asked for that and they they sent this to me for my problems.  Then around 8:00 at night I get a call from Apple (It went to voicemail)! Holy Crap! When have you ever had Dell call you back?  She tells me she wants to make this right.  She gives me a direct number to call them in the morning and to see if they can get me a new computer.

I call her back but it goes to voice mail. I leave my message.  2 hours later I get a call back from her and she offers to exchange the bad iMac that I’m sending back for a brand new one and they will wave the $80 difference.  She also tells me that I can still use my coupon later for anything I want from Apple!

Because the old Mac was already being sent back via FedEx, she immediately released the new iMac and changed the delivery from ground to over night  and it will be here tomorrow! (Which she did not have to do either!)

Apple fan or not, this is the BEST customer service I’ve EVER encountered!

If you’ve not joined the Apple family, and if this does not convince you why you should, nothing will!

This is one of many reasons I made the switch a few years ago and this is why I’m an Apple user for life!!

Apple
Technology
iMac
switch

Comments (7)

Permalink

AJAX Demystified Part 3 of 3

Part 1 of AJAX Demystified we discussed what is AJAX and gave a high level overview of how it all works.

Part 2 we discussed in more detail on how to use the xmlhttprequest object and how to dynamically load content onto the web page without the round trip. Part 3 we’ll get into some more detail that will give you a really good understanding on AJAX and its plumbing.

Opening the Request Object

The next line takes a bit of understanding. It takes three (3) arguments and depending on the arguments the outcome can vary greatly.

Open method Argument #1

. open(“GET”, sUrl, true);

Available input: GET or POST

Type: string

The first argument takes a string. It can be either “GET” or “POST”. A “POST” is usually used when you’re sending the server data such as a form submit. Since we’re not sending any data, it’s easier to use “GET”.

Open method Argument #2

.open(“GET”, sUrl, true);

Available input: a valid URL to the server page

Type: string

The second argument is the URL where to send the request. This is also a string. However it’s easier to create a variable beforehand with the sUrl variable. If the URL is not valid or it’s not pointing to the right location, the call will fail.

Our example we’re sending the request to a PHP page. However, we could have sent the request to any page that your server can understand. We could have used an asp.net page just as easily.

Open method Argument #3

.open(“GET”, sUrl, true);

Available input: true or false

Type: Boolean

The last argument tells the browser if we are sending the information asynchronously or not. If it’s set as true, then it’s set asynchronously. If it’s set to false, then the call is synchronous and will wait until the server returns with the response.

You may be asking yourself “why would I ever make a synchronous call?” There are several times where you don’t want the user to continue to use the application until the call is returned such as if the user submitted a transaction type of call. For example what if the page was allowing the user to submit an order? We would want to wait for the response before allowing them to continue.

Setting the Ready State of the Request Object

The next line is vital to making an asynchronous call.

requestObj.onreadystatechange = updateDateTime;

The onreadystatechange property needs to know what client side JavaScript function to call returning the response data from the server. This is the callback function. Without it we would have to wait until the response comes back from the server to continue. Remember the third argument of the open method needs to be set to true for this to properly work.

It’s vital that the onreadystatechange property is set before calling the send method of the request object. If not, the callback function can’t be called since the request object did not know until it was too late.

The last thing to remember is not to add the parentheses at the end of the function name when setting it to the onreadystatechange property. In JavaScript the updateDateTime would look like so:

function updateDateTime()

{

}

Sending the Request to the Server

The request object has been initialized, opened, set with what it needs to do, where to go get the information and what callback function to return the response. Now all that is left is to send the request.

requestObj.send(null);

Ok that seems simple enough but why are we sending a null? The reason is we are not sending any information to the server. The default then is to pass in a null object. A null is an empty value. We are sending nothing to the server because we are not required to pass any information.

The key to remember is that AJAX sends information to the server asynchronously and does not use the traditional form submit as we’ve done in the past. When the send method is called the user can continue working on the site. (However more than likely you should get a response almost instantly)

Nonetheless, if you’re having the server do a complex task that may take time, they are free to do other things with the page while waiting for the response back from the server. When the server is ready to send back the response, it makes the call to the callback function we setup with the onreadystatechange property of the request object.

HTML: Calling the request method

<BODY>

<H1>Get The Server’s Date and Time</H1>

<a href=”javascript: getServerDateTime()”>Make AJAX Call</a>

</BODY>

This is a very simple HTML body. All we have here is a header telling the user what the page is doing and a hyperlink.

One thing that you will notice with the hyperlink is that we are making a JavaScript call. It’s calling our AJAX function that will make a request to the server to get the server’s date and time.

We could have used a button or even a timer to go get the time of the server every X seconds. It doesn’t matter. However, notice that we are NOT using a form tag with a submit button. The JavaScript and the request object will handle all the request/response features that normally would have been done with the form tag.

HTML: Place holder for the Response from the server

<BODY>

<H1>Get The Server’s Date and Time</H1>

<a href=”javascript: getServerDateTime()”>Make AJAX Call</a>

</br>

<div id=”divDateTime”></div>

</BODY>

We added two (2) more lines of HTML. The first is a line break so that we have a space. The other is a div tag with an id of divDateTime. Notice that we have nothing in between the start and end of the div tag. We could have any text in there if we wanted to. When the server returns the current date and time, the date will be inserted between the start and end tags of divDateTime.

This is how we can update the HTML dynamically. Instead of a round trip with the entire HTML sent back again, only the server’s date will be sent. The browser’s callback function (that we set with the onreadystatechange property of the request object) is responsible for finding this tag and entering in the response from the server.

Server Side Code

<?php

$today =date(’l dS \of F Y h:i:s A’);

echo $today

?>

The PHP code above has a very simple task. It creates a date string and returns the response. Instead of sending back HTML like a PHP page normally would do, it sends back a fully formatted date.

If today’s date is Feb 22nd, 2007, it will return back Monday 22nd of February 2007 10:05 AM.

The PHP code could have been complex call like going to the database and retrieving information and then sending back a snippet of XML or HTML. We used this minimal snippet of code to show that it does not always have to be HTML or XML that it returns.

Handling the Callback function (Server’s Response)

After the server has completed receiving the request and is ready to return back a response, the callback function set up with the onreadystatechange property is called. The web browser handles this. It knows that the request object made the call and what function to call based on the callback that was setup.

function updateTime()
{

if (requestObj.readyState == 4)
{
var sNewServerDateTime = requestObj.responseText;
var elDivDateTime = document.getElementById(“divDateTime”);
elDivDateTime.innerHTML = “The Server’s current time is:”  +sNewServerDateTime;
}

}

Request readyState Property

Available output:

0 = Object not initialized

1 = Loading

2 = Loaded

3 = Interactive

4 = Complete

Type: Integer

The readyState property can be used to get the current state of the Request object. The return value that is important in the callback function is the value 4. The property returns that the request object has completed and we should be able to retrieve the response text returned from the server.

Request responseText Method

Available output: The response from the server

Type: String

Even though the readyState property has been set to Complete (4), we should have checked the status of the request object. If there was a problem the code should handle it. However for this sample we’re just going to assume that it worked.

(BTW you should never assume anything when writing real software! The only thing you should assume is that it could fail and should always check the state of any object you use)

If all is good we should have received the Date and Time Stamp value from the server. However this could have been a full set of HTML, XML or any data we wished to be returned to the user’s browser.

Document getElementById Method

This method is used to find an Element by its Id. We are looking for the element with the Id of “divDateTime”. If it’s found, we have a reference to the element.

innerHTML Method

The innerHTML method allows you to change the inner HTML of an element. We used the getElementById to find the div tag that we will use to dynamically show the server’s date and Time. This allows us to change the HTML of the page without reloading the entire page. Of course this was a very simple update, but it could have easily have been an entire HTML table of information.

Conclusion

The sample is very simple but it does show how easy it is to make an AJAX call and update the web page without having to update the entire page. Now that you have a better understanding of how AJAX works, you’ll have a good foundation to build upon

Check out the original PDF article I wrote over at Venice Consulting Group’s website.

PHP
ajax
javascript
ruby

Comments (1)

Permalink

Using Subversion Property feature to add Commit Comments

One of the features I remember using in Visual Source Safe was the ability to put in custom keywords within my comments that would automatically be updated each time I did a check-in. I thought this feature was not available in Subversion, but I was wrong!  Subversion uses Properties!

Subversion Properties

One of the features of Subversion is the ability to add your own Metadata to a file that goes along with the file each time it’s committed. Metadata can be changed for each commit and works the same way when your source code or document is committed.  Subversion provides it’s own set of properties.  One of the properties is  svn:keywords.

svn:keywords Property

svn:keywords property allows specific keywords to be replaced when ever commit to file happens.  This is great for leaving comments in your code that are updated each time a commit is done.  In our latest project we want to update the Author, the Revision Number and the URL (Branch, Trunk or Tag) on each committed.  This gives us a quick status of who last updated the file, what revision number was and where in the Repository.  Thinking now, we should add the date as well.

So how do you set SVN Properties?

There is a couple of ways. One way is to go into the config file on the server where the repository is located and make the pattern change there to use it. So each time a file of that pattern is added to the repository the svn:keywords property is added. By default this is turned off.

The other way is add the property to each file through TortoiseSVN.  This can be a pain if you have several files to do, but if you select all your files in your workspace, and then select the properties of the files, you are able to recursively add the property. However the drawback to this is that you need to add the property to any new files that you add to the repository.  Sometimes you don’t have access to the repository config file so this is the only way to do then.

Selecting Properties of a SVN file

Once you’ve selected the properties of the file(s), you’ll see Subversion tab within the file’s property sheet. Select the tab and click the Properties… button.

A property window opens where you can edit or select a new property for the file(s).

Here I have already set up the svn:keywords.  I have decided that for this file the only three (3) keyword values to replace are Author, URL and Rev.  If I wanted to add/remove values, highlight the Property and click the Edit.. button.

I can then add or remove the property values.  Currently there are five (5) values that svn:keywords will search and replace.

Author: The developer who last committed

Rev: The revision number when last committed

Date: The Date of when it was committed.

URL: the full URL to the latest version of the file in the repository.

Id: A combination of Author, Rev and Date

Once the keyword values for the svn:keywords property has been set to the file(s), subversion will look for these keywords and replace them with the information from the repository each time a commit happens.

Adding the Comment in your code that will be replaced by the svn:keywords

I’m doing this in C# but it really does not matter what programming language or file you are adding these keywords to.  As long as it starts and ends with a $

In mode code I added the following 2 comment lines (It could have also been on the same line)

Here you see I have // $Author$ , //$Rev$ and //$URL$

Now if I commit the file the keywords will be replaced with the following information:

The SVN Commit replaced the $Author$ with $Author: nhansen$.  If the next time someone else on the team commits the change, their name will show up here.

You can see that the revision number has jumped to 1290 when I commit some changes. (Several commits happened between when I first started working on this blog post)

This is a very cool feature of Subversion that happens to be hidden to most developers.  Many don’t even realize that they have this option available to them.  At Venice Consulting Group, we’ve begun using these new features on a few projects and I can say this has been a very positive experience so far.

If you have any other way of using the Subversion property feature, I’d love to hear them. Please add them to the comments section.

Technology
agile development
subversion

Comments (0)

Permalink

AJAX Demystified Part 2 of 3

Part 1 of AJAX Demystified we discussed what is AJAX and gave a high level overview of how it all works.

Part 2 we are going to get into more detail and actually show you some examples of how it all works.

No more reloading the page!
Let’s say we have a site that contains a list of all clients. We may have a search page that uses AJAX to select the clients from the list.

When the company name is entered we don’t want to reload the entire web page again. Instead we will make an AJAX call to retrieve the clients that match the search criteria. When the request comes back from the server, instead of reloading the page again, we only render the results under the search input area.

The way this all works is by updating the content of placed div tags within the HTML. We’ll get into the details in a second.
This image shows before the call is made and where we have the div tag placed

And after the callback is made back to the page:

AJAX: Do it yourself (DIY)

OK enough you say. Show us how to make an AJAX Call. That sounds fair. You could use one of the frameworks available, but I think to truly understand AJAX, you need to at least understand how to do it yourself without using a framework. Once you feel comfortable with this, I do suggest using one of the frameworks because the “heavy lifting” will be handled for you. By understanding the core of AJAX, I believe you will be less likely to make big mistakes with an AJAX framework.
There are a couple of things that I won’t cover while explaining how to use AJAX:
HTML: If you don’t understand the basics of HTML, this will be beyond your expertise. I would recommend getting a good handle of HTML first. I would recommend the Visual Start Guide.
JavaScript: I don’t expect you to be an expert, but you need to know some of the basics of the scripting language.
Document Object Model (DOM): I won’t go much into the DOM, but I will be using some of the DOM to find Elements of the HTML.
Server side Development. The example will use PHP for the server side. I will try to explain what is going on the back end. It’s not necessary to understand PHP, but if you’ve done any server side development, you’ll probably understand what is going on.

The Request Object (XMLHTTPRequest) – The core object of AJAX

Most modern browsers have the ability to do AJAX development through the request object. Without the request object we’re not able to do AJAX development. This request object is responsible for the calls between the browser and the server.
On the other hand I wish life was that simple. The JavaScript function will need to determine which version to use. Internet Explorer 6 requires the ActiveX request object, but the other browsers don’t understand ActiveX, so they require making use of XMLHTTPRequest object. The good news is that JavaScript has a nice feature: the try…catch exception handling commands. If the browser fails trying to create one, we can try initializing the request object with another call.
NOTE:
The actual name of the object is XMLHTTPRequest. To keep it simple I am going to call it the request object. This refers to the XMLHTTPRequest object in FireFox, Safari and Opera. If the browser is Microsoft’s Internet Explorer, then I am referring to the Msxml2.XMLHTTP or the Microsoft.XMLHTTP ActiveX Controls.
For this example let’s start by inserting some JavaScript into a normal HTML page. We’re going to create a JavaScript function called initRequest(). Add this in the HEAD Tag of the HTML
<head>
<title>My First AJAX App</title>
<script>
var requestObj = null;
function initRequest ()
{
try
{
requestObj = new XMLHttpRequest();
}
catch (failedNoramlRequest)
{
try
{
requestObj = new ActiveXObject(“Msxml2.XMLHTTP”);
}
catch (tryotherObject)
{
try
{
requestObj = new ActiveXObject(“Microsoft.XMLHTTP”);
}
catch (failed)
{
requestObj = null;
}
}
}
if (requestObj == null)
alert(“You’re browser does not support AJAX!”);
}
</script>
</head>
The first variable that is created is the request object outside of the function. This is a global variable. It’s global because we’ll be using the same object when receiving data back from the server in a different function. The function needs to initialize the request object. The correct XMLHttpRequest object needs to be initialized based on the user’s browser they are using.
If an exception is thrown, the code checks to see if it can use the Msxml2.XMLHTTP ActiveX control from Microsoft. (This object only works on Microsoft browsers running on Microsoft Windows) If that fails, then our last resort is to try the older Microsoft.XMLHTTP object.
Finally if the last exception is thrown, the user is out of luck! On the other hand this will be VERY unlikely. Their browser would have been several years old and probably could not use most of the websites created today. One solution you could offer is the ability to redirect them to the Molliza or Microsoft website to download the latest browser.

Calling the Request Object

Now that the function has created the Request object, it’s time to try it out and make a request to the server. Let’s start by creating a new JavaScript function that we will call from a hyperlink. Add the following code after the initRequest() function: (make sure it’s still within the script tag of the HTML Page.)
function getServerDateTime()
{
initRequest();
if (requestObj != null)
{
var sUrl = “ajax_getServerDateTime.php”;
requestObj.open(“GET”,sUrl,true);
requestObj.onreadystatechange = updateDateTime;
requestObj.send(null);
}
}
The first line in the function takes care of creating the new Request object.
If the request object is not null then the request object can be used. Next a variable is created that contains the URL string. The URL must point to the server page that will be receiving the request from the browser.
This concludes Part 2.
Part 3 wraps up our series on Ajax Demystified.

PHP
Technology
ajax
javascript
ruby

Comments (2)

Permalink

AJAX Demystified Part 1 of 3

What is AJAX?

If you think that AJAX is a cleaning product then you your reading the wrong article and you should stop immediately. However if the people you talk to on a regular basis keep using words like AJAX and web 2.0, then this article is for you.

The acronym AJAX stands for Asynchronous JavaScript And (+) XML.

OK…. But what does AJAX really mean?

AJAX has been described as way to build rich/dynamic Internet applications that are interactive and responsive. Rich and dynamic Web Sites and Internet Applications typically have one thing in common – they are heavy. Heavy in the sense that that entire rich content means larger downloads and slower performance for the end user. So, how does AJAX help to make sites more responsive? One of the primary ways is to render the page once and then update sections of the page without having to reload the entire page again. So now, with AJAX, every time a content element changes, we no longer have to reload the entire page, just that particular piece of content.

Where did the catch-phrase “AJAX” come from?

Back in early 2005, Jesse James Garrett came up with acronym AJAX. Looking back this is not the best acronym for the technology described but the Internet community adopted it and the rest is history. The irony of it all is Jesse did not mean for it be an acronym.

Do I have to know or use JavaScript to develop an AJAX App?

The short answer is no. There are many AJAX enabled languages/frameworks that require the developer to use little or no JavaScript. A few popular frameworks include Ruby on Rails, Microsoft’s ASP.NET AJAX 1.0, Sun’s Java and Adobe Flash. Each requires little or no knowledge of JavaScript to build an AJAX enabled web app. Most of the frameworks listed above create the JavaScript for you.

Nevertheless, if you don’t want to use a specific framework on the back end, then doing your own AJAX implementation gives you the greatest flexibility. The other possibility is to use a JavaScript framework that supports AJAX, one of the most popular being Prototype JS. In fact Ruby on Rails has integrated Prototype directly into its own framework. In our experience, using the Prototype framework still gives you the greatest flexibility without locking you to specific back end framework.

Do I have to use XML?

The XML part of AJAX acronym can be the most confusing part. At times you will use XML to send and receive data between the browser and the server, however most of the time you’ll probably be receiving HTML content and using the DOM (document object model) to update a specific section of the page. Don’t feel guilty if you’re not using XML, it’s not a requirement. This is another reason why AJAX is probably not the best name to describe the technology. You could create an entire AJAX enabled site and NEVER use XML!

Before AJAX we had the Postback! (Rinse and repeat)

Before AJAX enabled web applications, the process was simple:

A User’s browser makes a request to the Website.

The server receives the request.

The server processes the request and resends back the entire page.

A User’s browser receives the request and renders the HTML.

User enters some data, clicks a button or hyperlink and then sends the request back to the server.

Repeat the process.

However, there are a couple of problems with this approach:

The server is doing all the work. The server is sending the entire HTML of the page each time there is a request for the web page.

The amount of data sent back can be large and when it’s been sent back several times it compounds the problem.

The browser has to completely render the page each time it receives the content from the server.

The application does not feel responsive. You’re waiting for the server to give an update.

The site is not very interactive. If you don’t do anything with the page you’re not getting any feedback from the server.

When the first browser was created for rendering HTML, it was just that, a browser. New innovations were introduced for modern browsers (Fire Fox, Internet explorer 6+, Safari, and Opera) such as client side scripting languages (JavaScript, VBScript) and the availability of the Document Object Model (DOM). The average computer today and its browser are extremely powerful and are capable of doing more of the work that was traditionally done on the server side.

Finally, the number of potential people browsing your web application has increased and will continue to grow causing more work for your server(s). Reducing the workload by sending less content for each request, your web application will feel more responsive and will be capable of handling more users requesting content.

Let JavaScript and the browser do the talking!

Now let’s talk about the AJAX way. Instead of using the Form Tag to do the send requests to the server, we are going to use JavaScript to make the request. When the server sends back the information we use JavaScript to dynamically update the page without having to render the entire page all over again.

Another advantage is that the request is being made asynchronously (Hence the Asynchronous in AJAX).The user is still able to interact with the web application while the request is being made to the server. When the response from the server is returned to the browser, a call is made to a JavaScript function that handles the response. This is called a callback function. The advantage is that you’re not waiting around for updates to occur; this is what makes AJAX enabled web applications so powerful!

This concludes part 1 of 3 on Ajax Demystified.

Check out Part 2 where we go into more detail on how to actually write a simple AJAX app.

PHP
Technology
ajax
javascript
ruby

Comments (3)

Permalink

Need to Monitor your SVN projects? Use CommitMonitor

of those cool applications that I’ve found on the internet is a product call Commit Monitor.  It’s a great little tool that runs inside your task tray for Windows.  When ever a commit has happened you’ll be notified (based on the time you set to check the Repository)

This is very helpful for me as the CTO to know that the teams are actually committing their work and I can review each project without having to get a local copy on my machine.  This is also VERY helpful when your on a time and need to know if others on the team have committed any new changes that you may need to get to keep current.

Here is a screen shot of what it looks like. This is snapshot of one of our Servers that contains the current active projects we have going on at the time.  I have blacked out the names of the projects to protect the innocent.

This is the main screen for the application. On the left you can see all the repositories from a specific server. If you had other projects your working on from different servers, you could also add them there too. I have not seen a limation.  On the right pane, you have all the revisions, the date and the author of who checked in.

If you needed to get a diff on a what has changed, its just as easy as selecting the two revisions in the repository and clicking the show Diff.  If you have a specific Diff Program you like to use, simply select it in the options area of the application and it will use that tool.

When the application goes and checks to see if a anything is commited, you will see that that the icon on the tray is animating. (if you don’t like the animation you can also turn this off too.)

If you happen to be at the computer when the commit has changed, you’ll also hear a sound (same one as exchange so I had to change it because I thought I was getting email) and a message alert telling you the project, how many commits since you last checked the main screen for that repository, and the author who made the change.

To view the changes double click on the icon in the tray.  It will bring up the window that shows you all the projects your monitoring and any new updates since you last checked will be in bold with a number in parentheses telling you how many commits.

So that’s Commit Monitor in a nut shell. If think this tool would be as valuable as I have, download it and donate some money to the developer. I gave some money so if everyone did, we can support him to continue to make great tools like this one!

Technology
agile development
subversion

Comments (1)

Permalink

Want to see your youTube Videos in Higher Resolution?

One of the things that I don’t like about youtube sometimes is the quality of the video when it is encoded.   I have a HD camera and the quality is pretty good for the most part.  However when its encoded on youtube the quality goes south. 

The other day I was told about this trick you can do to watch your videos in higher resolution. I don’t know if this is a new feature coming soon and they don’t want to release it yet but it does work.

For example this video of mine

http://www.youtube.com/watch?v=V7y0Zt3X-zo
 
The titles are distored and hard to read.

however look at this

http://www.youtube.com/watch?v=V7y0Zt3X-zo&fmt=18

The quality is much better!

So append to the url &fmt=18 and you get the better resolution. I’m not sure how far back this will work on the videos but I have some video from May of 2007 that it works on.

You’ll also notice that there is a new icon that allows you to switch back and forth on the player. It only shows up when you add the &fmt=18

 

youtube

Comments (2)

Permalink

Apple replaced my iPhone with no questions asked

I’ve had my iPhone for about 8 months now and there was an issue with the side buttons on the phone that controlled the volumne and the mute.  They stopped working one day for reasons unknown. So I headed down to San Diego to the Apple store fearing the worst. I’d figure I’d have to fight to get them to fix it.  Well I got into the store, talked the Genious Bar dude.  He took a look, told me hold on a second and came out with a new iPhone and put my SIM chip into the new phone!  Wow. I thought they were going to send it in, I’d be out without a phone a while. Nope. Brand new phone!  Now that’s what I like.

I remember having an issue with my phone when I was with Sprint and they would find any excuse not to replace the phone. I had a minor scratch on the phone (normal wear and tear) and the guy said I must have damaged it on purpose so they are not going to replacement. My wife also had an issue and they would not replace it for free because they said she had split Coke on it.  WTF. She does not even drink Soda!  That is why the phone carriers should be very worried about Apple getting into their market because the days of screwing over the consumer are over.  Now the ultimate would be for them to get off of AT&T and become their own provider!! (one can only dream)

 

 

Apple
iPhone

Comments (0)

Permalink

VMWare Fusion Network settings to make a VM available on your network

There is a thread going on with Alexander Kazakov on my blog who asked me a question on how to use SQL Server in a VM from OSX using Ruby.  One change that you will need to make is the network settings for the Virtual Machine to allow the VM to be part of your local network.

The default is NAT.  Change it to Bridged (second selection).  Now the VM will be available from the host machine (OS X).  The VM will now be on your network, so make sure that its properly patched and all updates have been run.  This is really, really required if your using XP from a new install.  

This only works if your mac is on a switch or a router that is assigning an IP address. If your computer is connected directly to your DSL or Cable Modem your asking for trouble so make sure you have at least a router!!

 

Apple
OSX
VMWare

Comments (0)

Permalink

Vmware Products Rule! Both for Windows and OS X!

In the past, we’ve tried so hard to first use Microsoft products when available to fit a need.  However lately, we’ve come to realize that there are just some products that are better and worth taking a look at.  One of them is VMware.  We’ve been using Microsoft Virtual Server for over two years now.  Microsoft Virtual Server has worked OK, but its not been the best experience.

Recently when we moved our servers over to a new hosting provider and got ourselves 3 new 64 bit Servers with 8 gigs of RAM on each of them, we decided to use VMware Instead. All I can say is WOW, what a difference.  The configuration and performance has been outstanding.  Our development branch down in Mexico has also recently upgraded their servers to VMware too and based on my conversations with them also they love it better and can’t imagine switching back.

VMware FusionThis weekend I decided to give VMware Fusion for the Mac a shot on my iMac. In the past I’ve used Parallels and for the most part its been pretty good.  Last Month, one of my clients who happen to be using a Mac and run Windows in Virtualization mode suggested I give VMware Fusion a chance.  My iMac also has Boot camp installed and I’m running WIndows XP (Remember I switched back!).  VMWare has a great feature that I can use the native partition as a Virtual Image.  The performance has been excellent! I get the best of both worlds.  I can run in Virtual Mode while in OSX but still boot into Windows natively if I need to something like requires heavy use of the GPU.   It’s been extremely stable and I would suggest to anyone who is considering Virtualization on the Mac, to take a look at VMware Fusion instead of Parallels.

 

 

Apple
OSX
Technology
parallels

Comments (0)

Permalink

Akismet Rocks for catching Spam!

Caught Spam

Akismet has caught 52,258 spam for you since you first installed it.

You have no spam currently in the queue. Must be your lucky day. :)

 

If you blog and use word press (not sure why you would anything else), then you must make sure your using akismet!  This was been the best plug-in ever.  It’s amazing how many spam messages are sent to blogs now each day.  I think maybe 5 or 6 get through a month and when I tell akismet that its spam, I rarely see these spam messages again!

 

 

Technology
akismet
spam
wordpress

Comments (0)

Permalink

Tips for installing Subversion on Fedora Core OS 4

This week our company VCG leased a dedicate server that will run Fedora Core OS 4. We already have 4 dedicated Windows Servers for company tasks but there are some applications that require the use of a Unix/Linux server.

One of the tools we needed was Subversion (as far as I know you can’t run the subversion repositories on a Windows server).

I’ve compiled a few tips that should help with installing subversion on Fedora Core OS 4.

By default Apache server 2.0 should be installed. However one of the modules that may be missing is the mod_dav_svn module. mod_dav_svn module allows subversion to be used remotely through the webDAV protocol.

Install the mod_dav_svn Module

The easiest way to install the module was to use the yum tool.

yum install mod_dav_svn

Install Subversion

Next, install subversion by using the yum tool. (yum is our friend!)
yum install subversion

Now that you have subversion installed, the Apache server needs to be configured to use subversion remotely.

Configure Apache configuration file

With subversion installed and the required apache modules added, changes to the apache configuration file is required. The apache server’s configuration file is httpd.conf. It can be found at /etc/httpd/conf . (Some servers it maybe in a different location) The root user is required to edit the file. Fedora prohibits one from logging on the server remotely as the root user. However, after connecting the the server, the root user can be implemented.

Use the su - root command. You’ll need the root password of the server.

Since emacs was not install on the server, I used the always reliable vi editor to edit the httpd.conf file.

With your editor of choice, find the the load modules section and add the following:

LoadModule dav_svn_module modules/mod_dav_svn.so

Now let’s add the location section in the file to tell apache know where to find the subversion repositories
Add the following in httpd.conf file:

DAV svn SVNParentPath /home/username/svn/repo
AuthType Basic
AuthName "Subversion repository"
AuthUserFile /etc/svn-auth-file
Require valid-user

The SVNParentPath command allows for several repositories. All repositories need to be created under the repo folder in order for webDAV protocol to communicate with the repositories.

The AuthType Basic will require that the users to authenticate using basic authentication. The authentication is checked against a new file that we will create. (more on that in a sec.)

Create Auth User File to authenicate Subversion users

The next step is to create an authorization file for subversion. The passwords in this file needs to be encrypted. Use the htpasswd command.

htpasswd -cm /etc/svn-auth-file niels

htpassd creates a new file called svn-auth-file in the /etc folder. The -c option creates the file, -m uses MD5 encryption of the password. Once your run this command (Replace my name with yours),
it will ask you for password and a confirmation of the password.
To add another user, remove the -c option or it will recreate the file again and erase the previous user(s).

htpasswd -m /etc/svn-auth-file freddy

Creating the Subversion Repository

Creating the repository is really easy. I have the first repository in /home/[username]/svn/repo/test. Replace [username] of the one your going to use. The svn , repo and test folders will not be there, so create them using the mkdir command

Once the folders have been created, run the following command:

svnadmin create /home/[username]/svn/repo/test

If all is good, the required files for the subversion repository will be added to the test folder. (Remember to replace [username] with the name you are using.)

Setting repository permissions

One of the problems I had was the permissions to the svn repositories were not correct. Use the chown command

chown -R apache.apache /home/username/svn
This command will change the owner and group recursively to the apache user.

Now if all is good you’ll be able to browse the repository you created and be able to import a project succesfully to your new repository.
http://[nameofyourserver.com]/svn/test

The server should ask you for your credentials. Enter what you added to the svn-auth-file. Once entered, you should see the subversion root page with nothing in it. Use your subversion tool of choice to import a project.

That’s it. It you have any questions, please let a comment and I’ll see if I can help out.

Fedora
Technology
subversion

Comments (0)

Permalink