Configuration Version 2

This one goes back to my Configuration entry. Well, it turned out, 128 lines wasn't enough. See, when I write an XML document, I like to reuse tag names (see Element over at The W3), so, my old XML document of one line per object wouldn't cut it. The system would look up an object, but it will be a different type. For instance, I would use the "attribute" tag numerous times, but each time it means something else. One time it would mean the definition of an attribute, and another time it would mean "this attribute is the one that I want to use", or essentially, in as highly a technical way as I can describe it, something would reference an attribute that was previously created. Now, that one class that was 128 lines or whatever, is now 206. Still not a ton, and I wake up and thank God for letting me wake up one more day, and I also thank Him for recursion and reflection. Those are two of God's greatest gifts to any Computer Scientist. Each a gift in their own right, but get them together and that's how babies are born. It's SEXY.

Overall, here are the files and their line numbers in the Configuration Version 2 project:

Package voodoo.xmlconfig.domain :
ObjectMap.java : 7 lines
Package voodoo.xmlconfig.loader :
ConfigLoader.java : 104 lines
ConfigParser.java : 206 lines
Package voodoo.xmlconfig.nodes :
KeyNode.java : 12 lines
LookupNode.java : 45 lines
NodeMap.java : 47 lines
ObjNode.java : 125 lines
Package voodoo.xmlconfig :
Configuration.java : 39 lines

So there you have it. Sacrifices were made. Ideas were thrown around. XML parsing was ritually slaughtered. Never again. Woohoo.

There are some major features in this though, despite its brevity. When loading and looking up objects in a map at the same time, sometimes what you are looking up will not have been loaded into the map yet. I wrote my copy function to take care of this after the objects have been initialized and put into the map as basically blank objects. Copy then takes the actual values and loads them in. This is important because other objects already have a reference to the blank object, as opposed to the fully loaded object of the same type. This could cause problems in the future, but for my needs, it will serve the purpose. Another awesome feature is the ability to look up objects in a map in the first place! "I want to add a reference to this attribute to this object, but find it in this map under this key and this key." Sometimes, a map indexed with a key will reveal another map, so you can specify multiple keys. For my attribute, first, you look up the type, where many attributes can have the same type, then you look up the name in the resulting map of attributes with that type. This can be done infinitely.

Tune in next week. I just took my laptop out of its case for the first time in 2 weeks! I should be addicted to programming Java again in no time.

Awesome coding

Here's a function I just wrote that basically copies one object's data to another...

private void copy(Object src, Object dest) throws Exception {
  if (src.getClass().equals(dest.getClass())){
    Method []methods = src.getClass().getMethods();
    for (int i = 0; i < methods.length; i++){
      if (methods[i].getName().startsWith("get")){
        String setname = methods[i].getName().replaceFirst("get","set");
        Method setmethod = dest.getClass().getMethod(setname, new Class[]{methods[i].getReturnType()});

        Object value = methods[i].invoke(src,new Object[]{});
        Method clone = value.getClass().getDeclaredMethod("clone",new Class[]{});
        if (clone != null && clone.isAccessible()){
          value = clone.invoke(value,new Object[]{});
        }
        setmethod.invoke(dest,new Object[]{value});
      }
    }
  }
}


It's in Java, and it imports the java.lang.reflect package. It's wicked. Obviously not the most complete function. It could be in a BeanUtils class as a public static function. I could also specify whether or not I want "clone" to be used, instead of just checking if it's implemented and using it. One last thing, if the destination class is a subclass of the source class, it should still work, because the destination is guaranteed to have the same functions as the source in that case. This, of course, assumes that the objects are "beans".

State of the Interview Process

Now that I have a job and haven't started yet (won't until November 7th), I feel I can comment on the current interview process in the information technology industry. This is the same with all interviews I have been on. Maybe it's just my age, and that I'm still considered a "junior" developer, considering there are people that work at the places I've interviewed at that have 10+ years experience in the field of technology. I can give them respect for that, for being older, for being around more things, but I still really can't consider myself a "junior" developer. Experience-wise, yes, I have 4 years experience. But, knowledge-wise, I rank up there with at least an eight to ten year developer, just because I live and breath this stuff, and I'm writing software on my TIME OFF. Jeez :)

The interview process for every interview I've been on is the same. The interviewer mentions something in technology, perhaps a term used in Object Oriented Programming, or they ask you something about the language that you are being interviewed to program in, or whatever, and you are supposed to answer it in the best way you know how. Well, let me let those interviewers in on a little secret: Everyone asks the same questions. If you interview at one place and get something wrong, you're going to look it up and have an answer for the next place. Not that I ever mess up on any of their questions. I've always known the answer to "What's the difference between public, private, protected and internal?", but now it's more like I'm spitting it out from memory just from all the times I've been asked it. There are numerous other ones.

