Archive forICT

Analising and Unit Testing: A crusial part of development…or not

When I first started programming (started with Turbo Pascal and then Visual Basic), I realy enjoyed programming. It was a whole new world opening up for me. Whenever I needed a piece of software to make my life easier, I just sat down in front of the computer and started programming like crazy. VB was a sequential programming language where you could reuse functions by the use of modules, etc. It was fun to use and you could have a finished application within a few hours.

Then came the new hype, Object Oriented programming. The new hype, a new sherif in town. Offcourse when I started at college, we saw Java. I have to admit I had to get used to the idea of OO programming after being a sequental programmer for years. We also had a class where we learned how to analise our projects and manage them in a professional way. Put that class together with Java, and you had a few hours of sleep (if people even bothered coming to class). It was just so boring, I couldn’t see myself as a programmer. Having to analise everything into detail, and using unit tests to test your application, or even develop by the TDD method (Test Driven Development, witch means writing tests first, program later).

For my internship, I chose for the company AMI Semiconductor (now known as ON Semiconductor).  I had to develop some Testing tools for the Test Methodology Departement. After 4 months of intership, I still didn’t feel like developing. I didn’t have to analise everything (they where very loose on that mather), but Java just didn’t got my mojo running.

Then for some twisted reason, I stumbled into the world of web development. Using PHP, but mostly Ruby (On Rails), I wouldn’t change for anything else. I’m allready working for 8 months as an Information Architect, and I’m starting to realize, that the things they thought us about analising and unit testing wasn’t to let us fall asleep. Lately, I’m starting to realize that it is realy nessessary to have a good analisis before you start a project, and having some Unit tests wouldn’t be that bad.

I have finished a few projects at my day job as an Information Architect, and there are a few things that I would have done differently.  One of them would be to have a clearer view of the project. Not everything was analised, witch has become a real pain in the ass now. The client keeps on asking stuff that realy requires huge changes to the system. And after a few months, I realy want to put this project behind me. Second thing is to take some time to create tests. I start to believe they could realy help me keeping my code clean and bugfree.  Offcourse, that’s not only up to me. Some projects have a tight deadline, and a small budget, so the first things that get cut are analising time and time for unit testing (creating proper tests can take time, so they say…).

I still haven’t created a single test. But I have a new project comming up, witch I’m going to develop for Netronix  (my own company) .  And I can assure you, I will analise everything properly, not loosing the target of sight and even start to develop unit tests. This way,the project just can’t go bad and get sore. I don’t think I’m going to go for TDD (Test Driven Development), becouse I know I don’t have the discipline yet for doing that. But maybe in the future, when I get more experience, I’ll give it a shot.

So how about you other developers, do you take time to create unit tests and analise everything enough so you don’t lose focus on the goal? Maybe you guys can give me some pointers on how to write Unit Tests. I allready read some books, but having some practical advise would help me more out, then some theoretical rules.  My next personal project will be written on the Rails framework (sorry Symfony guys, but I think Rails will fit my needs better this time), so some Rails tips would even be better.

So when I can finish my project in success with a strong bataljon of unit test, I maybe can convince my boss to start creating unit tests for all our projects…well, I guess I’ll have to wait and see

Comments

Why I switched to Doctrine

As I said in my previous post, I would tell more about why I switched to Doctrine. I mainly started to think about the idea when I first heared that we were going to start a new project in Symfony at work. The lead developer decided to go for Doctrine ORM instead of Propel. So I wanted to know why go went for Doctrine. I allready knew that Doctrine is way faster then Propel 1.2 and it has more possibilities, but I just wanted to hear it from him. And I have to admit, he had good arguments.

The verbosity of the Doctine code is way better then Propel. The model mappings (in line of XML files or YAML) are bigger for Propel then for Doctrine, and in Doctrine you can do everything in PHP instead of using external files (consolidated code is a huge plus).

The API of Propel is also “time-consuming”. Check the following Propel code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
$c = new Criteria();
 
$cton1 = $c->getNewCriterion(AuthorPeer::FIRST_NAME, "Leo");
 
$cton2 = $c->getNewCriterion(AuthorPeer::LAST_NAME,
array("Tolstoy",  "Dostoevsky", "Bakhtin"), Criteria::IN);
 
$cton1->addOr($cton2);
 
// add to Criteria
 
$c->add($cton1);
 
$authors = AuthorPeer::doSelect($c);

