The Education of a Programmer (Me)

Just another site

Category: Programming

The value of slow coding

When I took my first programming class going after my Master’s Degree. My instructor then, John, told all of us that if we sat down to code and wrote 100 lines of quality code in an 8 hour day that we were really great programmers. At the time, I thought he was being somewhat facetious. I’ve worked on projects where I turned out several hundred lines of code in a day which was ultimately deployed and considered useful.

Then wisdom followed knowledge. I know how to code. I can figure out what I’m after, write it, and it will pass tests and it will work, but I also learned from John to re-visit my code and always try to make it better. Whether that’s more memory or processor efficient, or just generally create a better algorithm to do what I need to do; it didn’t matter, just to re-visit the code after I’ve left it alone for a while.

Now I’m working on a project and I realize that in the last two days, I’ve written maybe 200 lines of usable code, other than metadata code in wiring up a database to a web app which ensures better type safety, etc. That’s the stuff I write without thinking and while it’s necessary, it’s not the most stellar code.

This morning I found myself really proud of 4 lines of code. It took me some thinking and research to write 4 lines, but in the end, it was 4 good lines that did what I wanted and were well-crafted. So, now I’m realizing John was really right; slower coding produces better results.


Weird Font Post

Ok, I know that I usually write book reviews or about something I’m coding, etc. This time, I’m writing about something a little different; fonts. I admit, I’ve always been fascinated by them. I love the written word and have always studied orthography when I was in my Linguistics program. So it serves to reason I would be just as fascinated about fonts. I almost added a graphic arts program to my current mode of study just to have a chance to learn how to build my own fonts. Well, one font anyway.

I write programs, so I stare at a lot of code and I have searched through many many fonts, trying to find one that made me happy when I had to read so much code. I’ve seen many which were close except for something which would drive me to distraction. Maybe it was the curve in the lower case l or the lower case i. Maybe it was the dotted zero. (I even write a slashed zero in handwriting, thanks to my wife.) Whatever it was, it never fully felt right. Then I stumbled upon Input. The thing which stood out immediately for me was the option to customize the font to what I liked. They had options for miniscule a, g, i, & l. They have zero options, curly brace options, and asterisk options. Basically, I could make my font the way I wanted it to look.

Then as I would read about the development, I emailed the designer and got a very nice return email which invited me to continue to note things I’d seen in the usage.

It comes in the standard Mono, Sans, and Serif, with several weights and several kerning options, (regular, narrow, condensed, and compressed.) So to have it for Visual Studio, I make my own custom variation (InputMonoCompressed) and it looks fabulous, I can read it all day, and then I can use the other variations in other apps as I see fit with no headaches.

Best of all, you can use it for free in certain circumstances. However, if you want to use it for commercial publication or for your website, you have to pay for it. That’s fair in my book. When I can afford it, I might just buy a license to use it on a personal website. Until then, I’m going to gratefully read code in it while I work!

Out-thinking, but not outwitting myself

Like any good programmer, I keep trying to re-factor some of my code to make it more efficient, better, etc. Now that I’ve become more comfortable with Linq to EF and Oracle together, I realized it would be time to re-write our Hot Calls program. (Not what you think folks). Even though Syncfusion has come out with one of their Succinctly series books on NHibernate, I don’t know that I’m going to make the switch just yet. I would like to try it as a test some day so I can get familiar with it, in case I ever have need of it.

However, I started with the Poller which scans a database of incoming calls and takes the newest calls to a series of temp tables for the logic program to handle. This program doesn’t really lend itself well to either EF or Linq for that matter; so I’ve written the SQL by hand but I still wanted to tweak it. The headache was the first place which lends itself best to the tweaking was the exception handling. Finally, I’ve wrapped my head around overloading my functions enough that I’ve built workable overloaded mailing and logging functions which I can reuse as I’ve wanted to do for some time. Doing this appears to remove nearly 40% of my code base. That is going to be a huge difference across all of these functions. I know I have more re-factoring to do along the way and soon it will be even tighter. (Don’t worry, the commenting is still as verbose as always.)

Yay! Hail the little victories here and there when you can get them.

Book Review – Microsoft Visual C# 2013 Step by Step

I’ve recently been reading Microsoft Visual C# 2013 Step by Step by John Sharp. As usual, the disclaimer is that I received a copy of the book for free in return for the review. I’ve not linked to the book because I blog as part of O’Reilly’s reader review program and recently Microsoft Press books have been removed from their site. Out of courtesy to them, I am not going to link to Microsoft’s site for the book.