I agree, this is a quick way to weed out the people who have never done object oriented programming, and the other questions may weed out people inexperienced in other aspects of technology which are related to the question at hand, but how about this. Try to weed out people who haven't used those things and people who haven't developed anything even remotely difficult in their lives, on ONE question! My one professor in college said that most Computer Scientists, after working in the field for a number of years, couldn't write a working "Queue". Sure, it's no easy task, but we did it, learned the ins and outs, things to watch out for, etc. I have that extremely good memory, detailed in The Philosophy, Part I, so I'll never forget. Although, I did it in C++, now with fully object oriented languages, it should be a bit easier :) Not that you would ask someone to write a queue in an interview, but perhaps you would ask "You want to write a queue... which data structure would be easiest to use when writing a queue?" Somewhat open ended, yet extremely difficult, and you're really tapping the knowledge of your interviewee. You can use an array, keep the current positions as integers (beginning and end). A linked list would be simpler coding, as long as you have the linked list code already, although it's not an extremely difficult challenge to write a linked list (just give me a pad and a pencil, I'll code you a linked list!). Maybe you can ask "What can't you use?" on top of it. Surely, a tree based structure is useless. Easiest thing would be a linear list of some sort. That's a good question, and when I'm interviewing people in a few years, as long as writing code is still a profession, I'll remember that one. Other questions could be more pointed to the type of programming the interviewee might be undertaking if he or she were to be hired, like web programming, databases, web services, UI programming, etc.

I'm not here to tell interviewers how to do their jobs, but us interviewees who know what we're doing with the technology typically snicker under our breaths when asked "What is a dataset and how is it different from a data reader?" For those who don't know what they're doing, they can look up this answer and have it ready for their next interview. Even if their resume says they're the bomb but they're really not...

Another reason that I don't like this process is because I might not know everything that they ask at an interview (SHOCK!!). I might not know every single function that a "DataSet" has on it, every single type of constructor it has, or things of this nature. However, there is no need to ask a question like "You want to create a dataset from XML, how do you do this?" This also points back to The Philosophy, Part I. I explicitly point out that it doesn't matter if you know how to do something, it only matters if you know what something does. Or, in this case, if you know what something is capable of. Yes, you can create a DataSet from an XML document, but when have I ever needed to do this?! If I did ever need to do this, how in the world would I learn in the first place? By looking at a reference. If, for some reason, I never used that again, would it matter now that I don't remember the specific function to call, or would it matter more that I know that you can create a DataSet from an XML document, somehow? I certainly wouldn't think that I can create a Hashtable, or a bottle of beer, from an XML document.

I look forward to not going on any interviews again for a long time (crosses fingers after only having last job for 5 months).

Which came first?

This is a filler post. It's a play on the old riddle, "Which came first, the chicken or the egg?" It's computer science related, of course.

Which came first, the program or the compiler? It just baffles me, that before the first compiler, people had to type in machine code directly. The first compiler was made this way... it had to have been, right? It sort of has philosophical meaning behind it. The chicken would have had to have come first, but something made it, possibly building it up by hand. Because you can't have an egg without a chicken, how else would it get there? An egg doesn't just appear out of nowhere, but neither does a chicken... Theories point to some form of evolution or "intelligent design". It's a topic worth mentioning. One that I have no clear conclusion on. I tried to post on it a few weeks ago, did some research, and was unable to discount either. The more interesting argument is that of intelligent design. A compiler would have been made with intelligent design :) A supreme being, a computer scientist like me, designed the first compiler so other supreme beings could write software. Imagine a supreme being designing DNA, which is like machine code, and from a living creature comes the ability to make other living creatures. Is it science? Yes, that's what we call it. It's just whatever you happen to believe. I have come to no conclusion, though. The one site I visited, very much biased towards the God part, has a compelling argument. The chance that the Big Bang would have ended up with a part of it perfectly capable of allowing life is so small that believing that a supreme being started it all is actually the better bet. Imagine that. Those gullible scientists :)

Configuration

On Friday, I decided I was going to extend dumb to be able to read or write XML documents as data. Instead, I figured, with configuration, I should be able to write any document as I see fit, without worrying about whether or not dumb can read it. I decided to start a new project, and soon after, I finished it! It's along the lines of Jakarta Commons Configuration, although definitely not nearly as complex. It's just for XML configuration files following any scheme. Basically, I tell what a bunch of XML tags mean, and what class to load them as, and it reads my config files and loads objects from the xml, and makes them available by the xml tag name that are in my config files. This takes typically one line of XML for each type of object. It's simple.

I never read Jakarta Commons' Configuration code, so I didn't have a place to start. I only knew that I didn't want to read and parse XML using DOM. That type of processing, rather, the code for each type of XML document I can have, can be rather long. I had stuff written to read my latest XML documents, but I deleted it after I determined that my little configuration reader tool would do everything I need it to.

