Thursday, August 14, 2014

Damn it jim, I'm a programmer, not a data manipulator!

Ah but really, I don't feel like a programmer most of the time anymore.  And yet I write code.  But it seems most of it, like 90% of it, is just boilerplate code to transform data from one form into another.

Throw in filters, validation, and access permissions at different points along the transformation chain, and you have 99% of most web applications.

Why are we writing so much code for all of this all the time?  For a project I am faced with a decision.  Do I write code?  Or do I use some service which allows me to not write code?  It seems lazy, it seems like the way out for people who just don't know how to program, why would I as a seasoned programmer make use of such a tool?

But then, why not?  If I can use Dreamfactory to create a REST API to a database (complete with auto-generated documentation, authorization and permission checking, etc) and then use Appery to visually design a mobile app, and connect to the REST API, all without writing any code.. why not?

Granted there's still some edge situations that require some coding.  But the rest is just thinking about the data, how to present it, and how to store it.

I'm not really a programmer anymore.  I'm a data manipulator.

Or maybe I can put a nicer spin on it, and say I'm a "web application architect" - because there's still the process of defining the data, deciding how best to present it, and choosing the best tools and infrastructure to support it.

Monday, May 5, 2014

The Taste of Failure

The taste was still on my lips and in my mouth as I slowly made my way through the morning commute.  It reminded me of my failure over the last few days.   With nothing else to do with my brain I replayed the events leading up to that morning.

For more years than I can remember, it has been an interest -- near obsession -- of mine.  I’m not sure why, but I know it began with wanting to make my own pizza as a child.  Today, while I still yearn for that perfect home made pizza, my current goal is sour dough bread.

I’ve been baking breads for some years now.   I would characterize the results as being successful.  That is, of course, according to everyone else.  The bread is eaten and never lasts long.  The kids love the “salty bread” (baguettes) and soft pretzels.  Whenever anybody brings bread to church its assumed I made it.

But for me, the elusive true sour dough bread has not come forth from my oven as yet.  This week, I decided to try a new method based on a sour dough baking vlog I discovered from an actual chef.  It looked promising and seemed to address the issues I felt I was having.

The problem with sour dough is that you don’t just mix up a recipe and pop it in the oven.  Its a more involved process.  There are steps.  And timing.  Its a formula of sorts.  And yet there is a lot to it that is just intuition and experience.  This seems to be the appeal for me.  Baking bread, programming a computer, restoring a classic car.  Sequences, steps, processes, methodology, puzzles and problems.  These are things that get me going!

Everything seemed to be going well.  The sour starter was bubbling as described.  The sponge left overnight looked, well, spongy.  After adding the deceptively simple ingredients of salt, sugar, oil and flour, I proceeded to knead.   I could tell something didnt seem quite right at this point, but it was coming along like it always does.  I left the dough to rise all day.

When I got home, I could see the dough had indeed risen, but then fell slightly.  I pulled out the dough, folded it, formed it into the baguette shapes and left it to rise a final time.

In the morning, it had not risen.  I knew I had no choice at this point but to bake it and hope for the best.  While baking it did expand a bit, like it is supposed to, but not enough.  When it came out, it was hard and dense.  I had just invented hardtack.

I was severely disappointed, because this was to be my lunch.  I had already cooked a corned beef the night before.  I had the sauerkraut I made last week.  I had a plan!  Yes, I am obsessed not just with bread but with the idea of making complex meals entirely from scratch.  My other goal goes back to my childhood pizza experiments, and now consists of making mozzarella from scratch, as well as the sauce, and the crust.

I made the sandwich anyway.  My son, an early riser, was excited.  He passed on the bread after eating a few bites, but he didn’t recoil in horror.  Honey Nut Cheerios just seemed a better fit.  Then I tasted the bread.  It was hard, and chewy, but not in the good way a baguette should be - lightly crunchy on the outside, with a soft smooth crumb on the inside.  No, this was dense.  But oh my!  Was it sour!  It was really sour.  Over an hour later I could still taste the sour on my lips.

So, it was an epic fail.  Or was it?  My goal this time around was to finally get that sour dough flavor, and not just the “salty bread” flavor my kids seem to love.  Well, I sure scored big time on the sour flavor!  It was just too much and the bread texture was wrong.  Its so sour I started thinking of ways I could dry out the bread and grind it to a powder and use it as sour flavoring in quick breads.

And there it was.  A failure turned into a success of sorts, and the fruits of the failure repurposed for some future productive use.  Maybe this weekend I will try again.

Tuesday, March 4, 2014

Radio Shack to close 1100 stores...

