No server restart?

March 22nd, 2009 | by | devdog, rants

Mar
22

I follow quite a few blogs of various people that make headlines and have a coding background. One person in particular that somehow made the list many moons ago that I have failed to remove is Leah Culver. I think it was her ties to the midwest and the fact that she seems to be putting her ass out there with Pownce (which has since had to close its doors).

In her latest post, she talks about writing a plugin for Django. If you are unfamiliar with django, it is a web framework written in python which loosely follows the model-view-controller design pattern (source).

Before I go on trashing the comments in the post, I’d like to note, I’m not a django developer and never have been. But I think that my overall points come back to good design and practices.

Ok, May I direct your attention to this comment made by Leah.

Let’s take the only advantage first, “can update on the fly, no server restart”. This is a web framework correct? Why the hell are you restarting!?!?! I’m clearly missing something here but for all the web apps that I have created, a restart isn’t required. A reload of my web browser is, but I’ve never had to restart my application or web server. I’m really not sure what she is referring to here exactly so I’m guessing I’m missing something major here. Maybe the application she is developing for requires an application server that needs to be restarted in which case it would make sense. But for some reason, I’m not thinking that is the case. Someone please explain this one to me in the comments.

In the disadvantages of using a DB, I have a big problem with #1, “slooooow”. If your database is slow, it is usually one of four issues:

  1. Bad Code/Database Design – This is usually where people screw up. Maybe they have never run an application where there are several million inserts in a day. Or maybe they’ve never seen the affects of table vs row level locking on updates. Maybe they don’t understand why their query doesn’t match any of the indexes that they have setup. The developer may not understand what an index even is! This is why developers and DBAs need to be on the same page in the database / code design. Even if you don’t have a DBA, there are plenty of web sites out there that can help you figure out how to tune your application and find slow points in your database code.
  2. Improper Database Tuning – This is where a skilled DBA can save your ass. If you don’t have one on staff, contract this out. There are consultants out there that are worth it. Find a good one, pay him his price and you will be amazed at what they can do. If you happen to have a development crew that is fanatical on code optimization and speed, they will probably make up for having a DBA on staff. But it never hurts even to bring a DBA in for a day or two, have him look at the DB, make some suggestions and turn it into a training session to help your developers grow.
  3. Database Load – Let’s face it, some databases are very large and have grown to the point where it is time to expand the design.
  4. Slow/Old DB Server – At a certain point, its not worth your time to spend weeks tweaking every query on a server that is 2-3 years old. Throw new hardware at it and let the improvements there increase your performance.

I don’t really have a major issue with the rest of her list, they all seem to be fairly logical. But I just didn’t understand the advantages fully and the first disadvantage, well, as you can tell it drove me up the freaking wall. If the database is slow, there is a good reason for it all of which are fixable.

Now, with all that being said, I do kind of agree with her. IF the data is not going to change, why store it in a database. Having a flat config file is not the end of the world people. Its fast, saves a query, and never changes! But that last part is pretty critical. If the data may expand which very well could in this instance, it proabably makes sense to put it in the database even though it doesn’t fully seem like it needs to go there. if you have your database design in order, you should be fine and never notice a performance hit getting this data.

Comments Closed

7 things you didn’t know you could do with OpenOffice 3

February 24th, 2009 | by | devdog, rants

Feb
24

Recently, PC Mag ran an article titled OpenOffice.org: 7 Things You Didn’t Know You Could Do. I’ve always been a big fan of Open Office and have found it a nice alternative to shelling out the major bucks for the Office suite from Microsoft.

Here’s the run down of the list.

  1. Edit two or more parts of a document at the same time.
  2. Use OpenOffice.org to open legacy documents.
  3. Play a vintage Space Invaders game.
  4. Turn off the blinking light bulb.
  5. Save files in Office formats by default.
  6. Automate actions easily.
  7. Fix those single quotes.

