Monday, February 8, 2010

Let the battle continue | ColdFusion vs PHP

I’ve read many many………..blogs from developers doing their comparisons between ColdFusion and PHP and while some do have really good points I personally think they all tend to attack basically the same subject almost every time. The subject in mind should be obvious if you’re a developer that must have working knowledge of multiple server-side languages under your belt, as I sure do. One day I could be developing in ColdFusion, the next PHP or even some classic ASP on rare occasions.

Before I go into it I must state that I could care less what language I will be programming in any day, any time. Give me a language I haven’t seen before and I will figure it out as because lets face it, they’re pretty much the same here and there but mostly there.

First off, the obvious, database stuff:
Every ColdFusion developer knows that making a connection to a database server and querying database records is as easy as cracking open that first beer. As for PHP it can be done also with ease. Only difference I see is that you keep your database connection settings somewhere on the server or in the site directory. The annoyance for PHP is querying some records. If you’re a noob to PHP, you might find it difficult but if you’ve done it a couple thousand times, it should be second nature but ColdFusion is of coarse better at doing database stuff.

Now for syntax stuff:
As for ColdFusion’s syntax, it’s similar to HTML and is suppose to be easier for developers to understand and sure sure, it is in fact easier to look at but that’s about it really. PHP syntax should be very familiar to any developer that has played with languages that contain the norm of curly brackets, concatenation, escape characters and echoing out your variable values and such. One thing that I think PHP might have up on ColdFusion in the syntax stuff is that a developer who is familiar with Java, JavaScript, C++ and even C# can easily have an understanding of the mark up. Not a huge thing mainly because ColdFusion has the cfscript tags that you can use if you prefer to code in the norm.

Storing an include into a variable:
I might get whined at for this one but PHP is definitely better at this. For PHP, all you do define your variable and put the path to your include into a string via the include() function and that’s it. As for ColdFusion, you use the cfsavecontent tag which is a bit much to be honest. Yea, I know, if your programming via custom functions you can include the file that way and call your method but that’s not the point I’m making here. Know matter what, PHP got this one.

Opening and closing tag stuff:
ColdFusion and PHP are the same here BUT their not. For ColdFusion, you can put all your code into the page without having to worry about opening or closing sections of code when you need to put in some CSS or HTML. Not the case here for PHP and it’s definitely annoying to look at a page and all you see are opening and closing PHP tags all over the place. ColdFusion got this one, no doubt.

Function argument stuff:
Sorry Cfer’s but I think PHP wins this one also. To include an argument into your functions via PHP, just toss them into your functions ($parentheses) and delimit them by a comma as norm. For ColdFusion, you use cfargument to include any arguments to the functions. One thing that ColdFusion’s cfargument tag does have is the ability to set the type of the argument as well as if the argument is required. You know what, think I’ll call this one a tie because they both have their goods and bads.

File upload stuff:
ColdFusion is a beast when it comes to file uploads for sure. Use the cffile tag and toss in some common logic and you’re golden. But for PHP you gotta write the file as temporary file, do common logic, then use the move_uploaded_file() function to do more logic. ColdFusion got this one without even thinking twice.

Image manipulation stuff:
This one might be a toss up but we’ll see. ColdFusion has a boat load of image functions already available without installing anything special. Just open the image via ColdFusion and start messing around with it. That’s about it really. PHP is kind of the same but with some things that may or may not create some headaches. To do some playing around with images via PHP you must have the GD library installed and in some cases I’ve seen this installed by default but it all depends on the server really. Once you have the GD library installed you can pretty much do the same thing you can do with ColdFusion, such as resize, flip, crop, draw and tons more. But for the sake of having less headaches, I’m gonna give this one to ColdFusion only because image manipulation is there already and there’s no need to install any junk.

Community stuff:
Whoooooaaaaa buddy does ColdFusion have this one in the bag, in fact two bags……….maybe three. The ColdFusion community is just badass to say the least. Ask a question about ColdFusion on Twitter and you’re flooded with responses. BUT ask a question about PHP and nada, nothing, not even a peep will come from it.