The book is aimed, as you read it, for programmers who are wanting to get a foundation in the basics of C#. As such, the book is a good reference work. It takes apart each of the different parts of the language and shows you how they are used in basic format. The first part of the book introduces you to the language, it’s absolute basics, and Visual Studio. The second part, getting the object model under control. Part 3 extends it, and finally, part four shows you how to build something simple for Windows 8.1; as that is Microsoft’s application focus currently.

Overall, Mr. Sharp does an excellent job describing the basics. If you’re a more experienced programmer wanting to see what’s new in the language, this isn’t really your book. But that’s not a negative. It’s not designed for that level of programmer. The examples are clear and concise. However, my one concern is that, as with most beginning books, what you’re learning along the way doesn’t build on itself until the final portion of the book when it all builds at once. However, if you’re going to be new to C# and you’re not coming from Java, this is certainly a good book to start with.

The more I know…..

Well, the next part of the line is “The less I understand.” However, that really isn’t accurate right now. I am understanding more. Not necessarily getting where I want to go, but I’m understanding more. So far, in building the new admin section for the program suite, I’ve been able to get comfortable with a basic MVC program. Really it doesn’t have to do much, it does simple CRUD against the database and I have built custom tables for it to work with. There were a few neat tricks I’ve learned along the way which have made it much prettier. Now my headache is trying to get it deployed on IIS 7.5. I just can’t get it past showing me the front screen at the best I’ve got. Now the latest error is “System.BadImageFormatException: Could not load file or assembly ‘Oracle.DataAccess, Version=, Culture=neutral, PublicKeyToken=89b483f429c47342’. This assembly was compiled for a different processor” which implies that, though I matched the dll to the version which is on the server and is in the GAC, it still is fighting me.

Oh well! Back to the drawing board.


Down the road, I want to start implementing more SOLID principles along with Unit Testing and Mocks. It will be more detailed, but just as much fun to learn….

Stretching the limits

Well, this has certainly been a busy week for me. I’ve been working on the intranet site. I’m cleaning up the smaller pages before deploying them. I’ve also started the framework for the new version of the Hot Calls program. I’m going to use Entity Framework 5 and ODP.NET this time around. I can’t really use EF in the logic portion, but I should still be ok. I’m trying to work out whether I can stack multiple queries in the same method so I don’t have to have 11, but can shrink it down to 5.

Also started working with PowerShell to create a shell program which would allow me to help a co-worker with a batch extraction of SP2007 lists to be upgraded to work in SP2013. That’s going to be interesting because I haven’t worked that much in PowerShell, but with my Linux background, I should eventually grab on pretty well.

I took the first half of the A+ exam yesterday and passed it, so I have to finish stuff off for the second half and take it. That keeps me fairly on pace for class and means I’m going to make most of my goals for this period. YAY!!!

Well, that’s the quiet life of a programmer for now. Back to the books and the work for me!

Goals for 2014

Ok, I am going to do this post, along side everyone else who does it at some point around the new year. If you’ve been reading this, you know I do a lot of book reviews. Well, I need to change that a little bit. I need to start writing more about how I’m getting from point A to point B in my career as a professional programmer. At the same time, I have to do what all programmers should do and work on my skills to increase my abilities and my value as a programmer overall. So, with that in mind, I’m setting out a list of goals for 2014 and expecting that I will blog more about it as I go along.

1. Continue my degree course. I’ve been in school so long these days, I’ve become convinced I won’t get out of school. Well, all kidding aside, I’m around midway through my first term at Western Governor’s. I enjoy it and I’m seeing good progress, so I need to get moving faster in my mind. 

2. Learn a new programming language. I’ve heard it said many many times that if you want to get better as a programmer, learn a new language and  preferably something outside your comfort zone. Well, I need to learn two languages for the degree above: Java and Perl. So somewhere in there, I should start getting a jump on things and work my way into this.

3. Rebuild my current codebases. This is a punt as this is already planned for this year. I’m almost done with one site’s re-write and soon I’m going to do the other re-write and then re-do the major project. Really, I’m doing this because I know what I wrote works, but it’s not the cleanest or most efficient way of doing things, so I want to get better and if getting better means doing full re-writes, then so be it.

4. Write more websites. I have a list of sites I could be building or should have built by now, so it’s time to start scratching them off the list and getting stuff done. Take a couple of those sites and use them as portfolio pieces where I can show off, because I already know the customer needs on them and in those cases the customer doesn’t really worry about web presence, so it’s really a playground for me.