This falls under the laziness of a computer scientist, fully documented in The Philosophy, Part I. If I can write something to do something for me automatically, then by God I'm gonna do it. This one is particularly big, since I hate writing XML code every time. Really. I hate it, even in Java! This was the last time I have to do it for static configuration files. And when I update dumb to read and write XML databases, then I won't have to ever do it again. I can't wait, but that's a huge undertaking. I won't be doing it for at least a few months, or as need dictates.

Here's some sample xml (it reads an xml file to configure itself!! I know, it's ironic):

<obj type="map" spec="attributes" class="aproject.domain.attribute.AttributeMap" key="name" />

This says "When you come across the <attributes> tag, create a new AttributeMap and load that S$#@% in it". However, the "attributes" tag will have tags below it that also define objects or lists. So, each tag is defined in my config file, with a class, and can be loaded in, have properties set on it, and everything else. An object can have lists or properties, those objects can have lists or properties, so it's capable of some pretty complex stuff. My "ConfigParser" class, the one that reads all of the configuration files for your project, is only 128 lines though! A line in computer science is really nothing. It's one instruction. This is four of them:

public ConfigParser(NodeMap objs){
this.objs = objs;
map = new ObjectMap();
}


That's the constructor. Figure in blank lines, "import" declarations, and short lines like that, 128 lines is really nothing at all. And it WORKS!! Many thanks to recursion.

P.S. First game coming soon! Well, a LOT sooner than before I wrote this!

The Philosophy of Computer Science, Part I

Todd and I recently had a discussion where I described to him everything that I was working on currently, and my "dumb" system mentioned in the "Your Site Rules!" section. I had brought up my Philosophy of Computer Science. I couldn't explain it in such a good way though, so I will attempt to now.

I am a learner. When I'm done learning something, I go and learn more. I am not exceptionally brilliant, but apparently (or seemingly) I'm capable of absorbing huge amounts of data though. I take as long as the next person to learn something, but it sticks. My brain tends to tie things together logically, instead of memorizing something outright. So that I can remember small amounts of facts and deduce the outcome using them. I'm sure a lot of people do this. There are some that will memorize everything, but us lucky ones who can remember less but seem to memorize more, make more room in our brains for other small tidbits of information, making us seem exceptionally brilliant.

However, calculating an outcome each time you have to recall it is somewhat inefficient. It's very inefficient. When someone asks you how old you are, you don't calculate "well, I was born in 1979 and it's 2005, that makes me 26" every time... You just know that you're 26 or whatever age you happen to be. Or you lie to get into a bar or because you look younger than you are :)

Someone recently asked me "Why do you learn so many technologies, when you can be an absolute expert at one?" To me, this is an invalid perception of what I do. I don't learn any specific language. I spend a lot of time using Java instead of what I use for work, C# and .NET. When I was in college, the classes that I had made me realize the answer to this question. Not the "Programming Language Paradigms" class, or the "Organization of Programming Languages" class... these were Computer Science classes. I learned the answer to this question in my Philosophy classes. I took quite a few. My favorite one was "Logic". It made everything clear to me.

Computer science isn't "using computers to achieve a task". It's a connection of objects. Either different computers, different technologies, different objects in an Object Oriented Programming Language... different ideas with their own logic, connected together in a way that they all work as one beautiful system. Why I don't learn one specific language or technology is because you are then stuck in that technology. I happened to take jobs in only .NET in the past, so now I'm only able to get .NET jobs, which is part of why I don't learn one technology, but not the only or even most significant one. It's pretty insignificant, actually.

