IDE vs Text Editor for Web

I see more and more people are starting to do web programming (including HTML, JavaScript, PHP/Perl) in kind of IDEs like Dreamwaver, Frontpage, Nvu and so on. It looks a bit weired for me. First of all coding in proper text editor (like Vim) gives you all kinds of features like text highlighting, tags auto completion, multi-file editing and so on. Second, while writing your code directly in editor you specify proper names of styles/classes/whatever from the beginning instead of your IDE assigning some stupid names like style1, id15 and similar and than you going over to correct them (or sometimes navigating through 100 GUI menus to change them or even leaving them like that). Third, you can write all-browsers-compatible code from the start instead of dropping elements here/there which will perfectly work in let’s say Internet Explorer and then trying understand what code was generated by IDE and adjust it. Finally, coding with text editors makes you think more and thus make better code then just letting things go as they done automatically and then correct a bunch of problems and not taking into consideration other bunch of problems because your IDE couldn’t do it well and you haven’t thought about it since you even haven’t seen the code.

Status update

It’s been a while since I last posted here and I don’t feel like posting something huge here this time, so here is just a short life update:

  • Wrote all college exams (4 of them):
    • Artificial Intelligence - this is the only exam I feel like I failed. The subject is really boring, the teaches does not seems to be confident in the topic, exams were prepared by other professor who is very good in subject and probably did not consider that (as I believe) we were taught not in the best way. In addition the class is kinda boring. As I have concluded - it is like maths for me, but while in maths I know that I am totally stupid, here you think for the whole semester that the class goes fine and at the end you find yourself unbelievable stupid.
    • Software Engineering - this one went fine. A class is very boring and implies a lot of bureaucracy related to IEEE standards, but I think I managed it quite good mostly because IEEE has a lot in common with ISO stuff which I know not that bad.
    • Computer Architecture and Organization - went very easy because the amount of information given was very limited and a lot of it came out of previously passed Digital Systems.
    • Object Oriented Programming (based on Java) - went pretty good as well due to some programming experience I have as well as familiarization with many programming languages. One more time proved to myself that Java is not what I like - Perl is the best.
  • Preparing for the next semester - need to pay quite an amount of money for the college but already have some options. Thanks to all people who help me in this matter.
  • Learning AJAX technology and have a post about it on configfun.com here.
  • Preparing for the visit to immigration :( Hate this part of being in Cyprus, but have no other ways yet.
  • Planning to go for skiing one day into Troodos where there is some snow already. Hopefully my skiing equipment will be delivered to Cyprus by a friend of mine who is now in Moscow.

Working on Nagios perl module

I am currently working on creating a perl module do deal with Nagios configuration. The existing Nagios-Object package is quite limited, outdated and not that fully implemented. I checked it up and decided to rewrite it using my way.

Currently I am using Class-Generate package to help me with creating classes for Nagios object definitions and I already managed to write a parser which takes a path of nagios main configuration file, finds all links to object definition files and parses all definitions. One’s parsed, the definitions are stored as objects with all accessorts/mutators available.

I am also implementing object linkage so that the relations of objects can be used easily. Currently most of the stuff is already working fine.

In addition I am planning to implement the write function so that it is possible to create problem text config files with object definitions. Also thinking on getting on status log parsing.

The idea behind is to create a web admin panel for Nagios and extend the functionality, plus maybe I will do a new web frontend for Nagios, since the one given is not that good (anymore). I already have some web stuff working (based on perl, Catalyst, CGI-FromBuilder and Template-Toolkit)

MySQL Backup Script

JRB Technology blog offers a script on how to backup a MySQL database. The described solution uses perl to call three commands:

@b1 = `mysqldump -h localhost -u mysql_username –password=mysql_password mysql_database > /path/to/put/mysql_database.sql`;@z1 = `zip -r -9 ~/path/to/mysql_database.zip ~/path/to/mysql_database.sql`;@d = `rm -f ~/path/to/mysql_database.sql`;

I have posted a comment directly to the origin blog with some (as I see it) improvements, but unfortunately the comment was deleted, so I will reproduce it here.

First of all I think that there is no need to create a temporarily SQL file with dump from the database and then zipping it. The zip command supports getting data from STDIN, so this way, instead of running 3 commands, only one is needed:

mysqldump -h hostname -u username –password=somepassword databasename | zip -9 mysql_database.zip

Then I offered to hide a password, since otherwise it is possible to see it by running the ps command under any user during script execution, and password will be seen in the arguments list. To hide a password, we can create a text file which is accessible only to us (chmod 600) and store a password string there, then modify the backup command accordingly:

mysqldump -h hostname -u username –password=`cat /path/to/securefile.txt` databasename | zip -9 mysql_database.zip

This way, even if someone will see that the password for accessing database is in the specified text file, it will be harder to get it, since file is readable only by owner user.

Finally, I would like comment a bit on Perl script itself, which author of the original script provides: first of all, I don’t see any point of using Perl here, since nothing, except for calling standard commands is done during execution. A plain bash script would do a job fine. Anyway, even if you prefer using Perl, I would strongly recommend using -w switch and use strict; statement (even in such simple script, it is just good to use this every time)

Java Stuff

I think I have already mentioned before that due to the Object Oriented Programming college class I have to play around Java now. I was assigned to do a project in Java and I decided to check what I can do there. Being more a perl guy, I have a faced a numerous problems with Java which I try to overcome in all possible ways. Here is what problems I have:

1. Static method declaration in abstract class. This really drives me crazy :(. I have a case where I really need to have static methods in abstract class (with implementation code inside) and I can not do it which causes me a lot of headache.

2. I am really missing an analog of perl keyword __PACKAGE__ in Java. This, sometimes also have to do with the first issue. For example I want to create an abstract class which defines the structure of a database table model, and this class should have static methods such as retrieveAll or search to return an array of objects of this class. Lets assume that I am allowed to have static methods in abstract classes and that I have a __PACKAGE__ option, then I would write something like this:

abstract public class DBModel extends DB {

abstract static private String dbTableName;

static public __PACKAGE__ retrieveAll () {

DB myDB = new DB();
myDB.query("SELECT id FROM " + dbTableName + "");

if (myDB.getResultCount() > 0) {
int i = 0;

__PACKAGE__ itemList[];
while (myDB.getResultSet().next()) {

itemList[i++] = __PACKAGE__ new( myDB.getResultSet().getInt(”id”) );
}
return itemList;

}

return null;
}
}

public class MCategories extends DBModel {

static private String dbTableName = “customers”;
}

Like this, all classes which extend DBModel would have a static method retrieveAll() which would retrieve a list of all items from the DB.

3. Declaration and assignment to a variable inside of if/while/whatever. Sometimes I just need to do something like this (using the above example):

if ((Object[] objectsList= MCategories.retrieveAll()) != null) {

// do something with objectsList[].
}

If you know some workarounds, please let me know.