with this Doctrine code:

1
2
3
4
5
$authors = $conn->query("
 
FROM Author a WHERE a.first_name = ? OR a.last_name IN ?
 
",array('Leo',array("Tolstoy", "Dostoevsky", "Bakhtin"));

Propel doesn’t support his own query definition language like Doctrine, so every query has to be done through time-consuming API calls (and Doctrine also supports a object oriented API, so it is available if you need it). But it gets a lot more uglier if you when you need associations and eager loading in your queries, what can be run smoothley in Doctrine.

Doctrine supports 3 types of inheritance that you find back in Hibernate, where Propel is only limited in single-table-inheritance. This can be very usefull in the implementation of complex systems.

Doctrine support a sort of mixins (this at the act_as_* plugins of ActiveRecord), in a language that doesn’t support mixins :) . Even think about the “event listeners” like the before_save etc methods in ActiveRecord. (long live Rails right )

Doctine even supports migrations, and in the near future, they even will have automatic migrations (change the model definition, run auto-migrate and the DB is updated).

Some other nice features are full text searching, query/result caching, magic finders ($table->findOneByName), etc.

Doctrine is build in a logical way, the pragmatic use of ActiveRecord mixed with the power of Hibernate.

So be honost, I someone would tell you all the above, wouldn’t you just make the switch immediately?!?

Comments (3)

Switching to Doctrine

This weekend, I decided to give Doctrine a shot. Since Propel is the default ORM layer, I never really looked at Doctrine before. But reading on the subject got me interested. Luckely their is allready a nice Doctrine plugin available for Symfony, so the switch went smooth, without any problems.

I have to admit, that I was losing my mind in the beginning. I had to get used to the new syntax, and all the new possibilities of Doctrine just blew me away.

I made a backup of a running project developed in Propel (1.2) and just started refactoring the schema and chaning the code. It’s been allmost 5 days, and I wouldn’t go back to Propel at all. Even for the 1.3 version (where people say that it is even faster then Doctrine) . There are plenty of reasons why to stick with or switch to Doctrine, and to be honest, even those slightly speed increases of Propel 1.3 just can’t compete with them.

For those that are still not sure, just check out the Doctrine Documentation. You will find everything you want,  with some nice examples. And for some implementations in Symfony, you can download a Doctrine version of Askeet somewhere on the forum (I know it helped me a bit).

The project is going along nicely. I can’t say mutch yet, but I’ll keep you informed when it is  allmost finished. Their is still a lot of work to do, but I’m getting their, and with the help of Symfony and Doctrine, it just can’t go wrong.

Well, it’s been getting late, and after spending 15 hours behind the computer, I want to spent a few hours before the tv screen to relax.

I’ll explain later in detail what made me switch to Doctrine. In the mean time, let me know what you think about Doctrine or Propel and why you are using that specific ORM.

Comments

Long live Active Scaffold

Since I started my new job, I had to learn Ruby On Rails in a real quick pace. My employer wanted to step up to the next level with the web applications the company developed. For that, they chose for Ruby On Rails, so offcourse, like I was the new kid in the house, I had to start learning it.

Ruby is a very nice language to code in. It is totaly OO and the application structure and implemented patterns like ActiveRecord and MVC are just to die for. Not that I stop working in PHP (on the contrary, when I start developing in Rails, I simultaniously started learning the PHP Symfony framework).

During my learning proces in Rails, I came in touch with Active Scaffold. A quick way to develop a CRUD interface that adapts itself to your DB schema. So whenever you add an attribute later on to your table, You’re CRUD interface will automatically change.

At the beginning I have to say, I was a bit scepticle. I was still learning Rails (and still am) and the whole Active Scaffold thing was just overwhelming. I found it hard to get things done the way I wanted, just out of ignorence.
But after working with Active Scaffold for 2 months, I have learned its true power. Active Scaffold is just configurable in every way you want.

We have a project running at the moment that is totaly build upon Active Scaffold. Every CRUD functionality is based on Active Scaffold, and believe me, we have done some wacky things with it.

So living with Active Scaffold has been a real treat. I couldn’t work without it anymore. You save a lot of time creating a nice interface (you can easaly edit the CRUD to fit your needs in any way you want). I would suggest it to any Rails developer out there.

Anyone of you ever used Active Scaffold? If not, do it right away and let me know if you like it :) . Even you readers who have used it and probably still do, share your experiance with me, maybe you know some tricks I have not yet hear about.