With many technologies in Computer Science, and by technology I mean anything in Computer Science, I find it more important to know what they do, rather than how they do it. Ok, here's an analogy. You learn how to use chainsaws, you don't learn how to use one specific chainsaw. By learning how to use chainsaws, as opposed to one specific chainsaw, you can use any chainsaw. Why should technologies be any different. Writing a website, or using sockets to connect to the internet, or zipping up files, or using a printer, or writing graphics libraries, or using rule engines, or a scripting language, etc. Knowing what something does is much more important than knowing how to use one of those things. Memorizing one language is bad, unlike my "I'm 26" analogy. Being able to deduct this information, based off of that little fact that you store (it's a programming language), is huge. So, when someone says "This is a programming language", I immediately know that it will contain features like input and output (I/O), ways to connect to the internet, something for printing, ways to create objects and inherit from them, interfaces, basic objects like ints, longs, floats, Strings, etc, a mechanism for threading and synchronizing data access, etc. It's a programming language, it's gotta have this stuff, and logically, I can deduce that. So, now all I have to do is sit down with a reference and a text editor, and I can write a program using that language that was introduced to me 3 minutes ago. As I said though, this isn't only to do with programming languages. Tell me what a technology does, I'll show you how to use it in a programming language. I will need a reference, but it just makes sense to me that you call certain functions in a certain order with certain parameters, and it works. Nothing more, nothing less.

So, this is my philosophy of Computer Science, Part I. I'll have more soon.

The Way of Google's Future

I came across an article in my favorite tech news site, ZDNet, that said Microsoft had predicted 10 years ago that the Internet is the next platform. But, Microsoft still spent bazillions of dollars making Windows XP and the new Windows Vista. Meanwhile, under Microsoft's radar, 2 Stanford students develop something in their dorm room, a search engine, and in 2005, they are big. HUGE. Google. With Google's way of innovation, and their ideas and having the top minds in the field (except they don't have me yet :p ), they are developing a lot of things, and they are not platform specific, but they are for the internet. Gmail, Maps, etc. They have more, and you'll see them by visiting their beta section. So, now Microsoft is feeling the heat. Without having a specific operating system, you can use any of Google's Internet products. Microsoft just wants to take over the world, so they will fight this, and start doing their own, or they just don't want Google to get too big, because then they can go stealing all their smart employees, paying them the big bucks, giving them the Presidential Suites, etc, and using them to develop products specifically targeting Microsoft products, instead of Microsoft doing it to them. The playing field is leveled a bit.

It's an interesting concept, the Internet as a platform. How I picture it, the possibilities are endless. Before I had that vision though, and before I read that article, I had pictured something a little different, something like Google's platform, the latest desktop search. Plug in components into a base platform, and the base provides a lot of the functionality that the components need, providing quicker development. Think of Mac's Widgets. There's a widget container that can provide lots of functionality to the widgets, and then there are widgets that you can plug in. I always imagined something like an application container. I could have small apps that plug in, and you can open any of them from this container. I had thought of this before Mac's widgets, but instead turned towards internet applications. My main reason for this thought process was because of how Java works. I didn't know if you could make a Java program automatically run by double clicking it, you always have to open them with another program. Of course, have everything run under one program. (I later found out about JNLP, Java Network Launch Protocol, which launches 'JAR' files containing a Java program)

Sometimes solutions are so obvious for one problem and they aren't even considered for another problem.

What wasn't obvious to me is that this idea had already been done! In fact, everyone is doing it! When you visit a website, you are typically using an application written for the web. An application. Written for the web. My container application, the platform for running every program I write, is in fact your web browser. This seems like a great platform. Some obvious aspects that you have to watch out for are backing up data, security, limitations of certain web browsers, certain web browsers not following web standards, downtime, scalability, application flow, user experience, and users. Some great benefits to web applications are deploying, updating everyone's version instantaneously, data stored in a central location, and if you secure the server, it's virtually unhackable... if you develop it to be that way. Having a client application obviously has its benefits. You can access local resources (disk drives) and do stuff that you can't do in a web application, like video games and accessing hardware, and stuff that would kill the resources on a web server if too many people did it at once... intense applications. Basically, it depends on the application, whether you should make it a client application or a web application, and whether you can make it a web application.

There aren't too many downsides to writing a web application, but they are pretty big downsides. There is another one. HTTP. HTTP is pretty primordial. HTTP is the protocol in which web servers communicate with the world. It consists of numbered codes and data separated by line breaks. It was developed before XML. However, XML has its obvious downsides. It's heavy, lots of text. Depending on your data, XML can double the size. It's mainly used for text, so you wouldn't normally go storing your images in there. I only bring this up because of client/server applications, or server to server communication, which still falls under client/server. This is why SOAP was invented. SOAP is an XML format that was developed for multiple applications, infinite applications, to send XML data over HTTP. A standardized format is a good start. HTTP can stay as it is, as long as everyone uses SOAP. This was the advent of web services; small applications written to run on the server and communicate with the client. Usually just a function or two. There's a huge history there (search the internet for RPC or "Remote Procedure Call", you'll see what I mean), and the idea was to make a standard way, rather than hundreds of developers fending for themselves, all writing a different way to call functions over the internet.

One of the important downsides I mentioned with writing web applications is user experience. This isn't about making users laugh or showing help or different messages. This is about "perceived speed" of an application. Who wants to watch a progress bar at the bottom of the screen? Or watch as the whole website goes white and takes a few seconds for something to pop up. In client side programming, you typically develop a multithreaded application to improve user experience. Things appear to happen simultaneously. However, these applications run on a web server, and the only protocol for speaking between the web browser and the server is HTTP, which makes requests only at the user's request (hence the name) and provides responses, how in the world do you expect to make an HTML web page seem "multithreaded"?!? AJAX. You may have heard of it. It's "asynchronous" using JavaScript and XML. That's pretty much what the acronym stands for. This way, I can have JavaScript make requests back to the server without the user's interaction, typically on a schedule (every 5 seconds, every minute, etc), and get that ever-so-desired perception of multi-threading in a web application, significantly improving a user's experience.

Google has realized this. Maps and Gmail use AJAX extensively. It is the way of the future, and it is important enough that soon every browser will have it. But this isn't just about writing a web application that appears friendly to the user. It's about writing many applications that are all friendly with each other, and that all appear friendly to the user.

Imagine an internet portal, a website that you go to as the first page you visit on the web. It has everything. News, stocks, your email, messages sent to your IM client that you missed, emails from other accounts you have, voice mails from work and from your cell phone, reminders about events in your calendar, and anything else you can think of. This is Google's vision... probably. Imagine having all this personal data on one website, collected from many different web applications, each using SOAP to communicate with each other, sending XML to the user's browser on each AJAX request, and reading all this personal data on the fly, determining which advertisements to show that user. Advertising is Google's main source of income still, besides selling stock.

"But Google's also buying up loads and loads of dark fiber and buying wireless internet technologies and WAPs" you say... Yes, they have invested in a company that can triangulate exactly where you are when you connect to a wireless network. So you can search for the closest guitar shop to the exact point on which you are standing. This on a portal full of all of that other information I mentioned would just be showing off.

This is where I think Google is heading. As with its search technology, I think the Internet can do better. I must emphasize this. I've mentioned this before, here. I think all of Google's web applications will supply their data this way. I quote myself:

"Imagine, if Google, instead of just reading all of the HTML through a website url, can just ask a website "Yo, what's your deal?!" and the website can respond back "Dude, I am a guitar shop, here are my wares.""

RDF is this for news. Somehow Google is able to extract prices of goods on websites as well, and build a shopping cart around them. But instead of Google just being able to search these results for items you may be looking for, what if there was no website that actually sold this stuff, but Google just read data from a server, through another protocol, and did everything: shopping cart, credit card processing, etc. Google would be the only online shop. Or, what if someone else did this. Like me! No, there's an "end of the world" scenario in there somewhere. No more online shops, just Google, and less jobs, and less money, and more Google. It could be bad, let's hope that they're only doing the portal mentioned above :)

Website Development Ceasing

Today, I have ceased development on this website. I will still be making news posts, uploading music, adding photos, etc, but I won't be making new features or even fixing bugs. I won't be able to! Actually, I will be able to, but just pretend I won't. I'll be "branching" the code used in this site, sort of backing it up if you will, rewriting all of it, hence breaking this website on my local machine. I will have backups though. There are a few things wrong with it.

First and foremost, I have ideas. Lots of ideas. I will be building a new site, called stringed.org which will just be a showcase of technology. This was explained before. If there is news on there, you might see posts like "Jason is t3h l33t" and just utter garbage like that. Come here for the real news :) It will just be test data, and it'll probably be open to the public, so you will also be able to log in, or just click an admin link, and edit things and input crap, just like I can! It'll be fun for everyone.