5. Blog once a week. Most days, I don’t know if anyone actually ever reads this, but if I want people to read it, I need to write more often. So I’m going to commit to at least one post a week so I can start writing enough to get attention and hopefully keep an audience. It’s my fault that this blog seems to languish at times, so I am the only one who can fix it.

Well, that’s a lot for one programmer this year, so it’s time to get cracking. See you soon!

New Packt Publishing Offer

As  many of you readers are aware, I do book reviews and occasionally help promote sales for publishers. Well, Packt Publishing is back with a new offer.

They are running every eBook or Video in their collection for $5 each! That’s a great deal in my opinion. They have a lot of high quality titles on various topics and they have great customer service to boot! Here are their details on it: The $5 eBook Bonanza is here! Treat yourself to the eBook or Video of your choice for just $5 and get as many as you like until January 3rd 2014. To get you started, we’ve put together the Top 20 titles of 2013 for you to pick up here. But don’t forget, you can get ANY eBook or Video for $5 in this offer

The link to get the discount is here!

$5 ebook Bonanza1 template 1

Better days since

Well, I have a skeleton site up that implements an .edmx file in the Models folder and maps to the respective tables and I have basic CRUD pages which will work when I launch it in test mode. It’s uglier than sin, but it’s getting there.

I’ve been working through some other tutorials for MVC4 so I can make sense of ways to do this on my own and do a better job with formatting and database updates. I do feel immensely better because it is all coming together. I’ve found it’s easier for me to get it when I’m writing it rather than reading about it.

The nice part of the most recent tutorials I’m working through is that I am getting experience with Ninject, Moq, and unit testing in VS2012. I think I have finally turned a corner and am starting to make more sense of what I want to do and how to do it the best way possible.

Frustrations Abound

I’ve read the start of the quote, “These are the days which try men’s souls,” and have now found a way to certainly apply that in my career. I’m trying to re-build some vintage ASP VB6 sites. Currently, I’ve cleaned them up and made them workable, except for one page because the Oracle back end for that table uses a CLOB data type and VB6/ASP can’t handle CLOBs.

What I really want to do is use MVC 4, Entity Framework, and ODP.NET to create something workable and aimed toward being there in the long run. (Basically, I don’t want to have to do a major re-write in 3 years when the database is switched from Oracle to SQL Server and it all becomes easier.) Therein lies the problem. Wiring up 2 of the 3 components isn’t difficult. I can get EF and MVC4 to work well as I can get EF and ODP.NET to play nice, but add in all three and I feel like I’m in uncharted territory. So I’m going to start blogging and documenting what I’m discovering in hopes that someone else might have some info (if anyone else reads this) and can help me find the pieces I’m missing, or will be able to follow my trail into this and hopefully get something productive out of my morass.

I can do the first part on this rig. (I have two rigs I work out of, one faces the world and the other faces a private subnet that doesn’t have outside access.) So I create an MVC4 project and ensure the latest jQuery, ODP.NET, and EF are all part of the puzzle. I have some ideas of the different controllers and models I’m going to need on the first project. It’s the administration piece which will access existing data tables for a program which monitors events as they happen and sends notification emails to subscribers based on agency, call type, and/or the number of responding units. (There is also a portion for notifications based on the address of the event). So I need to administer the subscribers, the locations, and the call types. The subscribers need to be administered overall, but need to also be filtered by the agency to whom they “belong” as well as the agencies to which they subscribe. The locations need to be administered overall and certain groups of locations need to be gathered together for supervisors to monitor. The call types and subtypes need to be administered to determine when we need to make changes to automatic emails. Plus I have a couple of data grids which show what’s in the pipeline being evaluated and what has been sent out to subscribers. Overall, this shouldn’t be hard. I have 3 CRUD areas and a couple of simple dataset queries. Again, this isn’t rocket science. I already have the tables in place, so I don’t need Code First, I need Database First.

I can connect to the database on the second rig and when I create the project,  I create it on the second rig (from the first one) so there won’t be any problems with it pulling up and being able to code. I can edit the web.config file so I can connect to the Oracle DB. (I’ve gotten decent at that) and I know the queries I need at each stage. I should be able to put all of this together easily, but I’m just not making the last connections to link MVC4 through EF to ODP.NET to reach the DB in a meaningful CRUD environment.

Well, more later…..