Other general stuff:
ColdFusion and PHP both have the normal functions that every language has such as creating and manipulating an array structure, zipping files up, executing .exe or unix binaries, error and exception handing, support for basically any database, a form of creating application wide variables and security functions for SQL Injection.

Let’s face it, every language has their annoyances even Microsoft’s beloved .NET, but all that matters is how you handle those annoyances, which is one of the main reasons why I love programming as much as I do. You get a job, you start that job, run into walls while working on the job, you figure out how to break the wall down and you get to raise you arms up in the air like you won a battle.

In my opinion and that’s all it is. Is that the community for any language should be willing to give each other a hand or even some solid knowledge about how to accomplish certain things especially to the newcomers and this is where ColdFusion definitely wins the battle.

- Pete

Monday, January 18, 2010

BWT Simple PHP Contact Form

Just got done putting together a very simple form available for download that I decided to call BWT Simple PHP Contact Form. Simple name for a simple script.

BWT Simple PHP Contact Form as the name states is a simple contact form that can be implemented into any website, on any server that is running PHP5+.

All form validation is check by the server and contains no JavaScript and is written in the form of Object Oriented Programming (OOP).

That's about it really.

Please feel free to download the script and give it a go.

Click here to download

- Pete

Saturday, January 16, 2010

Simple OOP Form with PHP

Let's face it, as a developer, you WILL have to do some playing with PHP. It's just a matter of time and if you can't stand the language, you're gonna have to just deal with it. As PHP is still one of the most widely used server-side languages today, it's juts best to learn the language, and learn it the right way.

Now, when I say the right way, I mean, by using programming best practices as stated in my last blog about UML, MVC and OOP. This blog is about OOP in general and why it is the best and cleanest way to program your applications.

Below is a very simple example of PHP OOP and forms:

The PHP the class:
class HelloClass
public function sayHello($obj)
echo $say_hello = "Hello there " . $this->hello_name;
return say_hello;

<form action="" name="hello_form" method="post">
Enter your name:<br/>
<input type="text" name="hello_name" value="" /><br/>
<input type="submit" name="hello_submit" value="Say Hello"/>
<input type="hidden" name="hello" value="true"/>

Define the objects:
$obj = new HelloClass;
$obj->hello_name = $_POST['hello_name'];
$obj->hello = $_POST['hello'];

The results:
Hello there "Name that was entered"
Ex: Hello there Pete

I know the code might be a bit messy on Blogger but feel free to download this example here.

- Pete

Friday, January 8, 2010

OOP, UML and MVC, What? and Why?

As a developer, there comes a time when you start to get deeper and deeper into learning new ways of writing and structuring your code. I've been doing TONS of research and playing around with some techniques that are of coarse well known but to be honest I'm not exactly sure who really uses them, at least and unfortunately many co-workers are quite clueless when it comes to these techniques.

The techniques that I am referring to are OOP (Object Oriented Programming), UML (Unified Modeling Language) and MVC (Model View Controller) which is basically a way to organize your stuff in a manner that you should already be doing in the first place.

First off, OOP. I can't be the only one that had a tad of trouble getting their foot into the door and actually understand what on earth this was and why it is so important when developing basically anything and everything from simple show a name applications to more complex applications where there are many functions firing off at the same time.

OOP is a beast and once you get it, you know because it hits you like a train, making you think, OMG I can do this and yes, yes I do understand it.

At first I began writing some functions thinking I was writing OOP even though all I was doing was creating a bunch of functions and firing a main function instead of creating any classes which means I was still technically writing procedural code, yucky.

But that one day came and I got hit by that train that made me say, Oh jeez I was doing this all wrong but thankfully I get it now and will continue to do it the right way.

Now for UML. This isn't exactly all that new to me in a sense because when I was handed a project I always always always created a simple diagram which included needed functions, database tables with row names, foreign keys and so on.

Thing is, I'm not sure anyone even uses this technique to build their applications and by all means if you do please let me know.

Finally MVC which let's be honest, you should be doing this technique no matter what because it makes sense. Like OOP, there are many developers that might have trouble understanding what this is and why they should really even bother with it. The truth is that you should and it helps greatly when applications start to get larger in scale and you need to scale your application with ease and ridden the possibilities of introducing big nasty bugs into them.