Looking through the list, #1 seems like a good one, #2 is very useful when digging through old files, #3 wait…what the f*ck?!?

Why is #3 there? Why is that released code? I know that some developers think it is cute to hide easter eggs in their code. I’m not one of them. I believe that code should be lightening fast and this extra crap just annoys the crap out of me. You’re taking up hard drive space and resources. Oh sure, everyone has several terabytes of data on their PCs…not true jackass!

OpenOffice needs to be a serious tool and start leading the word processing, excel, presentation fight. Apple is making a good stab at the Microsoft juggernaut. But the OpenOffice developers need to cut out the crap, optimize the hell out of their code and start kicking ass and taking names!

Comments Closed

Ugly Code

February 14th, 2009 | by | devdog, dumb people, rants

Feb
14

With my recent project, I had to do some research for the bits that make up the msRTCSIP-OptionFlags field in Active Directory for OCS users. There were certain operations that are not 100% supported by HMC so often times you have to fill in the gaps. The definition of this field is as follows:

This attribute specifies the different options that are enabled for the user or contact object. This attribute is a bit-mask value of type integer. Each option is represented by a bit. This attribute is marked for Global Catalog replication.

source

Unfortunately, in my searching I found not only the technet article, but I also found this

Here a sample of some of the code that you’ll find….

if strOptionFlag = "" then
objUser.Put "msRTCSIP-OptionFlags", "16"

else

‘If user not enabled then do not enable OCS
if strOptionFlag = "0" then
objUser.Put "msRTCSIP-OptionFlags", "0"
‘If user is enabled for Public IM then keep Public IM enabled and enable RCC
elseif strOptionFlag = "1" then
objUser.Put "msRTCSIP-OptionFlags", "257"
‘If user is enabled for RCC then keep RCC enabled and enable Enhanced Presence
elseif strOptionFlag = "16" then
objUser.Put "msRTCSIP-OptionFlags", "272"
‘If user is enabled for RCC and Public IM then keep RCC & PIM enabled and enable Enhanced Presence
elseif strOptionFlag = "17" then
objUser.Put "msRTCSIP-OptionFlags", "273"
‘If user is already enabled for RCC and Enhanced Presence then keep settings
elseif strOptionFlag = "272" then
objUser.Put "msRTCSIP-OptionFlags", "272"
‘If user is already enabled for RCC, PIM and Enhanced Presence then keep settings
elseif strOptionFlag = "273" then
objUser.Put "msRTCSIP-OptionFlags", "273"
end if
end if

All I have to say is wow! You’ve got to be freaking kidding me. Are there programmers out there that don’t understand what a bitfield is supposed to be or how to do bitwise operations? That’s like the first freaking class in a Computer Science degree. This is where you learn about Big 0, Binary numbers, loops, variables. If you are a programmer reading this blog and you don’t know what a bit field is and how to us it. Google it, read up, and rid the world of ugly ass code like what I found above.

Now technically what this person is doing would “work” since it is setting the integer with an appropriate number. But wow is this the WRONG way to do it. I’m afraid to see this persons code for when they need to check and see if the RCC bit is set for the user. Technically, they should be able to do a simple bitwise operation and check it something along the lines of:

if(($msRTCSIP-OptionFlags & 0x0010) != 0)
{
// RCC is set
}

I have a feeling that this person is doing for the following:

if(value == 273)
{
X is set
Y is set
Z is set
}
else if(value == 257)
{
Y is set
Z is set
}

This is a very simplistic psuedo-code example. But wow…I’m still in shock that this type of code is out there…and posted somewhat recently in October of 2008!

I really hope I run into this guy some day so I can beat him with the clue-by-4.

Comments Closed

The need for speed

January 28th, 2009 | by | design, devdog, micro$oft

Jan
28

As I’ve written before, the main engine that we are using to provision users on our Exchange system is Microsoft‘s Hosted Messaging and Collaboration (HMC) framework.