Second, I have ideas :) Ok, so that's the same as the first, but I have to reiterate the fact that these ideas could be life changing. You might be working for me or for one of the companies I will own in a few years, so you might want to respect these ideas. The future is easiest achieved in a non-persistent world. That's a cool quote that I just made up. You know all the movies about the future (most fresh in my mind is Minority Report) where everything is different. Buildings are futuristic, cars, houses, everything. We won't ever get there because it will just be too expensive to tear down a building and make it "futuristic". However, in software, it's very easy to tear something down and re-do it. Not for gigantic companies, but for us "hobbyist" software developers. True, I do it for a living too, but I do the hobby stuff more passionately :) That's because I only work on the cool stuff at home. I am doing cool stuff at work though that I haven't done anywhere. I'm rambling. Anyway, if I can just get a good idea in my head, like I have now, I can throw away most of what I have done and start fresh and build my idea. It might not be life-changing for everyone, but I'll get a kick out of it... :)

Third. I just always think things should have three points to them. Three is the magic number. But really, I'm someone who quickly bores of programming. If you've written one input screen, you've written a thousand. If you've updated one table in a database, you've updated a billion. Same thing with most tasks in programming. However, if you have written something to automatically generate SQL for you and update a database, then you don't have to write that thing again, and you never have to write SQL or anything to update the table AGAIN. I wondered when I got done writing "dumb", and still was doing repetitive tasks, like scheming a database out, building input pages, building output pages, building backing beans, etc, if it could all be automatically done for me. That is what I plan on figuring out with this new design. I will find an answer, and that answer will be the future :) For me anyway. I'll buy you a hoverboard when I'm there.

Website Woes

