Tag Archive: project

codingI’ve been fairly quiet on the blog the past two weeks. This has been because I have been head down in code catching up from the holidays and being sick. I know all to well how abstract and vague I’ve been on what The Project is. I’m still shooting for a grand unveiling upon the ides of March. (March 15 for those who read not the Shakespeare)

I however do not want to be without any information. So I decided to play the magnifier game. This is the game where you show someone a picture of a common object through a magnifying glass and let them guess what it is they are looking at. Granted, that’s not my intent. I know what I’m showing is intentionally obfuscated to hide The Project’s intent.

However, I want to show a checkin from one of the classes that I did today to talk about what’s going on.

I’ve make no secret that this project uses a database to manage the content and Java and Tomcat to serve as a buffer to clients. Today, I am working on the database upload abstract class. In revamping my Java Servlets this past week, I have managed to completely abstract the query command class to the point that I can create any pre-packaged SQL query on the database into a 4 line subclass. This subclass can handle variant queries, compares, subqueries, and most importantly documentation on the return. This work made me very happy.

In pushing data up to the database there is more work needed. I have to verify that the call is including the correct information. I have to make sure that the subclasses have defined the necessary info to check. (So subclasses will be closer to 10 lines instead of 4)

Effectively, a push command should identify the table in the database, the usable column names, the required column names. And of course error check and return the response in a consumable way.

Below is my checkin comments from today’s abstract Class work. (Note there are redactions)

(Ah, the fun of Java)

imports java.util.List
adds ivars
	MUST BE OVERRIDDEN List requiredHeaders
	MUST BE OVERRIDDEN List usableHeaders
	String sqlQueryHeaders (for building sql update)
	String sqlQueryValues (for building sql update)
doSQLQuery() now doSQL()
	setRC not setRS with executeUpdate instead of executeQuery
	Sends a formatted json error response (put, not get)
validateSubClass() (new)
	Checks to see that there is at least 1 usableHeaders
	Checks to see that there are no more required headers than usable headers
	Checks that all required Headers are in usable Headers
	Checks that there is a table conversion equiv in getDbaseTable() {below}
	Throws Exception (Programming error) if any of these cases fail.
validateRequest() (new)
	Verifies that required headers are in the request http Header
	Returns first missing required header if failure
processHeaderPair() (new)
	examines each HTTP header pair
	searches for headers that are: Package.Command.usableHeader
	converts them into caseCorrected usableHeader and Value
	Appends them into Strings for use in SQL Update request
getDbaseTable() (new)
	converts servlet full DNS name into table in Database
	returns null if not set.
doPost() now doPut()
	Adds failNote as a return from validateRequest()
	Calls validateSubclass()
	Calls and evaluates validateRequest()
	Runs ProcessHeader() while iteration headers
	Builds SQLQuery (Should be update)
	Calls doSQL() and evaluates
	re-Enables SqlResult display in output
	ErrorIn -> ErrorLoc
	Shows failNote

On top of this, since you can’t test a PUT command in a browser; I’ve had to write a mini Putter app on my Mac. Let me assure you, hopping back and forth between Cocoa for OS X in Xcode and Java for Servlets in Eclipse can be a bit of a mind scramble.

This has been a personally hard week for The Project. Iin moving the data structures to MySQL as a database I had to also start developing Java servlet code. The reason for this is that it creates both the ability to have a Web-API for any number of clients: iOS, Android, Win, Mac, etc… while at the same time affording more ease for Web functions.

mgbUnfortunately my Java and Servlet knowledge were (and likely are) still lacking. The problem is that when you start a new programming environment you basically create sample code to test what you are trying to write and then adjust that code as you see success. Then you build on top of that. This sounds like a good idea at first and then you realise, that you are in fact building an upside down pyramid.

You learn one thing and you carefully build on top of it. This lets you learn a few more things so you balance them on top of the one thing you started with.  At some point you have to realise that you can’t build any higher because it’s all balancing act. This is where architecture comes in. Architecture takes the tools and designs a strong foundation. It designs a good skeleton and lets you put things where they best fit in.

All this CS theory sounds great in general; but at the same time you are trying to get a product done. This past Tuesday I hit a roadblock. The way I had put my Java class together, there was no easy way to add the next function. For those with understanding; I was dumping EVERYTHING into one class. I’ve been doing Object Oriented Code for a VERY long time. I knew how wrong my code was (in design) but it worked and got what I needed done.

So I was left with the very hard process of:

“Do I keep shoe horning in, to get a working version OR do I use what I have to build into something designed from scratch and put me back about a week?” This is the ‘Ooh, Shiny’ that as an engineer it’s very easy to get blown away by.

  • The project started with a client and hand build data. (Working on the client)
  • Then the data moved to a database. (Drop client work on MySQL)
  • Need to add data remotely to database (Lock in database, make data client)
  • Now a connector was needed between the clients and the database. (Web service, go to Tomcat, Java, Eclipse, learn new tech)