So I guess Radio Shack (or is just The Shack now?  Who's brilliantly stupid idea was that?) is not doing well.  No big surprise there!

Here's an idea.

F*ck all the consumer BS products that they can't compete with Walmart on (cables, batteries, cell phones, etc).  Fire everybody that doesn't actually know about electronics and building things.  Stock the stores with awesome stuff like robotics kits and little computer boards and such.  But that's not enough.

Put in work benches. 

Turn the stores into maker-spaces.  Have classes for all ages on making robots and spy devices and little computer controllers and such.  Sponsor local schools that have engineering programs or create such programs.

Make it so that when the next kid walks by the store in the mall his mind is blown when he sees robots and blinking lights and kids with their parents making cool shit.

I never go into Radio Shack anymore.   My son wouldn't even notice the store.  But I guarantee if we saw THAT Radio Shack I wouldn't be able to tear him away from it and I'd probably drop some serious change there.

Just sayin.

Thursday, November 21, 2013

Common Core

I work for an educational software company.  Common Core is a big deal around here.  I wanted to dispel a few myths that directly apply to my personal work:

"Increased data collection.. why the obsession with data?"
-- Yes, we are all about data.  The software allows the collection and subsequent analysis of a ton of data.  Is this an invasive affront to privacy?  Are we gonna sell this data or let people who dont need it see it?  No!  We have security and we dont sell data to marketers.  We allow teachers, nurses,  administrators to get reports on this data in order to help the students.  Collecting this data is nothing new in schools.  Being able to actually categorize it and build reports on it and actually use it for something positive is new.  How is this bad?  Now we can easily make sure everybody who needs to know about a kids obscure food allergy knows about it, or that his online assessment testing shows a particular spike in one subject area that nobody would otherwise have noticed.

"Its expensive and directs money at evil special interests like e-book and computer companies"
--  Um, yeah, because its the 20th century and we have computers and e-books now.  Hey does anybody know how much a regular textbook costs?  And how often do they update them?  Does anybody really want to keep using Scantron sheets and filling in bubbles for testing?  It may cost more upfront, but with computer based assessment testing teachers can modify tests easily and create better tests for kids.  And e-books can be updated constantly instead of once every few years.  For less $.  A lot less.  An ebook reader can cost less than a single textbook and hold a hundred books updated constantly.  And this is bad?

"Nationalized testing is bad"
--  Really?  We already test kids.  Problem is, there's no standard.  Kids from one state can move to another state and be behind in school because of different standards.  This is a matter of national pride and should be a patriotic issue.  As an American I'd like to know that we as a country have minimum standards for our people.  If you have an issue with testing, that's one thing.  But we already test kids, we have to measure their progress somehow, why not have a national minimum standard?

I could go on and on but I'll stop now.  I have to work on some software that lets teachers and nurses collect a ton of personal data on kids.  No, really.  And I'm proud of my work.

Thursday, October 17, 2013

Resurrecting old code

So, what do you do when you've abandoned (not by choice, mind you) a project for 6 years, and a request comes in to resurrect it (and they're willing to pay)?

Step 1: locate the files.

So, when I got my first MacBook pro, I created a VM from my old windows laptop that contained all my development stuff and ran it with Parallels.  Awesome!  Over time I stopped using the VM as I got used to using Mac native applications.

Then I got a new MacBook with my recent job.  I didn't copy over the VM's.  A few months later the harddrive in my old mac started acting funky so I replaced it with another drive and a fresh MacOS for my wife.

Now I tried copying off that VM and it just wont work.  So I went and dug up the original drive from that windows laptop.  After waiting forever to copy off the source files, I wound up with an empty folder on my Mac.  WTF?  Yeah, no go after several attempts.  So that drive is apparently bad too.  It is 9 years old though.

Ah!  Luckily I had a time machine backup of my old mac.. but it wasnt up to date, almost 2 years old.  But I don't think I really did anything with the windows VM so the backup should be fine.  Eureka, I've got my old system back.

Copy the source over.   After another search I located some DB backups.

Step 2:  remember how to set the system up.

I had a complicated, delicate system where there could be multiple code installations and client databases, along with a licence key server.  Each install would check with the key server to get a key which contained usefull information like how many user logins were purchased, what the db name was, etc, or if the key was expired and the system could no longer be used by that client.

I had to remember how to configure the config.ini, how the key server worked, where the DB data for that was (since there was no template stored along with the code).  I also had to remember my password.  And that the database migrations needed to be run.  etc.

After a day, I got it all running again.  Amazingly, the gui seems to work just fine in a modern firefox.  I guess my javascript and html wasnt that bad after all!

Step 3:  Gag at the site of such old, clunky code.

The original code for this project was created with a development tool called CodeCharge Studio, which generates most of the boiler plate-like code for you, based on an existing database.  At the time, this seemed like a great idea, and got the system running very quickly.

The code however is horrible.  Its not using any framework beyond PHPLib, one of the very first code libraries for PHP.  It works, but its not real extensible or flexible.  It does work in the latest PHP with only a few minor fixes (my fault), so that's nice.

Since I don't want to be beholden to a Windows only dev, I'm just going to toss the notion of doing any further coding with CCS.  If this client pans out and starts paying for the software, it will be time to refactor everything and convert over to a real, modern framework like Symfony or even ZendFramework.

Sunday, March 3, 2013

You don't know REST

I've been reading about this new-fangled thing called Hypermedia API's.  Apparently, this comes as a result of REST failing and now we need something even newer.  A hypermedia API isn't really anything new, just as REST wasn't anything new.  The problem stems more from the fact that few people actually understand what they have on their hands and how to use it.