So, I'm trying to get my laptop ready for more development. As you may have read, I've installed Gentoo Linux on my laptop recently. This has turned out to be quite a learning experience. Gentoo is no self-installer. You end up learning a TON about Linux, boot loaders, file system, device drivers, configuring a kernel, compiling a kernel, setting up partitions for boot, swap, and system, mounting the system, and just about everything you can imagine. There is one thing I can't figure out though. Laptops have a touchpad for a mouse. Most of these touchpads are one brand, and that's Synaptics. Gentoo has drivers for these devices, and there are other drivers out there. I can't get it to work. The mouse part of it works, like basic movement and clicking, but mine also has a scroll "wheel", which is actually a touch scroller, and I can't get it to work. The thing is, when my system boots up, I can see that Linux has found the Synaptics touchpad, however, the drivers don't recognize it. It sucks because the reason I was so fast at working on that computer is because of the mouse setup. So that's keeping me from working on my website. I can work as it is, but I want my mouse damnit.

Another thing that's keeping me from working on my website is that my website isn't working on my computer. I set up MySQL and configured it, so that's not the problem. I can compile it in Eclipse, so that's not the problem. And Tomcat works fine. The problem is, Tomcat stopped development on the 5.0.x version and is only working on 5.5.x. The new version of Tomcat only works with the new version of Java, Java 5. I got all that to work fine. The thing is a software problem. When I run my website, the thing tells me it can't find this one function in this one Apache class. I know the problem, the new version of Tomcat uses new versions of Apache classes, and JavaServer Faces apparently uses an old, deprecated version. Or they're just completely different. For a new version of software to not support the old version is practically a bad enough crime to seek the death penalty. Apache knows this, so it leads me to believe that they are just different. I have the old version that JSF used to reference, and references for compiling, but I'm not about to overwrite the newer Tomcat's version with it. That screams bad news.

One last reason that I can't work on my website is because of video games. They're too fun.

Google is not a mini-OS

I ran across an article that called Google's new "Desktop Search" for Windows a "Mini Operating System". I posted a reply. When I think "Mini-OS", I certainly don't think of a program written to run on an operating system. When I think "Mini-OS", I'll tell you what I think: Embedded Linux. That's "mini" and that's an "OS".

So what does an operating system do exactly? The first and foremost job of an OS is to interface with the hardware; let you save files on disk, use your monitor, your modem, your attached peripherals like printers, digital cameras, webcams, and anything else. This includes interfacing with your network card and implementing the TCP/IP stack so you can connect to the internet. Also, it includes a "platform" for writing software, an Application Programming Interface (API). Lately, operating systems have included all types of goodies, like integrated search (Mac OS X) and widgets (Mac OS X). This is simply "value added" stuff. Since an operating system might come with these things built into them, it does not change the definition of an operating system. Even if adding "Mini" to the front of it makes your observations less serious, you still have "OS" at the end, invalidating your generalization. How about call it a "program". That's what I call it. A program that happens to search your files and have plugins for stuff like weather. I don't even use it and I know that it's not an operating system.

One comment came from Google.

--- "We're really trying to make this into a platform"
---- Nikhil Bhatla, product manager for Google Desktop.

That can be confusing. I'll have you know that Eclipse is called a platform. I don't boot my computer into the "Eclipse" OS, though. It's a Java editor. A very great one. What this person means is that they will be developing programs on top of it. Which is why Eclipse is called a platform, you can write PLUG-INS. Technology is so misunderstood.

I'm a stickler for technological phrases used in the right way. I'm sure doctors, architects, lawyers, and every other profession will get just as upset if you butcher their terminology. Like, if a man finds a person murdered in the alley, and calls the police and says "We have a grand theft auto here." I'm not the only one :)

Here's another thing about it. That site, "paidcontent.org", is apparently a pretty highly visited site, and one that is as qualified to interpret that Google quote as I am to interpret Shakespeare. They call Google Desktop a mini-OS. People who read that are going to just go ahead and agree, usually. Unless they study. And they'll make posts on their websites, and it's like that game we would play in 2nd grade. One person starts the chain by thinking of something to whisper, and it goes around til the last person, and the last person says what the message is. I don't care if it starts out as "An apple a day keeps the doctor away", it'll turn into something like "A quick brown fox jumped over the lazy dog." Somehow. Let's just call into question every term that every past computer scientist has defined. I've run across at least 3 sites that refer to that post, and also call it a "Mini-OS".

This is another problem with the internet. If the facts are right, it's a beautiful filtering process, eventually making its way to everyone. But if it's wrong, it's like cancer.

Overwhelmed

I'm going to clean my room today. It's not like there's food and wrappers and dirty plates all over the place, but there is a lot of computer stuff lying around, and soda cans. But, I look around and I'm like "F#@%#$@!!!" That's all I can mutter. But, then I just remember the definition of recursion

an expression such that each term is generated by repeating a particular mathematical operation

So, WTF in the WORLD does that have to do with cleaning my room? Simple. Well, let me break it down into a function.

int removeItem(Item[] items){
if (items.size() == 0) return 0;

items[items.size()-1].remove();
return removeItem(items);
}