I’ve had a few issues with it and various hoops that I have had to jump through. Many of which I have not had a chance to document on this blog. Those will hopefully come out in the coming months.

Today, I was dealing with a speed issue that we have been having in our customer portal that hits HMC. The page is pretty basic, it gives a listing of all the users, the name, login address, what package they are assigned and then some actions that can be taken on the user such as edit, delete, disable. This is all in house code that shows this information with calls being made to HMC to get the data.

Unfortunately, I made a mistake in my initial development. Originally, I got a listing of all the users and had 90% of the information that I needed. Another call was needed to get the assigned package for each user. If you have 5-10 users, this isn’t a huge deal. Try it with 100, or 1000. It gets really ugly really fast.

On one particular customer that I was looking at, they have 120 users. Their page was loading in 41 seconds. 41 freaking seconds!!! 7 seconds for the AD search to grab the users with mailboxes. Then somewhere between .1 and .3 seconds per user to equal 34 seconds of the page load.

The solution, remove the package display code.

What? But doesn’t the user want to see this data?!?! Maybe. But seeing as they have to go to the edit page anyway to change the package, it really isn’t needed on the account listing page. So why display it there. It slows down the user experience which is more of a negative than having it on the page.

It wasn’t an easy decision to remove this information. I thought of a whole bunch of ways where I could tuck that data away so I could grab it more efficiently. But in the end, less is less. Removing that data cleaned up the look of the page and vastly improved the load times. Its only been in the wild for a for hours so we’ll see what the users have to say about the change.

Comments Closed

Hacking WordPress

January 27th, 2009 | by | design, devdog, rants

Jan
27

I’ve been doing quite a bit of side work for friends and family putting together some low traffic ‘business card’ sites. I used to do a lot of custom programming for each of these where I would put up the site and then have a CMS on the back end so they could log in and update the content.

This worked out for a while and I had a pretty basic CMS built that I could plug in where needed. But, as with everything, the feature set that I needed kept growing and I was pretty short on time to implement the features that I needed.

To solve this, I started looking at the various blogging engines that were out there. The one that seemed the easiest to pick up, was pretty popular, and had a ton of plugins for the things that I was looking for was WordPress.

As a blog engine, it does great! It is actually what is powering the site that you are reading now. As a CMS, it does OK. I can create static pages, setup some assemlance of structure with sub pages and decent navigation. There are a ton of themes out there and a lot of people have tutorials that can tell you how to hack them up to make them look the way that you want. But there is one major thing that is bugging me. The code!

Seriously, have you looked at it? Maybe I’m anal retentive. But there is html and PHP mixed together all over the place. The code looks like it tries to implement some sort of MVC where the view is in the theme. But good god, do not go looking through that pile of poo.

Here is an example of what I am talking about:

 <p>
    <label><?php _e('Username or E-mail:') ?><br />
    &lt;input type="text" name="user_login" id="user_login" class="input" value="<?php echo attribute_escape(stripslashes($_POST['user_login'])); ?>" size="20" tabindex="10" /></label>
  &lt;/p>
&lt;?php fake_do_action('lostpassword_form'); ?>
  <p class="submit">&lt;input type="submit" name="wp-submit" id="wp-submit" value="<?php _e('Get New Password'); ?>" tabindex="100" /&gt;</p>

I couldn’t even do that big of a snippet due to all the hell it causes when you post wordpress code on a wordpress site. But the <?php ?> tags are scattered all over the code base. Its a royal mess.

What WordPress needs to do is come up with some sort of code standard or guideline. Then reject anything that doesn’t meet that criteria that they have linked up on their site. This is a full review of all the plugins and themes that they have.

Yes, I’m serious about this!

It will take a long time to do. It will take a lot of man hours to complete. But in the long run, the code will be easier to maintain, extend, and quickly allow users to join the rank and file wordpress developers. It will also allow the hacks out there to become better programmers. Which is something that the code base desperately needs.

Comments Closed