My cursory understanding of a Hypermedia API is that it does for web based API's what HTML did for Documents on the web.  IE, in theory it makes an API self descriptive and navigable, the way an HTML website is - you can point a generic content consumer (browser in the case of HTML) at it, and its viewable and usable by a human.  Simple things like using URI's instead of some internal ID number to refer to other resources (like a simple link in HTML) or some kind of known data structure to define the inputs to a resource (HTML FORM).

That's all well and good, and in many ways useful to do.  But API's aren't consumed by a human, but rather another machine.  So the analogy of saying Hypermedia API's are like HTML is kinda wrong.  And its not going to work just like that.  I like what David of Ruby On Rails fame has to say about it.

I think the real problem here is the same reason why REST (and various frameworks) often fails, and that's because of a misunderstanding that goes back many years; that of the Model.  That's the M in MVC and I think too many people get it wrong.  These days, Model usually means "Database record".  So, its natural when you take a typical modern framework that makes Model synonymous with Database and make a "REST" API where its doing not much more than just exposing those models and a CRUD interface.  But thats not REST - REpresenational State Transfer.  Thats just tunneling your database to the browser.

See, models, in the original MVC, were meant to be just that.. models.  Not the real thing as internally manipulated by arcane code written by programmers who think that way.  Models, as in, a conceptual way of viewing something.  Typically, a way of viewing something that makes sense to the typical person who might be using the system.

That's what make HTML so great.  Anybody could come along to a website, and view it.  Anybody could quickly learn to click on hyperlinks to find more stuff to view.  Its not so much that the HTML describes itself and how to interact with it (even though it does to a degree).  Its that the HTML was (if it was done right) designed to be used by a human.

API's are typically not designed for a human, right?  So our brains fall out of our heads and we just offer up direct versions of database objects.  But that's not right.  What happened to the REpresentational part?  Just because it's API doesn't mean it can't make sense to an end user.  Isn't that kind of the point of API anyway?  To provide an abstraction to your data?

REST implementations fail often because they are not providing representations of the internal data, nor do they provide much real state other than the HTTP verbs.  So Hypermedia API was "invented".  But people are still serving up literal translations of database tables instead of coming up with sensible, intermediate Models that make sense to the consumer of the API.

This is also aside from the fact that people also get the V in MVC wrong.  Views were never meant to be these statically defined immutable bricks that fit perfectly to the model.  They were supposed to be ephemeral things that were created on the fly as needed to present the model to the user under the guidance of the controller.  Most MVC frameworks get it all wrong.

So in summary, you're doing it all wrong!  Lets stop arguing about REST and Hypermedia API's and thinking these tools will fix our problems, when really the problem is more about the data we are trying to let a user manipulate.  If we get that data right, that Model, the rest will come.

Thursday, November 1, 2012

Chili Recipe

I entered the chili cookoff again this year, and lost.  Although I came in like 5th place, I still had people ask me for the recipe.  Which of course, I didn't write down.

So let me retrace my steps.

First, you're going to need meat.  And spices.  So, I picked up 2 lbs of lean ground beef and a pound of sweet italian sausage (not links, just ground sausage that looks just like the ground beef).  I got these at Henry's.  While you are there, get a package of baby bella mushrooms.

For spices, I got ground cumin from somewhere in a little baggie.  I got whole dried chili pods in bags, both California and New Mexico.  I had trouble grinding these up, though.  First I tried my nice burr style coffee grinder, but they were too light-weight to fall into the grinding blades.  Then I tried the blender (a Ninja).  That didnt work real good either, I ended up with flakes and not powder.  I used it anyway..

You'll also need some tomatoes..  I used two small cans of Ro-Tel.  I like beans, so I used a small can of Sun-Vista pinto beans.

Rounding out the ingredient list is 2 shallots (these look like small yellow onions) and a garlic bulb.

Here's the preparation (because just throwing it all in the pot is too easy).

First, brown 1 pound of beef and the pound of italian sausage, and drain off the fat.  Put this in the slow-cooker.

Finely chop the mushrooms (and finely as you can), shallots and garlic.  Then, put a tablespoon of olive oil (or whatever oil you prefer) in the same pan you browned the meet in, and saute everything.  Dump that on top of the meat.  Deglaze the pan with a 1/4 cup red wine, and cook off the alcohol.  Pour that into the cooker.

Then, dump in the tomatoes and the beans.  Add a generous tablespoon of each chili powder, and a teaspoon of cumin.  If there's not enough liquid, add a cup or 2 of chicken or beef broth.

Mix it all up and cook on low for a few hours.  You could be done, but I wasn't satisfied at this point.  So I added the other pound of ground beef (after browning and draining).  I also added a small can of black beans (Bushes Best).   Two tablespoons of brown sugar, and another tablespoon of chili powder and a teaspoon of cumin, and finally, for good measure, I added a 1/4 cup of brewed coffee that I hadn't poured into my cup that morning.

Continue cooking for another hour or 2.  Lastly, add a bit of masa (corn) flour to thicken up the liquid and add a bit of corn flavor.

So that's my 2012 belated chili recipe.