But what is MVC? It's simply a way to slice up the code for your application into sections that make sense. Model, View and Controller, which should be obvious of what they do but instead of me trying to explain it all, try reading the Wiki on it here...

Enough of my ramble, I plan on tossing up a few examples of some OOP concepts in some future blogs in a few different programming languages.

- Pete

Wednesday, December 30, 2009

Goals for 2010

Every year I make a list of goals to accomplish and lord knows that I have gotta try and do something because 2009 wasn't exactly a great year for myself.

5 Reasons 2009 sucked:
  1. Left a bad paying job for a relatively better paying job and went back to the bad paying job
  2. Lost 2 cars which led to trouble all over the place
  3. Lost a chance to work for a great company but lost that due to the economy
  4. Both brother in laws got into a bad car accident but thankfully survived
  5. Health insurance went up dramatically due to economy
5 Reasons 2009 kicked ass:
  1. Saved a ton of money to help get out of debt
  2. Took a trip to the Carolina's to meet gf's grandparents and see brother in law
  3. Went to first developer conference. Was awesome!
  4. Bought a newer car
  5. Finally got my laptop after saving for way too long
Goals for 2010 (not in any specific order):
  1. Secure a position with a company that pays their developers more then Walmart
  2. Continue to learn the languages that I have been studying
  3. Get a car that doesn't need it's oil checked ever other day
  4. Work harder at getting freelance service known
  5. Complete CMS Leo project
  6. Get married to my fiance of 13 years.
  7. Buy a house, buy a house buy a house
  8. Learn to relax a bit more and less stressed out
  9. Somewhere in there I'll also try and find time to drop a few pounds
My fiance was told to burn a certain candle for good luck in the following year and she did. Hopefully this will FINALLY be our year to succeed and accomplish what we've been trying for many years now.

- Pete

Tuesday, December 29, 2009

Get those images out of PowerPoint

Every now and then as a developer you get handed a disk or and email sent to you and someone says, here are those images that you need for the bla ba bliche project.

Problem is that once you toss the disk into the drive or open the email to get the files, all you see is a damn PowerPoint presentation. You may think at first that you're gonna have to save each image individually and before you even try to do something as silly as that give this little trick a go and see how you make out. It just may save you an hour or two or more of nonsense.

  1. Get Open Office here and install that badboy once it's done downloading.
  2. Open the PowerPoint file with Open Office.
  3. Save the file as ODF Presentation .odp
  4. Now give the file a new extension of .zip
  5. You should now see a zip file, so how about we open it.
  6. Extract all the files in the zip file or just the Pictures directory.
  7. Your photos should now be available to you in the Pictures directory.
Hope this works for you as it did for me. Found this out just by messing around trying to get some images from out of PowerPoint without saving them one by one.

- Pete

Sunday, December 27, 2009

Love of a new language

More than recently I've been having a go with the Python programming language and must admit that I absolutely love the language and now that I received Programming in Python 3 by Mark Summerfield I feel that I can go full force into learning this wonderful language that doesn't seem to be going anywhere, anytime soon.

When I first heard about the Python language I remember watching a tutorial on YouTube where a Googler rambled on about some real intense programming stuff with Python and of coarse I had no clue what he was talking about at first. Of coarse this was before I started to dive into the OOP club and might not have even completed my first year of hands on experience and still writing procedural code.

Once I started getting the general idea about how to do the OOP thing I began to get more and more curious about other programming languages and thought it might be a good time to do a bit of fiddling with Python since it seems to be a very popular and unique language.

The syntax is very easy to read and understand and actually takes less code in some cases compared to other languages such as PHP, Java and C#, for instance:

PHP, C# and Java - if(apples == "nom nom nom") { // do other stuff }
Python - if apples == "nom nom nom"

And of coarse the data type thing that needs to be done in some languages, but not in Python, no need to define your data types there.

Basically, you can do anything and everything with the Python language that you can do with all the others with the possibility to write less code along the way also. Now, don't get me wrong, I don't have a care in the world how much code I gotta write but sometimes certain things just click and the Python language is doing just that with my brain at the moment.

P.S. - Thanks for reading this ramble and I am VERY aware that it's not at all informative :^)

- Pete