Of course the actual product client hasn’t moved in two weeks as far as code. The data entry client ramped up last week, but the connectors aren’t there.  So, the fear is not putting so much into one that we don’t move forward with the actual Gem of the lot.  This week I had to decide… how do I proceed and will the decision be right or wrong.

On the one hand it was ‘keep pushing forward and working around the problems being created.’ On the other it was ‘Stop, learn, regroup, rewrite, take the hit.’ And this decision was going to leave me unhappy due to the cons on both sides.

After two days of being in really crappy head-space over this, I realise that this is my product and unlike many of the companies I have coded for: I want it RIGHT. I do NOT want it RIGHT NOW. The dates I set for release are still somewhat arbitrary. Better I be happy with what is under the hood.

Digression. When I was 21 years old my father bought me a 1970’s red MGB convertible (Similar picture above). This thing was beautiful. It was missing some mirrors and had no seat belts (some did.) My father managed to snag this beauty for $800. My dad also never actually looked at the condition of the car. When we opened the hood we saw the electrical had been ripped out and replaced with speaker wire. Half the gauges didn’t work on the dashboard (including Oil, temp, and Fuel) The car also didn’t have a starter button.  I could ramble on telling stories about this car that I eventually named Truddi due to the car’s penchant for having multiple personalities. The point is that the car looked beautiful, but it had horrible guts. There is the right way to wire a car and a wrong way.

While you may think, “Well, aren’t you just ripping out the wiring and redoing it?” The metaphor here is that I am making sure that what I put in there from the start is correct, and not just a pretty outside with horrid innards that don’t belong. And you can believe me that I’ve been asking myself these questions and fighting both sides of the battle.

(long sigh) Well, enough procrastination. Time to design and write some Java from scratch. (But profit from a distributable JAR)

hurdleA happy new year to all! May we all join in peace with the shared knowledge that for the next month we shall all be writing “20134″

The reason I put “Vacation” in quotes like that, is that when you are the sole coder on a project of your own devising for your own release for your own product for your own (intended) revenue. The only think that delays said revenue is said sole coder. So you find yourself working even when you say you won’t.

This week was predominantly learning Java and Servlets. I would be a fool to say that I’ve learnt it all. But, I seem to now have enough under my belt that I am successfully using Eclipse, making a minimal number of Syntax Errors per revision, pushing the class to the Tomcat server, and seeing the fruits of my work.

And what are said fruits?

Originally my client was pulling data from a JSON file that I belched out from a program that made the data than I entered by hand. This JSON file was a static resource that had to be kept up and verified with each data modification. This was a painful process.

Google-r Bruno Oliveira puts this very well: (click for a larger version)geeks-vs-nongeeks-repetitive-tasks


When left to our own devices, we will try to simplify long and annoying process. We may do so through some even more annoying process, but the payoff is ginourmous.

Last week I had a monolithic JSON file with every bit of data in one place. This week, I now have a MySQL database with the data broken into different tables and a Tomcat Servlet, making the necessary calls to create only enough JSON data  populate the view on the client. This is reduce some major overhead and going forwards will allow far better expandability, data management, and communications scaling.

Ain’t net tech awesome in the 2010s? This is so much better than trying to compress user level data into a few bits in a byte because you only had 400K to store your data and your BBS.

Important Java tip:

In a try-catch-finally block, finally is always called.

Do not assume that you are in finally because your try threw an exception. Cleaning up resources that you built in try during finally will really make your program fail.

300px-Tomcat-logo.svgWith the holidays, the usual entertainment segment of the blog has been on holiday. We do promise not one, but two post Sing Off wrap-ups. I’m pleased to announce that many of you really seemed to enjoy the Armchair Judge; so we’ll be bringing her on as permanently as she wishes to participate.

But onto the project. Code in the project itself was fairly quiet. I put in some analytics and testing libraries to allow me to start getting the alpha into people’s hands to abuse and give feedback. In doing so there’s been a lot of Product Management and Software Management going on. As always, read the following “We’s” as the pre-corporate “I” 😉

We’re now running Jenkins, Bugzilla and Tomcat on our internal servers for the purpose of building, running, and monitoring our software. We’ve added in hooks for Flurry and TestFlight to make it easy to track usage, take feedback, and distribute alphas. I have been re-doing the company’s NDA so we can send out the alphas to people. Also, we’ve put dual 1TB RAID’ed drives in place for data security as well as system backups. We’ve been running gitolite for SCM. All of this is running on OS X 10.8 + Server on a Mac Mini. So updating that to 10.9 will be an experience.

I’ve also given the app to our first Alpha tester. In the first evening we got two bug reports (S, You rock!) as well as a few unanswered feature questions. I’m more than happy to get more testers like this! Further, I did do some coding to create a data entry front end application to let me enter and validate data more easily.

So, currently I am looking for Java folks who’ve done Tomcat, general hobbyist programmers who might like to do some pre-financing work, and testers. Feel free to drop a line on this. 🙂

Well, it’s back to Tomcat for Dummies for me.

More soon!