05 December, 2008

New Projects & Version Control Systems

It has been over a month and a half since my last entry and I apologise for the delay. I have been working tirelessly to finish up my primary design, development, implementation and maintenance functions on what has been my primary project for the past thirteen months. I've been doing this so that I may jump head first into my next project, which while not being a 'huge' undertaking is big enough. By big enough I mean that doing well at the project will land me the role of redesigning a major site from the ground up into the Django framework.

For the past 13 months I've been working heavily in the world of Django and find myself absolutely enamoured with it. I have designed a considerable amount of applications for Django, though none of them are released to the world because they are the product of a contract. My field of expertise was never in that of online applications and/or frameworks so it is stil a new world for me (if we exclude the nine years running a twelve line bulletin board system on a heavily modified Amiga).

I've always been happiest working in middleware and engineering backend systems, though I have to say that I'm finding a certain level of pleasure from the results of my front-end work. When i wrote backend systems, the only others who could appreciate said system(s) other than myself, were developers privy to the project. On frontend systems, there are actual users who I would like to think 'benefit' from my designs and implementations. It is nice to know from actual users that your work is appreciated. Call it ego stroking, or call it what you will but I find that it does inspire one to keep pressing on regardless. I happy to be doing these projects and as soon as it is launched, I'll be happy to post about it here.

This brings me onto the second purpose of this entry, my new favourite version control system. In the beginning of my experience using version control systems back in the 1990's, I simply used CVS like the rest of the world (sans those lucky enough to use Perforce). As time and technologies advanced to newer and better systems, I followed along and moved up to Subversion. Subversion was a well done upgrade for CVS users and easy enough for the uninitiated to learn. I used this most recently when I did work for Curlington Boat Factory (name changed to project myself) writing their point-of-sale returns authorisation/queue system in Python for four hundred some odd cash registers. This worked our quite well despite the fact that the software house for whom my partner (at the time) and I were contracting weren't able to provide the subversion server on their machines until we were 7/8ths of the way through said project. We ended up (very early on mind you) taking matters into our own hands and setting up on my partner's server at his apartment. This wasn't looked upon highly by said software house, but any CVS on any server regardless of not being in control of the software house was far better than no source control at all.

Next we come to my brief stint working for a OCD kid who started his business at the right time with mom and dad's money, but due to poor decisions on his behalf watched it dwindle in popularity, further plagued by poor management and attempts to treat a small business as if it were a conglomerate thereby sealing its fate with a tender kiss on its cheek. I thankfully left the company before the owner went psycho and let go of all the talent in a horribly vicious manner. Before all of that ugliness transpired, I went forward with trying the newest and brightest trend in distributed version control. I am speaking of the one and only 'Git', championed by a certain arrogant (albeit brilliant) Finnish kernel programmer. There was an immediate joy in using Git and I have to say that most striking feature is the blazing speed when dealing with a large quantity of files. I established all of the existing software base for said company (over ten years worth) into its first repository, utilising Git. Yes, for over ten years, there was no VCS in place. Git really did shine in this role, though I am pretty sure that due to myself and the system administrator not longer being there, cob webs must be forming in the places where Git once speedily did its work.