As you can see, it's all about performing the same action, over and over again, but with a twist. Recursive functions call themselves. It's a very neat way to think when you're writing a program, and once you start to "think recursively", which I have to admit took me a few months in school, then you start to always think recursively, which is why I post this entry. So let's look at the program.

public void cleanRoom(){
Item[] items = ;/// get items from "Room" database
removeItem(items);
}

So, calling removeItem once will clean your entire room. Of course you could just have a "for loop":

for (int i = 0; i < items.size(); i++){
items[i].remove();
}

This gets into asynchronous access issues, array indexing issues, and everything that I just don't want to have to deal with when cleaning my room. You would have to reverse the loop, from items.size() to 0, and it's just too much thinking for something that shouldn't take much thinking at all. Grab item, throw it in trash bag. That's it. I'm not thinking any more than that. Thinking's stupid.

Thinking this way helps me to not feel overwhelmed. It's just one action, repeated over and over again, until the room is clean. And, the room will be clean when I cannot repeat the action any further, when there are no more items. Or when I'm passed out on my bed under a pile of computer game and parts boxes, and shoeboxes, coincidentally. That helps me as well as putting on my favorite tunes from Jimi Hendrix and Cracker. This is going to rule.

Hopefully you've learned a bit about recursion and computer programming, and how someone can think about this stuff all the time, except when they're trashed. Get it, trashed?! I kill me.

A Few Site Updates

For the last day and a half, I put some pretty major work into this website. However, the only parts you'll see are in the comments section, and now a News post can have multiple categories associated with it. The thing about the last one is it's not easy at all. You need a few things.

#1 Table structure
#2 Change all your code that uses just a Subject in the news table
#3 Create a dual select box (which I needed anyway)
#4 Create a data list control to list each subject associated with that news post underneath it.

Numbers 1 and 2 were simple, but time consuming. However, numbers 3 and 4, with a new technology and very little documentation out there to go on, can be particularly daunting tasks. In the end, the amount of code written was not at all proportional to the amount of time spent on it, but that's usually the case in Computer Science and programming. You think and think and think, then the easy work begins, unless of course you're using a technology that you aren't too familiar with, like JavaServer Faces. I've written web controls in the technology before. The menu control, for instance, and the calendar control. However, unlike the menu and calendar controls, the Dual Select list is an input control, and the Data List control is an interation control, neither of which I had developed in JSF, up until this weekend.

Here is what the dual select list looks like:



And here is the short amount of JSP code that writes out all of the categories under a news post.



Now the code to "plop" a dual select list onto a page



Simple.

Now I just have to go through all of my news posts and properly categorize them. I'd rather drink gravel.

Two Very Contradicting Ideas

Recently, I had two very contradicting ideas. Keeping in the moment and thoughts of wanting to create a very good website with as little programming as possible, I had one idea. But then, looking at every website out there, I had another idea. Judging by these very short preludes, the second idea would be more of a revolution. So let's start with the first one.

Going back to the second class I had in college on Computer Science, we learned about "templates" in C++. "Template" is an overused word. In C++ it was probably misused. The basic idea then was to be able to write a container class, like a linked list, and use the same code to hold any type of object, be it integers, characters, built in objects, or your own objects. Anything. Converting this idea to a website could prove to be interesting. But it would add confusion for explanation, because I will use the word "template" in a completely different meaning, perhaps its designed meaning. So imagine having a list, and being able to add calendar events, downloads, news posts, links, pictures, etc to it. The web adds a need for "forms". Input forms, output forms, perhaps list forms (when shown in a list, which columns to show), among any other imaginary forms. These just define how the object translates from a piece of data to a viewable form, and vice versa. You would potentially have mounds of data, all in a list, and any of those objects could be placed onto a web page, modified, searched, linked, etc. You would just define the templates, the forms for viewing, inputting, and listing these items.

I never heavily considered this idea, simply because that's not the best way to store data. Searching would be a nightmare, the list could potentially become gigantic, and it would just be really difficult to do anything special with it. It would need tons of programming, something I'm not up to do :) Then came my very contradicting idea that says data should not be in a list.

Thinking about my first idea, it seems very hard to manage. Imagine giving someone permission to edit one record. Imagine, if everything is in one list, showing just downloads, or downloads under "Home Movies". You would have to search all of the data inside each record. What a pain in the butt. This other idea, then, doesn't have to do with making the best web page with as little code as possible. It is completely unrelated, except for the fact that an actual list is a bad way of showing information. Everything is a list. When you read the newspaper, articles, whether you realize it or not, are sorted in an order, in this case, an order of categories, and then an order of what's most important, and what should show up on the front page. On my website, news posts are only sorted by date, and I only show the first 5 on the front page. Some of these posts are really just thoughts, and they should all be read, not just the first five. So, there must be some way of keeping everything in context. I've had a hard time describing this idea, even to myself, and have had an even harder time thinking about how to represent this idea in what would eventually become a web page.