Comments

Cross-browser CSS

A few days ago, I had to finish up a new website. Nothing fancy and all that, just a basic, simple layout website. As usual, I developed the thing only viewing it in Firefox.  I thought it wouldn’t matter that mutch to other browsers since it was pritty basic. So after some nice work, I uploaded everything and let the client know his site was online.

After he must have viewed it, he let me know I forgot to post some pages. I didn’t understand what he was talking about, since I knew thos pages were available. So I mailed him back with some directions how to navigate too that page. He replyed he didn’t know what I was talking about.

And then it struck me. I realized I forgot to view the site first in IE6 en IE7. So I fired up IE6, and found no problem. That was pritty strange, since normally, it is allways IE6 that is b*tching the most with CSS layouts. So then I started IE7. And yes, their it was. I navigationbar has disapeared. For some reason, the navigation block was hidden underneath the the page content.

So I started reviewing my CSS code. Seemed like I have to enlarge my header and use less padding for the navigation bar. A small problem, that’s for sure, but it still took me almost 30minutes to figure out that was the problem.

I know that numeroes forum threads and other blogposts flame about the problem of css incompatibility between browsers. Well, I won’t becouse I don’t see any problem…
95 % of all CSS designs work alike under all none-IE browsers. The only browser that works his own way is IE, so it should be very simple for all internet users. Just kick IE out to the curb. Not only for the sake of those poor webdevelopers, but also to protect you from harm of mallware and virusses.

So do yourself a favor and download a browser like Firefox or Safari. This would make the internet a better place

Comments

What is a good developing platform?

I’m one of those guys that loves to switch between platform. One time, I just feel the need to use Linux, the other, I just run back to Windows. During those switches, I have experienced both sides through the development process of software and websites. But still I’m not so sure what platform fits my needs.

On Windows, everything is easy to install and configure. Click a few times and you are ready to go. I use some fairly popular developing tools. For PHP developing, I use Zend Studio. To testrun my PHP webapplications, I run WampServer. For Ruby On Rails, I chose Netbeans 6 with InstantRails to run them on. So thing run pritty smoothley.

On Linux on the other hand, you can run into a few problems if you run into missing dependencies. But still, that is easaly solved through yum on Fedora boxes. On linux I pritty mutch use Eclipse PDT for PHP developing and Netbeans for RoR. All those applications are run through a native install of Apache, PHP, MySQL, Mongrel, and RoR.

So it takes more time to get set under Linux. The thing I haven’t thought off is what the system performance is between the two. Windows XP is pritty fast, and with the comming of SP3, performance will increase. Linux is also pritty fast after some finetuning of the kernel. Probably even faster then XP when you finish up configuring your whole box.

So what platform is better? I just can’t choose, and I realy would love to finally stay with one system. There is even a third possiblity. I’m playing with the idea to buy a MacBook Pro. I never worked with a Mac before, but what I have hear of, it is pritty neat. The only thing I’m not sure of is if all the software I need is available on Mac. I like to use free software. I know that Zend isn’t free, but I need it for work, since we develop our webapplication online directly through FTP. And that is something that Eclipse and other development tools miss.

So maybe some of you readers can tell me your experience of the development platform you use, and all the pros and cons.
So don’t hesitate, and please do tell me :)

Comments

Google SEO and pagerank driving me nuts

Since I re-develoment my website, I started to think about search engine rankings and google pagerank. So during the development, I made sure that I had clean HTML, and made proper use of meta tags.

I’m still “developing” as we speak, since I need some strong texts to put on the site, but I can allready see more incoming visitors through Google Analytics. But the thing that is bothering me is the pagerank.

My frontpage has a pagerank of 3, but when I go to other pages, I get a pagerank n/a (not available). Now, having a pagerank 0 would make sence to me, but a n/a is just to weird.

I have read a lot these past days about SEO and pageranks, and I know it is calculated through the number of high quality backlinks, but still that doesn’t explain the n/a status. I rather would expect a 0.

The next thing I would like to achieve is to rank higher in google. Since I have some tuff keywords like webdesign, webapplications and hosting, I know it will be hard to do well, but I can’t seem to find myself in google now when I search on these words.

So rewriting my texts will be the first thing to do, but if anyone of you readers out there know other ways to score better, please do let me know. I’ll be very greatfull.

Comments

Next entries »