Let us fast forward to my newest discovery (if you can actually call it one as such). On this newest project which I just started today full time, I have been doing administrative setup work for the past few weeks on and off in small gaps of time as they availed themselves to me. The normal deal of establishing a dedicated server on a FreeBSD host (as Linux just will not cut it for me even though I've been using it since kernel v0.99d), along with all the necessary bits. Once the development languages, utilities, database and web servers were in place the issue of VCS came into play. For this time around I decided that Git, while great for many projects doesn't seem as pythonic a package as I'd like. Using Python long enough really makes one desire beauty, power, simplicity and consistency in all of their tools. This brings us to the most pythonic vcs of them all, Mercurial (known simply by its periodic table element, Hg). Mercurial, like Git is also a distributed version (revision) control system. Easy to setup, easy to use and highly recommended. I'm not going to wax poetic about the differences between these systems as they all serve a purpose. What I will do is state very clearly that Mercurial feels the most natural, works rather well and is quick at what it does. Your mileage may vary.

Until next time...

16 October, 2008

Django Projects Galore and Vile Ethics of other Coding Firms..

It has happened yet again. I've been brought on for another Django project. This time it is about taking an existing site for yet another magazine publisher and converting their Wordpress driven site into a real full-blown site complete with blogs, forums, user profiles, dynamic main page content, complete customisation from within the framework and included applications and ultimately a site in which a developer is not needed for day to day changes.

As it exists, this publication is an off shoot of their primary magazine. A magazine whose website was written and managed by an outside from that I believe coded the entire site so as to require additional invoicing and servicing for all but the most minute changes. This is a disgusting business model and one with which I've had the misfortune of experiencing whilst working as a sub-contractor to a sub-contractor for Burlington Coat Factory.

The H-1B Visa Project Manager who wasn't too fond of me because I don't believe that coding in dress attire and/or a tie makes someone a better worker (to the contrary, i will NOT wear dress attire for day to day work as it is a pointless expression of old brick-and-mortar mindsets). He also was the first time that I was reprimanded for having an eloquent solution that adapted automatically to the growth needs of the end-clients database/system. I wrote the software to handle dynamically gathering and sequencing additional 'like' fields as they were added to Burlington's transaction schema. The way I designed and wrote the software, the MOMENT the schema changed, my software contributions would immediately include relevant changes, without a restart of any of the daemons I engineered. I was told that the reason why i shouldn't have done this is because the sub-contractor for which i was writing this code could then go back and charge an exorbitant amount of money each time minor changes were made. This disgusts me, and I find it ethically wrong.

I am an engineer and work independently by choice as I can first and foremost hold myself and solutions I produce, to higher standards; delivering what my clients want and need, not solely based upon what they say they want and most definitely not building them into a corner for profit over common decency and professional standards.

Once the project has been completed, I will be quite happy to share the url(s) with CodeDEVL readers.

10 September, 2008

Django 1.0 has been Released, Film at 23:00.

I know that it has been a while since I have last posted, but I'm not one to post meaningless empty ramblings on a regular basis. I just want people to know that I'm still alive and will still be posting when I have something worthy of your time.

I will mention in brief that Django v1.0 has been released and we are all thankful to BDFL's Adrian Holovaty and Jacob Kaplan-Moss for their amazing efforts in making this release come to fruition. I would also like to add that the biggest 'gotcha' between .96.x and 1.0 is in the standardisation of certain db api arguments. maxlength has become (more aptly) max_length. There is also now a DecimalField type which can be used rather than the less accurate (for monentary purposes) FloatField. Read all about it at the Django Website.

Finally, for those interested, I have also started another non-computer related blog over at Bucks Bicycling, a site related to vehicular, commuter, recreational and sport cycling. I'm currently working on a fixed gear conversion of an old cheapie AMF Roadmaster Scorcher as well as a 1985 Schwinn Sprint road bike.

I will be posting shortly pending upon the official status of the newest Django 1.0 based project on which I've been secretly working.

Till then..


18 July, 2008

In defence of the lone coder archetype

All too often these days we see companies and methodology evangelists touting the system du jour whether it be Extreme Programming (XP/Pair Programming), or Agile as being the "One True Path" to coding enlightenment. All other be damned is roughly what said mantra translates to in common speak. We're told to beware the engineer who works alone in a dark back room for weeks on end. We're told to such a thing is heresy against the gods of modern application development.
We're being lied to by the methodology evangelists. I'm not here to down speak any of the other methodologies currently in use for software development. I am here, however to point out the benefits of the 'lone engineer' (not to be confused with the lone gunman). Lets set a few things straight though.
A coder with little to no professional experience in the field is not the optimal individual for this kind of setup. This is more for a seasoned professional who has at least been a team lead on several projects from conception through maintenance phases. I'm not saying it isn't possible to pull it off without significant experience, but I wouldn't place bets on such an individual succeeding at the whole task at hand in said company.
This kind of environment requires a disciplined engineer. We're talking about someone who knows the questions to ask, and how to dig deep to find the true needs of the client(s). This also means that the engineer needs to stand his/her ground when it comes to setting a solid schedule for phases of the project(s). There is room for variability in terms of time frames for each phase, but that the plan must be laid out in a linear fashion. This is engineering after all, and one doesn't plan to build the rooms before the foundation is laid.
Agile methodologies are more akin (though not parallel to) modular housing construction. Individual sections or units can be build simultaneous and changed (to a certain extent) by separate sub-teams. Whereas the lone engineer mentality is more akin to traditional construction in which the design is finalised, the foundation is laid and construction occurs in layers from the bottom up with customisations being generally last.
This isn't to imply that software built in this manner cannot change or adapt in a timely manner, far from it. Seasoned engineers/developers understand that the only true constant is change. We constantly work on new ways in which to design flexibility and mutability into our systems regardless of the specifics. This however just goes back to one of my earlier points in that this requires someone who isn't wet behind their ears. You can only know and plan for the unexpected via flexible designs after having cut your teeth in real world projects, and by faltering. Everyone makes mistakes, and it is through these mistakes that we grow and better ourselves. I'm not implying that senior level engineers don't make mistakes, I'm just pointing out that their success to failure ratio is pretty strong in favour of the success side.
One of the key benefits of the lone engineer methodology is that focus can remain solid with no deviation due to intra-coder/intra-team conflicts. And while this can at teams be a negative, overall it proves itself beneficial towards the ultimate goal, a finished software package/eco-system designed from the ground up to benefit the requisitioner(s)/client(s).
The issues of coding standards still must be kept, however there is definite consistency when only one individual is involved. This is also a liability as said engineer must have strict standards, commentary and documentation from beginning to end so that in case of any situation rending the engineer on the project incapacitated in any form, another could come in and continue with minimal delay. These are issues which affect other methodologies, some more than others.
There are downsides as well though. There are no direct peers upon which one can depend in times of need or collaboration. There are no peers to assist in code review sessions, meaning that the QA of any project must be proficient at testing, and enforce strict recursion testing when any changes are made to a product in production as QA becomes that final line of defence against human error. The reality is, no usable (as in serves a real purpose) piece of software is bug free and to think otherwise is the sign of a fool. What is realistic is having a system robust to handle errors when they occur, even if that is infinitesimally infrequent.
I'm getting off track here. My point is that in this newer, more extreme era in which coding fundamentalists believe they possess the one-true-way of coding and all others be damned, we must step back and realise the grave miscalculation they are making so boldly. After all, those methodologies weren't what were utilised to get us where we are today, nor were they even thought of when some of the staples of our art were invented. This doesn't mean that the next great piece of software or language won't be produced in such a manner, as it/they may. It means that we as professionals shouldn't be so narrow minded with tunnel vision when approaching different methodologies in an attempt to find which works best for the project/company/industry at hand.

26 June, 2008

SimulaE Cartography Program - simulae-kaart.py

As a quick follow up to the previous entry regarding rooms being a void and not an object, I can happily announce that the first working alpha of simulae-kaart has been committed to code this evening.

The function of this bit of code is simple:  Produce the necessary wall/barrier objects needed to create the voidspaces we call rooms.

The current working codebase does the following already:

* Allow graphical design in a 2d environment utilising unicode representative tokens.
* Returns Multidimensional Lists designating literal start & end points of wall objects
* Allows for walls in traditional cardinal orientation (north-south, east-west, nw-se & ne-sw)
* Also allows for arbitrary wall/barrier positioning at any angle (true 360 degrees).
* Default scale based on cubic decimetres, variable scaling coming soon.

Upcoming functionality to be added:

- Auto population of a given map grid
- Auto insertion of portal objects inside any giveen barrier/wall object.
- Automatic map scaling down to the smallest micro and largest macro levels

Stay tuned for further information.  If anyone else is interested in signing up for future beta
testing, I can be reached at this domain, under the email account of eric. 

-e

05 June, 2008

Simulae3 Update: Room Object? What ever do you mean?

This is just a simple, quick update to let it be known that the issue pertaining to how to accurately represent a room in Simulae3 has been resolved.  I spent about an hour with a blank book of graph paper and pen poised in my hand and thought about the problem till the following realisation hit me:

Rooms are an abstract, a void.  They only exist as a concept without substance to us.  They are the empty space created by barriers, some of those barriers contain portal objects (e.g. windows, doors, openings).  It is using this logic that the next piece of Simulae3 can be designed.  

SimulaeKaart.py

A simple cartography-based program (kaart) being the word for map in Nederlands (Dutch).  Physical space will be represented in 10 centimeter square grids (though variable map design may be possible).  The whole point of this is that in the real world, we use GPS and surveying to accurately place physical locations, Simulae3 will be no different. 

The other quick note is that the concept of rooms are also knocked out in that a room knows not of its purpose, it is only by human reasoning and deduction that a particular enclosure/void/"room"'s purpose can be ascertained.  If you take an empty house with two rooms near the room with the stove and dishwasher, how does one know which is the dining room (if either).  One doesn't, one chooses to assign that role by the placement of the appropriate objects (appropriate to a dining room that is) within said void. 

Simply put, this conundrum has been resolved and the next phase of design and coding can continue.


28 May, 2008

Migraines: A common misunderstanding

Mi - graine: (n)
A headache characterized by throbbing head pain, often greater on one side; may be preceded by a warning (aura) and accompanied by nausea, vomiting, and sensitivity to light and sound; in rare cases, weakness, language problems, or other neurologic disorders are associated with migraine.


Over my years of coding I've endured what I thought were migraine headaches, not uncommon to those of us who spend waking moment after waking moment staring at multiple screens as part of both work and hobby.  I say "thought" because up until this past weekend, I was sure that the harsher headaches I had endured qualified as the infamous 'migraine' variety.   I was wrong.
On this past Saturday, I had the pleasure of seeing one of my best friends (and also my best man at my wedding) tie the knot with his sweetheart (both are coders by trade as a sidenote).  The day was perfect, the weather was wonderful (as it was an outdoor ceremony) and all was well in general.  I on the other hand aside from coping with sciatica down both sides of my body (a relapse of a previous L4/L5 left disc rotation), awoke with what I thought, was one of my annoying 'migraine' headaches.  I took Excedrin Migraine along with Vicodin for my other-pain and proceeded onto the wedding with my wife.  The headache didn't subside, regardless of a second round of 'migraine' strength medication.

The first lesson to be learned here is that Excedrin Migraine (I'm pretty sure any over the counter "migraine" medication as well) , while great for 'bad' headaches, is lightweight against 'textbook' migraines (more on this later).  

     After the wedding was over and we made the drive home (hellish for me as my headache seems to have grown from annoyance to throbbing), I started to feel dizzy with a bit of nausea, yet did not succumb to an involuntary protein spill thankfully.  I ended up retiring fairly early figuring that my 'migraine' was just particularly bad and was exacerbated by the fact that our table at the reception was next to the live band.
     Sunday morning arrived and that horrible headache was still present.  I took two vicodin and several aspirin in the hopes that it would finally kill the beast within but it was all for naught as much to my dismay, the headache only soldiered on.   I spent much of the day in a narcotic (vicodin) induced stopor in an attempt to mask the pain which was at this point pressing heavily on my head, and would remain this way the rest of the day into the evening when I retired early in an attempt to once again let tomorrow come without the now 36 hour headache.  Little did I know that this was about to get worse, much worse. 
     Memorial Day arrived, complete with plans to go to my in-laws for a barbeque and family goodness.  04:00 on the clock and I arose from my sleep to the udder shock that the pain was not only existant, but worse.  I quickly (well, as quickly as I could) went downstairs to take three Advil (I was now out of Excedrin Migraine), and then return to bed, hoping this was finally the end.  The time was 08:00 according to the clock and I was expected to rise.  Problems.  The headache was still there, and it was rather angry with me.  Outside of glancing to see that it indeed was 08:00, I had to keep my eyes shut, the dizzy feelings, nausea and pain from the light (through the blinds, mind you) was unbearable.  It felt as if my head had been mounted between the the grips on a vise.  I at this point, took the decidedly un-male action and asked my lovely wife (and child) to get me to the Doylestown Hospital Emergency Room.  Something was obviously wrong and I was quite worried, not to mention blinded by the pain.  
     After what seemed like an hour (when in reality it was half of that), I entered the ER and was promptly thrown in a wheelchair, tagged and admitted to ER room #5.  At this point the pain caused me to writhe in pain in my open-backed hospital gown in my new metal bed.  Another 10 minutes came and went, along with an increase in the pain until one of the nice ER nurses (and a doctor I believe) tapped my arm to place an IV line, which was utilised shortly thereafter to inject a medication (a narcotic of which I'd never heard) that immediately overpowered the pain with a feeling of numbness.  This enabled me to speak somewhat lucidly to several nurses as well as a doctor about all of the aforementioned backstory leading up to this point.  
     First comes the catscan at this point to check for abnormalities.  None found.  Then the blood tests, no oddities either.  ER Doctor then comes to the conclusion that a LP (Lumbar Puncture) was the next logical step.  I consented, though it was not to be, after a considerable number of jabs and sharp pains, said doctor gave up and contacted a Neurologist who would come in later to do said LP.  
     The pain started to return and I was given another dose of said magic narcotic.  All remained well for another 90 minutes or so (at this point, I've been in ER room #5 for approximately 6 hours).   During this time the Neurologist arrived and I spoke with him and allow him to have a crack at a lumbar puncture.  Needless to say he was an expert at this procedure and was able to withdrawal 4 vials of the clear cerebrospinal fluid from my spinal column.  He then surreptitiously disappeared for what seemed like hours.  
    It was at this point, my pain surprisingly started to return, first on the right side of my head, but then started to migrate over to my left side as well.  The pain became so severe that I could tell that the lights were on in the next room over (separated by a curtain), even though I had a folded over pillow case upon my eyes, with my hand over that.  The lights in my room had been out since my arrival as they were painful, even with my eyes shut.  I felt as if I were going to tear the metal sides of my bed clear off.  I suffered like this for another 60 or so minutes as we were awaiting the results of the spinal fluid from the lumbar puncture, and it was already stated that I was given an extraordinarily large amount of narcotics already and they worried about providing anymore until they knew more about the cause of my pain.
     After all was said and done, I was told that this whole episode of the worst head pain in my life, was a 'real' migraine.  I was told that they would provide me some additional medication intravenously before being discharged which would 'kill the headache' this time.  I was also being given more subscriptions, one for vicodin (as if I didn't have enough for my back pain, which I already try to avoid using), but a medication which i had never heard of before, specifically meant to stop migraines at their onset.  That final migraine killing injection came, along with a complimentary spewing of my stomach contents shortly thereafter and I was on my way to being released.  I was informed by the doctors that there were a few things I could do to keep migraines at bay aside from the medication provided.  

"Caffeine, Caffeine, Lots of Fluids, and of course, more Caffeine."

     I'm thankful to all of the wonderful nurses, doctors and specialists who provided help to me after suffering what ultimately will be remembered and hereafter referenced by me as the 60-hour migraine.  I will never use the term "migraine" mistakenly to mean a "severe" or "bad" headache as they not only aren't in the same ballpark, they're not in the same league, region or country.  
     I decided to share this with everyone in the coding community because I'm sadly sure that this will happen (if it hasn't already happened to some of you) again, and to others.  I hope that having read this, those who find themselves suffering one of these 16 tonne behemoths will not wait an exorbitante amount of time before doing exactly that which I did, contact professional medical help as quickly as possible.  No one should have to suffer that kind of pain any longer than it takes to realise what said pain was; that being a 'real' migraine.  

     Wishing everyone good health.

Eric

21 May, 2008

Simulae3: A Testament to Socratic Design.

Socratic Method: the pedagogical technique of asking leading questions to stimulate rational thinking and illuminate ideas.

When I first started working on SimulaE (long before it was even referred to by the aforementioned name), it was a solo project.  This isn't to say that I haven't written all of the code from day one to this very moment, because I have.  I can however say that the design portion of its various incarnations wouldn't have evolved in the manner which they did were it not for the diligent use of the Socratic Method.  

My earliest versions of designing the Simulae virtual world simulation suite of libraries and what not were designed and written by me in response to the original interactive fiction/text adventure engines, then consequentially MUDs (Multi User Dungeons).   The proof of concept of building a better designed mousetrap was simple enough to bring to fruition.  This took place over years, dependent upon my free time and interest in furthering what was simply a flight of fancy for me from my programming youth and Zork playing escapades. 

What really became apparent was when I worked for another company and had the pleasure to work with a very intelligent individual by the name of Tim.  He is a systems/network administrator as well as a capable coder though the latter is not his primary goal, nor role professionally.  

Tim was interested in my Simulae project and as such I found a kindred spirit through whom I could interact by applying the aforementioned Socratic Method.  Through a constant back and forth barrage of theories and examples along with postulates about the hows and why virtual components modeled after reality need to be viewed in a certain light, we would come up with a whole new understanding about the direction of the project.  

It was during this time initially working together that the present tense English Parser component (parser.py) came to be realised and produced.  It took a total of seven point-releases to go from simple noun verb understanding to parsing complex compound sentences with a massive understanding of 45,000 adjectives, 9,500 verbs and multitudes on various parts of English speech.  This series of productive success if anything re-enforced the validity of this methodology in the realm of software design. 

It is now though, with this in mind that I have taken utilising this method to the next level and enacting it with completely uninvolved individuals (uninvolved in the sense of the projects topic and internals).  In the past several days Simulae3 has emerged from the bowels of my TextMate application.  The code is simple, shorter and far more capable than any previous incarnation and things are moving forward at a great clip.  

This brings me to the current point of interest and a call for assistance for anyone willing to get into sometimes heated dialogue about object models.  The object model system is based around the three basic SimulaeObject types.  The only piece of the puzzle still causing an issue is the matter of Portal Objects (entranceways between other container type objects.)  

For the sake of argument, just look at it this way:  A room is a container, that leads from one room to other rooms of 'greater' building enclosure.  A set of lips in a Mobile Object (hereafter MOB) (e.g. 'actor' in OO/UML terminology) is simply a Portal Object to the mouth of said MOB.  A window is simply a portal between the outside 'container' object (in this case a root SimulaeObject), and the room in which our Actor/MOB would be in (to see said POB destination from said perspective).  

I need others with whom I would be able to work out ideas so that this conundrum can be resolved and the next phase of Simulae can come about for code release and testing.  If anyone is interested, contact me at this domain via my email address: eric

I am going to finish on that note being that due to medical reasons dealing with my sciatica, I ingested a full dosage of two Vicodin tablets (as per my primary physician), and as such I'm getting ready to crash hard.   I hope to hear from some of you in the hopes of moving forward, but I'd like for Tim to give me a call in any case so that I we can bounce some ideas back and forth on these issues.


27 April, 2008

SimulaE - Model Update

I've made mention of my virtual world simulation project on multiple blog entries, most recently related to Ruby and making a rewrite of the existing engine in said language to test out its applicability (the language not the simulation), which by the way I found to be the lesser language for this kind of application, but I'm not saying anything about the language as a whole.  Either way, onto SimulaE, which after all is what this post is about today.

I have been rattling my brains (and occasionally those of my friends) regarding the basic SimulaE Object model, which up to this point has served its purpose.  Though the time has come for it to evolve.  It can implemented in a simpler manner and I have known this in my mind all along though it hasn't been an issue in the process of designing the parser which has for the most part been satisfactorily completed. Now that my focus has returned to the object model, I feel it a fine time to share that update thus far.  Comments are always welcome and most are appreciated.  

The fault before was that I broke the objects into the wrong sub classes.  Originally I had the parent Object class,  and subclasses for Room objects, Exist Objects and Person Objects.  This is a horrible idea and leads to unnecessary complexity.  

The newest model:

Object (super class)
MovableObject (isa Object)
PortalObject (isa Object, isnota MovableObject)

PortalObjects, hereafter POB are a much more dynamic version of the previous "room" objects.   A POB behaves in the following manner(s):

1. Object(s) enter into the object containing said portal.
2. Exits an object when contained therein.
3. Can exit (when specified) to a specific object, though by default exists to the parent container object.

If a MovableObject, hereafter MOB, is not contained within the same container as the POB, POB leads into the container.  
If the MOB is contained within the same container as the POB, POB leads out of the container.

By working in this manner, we ensure that the simulation object model more closely mimics the real world, whilst still allowing for exceptions to transpire for non-real world based applications of this group of models as well as anything they may be working on at CERN in Switzerland which breaks our current understanding of physics. 

I haven't had time to implement this new set of models yet, but as I write that code, I will be posting the revised Python source.

24 February, 2008

Quick Django Tip: Dynamic Application Object Retrieval

In my recent django adventures I needed to introduce site-wide search functionality and in the process of doing so, encountered a small roadblock towards doing so.  Apparently due to the nature of Django's API for db interaction (as of the last stable release version), there is a limitation as to the use of python variables in API calls.  I found this to be a hinderance, but only for so long.  

The follow code snippet was something I whipped together which by utilising Python's 'eval' built-in, overcame the aforementioned limitation regarding the API's ability to interpolate native Python (e.g. non-django explicit) varaibles.

Things to know to understand the following example:  

 search_input is a list of cleaned and pre-processed user-driven terms, split into separate expressions, (e.g. ["dynamic langauge", "agile", "programming", "paradigm"]). 

 search_schema is a dictionary in which the key is the django model/class through whose objects we are attempting to search, and the value is a list of specific model attributes to attempt said search.  (e.g.   User_Profile : ['firstname' , 'lastname', 'address_1', 'bio_info', 'favourite_books'])

container_xref is a simple alias mapping for the actual django application names to our internal references inside this search code base.  Obviously this whole bit could be written without said setup, but for readability given the scope of the actual application involved, and the fact that I was not searching simply a few static fields in one django application, but several dozen fields through about two dozen separate applications, this container_xref dict was appropriate.   It is through this mapping dict which we place any matched object results (so as to not waste any additional space via unnecessary list initialisations.) for eventual results generation.

Note: the key "total_results" in the container_xref was a simple means of keeping track of overall search matches, rather than relying upon the Django templating engine (view) from doing work responsible from the processing (controller) perspective.  In retrospect, there are better ways this could have been handled, and in future point revisions, this will be addressed.

------

for search_string in search_input:
  for application in search_schema.keys():
    for attribute in search_schema[application]:
code_to_eval = "%s.objects.filter( %s__icontains='%s' ).order_by('-id')" %       
                     (str(application), str(attribute), str(search_string))
        try:
          eval_results = eval(code_to_eval)
          for eval_result in eval_results:
            if eval_result not in container_xref[application]:
              container_xref[application].append(eval_result)
              container_xref['total_results'] += 1
        except Exception:
    ### Case specific exception handler types, assignments and resultant actions 
          ### specific to each application in which the above is implemented, go here.

-----

As can be seen from the above, simple inline substitution proceeded by evaluation of said string results in post-compilation dynamic search functionalities within django, addressing simple problems one might run into with the existing API which will most likely be addressed in future versions.  

Your results may vary.

Eric

19 February, 2008

Ruby: Somehow I overlooked this Gem of a Language

About 5 years ago I started looking into a language that prior to it's "Rails" fame, was lesser known and even lesser utilised.  I tried it a bit and found it leaving me wanting more.  I've kept tabs on it over the years, reading the tutorials and writing several quasi-AI experimental applications for my SimulaE research, but I ended up being enticed by Python, a language which I stand by, including the wonderful (but until recently unused by me) framework Django (Python's Rail's equivalent, focused on Publishing).   

I've programmed professionally using Python for several contracts/years now and find it quite enjoyable.  In fact, I'm currently coding specifically in Python for Inkedmagonline.com, but that doesn't mean that I don't continue my personal exploration and education for both personal and professional reasons.  I decided to re-experience Ruby by picking up the hallowed PickAxe book and giving it another honest chance.  I'm glad I did.  

I believe that Python, and the values espoused in Tim Peter's "De Zen van Python" (The Zen of Python) (my copy just happens to be in Dutch, otherwise I'd post it for others) have helped me to look at Ruby in a different light.  There are some key differences in the two languages, but I can see now the inherent power in Ruby that I was overlooking before.  In fact, some of those key pieces, syntactically as they were which make Ruby so enticing this time around are the very same 'features' I feel are missing in Python.  It only took me working in an environment with situations where said language features would prove the best solution to the problem(s) on hand for me to realise it.

I am not going to spend time detailing all of the specifics, though I may mention one or two nonetheless.  I'm more so bringing this point up so that others might be reminded that giving something new a single chance might be to your own disadvantage.  After all, I didn't like Python the first time I tried it either.  I think it is partially a matter of how we grow as developers that allow us to know what we're missing, that same spark of realisation that gives us the "a ha" of relief when we find it hiding in a new language, programming methodology, etc.  
What brought me back to looking into Ruby a second time is of all things, Smalltalk.  The whole "everything is an object" concept is nothing new to me, or to programming languages.  However in dynamic strongly typed languages, it is.  More importantly is manner of how even rudimentary objects such as integers, floats and strings are treated in Ruby.  They have methods which can be both called using the standard instance.methodname call format, and have their standard methods overridden.  The second being something far more wonky and kludgy in Python (and a non-option in perl).  

The fact that key methods are instance based such as "len" or "length" for example makes a world of difference for consistency.  It speaks to the overall design that "Matz" (Yukihiro Matsumoto creator of Ruby) had in mind during the planning phase.  In Python, a language in which everything is truly an object as well, this starts to get rather confusing.  While Python does treat every integer and string as an object, it mixes the traditional functional paradigm for calling items such as 'len' so that to find the value of 'a', one would type len(a), as opposed to the more object based a.len ..  This seems counter-intuitive and quite frankly a real surprise when you look at the overall design of Python.

I'm not ripping on Python as I do wholeheartedly enjoy the language, I'm just starting to feel aches and pains over decisions which are ingrained into the language, as well as not being seen as an issue or being addressed in py3k (or Python 3000/Python v3.0) as it were.  I just think that my eyes have been opened to Ruby again and I like what I'm seeing.  I am actively looking to find a future professionally as it were utilising it as nothing beats having fun while accomplishing what one would hope accounts to 'great' things.  We'll see what the future holds.

Next Step:  Migrate my SimulaE virtual world/real model object simulation from Python into Ruby as a test run.  Lather, rinse, repeat and then see what the side-by-side comparison's look like.

Until next time...


05 February, 2008

The Importance of Being Challenged

In this most recent engineering, architecting and development endeavour which I simply refer to as my "job" or "contract", I have come to some conclusions which I feel require sharing.  I'll be very straightforward so as to not waste certain readers' time.  Many of the more seasoned lifetime coders will know (and have experienced many times over) that which I am writing about, which can be summed up as such:  If you are not being constantly challenged, you are atrophying as a developer.

I often write about my own experiences as I know them better than any single other developers experience(s).  This is not because I feel that I'm the end all be all of coders.  Far from it, I do feel that I'm good at what I do, however I prefer to look at my writings as a form of navel gazing, a self-reflective ascertaining how I can better grow in my art and profession.  It is exactly the same manner in which I'm going to proceed regarding today's message.

As I have mentioned, I have most recently jumped into a contract situation at the personal request of a rather successful life-long entrepreneur and given that the opportunity sounded rather interesting, I turned down a salaried position worth almost double because the challenge that was proposed.  Please don't get me wrong, I took a position fixing a half-assed php open-source hot or not style rating system because the employee responsible by no fault of his own necessarily, and due to a lack of a sense of urgency was unable to get a system such as that prescribed, in place by a contractual client deadline.  This was not the reason I took the contract, whilst simultaneously being precisely why I took the contract. 

I'm not a fan of php in its current state (though it has been improved upon since my first dealings with the language), and most definitely not a fan of a vast majority of already written php applications open source or otherwise, but the latter point is more an issue with those specific applications and their designs and integrations.  What I am referring to more so is that I was brough into an environment where it wasn't the same old same old.  Now I wouldn't have stayed were the job going to continually require php specifically and exclusively simply out of my desire at the time to branch out skill-set-wise.   I did know that while I don't consider myself a web developer, I would be required on more than one occasion to work on web applications and having come out of many back-end intensive positions wasn't sure if this is somewhere I'd want to remain.

These weren't to all be simple ones either, any moderately proficient web developer and non-web developer alike could figure a good many of these solutions out.   What really did it for me was that I would be required to not only work under a fairly frequent set of short deadlines due to the nature of the publishing industry as well as the time frame required to keep the site and features current.

The importance of all off these ramblings is this simple point.  Being experienced and disciplined as a Software Engineer/Developer/Architect, etc. ad nauseam helps me to know 'what' I need to do, and gives me insight as to how I might go about solving an issue.  It is however, the actual specifics which put those tidbits of understanding and knowledge into play which go outside a given comfort zone.  It is only then, when we find ourselves in unfamiliar territory, under threat of tight deadlines coupled with our own personal desires to do our best and produce code to which we are proud to associate our name.  

I know that earlier in my career there were times (albeit very few, which I can honestly say) that I too fell into this 'comfort zone'.  I found out though, that this comfort zone is boring and causes one to stagnate.  We code because we love it.  Coding and problem solving is in our blood, and in our hearts.  It is how we look at the world and as such isn't something from which we can remove ourselves.  

If you only know low-level languages, learn a high level language.  If you only work in functional programming paradigms, learn object or aspect oriented ones.  If you only work with interpreted languages, learn compiled langauges, etc.  I'm not saying give up your current lingua franca, I'm simply saying expand your horizons.  The more ways you have of looking at, describing and ultimately understanding a given problem, the more ways you have to solve said problem.  This doesn't solely benefit you, it benefits everyone for whom your code will be written and utilised. 

You knowledge needs to be a living, dynamic pool of information, not a static, never changing one and the way to ensure that is to aggressively fight off the status quo.  Be aggressive, absorb all that you can.  The best way to do this isn't by dipping your toes into the shallow end of the kiddie pool, it is accomplished by putting on your goggles and climbing that high dive, plunging in head first.  

Take a chance for once, you might just learn something.  

Till next time..

29 January, 2008

Arc: An evolution of Lisp/Scheme, or a outdated implementation at launch.

So the day has finally come in which prolific geek & insightful essayist Paul Graham along with Robert Morris released Arc, their evolutionary love child of Lisp & Scheme.  I think it is safe to say that many of us have (and will continue to) read Paul's wonderful essays on a multitude of geek and coder centric topics, and generally with much joy and agreement.   Many of us have been following the work that Graham and Morris have been undertaking with the new baby "Arc". 

Now that this day has arrived, we can see that it wasn't as deserving of all the pomp and circumstance to which we were planning for it to be attributed.  Seems that there are a considerable amount of deficiencies and intentional short comings to the language.  Normally this wouldn't be seen as anything out of the ordinary for a 'new' language, and would be generally a non-issue.  

The problem is that this is the year 2008 and people have come to expect more from their languages.  Ignoring established standards along with ignoring the need for designing to meet the needs of developers globally all the while using the cop-out of it being purely for exploratory programming is just bad form.   

The world doesn't need another Lisp, the original is wonderful just as it is, that's part of its beauty.  I don't see anything in Arc that couldn't be done as functions and/or macros in Lisp that required the entire 'creation' of a new language.  The way I see it is this; for prototyping as well as production usage we already have several languages that excel in those domains, specifically Lisp and Python.  

Generally the idea of rewriting existing languages with little difference from their predecessor(s) is a waste of time and effort which could've been better spent elsewhere.   There are exceptions to this scenario such as that of Ruby.  It is a language that in the past I used to dislike because of certain key flexibilities much akin to the reasons for spaghetti perl, but it successfully fixes many of perl's wrongs, and corrects some of Pythons short comings as well.  It serves serves enough of a purpose as that of supplanting perl with a better thought out design, and thanks to Rails, its future looks solid.  

Arc on the other hand is like a still born fetus.  Much was expected and there was potential to be just like its parent(s), but death was announced during a delayed delivery and upon further examination, it was discovered that it wasn't a proper offspring, but a clone in fetal form.  My advice to Paul and Robert is the following:  recall the release, and make it truly something worthy of release, with proper compatibility and compliance with modern norms.  Make it usable to others as opposed to just a few tinkerers interested more in lisp and scheme basics. 

An on a more pleasant note to Paul;  Please keep on writing your essays and providing your viewpoints as they are appreciated, I just wish that your judgement call in the case of 'Arc' was as well thought out as your writings have proven to be over time.


04 January, 2008

The New Django Powered Inked Magazine Website is Up!

This will be rather brief as it is more of an announcement than one of my more traditional journal entries. 

After a  short two or so months from start to finish, I have successfully setup my first Django powered website.  Inked Magazine has been relaunched effective January 2nd, 2008.  This replaces the Joomla powered site which existed prior to both myself and the current ownership of the magazine were involved in the project.  

Phase one has been completed, with extras.  The customer photo galleries, the cover photo application, the user profile system as well as the main magazine feature areas have been established and are active.  As of today, I will have available for all registered users the ability to host a blog on our site (using our software which I wrote in a few days), mind you it is still early in the feature process, though it without doubt serves most blog authors needs.  

I will be adding features as time progresses, but until mid-January 2008, I'm on a tight schedule to build the entire forum application so that the beginning of the "New and Improved" Inked Network can go live.  

I don't think one needs Ruby on Rails when you have Django.  Much of the same great functionality and without having to use Ruby all the while using Python.  [Update: After having revisited Ruby as a language on its own, sans Rails notoriety, I've found that my previous assertions regarding Rails specifically was unwarranted.  It simply took my experiences with Django and Python to make Ruby and Rails far clearer to me.]

I will return to my normal posting after the Forum application is up and running.  

Till then, keep on coding.