Obviously, a list on a web page is meant for sequential ordering, which means sequential viewing, which translates to most of my posts not getting read. Taking these items out of a list and showing them in another way is the key. But how?

Neat Function I Wrote

Here's a neat function I wrote as part of the photo album part of the site. It takes an image, a width and height, and an output image and creates a thumbnail with size "width by height". I will add that no part of this was with aid :-) Except for the Java 1.4.2 API Specification and a little brain power and some memory about how to scale geometric objects...

public void writeThumbnail(ImageInputStream iis,int w, int h, ImageOutputStream ios) throws Exception {

BufferedImage img = ImageIO.read(iis);

BufferedImage tnail = null;

double sx,sy;
sx = ((double)w)/img.getWidth();
sy = ((double)h)/img.getHeight();

AffineTransform at = new AffineTransform();
at.setToScale(sx,sy);

AffineTransformOp xop = new AffineTransformOp(at,AffineTransformOp.TYPE_NEAREST_NEIGHBOR);

tnail = xop.createCompatibleDestImage(img,null);
tnail = xop.filter(img,tnail);

ImageIO.write(tnail,"JPEG",ios);

ios.close();
}


I should add that there is another function that takes two strings instead of Image streams, both full filenames. I could add one that takes just an input stream and output stream for both, not image input and output streams. That way you could potentially write a thumbnail over the internet :-P A practical example (I like practical) would be to enter a URL of an image on the internet and save a thumbnail of it on your computer.

[Update] Check out the much quicker load times on my album Trip to Lewes. If you've seen it before you'll know. The next step, per Doug's very angry suggestion, is to have some sort of easy image navigation system... We'll see if I want to do it.

[Final Update] I made the photo albums a little easier to navigate. I'm still stumped as to a good way to do it for this site. It goes along pretty well with how the rest of the site is laid out, so, I guess we'll hear from Doug about how I did :)

Programming Rocks

Today, I was trying to make a simple content management system, and one part of a CMS is to be able to put that content onto a menu so you can have it easily show up and look like it's part of your website. Well, I have a menu system that seems to work. So, do I build capability into the content management system to be able to use my menuing system or do I build the menu system to be able to add content to itself???

Well, keeping to my philosophy as of late (besides just reading Plato), I like the second option. Sure, why not have a way for a menu to add a content page to itself? Of course you ask, isn't that stupid? Well, yeah, unless you make it completely reusable. In other words, the menu system can add anything to itself, as long as it's a menu-able something or other. And to define something as menu-able, you basically have to say, ok, what things are needed in order to add something to a menu. Well, in my system, all you need are a page, some text to display, and maybe you want to be able to supply parameters, which are built into the menu system. Ok great.

So, in a file called menu-objects.xml, I can define menu-able objects and supply parameters for them.

There are a few more things needed for the database. You want to have a list of things that are menu-able that you already have in the database. So, the screen can popup and say "what do you want to add a menu item for?" and you pick, say "content", and then a list of the content will show up and you can select it, type in a menu title, pick the menu, pick where on the menu you want to put it, and it's done. These are all simple mouse clicks.

Why can't content add itself to a menu, you might ask? Well, what if I want to add a ton more stuff that can be menu-able. What if I want to make news menu-able? I don't want to have to rebuild news... content isn't the only thing that's potentially menu-able. Also, I built the menu to be swappable later if I wanted to make another one, or add new features, I can just inherit the previous menu, add new features if I want, and without too much work, there's a new menu up there. Plus, I just don't like things depending on other things. Why have content depend on a menu system? Why have news depend on a calendar? Just have each thing be self contained, that's what I always say.

This philosophy I realized when I built the calendar. Do I want to add code to each object that is "calendar-able"? Code that, as it is, already works for the most part? No way. The only thing is, should the calendar be able to exist without this notion of calendar-able objects? Absolutely. And besides just not having any objects listed. This calls for the notion of a very advanced mechanism. One that brings joy to my once joyless heart. Interfaces and abstraction.

So, I want a calendar to be just a calendar at one time, but later transform into this amazing thing that can get events from your database, plot them onto itself, and have it clickable so you can see those events. Well, the fact is that it can't. At compile time, it should know that it might have to deal with calendar-able objects. That's pretty much the nature of programming. The best solution though, is to have an interface for something called a CalendarableObject and another interface to supply these items, called CalendarEventSupplier. The beautiful thing is, you can create a NullCalendarEventSupplier, set it as the supplier in an xml file somewhere, and your calendar is now just a plain old calendar with no mapped events. However, create a DatabaseCalendarEventSupplier, and it's now transformed into something that makes calls to your database, gets events, and plots them onto the calendar.

I love programming.