Wednesday, January 13, 2010 #

Separating Passion & Common Sense from Bad Decisions

Technorati Tags: ,

I’m sure there are a lot of us who are very happy in our jobs, and that there are still some great companies out there that drive a great team oriented environment and take time to think about business process.  I know I’ve been there a few times but it’s also becoming more rare as many companies are starting more and more to drive a slave-driven, non-team oriented culture in some work environments in America today.

Also, I consistently hear “Nothing is going to be perfect” in your job.  And that’s definitely true and personally I never have expected “perfection” in my job in terms of the expectation that I will be 100% happy 24x7.   I’ve been in some absolutely wonderful environments and lost them due to situations beyond my control (company goes out of business,  moving, etc.).  But I’m talking about environments that are so bad, they literally cause stress for the majority of their employees daily because they are just horribly run environments and have been for a long time…and usually this will never change for that particular employer.  This is what the article addresses.

As engineers, marketers, really any profession… it’s very hard for us to 100% of the time “just be a little worker bee, do what’s told 100% of the time, and go home”.  The whole point of teamwork is to have opinions, ideas, or be able to give constructive criticism (questioning a process for the good of the team and company) as long as it’s not overbearing & politely communicated to your peers.  You can’t expect a team to come up with good solutions unless this naturally takes place.  And it’s the job of the manager to facilitate this, listen, and take ideas and talk about them to help promote and maintain a great team oriented environment.

With that said however, I have some advice to give.

First, there are often times in any environment (good or bad) where a business decision(s) will be made by a manager that:

  • seems to be based off a bad/inefficient process model
  • is politically motivated
  • is (baseless) seemingly grabbed out of thin air with no thought behind it
  • is based on a power trip by the person making the decision
  • is made solely in order for the individual making the decision to look good in front of others (personally motivated)
  • is made as a result of laziness
  • are so bad at times, that you’re instantly unmotivated and think how the heck and I still working here?
  • does not care to drive a team oriented environment
  • etc.

And there are also in these same environments some very smart, talented, team-oriented members who:

  • have experience over x  years in many cultures, environments, teams
  • truly care about working as a team, driven not by politics or heir say.  Honest hardworking colleuges
  • have a lot of input based on proven industry best practices
  • have common sense that others lack
  • have a strong work ethic
  • have passion to do the best for the business, not “just to get it out the door”
    • the overall goal is a “do it right the first time” and “business process improvement” mentality or at the least some focus on a good amount of quality so that it is extensible later

If you’re reading the 2 lists above, they conflict at times.  And in bad environments they conflict a lot.  They are 2 completely opposite types of people.  And in my experience working in both good and bad shops over the last 10 years, they can make it or break it for the success of your career and personal life.

So here’s what you should learn from this:

  • Like it or not, you can’t influence everything no matter how hard you might wish to try even if it’s for the good of the team or company
  • Know when and if to fight your battles
    • stop and think about it first.  Is it that important to be fighting at this time?  Timing is everything
    • is the person you’re trying to persuade in a good mood?  Bad moods shouldn’t affect teamwork but unfortunately life is not perfect either
    • is the person you’re trying to persuade stubborn in that persuading them more at that point in time is only going to work against you?
    • is the issue you’re trying to passionately help to improve really something you need to put all your energy into?  (sometimes we think it is, but it’s really not)
  • Sometimes even though you’ve politely constructively criticized a bad decision and did it ever so carefully, there is a time to stop and let go
  • Don’t just always give up though
    • Take the bad idea, and instead of constructively criticizing it, lift it up instead.  Give them credit (what are you nuts??) and put small twist on it thus creating a win-win situation for the both of you
    • Read a great book: How to Win Friends & Influence People

and this:

  • If the environment you’re working in is not team oriented due to management, most likely coming on too strong at your current place of employment is only going to throw oil on the fire
    • It’s not worth it.  Just get the job done, do it well, and go home.  It’s not worth your extra energy in these cases where bad decisions are consistently made because that energy can be looked at as a negative to bad leaders who refuse to run and promote a true “Team” environment
  • Think about the fact that if married, you need to hold this job for your family (or future wife and kids, your dog ;) or what have you)
  • Turn it into a Learning Experience.  I know, what is there to learn from a bad decision?  Nothing, but outside that bad decision you will ultimately learn something when you’re coding, documenting, etc. View it this way and it might be a little more palatable in those times

It’s often tough for some professionals who unluckily end in some pretty awful environments (non-team oriented, code & run, slave-driven mentality, driving fear into a team instead of teamwork, you name it).  But the fact is, there are times you need to find ways motivate yourself in these unfortunate situations, keep your mouth shut, and give up that passion at times so that you can live to fight another day.

If you ever end up in some of these really bad environments, you need to let go to help reduce your own stress. 

By nature some of us just truly “care” about doing the best for the company we’re employed with as well as the overall team we’re working in.  We are not cocky, but just very enthusiastic.

Sometimes we do have to be that “little worker bee” who always does as told, when you know without a doubt that the decision(s) being made that particular day makes absolutely no sense or will undoubtedly fail.  It’s one point in time where it may not make sense.  And that time will pass.  It’s for your health, sanity, and well-being to be able to let things go.

Conclusion: You can only control so much and that passion & truly good intent can sometimes get the best of you my friends.

posted @ Wednesday, January 13, 2010 9:47 PM | Feedback (0)  

Monday, December 14, 2009 #

System.UnauthorizedAccessException: Access to the path is denied

Technorati Tags:

I came across this pain in the ass error today...pretty common I guess.  I was trying to do a System.IO.File.Move (which is in essence a copy as we all know) and kept getting the error System.UnauthorizedAccessException: Access to the path is denied.

The code:

private void RenamePhysicalFile(string uploadedFileName)
{
    string existingFile = Path.Combine(SoePath, uploadedFileName);

    if (File.Exists(existingFile))
    {
        try
        {
            string newFile = Path.Combine(SomePath, existingFile.Replace(existingFile.Substring(0, existingFile.IndexOf("-")), someTestString));
            File.Move(existingFile, newFile);
        }
        catch (Exception ex)
        {
            ErrorLog("Image Copy Error: " + ex.ToString());
            throw new ApplicationException("There was an error during a rename(move) operation on the Saved Item upload file: " + existingFile + " error: " + ex.ToString());
        }
    }
    else
    {
        ErrorLog("File does not exist or path is invalid for at the following filepath: " + existingFile);
    }
}

The .Move tries to perform a delete of the file to be renamed then creates a new file with the new name.  Well, eventually after adding a slew of users to the NTFS permissions to that .jpg and giving users such as Network Service, pcname\aspnet, mydomain\myusername, and so on) and still kept getting this error, I finally resorted to fiddling around with the user/context running the app pool of my site in IIS. 

I changed the app pool identity in IIS 7 (advanced properties) to use LocalSystem instead of Network Service and it works fine now.  Even though network service had full rights and Network Service was the user running my app pool, it still did not have the ability to delete and create new files in that directory for whatever reason (if you know please do reply to this).

System user did have all the rights just like Network Service but for some reason, LocalSystem with the app pool works for this and not Network Service.  I am running Vista 64-but with IIS 7 and a .NET 3.5 web application which uses this app pool now configured to run using Local System.

iis_app_pool

Anyways, the problem is resolved, my website is running under the LocalSystem account instead when firing up the asp.net site and File.Move works great now.

Adios.

posted @ Monday, December 14, 2009 10:16 PM | Feedback (1)  

Monday, October 26, 2009 #

Microsoft Expression Super Preview Tool – Completely Useless ?

Technorati Tags:

Today I was all excited about ditching my VM running Windows XP that I use to test IE 6 as part of my cross-browser testing for our e-commerce website and to use Expression Super Preview instead.

So I fired up Super Preview for the first time.  Very cool. I’ll be able to bring up any web site and see multiple views of it in most major browsers and their past and current versions right? 

Well, it seemed like a huge productivity gain, until I actually tried to USE it that is…

superpreview1

superpreview2

superpreview3

There’s a MAJOR functional problem with it.  YOU CAN’T INTERACT WITH THE SITE THAT YOU PULL UP! Look above, I can’t log in.  That means that most of the pages I can’t even view in this tool.  What’s the point of even using this tool then?

How am I going to test anything if I can’t even log in or click around?  Because you simply can’t!  I tried to log into the site and all you get is the DOM elements shown at the bottom of the screen.

Any serious non-static website these days require an auth before you even get to 80-90% of the pages!   So this tool is only good for at looking at the Homepage, an About or Legal static page on any website?  It’s pretty limiting don’t you think?

So, sadly, MS pushes what could have been a very useful and cool product to production that nobody else really has (at least not that I am aware of)  but we can’t use it in a realistic web world.

It’s our job as customers/consumers of MS products to point these things out and challenge the usability of what they push to production.  Hell MS should already be doing this but in my observation of this tool alone, it’s still an issue…usability and therefore practicality to the real-world and daily process of a graphic designer or software engineer is really not being considered.

Clearly they did not think about usability or practicality because so far, this Super Preview Tool (even the IE plug-in) is of no use to real business based developers & designers at this point which is really just amazing to me that the product is even being marketed as something that us usable in a real business environment.

posted @ Monday, October 26, 2009 11:39 AM | Feedback (5)  

Monday, October 19, 2009 #

Multiline Scroll Box in ASP.NET

Technorati Tags:

Just a quick little tip I came across while trying to figure out how to render HTML into a scrollable textbox.  Originally I wanted to create a Terms & Conditions scroll box, nothing special here.

What was driving me nuts was the encoding.  I had created an ASP.NET textbox, set it to multi-line and set the text to it from code-behind. 

I’m tired of using ASP.NET controls, especially when you can do something like this much easier with plain HTML and CSS and it’s working just fine cross browswer and always will.  And as I’ve worked a bit in MVC on a team, I move away more and more from ASP.NET controls when I still work in some classic ASP.NET environments also in mark-up.  You absolutely don’t even need those controls at all in ASP.NET.  So decided to switch to a div after finding out that you can just do this with a div like so:

<div id="divTerms" class="scrollableDiv-500x130" runat="server">

Here’s the class (note that this won’t work with an id..as you know you can use for styling also):

.scrollableDiv-500x130
{
	width: 500px;
	height: 130px;
	overflow: auto;
}

Now the ASP.NET part of it in terms of setting the text from code-behind:

private void SetTermsText()
{
    StringBuilder termsText = new StringBuilder();
    termsText.AppendFormat(@"<p class=""bold_black_12"">Some text here..</p>");
    termsText.AppendFormat(@"<p>some more formatted text...</p>");   

    divTerms.InnerHtml = termsText.ToString();
}

scrollablediv

posted @ Monday, October 19, 2009 9:02 PM | Feedback (0)  

Wednesday, October 07, 2009 #

Oh, That’s Just “Academic” Talk, Not Reality

Technorati Tags: ,,

I’ve gotten pretty worked up lately about comments from those developers who frequently hack stuff together and apply code & run atmospheres in their shops because they just don’t know any better and think this is the way to satisfy the business and their development team.

What am I talking about?  Comments like this:

“Oh I’ve read articles before from people like that.  A lot of that is just academic and theory, and not reality”

“You’re trying to make too perfect of code”

“The UI doesn’t need to be pretty”

“Just put it somewhere, it doesn’t really matter.   I don’t care where it goes, just put it anywhere, whatever works”

If there are comments that really annoy me, those would be the top 4 and when you hear this consistently, it outright makes you want to just quit sometimes and give up because you’re working with people like this.

Comments like this are completely naive and are stated to dodge a discussion. 

Let me break it down for you.  “Academic” has nothing to do with:

  • Properly scoping out a project based on some rough yet fairly detailed Functional & Technical specs
  • Developing by small feature iterations that are actually achievable (part of Agile)
  • Caring about a UI in that you do care about aesthetics.  You do care about site flow.   You do care about graphic designers because it all helps to translate to USABILITY
  • Caring about design patterns in code and applying them (but not over architecting)
  • Caring about clean code so that the next developer doesn’t get lost in a mess
  • Caring about physically architecting files, projects, etc.
    • using names that make sense for filenames, assembly/project names, folders to organize code files, etc.
    • Think about MVC, you HAVE to!
  • Actually prioritizing tasks based on “Business Needs”. 
    • Not bait and switching every other day based on no reason other than this or that person thinks we need this feature but nobody actually thought about priority and ROI
  • Applying all 3 types of testing: Unit testing, Quality Assurance, and Usability

This is not Academic, it’s smart business.  It’s not just related to IT.  If you create anything, are you going to blame engineers who care about producing a product that is maintainable and extensible and then say this is just being “Academic” or this is “Only For Big Teams”?

It’s only those code & run developers that are the ones even using that kind of statement, and I resent the fact that these are the people running IT shops in a lot of cases.

Stop with the BS.  Caring about producing quality extensible products has nothing to do with “Academic” vs. Real World.  And give me a break, I know what over documentation is, what over planning is, and what scope creep is.  It’s called Waterfall…been there.  I’ve had people assume that’s what I’m talking about.  Again, naive.  And obviously you can tell when something is being over architected but in many cases the person saying it’s being over architected thinks so because they routinely settle for dirty code.

To say that because we want the team to continually focus (I’m not talking about “perfection” or “pretty”…please stop it with the BS) on clean code, manageable files with names that make sense, class names that make sense, method names that make sense, using Interfaces in design is no reason to come back with a statement that includes “Academic”.

In fact I came across an issue recently where I had an Ambiguous class name conflict because we did not think about naming some .aspx with names that make sense so consequently some DL classes had the same names and thus several Ambiguous references and name collisions that were totally avoidable.  Most likely it was because of this mentality that “fast” is the only way to go that it we had that conflict in the first place because we were in a rush to get it to market.

If you’re one of these people who use excuses to dodge good process stated above, then I think you should rethink your profession and how you are abusing it.

posted @ Wednesday, October 07, 2009 10:10 PM | Feedback (1)  

Worst Development Blog Post Ever – By Joel Spolsky

kool-aidProgramming The good thing is, I don’t have to ramble on as to why this is probably the worst post I’ve ever read relating to development.  I think if I did my rambling would be an 800 page book.

But here it is, the most naive post I’ve ever read.  I suppose I shouldn’t be acknowledging and giving this guy any kind of attention but it’s so bad, I feel an obligation to share a post from a true Salesman which is what he is, not a developer:

The Duct Tape Programmer (la la la la Lame?)

Interesting Joel, I wonder why you don’t enable commenting on your posts?

I cannot even believe anyone would promote Code & Run.  No matter how you dice it, it’s not just over engineering that he’s talking about, read all of it!  He promotes Code & Run simple as that.

No people, this is NOT reality or what should be reality in your development shop, and it’s NOT smart business sense.  Unfortunately there’s a lot of morons out there who think this code & run mentality fits the bill.  It’s called controlled iterations, prioritizing your tasks, realistic deadlines, and caring about wtf you produce and that means you don’t run to get things out the door no matter what you say about business needs this or that.

Now for the posters who obviously have a brain:

Duct Tape Programming? - Certainly not THAT way...

The Duct Tape Programmer

This is true to what I believe and Uncle Bob stated it perfectly:

“The programmer who spends weeks building the perfect structure does just as much harm to the project as the programmer who hacks a bunch of crap together. Neither have struck the balance that’s required.”

Now I don’t have to read Uncle Bob’s post either to know that, I have experience that has proven that.  It’s not “academic” and that’s a lame excuse and just dumb response that I often hear from some developers who do actually apply code & run chaos to their every day delivering for the business.

Just Stop. Please.

Debunking the duct tape programmer

The State of Spolsky or: How I Learned to Ignore the Legacy Programmer Boss

Has Joel Spolsky Jumped the Shark? (this is old and unrelated but relevant)

WTF does academics have to do with smart project planning, not too much documentation (so you CAN get stuff done) and a BALANCE between finding the critical path in your code vs. over architecting an app?

If I were to run my own business like this I’d be completely ashamed; this would surely reflect bad on me if I was the owner and probably my employees would hate working for me.  It’s like waking up every morning with your wife beater shirt on telling her to make coffee because I don’t even know how to run the damn machine myself.

It makes me lose sleep at night knowing we have salesman posting about how to Code & Run out there.  Stick to selling, do not run an IT shop.

Is Joel going to make some more Kool-aid for us? And if you’re driving the big yellow bus, please do let me off soon please.

posted @ Wednesday, October 07, 2009 9:53 PM | Feedback (8)  

Tuesday, October 06, 2009 #

Page O’ Nerds

Technorati Tags: ,

 urkleI was browsing the net, looking into what Lucene.NET is all about.  Interesting enough, I was awe-struck when I came across the official “Page O’Nerds”!  In fact though it was the most interesting page in the entire apache site because it actually “drew my attention” and had some real content in it other than plain text.

This link brought forth to you from an anti-Java, Oracle, ColdFusion (believe it or not, some places still use it as sad as it is), PHP, Unix, and Apache dude…yes very shallow but true and I’m not afraid to admit it.

You ever wonder why Java, UNIX, and Apache pages are so damn boring and why you get lost so much in them with useless information?  It’s because programmers who stick with this idea that “old school is cool” think that text is amazingly hip.  I think that’s just ridiculous and I get tired of sites that look like they were built in the early 1990s regardless if it’s “just a site about development”.  I just love the old school blue links…well, not really and I think it’s quite annoying to my eyes.  Blue needs to be phased out of nerd pages period…there’s just way too much of it.  Try some new colors besides red, aqua, grey, blue, and yellow people.

I think I almost when blind with the red box on this page.

Look at StackOverflow.com for example.  Yea there may be nerds programming that site, however you’re not going to see any nerdy old school blue there, no way and I respect that.  If I had to code in Java and use Apache, I’d fall asleep looking at their sites.  I don’t care what you say, when you’re looking up stuff on the net for development (whether is documentation, forum, anything) it is nice to have a site that gets you a little more excited than a textbook looking 80s site these days especially when you’re on the net for hours looking stuff up.  How about we go back to black and white TV while we’re at it?

Thumbs up too for sites like jQuery, Codeplex, etc. that actually get you excited about code because their site doesn’t make you drown in black and white text. 

Yes, I am automatically a nerd…simply because I develop…I won’t argue that.  I suppose now you want me to post my picture to prove I’m “cool”; not a fat chance.  However between you and I (cool developers): blue links are just lame no matter what site you’re talking about.  Style those f’ers.  

And to the true “nerd Developers” (yes, architects..who might even be you right now) please get out of your tight blue jeans, puke colored pants, yellow stained shirts, shirts that look like they came from goodwill, unmatched shoes, and thick glasses and live in the today and that includes understanding that black and white terminals, blue links, and a site with just text is no longer acceptable or “cool”.  Have some respect for yourself other than just "I live in a cave”.  Fortunately I dress half way decent and present myself with a pair of shoes, shirt, and pants that “match” on a typical basis.

I’ve said my peace about a few things in general about development here…one being that I think being “nerdy” is not “cool”.  Second being that I don’t understand why we as developers think it’s hip or cool to have a site today with all text and blue links. In other words, it’s getting old people.  And this is the only post you’re gonna see on my site categorized as Java so there’s my contribution.

Is this post lame?  probably.  And you’re definitely entitled to your opinion as well.

posted @ Tuesday, October 06, 2009 8:13 PM | Feedback (5)  

Sunday, October 04, 2009 #

Switch Connection String Being Used Based on Constructor Flag

Technorati Tags:

I want to talk about an interesting scenario I had in code recently.  We wanted to change up a connection string based on a flag to any Business Layer method calls being made.

First here’s some facts:

1) We had a base class called DatabaseBase

2) We had a derived class that inherited the base: SomeProjectDB : DatabaseBase

3) Business Layer method calls would eventually use an instance of SomeProjectDB in part to make the associated Data Layer method calls for a BL method

So for example you might have a Business Layer method like so:

  1: public Order GetOrder(int id)
  2: {
  3:      Order order = db.GetOrder(id);
  4:           return order;
  5: }     

You’d have an instance of db which is an instance of SomeProjectDB.cs created somewhere in code so you can reference and use it.

So then in one of my web services I could have something like this originally before I implement the check:

  1: [WebMethod]
  2: public Order GetOrder(int id)
  3: {
  4:      MyBusinessLayerNamespace.GetOrder(id);
  5: }

Goal: We wanted to use a different connection string than the default if the business layer method calls were being made from a web service (.asmx) like above so that we could make calls using a more secure connection string (one that did not have so many permissions to stuff we really don’t need).  Since the alternative connection string would be much more secure than the one we normally are using.

So for any BL method calls we were making in our service methods we are going to use this special connection string.  That connection’s SQL user would only have rights to any procs or other resources necessary to run any of the calls that were being made to any BL methods from our web service.

So here’s the base class:

  1: public class DatabaseBase
  2: {
  3:      private readonly string connectionString;
  4:      private bool useCounters;
  5: 
  6:      public DatabaseBase(string connectionString)
  7:      {
  8:           this.connectionString = connectionString;
  9:      }
 10:  
 11:      ... rest of code
 12: }

And for example, here’s SomeProjectDB:

  1: public class SomeProjectDB : DatabaseBase
  2: {
  3:      static string defaultConnString = ConfigurationManager.AppSettings["DefaultConnString"];
  4: 
  5:      public SomProjectDB() : base(defaultConnString)
  6:      {
  7:      }
  8: 
  9:      public SomeProjectDB(bool useWebServiceConnection) : base(
 10:             useWebServiceConnection ? defaultConnectionString : 
 11:             ConfigurationManager.AppSettings["SecureConnectionString"])
 12:     {             
 13:     }
 14:   
 15:     ...rest of code
 16: }

Now I can create an instance of this two ways from a Business Layer method:

SomeProjectDB db = new SomeProjectDB(); 

this would use the default connection string.  Since calling the parameterless constructor would end up with the instance of SomeProjectDB passing the local backing field defaultConnString to the base class’s constructor

SomeProjectDB db = new SomeProjectDB(true);

this would call the overloaded constructor that requires useWebServiceConnection.  Then I’m passing the incoming useWebServiceConnection value straight to the base class’s constructor and checking whether that value is true to handle which connection string should be used.  If it’s set to true, use the special connection string with more security “SecureConnectionString”.

So now, the call in my web service would look like this:

  1: [WebMethod]
  2: public Order GetOrder(int id)
  3: {
  4:      MyBusinessLayerNamespace.GetOrder(id, true);
  5: }

MyBusinessLayerNamespace.GetOrder method would have a new overloaded method  that I could use which could take in the true parameter to determine that it should use the secure connection.  That BL method would then call db.GetOrder(true) and we’d use that object as part to call the data layer GetOrder method to ensure that DL method is making transactions over that more secure connection string.

Anyway, it’s a lot to think about, thought this was kinda an interesting little problem.  This is how I solved it.

posted @ Sunday, October 04, 2009 10:43 PM | Feedback (0)  

Friday, September 18, 2009 #

Do Not Return True/False on a Transaction Success/Fail

Technorati Tags:

There are many times in some shops I’ve worked where I’ve seen developers return a boolean back form a method for a transaction fail vs. succeed as a way to determine whether to do something next in code.  A transaction could be any type of work.  I talk about transaction here in a generic way; insert into a db, copying of a file to a directory, you name it.  

Here’s an example:

public bool DoSomething(int someID, ..., ...)
{
    return db.DoSomething(someID, ..., ...);
}
 
In this example the caller would get a true/false returned based on if the code was successful or not.
 
Why is this horribly a bad way to handle success/failure of something that “happened”?  Well here are 2 obvious reasons:
 
1) The caller gets a false back.  Ok, what the hell does that mean?  What if I need to know why for obvious debugging/troubleshooting purposes, especially if I’m gonna call this method from a service
 
2) I’m not returning something back that is useful.  A descriptive error is useful.  If not that then I should be sending back a more useful object that I can do something with.  No, a boolean in this case is not a smart idea.  It tells me something happened but nothing more.  It keeps me blind especially if I ever have to debug further at any time to figure out why it was false!
 
To me, that’s a very lazy coding unless you want to purposely eat the error.  In this circumstance there’s no reason to eat it basically by sending back a false.  If you’re logging it fine but again, to the caller it’s not helping them at all.  While it might work, it’s not going to help when you keep getting false back and wished that the method would be much more helpful and not so mysterious.
 
And you really shouldn’t be eating the error unless you have a good reason for it.  In this case you’re not handling anything and you’re not doing your caller any good or the rest of the code to be built on top of this because then that code becomes lazy also because all it has to do is check for false.  Soon all your code is checking for true/false and you have no real debugging capabilities when you wonder why am I getting false, false, false when you step through your code on a bunch of method calls to try to figure out wtf is going on.
 
This is nothing new, just a reminder again to write write clean maintainable code.
 

posted @ Friday, September 18, 2009 9:45 PM | Feedback (4)  

Can’t See Recent Commits in Tortoise SVN Log

Technorati Tags:

After restoring a backup repository today and then checking in some code to it, I noticed that the commit showed successful but when browsing the log I did not see it in there.  In fact no commits were showing.

It ended up being the History cache.  The solution was to disable it and update the existing cache (who knows if there’s a quicker/easier way but this is just what I did in the spur of the moment).

So uncheck the caching (I don’t really care about performance):

cache1

Then I updated the existing cache (again I don’t know if this is necessary, I just happened to try it without looking much into it):

cache


posted @ Friday, September 18, 2009 9:30 PM | Feedback (0)  

Can't Open File txn-current-lock – Tortoise/Subversion

Technorati Tags:

Today I had to restore a backed up repository.  I backup our entire C:\Repository on our dev server and simply copy it back to restore it as the server had crashed (don’t ask me why..I was not involved nor was there an image to just take and restore).

Anyway, after I did, the repository version was perfect and up-to-date so we could carry on.  One error I did get initially after starting to use the restored repository was this when I tried to check in a test change:

errorscreenshot

This simply happened because my C:\Repositories folder was set to read-only on our Server 2008 dev server.  So, I simply removed that flag on the folder and it was fine and I was able to check in my code again.


posted @ Friday, September 18, 2009 9:21 PM | Feedback (0)  

Friday, September 11, 2009 #

Quick Extension Method for Grabbing Exception.Data

Technorati Tags:

This is nothing spectacular and exception methods are used all the time.  But thought to just post up for those of you who haven’t used them a lot.  Today I needed to check that Exception.Data is null.  If it was not, I wanted to then send a string. 

First I added the data to the exception which is just the SOAP text that was sent via the HttpRequest that was used in a method that I called:

XmlDocument doc = new XmlDocument();
doc = CreateRequestXML();
 
// Grab the SOAP that is being sent for possible logging later
_SOAPSent = doc.OuterXml;
 
....
try{ ....}
catch (Exception ex)
{
    // include SOAP string that was sent
    ex.Data.Add(Constants.SoapRequestData, _SOAPSent);
 
    throw;
}

And I ended up just creating an extension method to handle checking for that value and if it’s null, and returning the string back without error if the data key is not available:

namespace [CompanyName].[ProjectName].Extensions.ExceptionExtensions
{
 
    public static class ExceptionExtensions
    {
        /// <summary>
        /// Gets the exception data.  If no data exists returns empty string
        /// </summary>
        /// <param name="ex">The ex.</param>
        /// <param name="key">The key.</param>
        /// <returns>Data retrieved from Exception.Data</returns>
        static public string GetExceptionData(this Exception ex, string key)
        {
            if (ex.Data != null && ex.Data.Contains(key))
                return ex.Data[key].ToString();
            else
                return string.Empty;
        }
    }
}

Now I can use it like this when I want to safely retrieve the data:

catch (Exception ex)
{
    string soapcalled = ex.GetExceptionData(Constants.SoapRequestData);
    service.LogFailure(..., ..., ..., soapcalled);
}

I used a string constant as the key to prevent magic strings being specified as a param.


posted @ Friday, September 11, 2009 4:45 PM | Feedback (0)  

Thursday, September 10, 2009 #

Using Exception.Data to Append Extra Data to Your Exception

Technorati Tags:

This is one of the rare times I’ve needed to append some data to an Exception.  And I really hadn’t used Exception.Data before.  So today was interesting.  I was tired of this third party API causing me inconsistent results when we call methods (because the API is not very reliable in the first place) so I wanted to log the SOAP request that’s being sent every time as part of any logging/debugging which is very useful when you only have just the .NET exception stack and really are missing the other piece of the puzzle, which is what was the SOAP data that was sent over the HttpRequest when you got the error in the first place.

But if you’re handling exceptions correctly and logging them somewhere you should be able to get enough information from your logging to figure out what went wrong in most cases.

Here’s an example of how I used Exception.Data today.

1) I’ve got a Request.cs abstract class

     In it, I’ve got the work of setting up and sending the actual HttpRequest via this method:

public Response.Response SendRequest()
{
    Stream requestStream;
    Stream responseStream;
 
    XmlDocument doc = new XmlDocument();
    doc = CreateRequestXML();
 
    // Grab the SOAP that is being sent for possible logging later
    _SOAPSent = doc.OuterXml;
 
    // Determines if API call needs to use a session based URI
    string requestURI = UseAuthURI == true ? _requestURIAuthBased + SessionID : _requestURI;
 
    byte[] data = XmlUtil.DocumentToBytes(doc);
    HttpWebResponse response = null;
 
    // Create the atual Request instance
    HttpWebRequest request = CreateWebRequest(requestURI, data.Length);
 
    request.ContentLength = data.Length;
    request.KeepAlive = false;
    request.Timeout = 30000;
 
    try
    {
        // Send the Request
        requestStream = request.GetRequestStream();
        requestStream.Write(data, 0, data.Length);
        requestStream.Close();
 
        // get response
        response = (HttpWebResponse)request.GetResponse();
    }
    catch (Exception ex)
    {
        // include SOAP string that was sent
        ex.Data.Add(Enums.ExceptionDataRequest.SOAPCalled, _SOAPSent);
       
        //Throw to retain data
        throw;
    }
 
    ....rest of this returns a response back
}

Notice these lines above:

   _SOAPSent = doc.OuterXml;
        // include SOAP string that was sent
        ex.Data.Add(Enums.ExceptionDataRequest.SOAPCalled, _SOAPSent);
        //Throw to retain data
        throw;

So I catch the exception and also appending some data to it using Exception.Data.   What I added to it was the SOAP text that was sent in the HttpRequest.

Now here’s what you can’t forget to do.  You need to re-throw the exception to retain it as I did above or else you’ll lose that data.

2) So now in my code-behind of one of my .aspx I have the following:

private void SomeMethodInCodeBehind()
{
    ...
    try
    {
        xxx.UpdateFrequency(...);
    }
    catch (Exception ex)
    {
        service.LogFailure(..., ex.Data[Enums.ExceptionDataRequest.SOAPCalled].ToString());
    }
       
    Response.Redirect("somepage.aspx?freq=1&action=" + _actionID);
}

So here I’m logging the exception and then retrieving that SOAP string that was sent to also log that:

ex.Data[Enums.ExceptionDataRequest.SOAPCalled].ToString()

3) xxx.UpdateFrequency, the method that I called from code-behind looks like this:

public void xxxFrequency(string email, string actionID, string listID)
{
    ...
    UpdateFrequencyRequest request = new UpdateFrequencyRequest(actionID, email, listID);
    UpdateFrequencyResponse response = (UpdateFrequencyResponse)request.SendRequest();
    ...
}
So ultimately this is being wrapped in that try/catch in my code-behind.  I make the request and am calling SendRequest().  When the request fails, it will throw that error up the stack until it hits my catch statement in my code-behind in #2.  Then I can easily grab the SOAP that was called during that failure.

Now I can log the SOAP anytime I call the request class’s SendRequest easily throughout my code and get something such as this to log and use for debugging if needed:

<Envelope>
  <Body>
    <SelectRecipient>
      <LIST_ID>11111</LIST_ID>
      <EMAIL>someemail@domain.com</EMAIL>
    </SelectRecipient>
  </Body>
</Envelope>
 
 
Notice that I also setup an Enum so that I don’t have any magic strings laying around when I’m accessing the keys from the data dictionary.

Pretty cool stuff, common, just never used the data dictionary on the exception object much but definitely powerful.


posted @ Thursday, September 10, 2009 8:14 PM | Feedback (3)  

Sunday, August 30, 2009 #

Deploying a Web Application Project Still looks for Code-behind during Runtime

Technorati Tags:

When you deploy a WAP project, you don’t need to copy up any code-behind pages for .aspx pages or user controls (.ascx). 

However, I was stumped when recently I had an old WAP project that I was working on and needed to deploy some updates.  I published it via the Build | Publish option in VS 2008 and then selected only to publish the minimum required:

publishwap

But I was getting errors during runtime stating that it could not find the code-behind page to default.aspx.

Anyway, the problem was I forgotten that about 4 years ago, I had copied the files from an old website to a WAP project.  But at the time, I didn’t actually convert the .aspx pages to WAP.  That’s why I was still getting that error during runtime even though I had copied them into a brand new WAP project.  So I simply right-clicked the WAP project and did a “Convert to Application”.  Since this was a very small non-complicated web site, I had no issues and this resolved that deployment issue in production.

In a future post, I will talk about how to convert a very large complex website project to WAP, something I had to do recently at work.  I’ve never really used websites and it’s always been WAP in the past 5  years so this was a royal pain in the ass due to the complexity of our huge .com public site.  Hopefully I will provide a very clear path to converting…because some of the articles out there are pretty lame and don’t really tell you all the details you need to know.  So look for that coming soon.


posted @ Sunday, August 30, 2009 1:53 PM | Feedback (1)  

Monday, August 24, 2009 #

Running 64-bit Binary References in Visual Studio

Technorati Tags: ,,

I had an issue where we wanted to start including the 64-bit assemblies to our WAP project replacing the 32-bit references.  I was getting errors during runtime stating that it could not find the 64-bit assemblies when trying to run the web site on my local Vista 64-bit PC.  Yet if we added the 32-bit assemblies to the web project instead and then deployed to our 64-bit Server 2008 Development Server and then copied back over the 64-bit assemblies into the bin of our web project, the site ran fine.

There is one little problem that I was not aware of till now since we’re now using a lot more 64-bit processes these days.  Visual Studio (in my case 2008) runs only a 32-bit built-in web server process.  Personally I like using IIS instead anyway when debugging my ASP.NET apps.  It’s truer to what a real environment is anyway rather than relying on the funky built-in web server which does some real weird things sometimes.  So because the built-in web server in IIS is only 32-bit it’s not going to be able to run or find 64-bit assemblies therefore you’ll get runtime errors like this.  So out goes the built-in web server option.

So I changed my web project to use IIS instead:

1) Go to the properties of your WAP project.

2) Web Tab.  Select “Use Local IIS Server”

     useiis

3) Click “Create Virtual Directory”.  This will create a new Web Application automatically for you in IIS instead of having to create one from scratch yourself.

4) Now go to the app pool that your application is using.  Go to its basic settings and make sure you are using “Classic” for the Managed Pipeline Mode

    basicsettings_apppool

5) Go to the advanced properties of your app pool and make sure “Enable 32-bit Applications” is set to false

     advancedproperties_apppool

After this, I was good to go.   I was able to attach the 64-bit assemblies and the site would run without any errors because it’s now running in a 64-bit process.


posted @ Monday, August 24, 2009 9:02 PM | Feedback (1)  

404 Error When Running Web Applications in IIS 7

Technorati Tags: ,

Today I was getting an annoying 404 (page not found) on any Application in IIS 7 I created.  I was trying to run our .NET 3.5 web application project and I knew everything was setup right in terms of configuring the site in the IIS Manager.  I looked at my hosts file, everything I could think of.

I’d create an Application (right-click the default web site in IIS 7 and choose Create Application) manually as well as tried to create one through VS 2008 (in the web project properties, go to Web tab and select to use IIS and click the “Create Virtual Directory” button.  Both ways you can create an Application in IIS under whatever web site.

Anyway, after all the troubleshooting it just came down to the fact that I did not have the IIS 6 Metabase and IIS 6 Configuration Compatibility portions of IIS installed.  I figured I did not need them because they were “legacy IIS 6 stuff”.  Well you do need them if running localhost.  I guess usually I had installed as I never had this problem before, but probably this time around on this new system figured I did not need it.  Well I was wrong.

Honestly I think it’s just dumb that we need to enable a feature with something labeled “IIS 6” when we’re using IIS 7 and .NET 3.5 WAP projects in VS 2008.  It’s just weird.  MS what were you thinking?

So Make sure you install this when you enable IIS.

iis6  


posted @ Monday, August 24, 2009 8:43 PM | Feedback (0)  

Monday, August 17, 2009 #

“We want it fixed, but don’t spend too much time on it”

Technorati Tags:

tasks I just love this one.  These kind of statements really piss me off as a developer especially when I have a task or two I’m already working on.  This has got to be one of the worst lazy ass one liners you can get from a manager these days in development.

So here’s the story:  You get a new request in straight up from a user (because unfortunately there is no proper ticketing system or any process in place at any time whatsoever).  Boss asks “what’s the problem”.   You explain shortly to your boss the problem that the user painted.  Boss tells you to take care of it.  But at that point, it’s too late in the day to really start tackling it and you have other more important tasks that you already started for your boss that day.

Next day comes, you now start on that task first thing in the morning.  Suddenly though you are invited and required to attend a 2 hour meeting that your boss never told you about...very nice.    He wants you to abruptly stop all you are doing to attend.  And granted this meeting was not an emergency.   You go to the meeting and get back.  Boss walks back from meeting and says “Hey, about that problem, we want it fixed but don’t spend too much time on it”.

Stop.  Lets rewind that again.  What’s wrong with this picture? A LOT.

1) First and foremost above all else, are were expected to get existing tasks done.  That statement throws a wrench into the engine

2) You were unprofessionally interrupted about a meeting everyone else was informed of days before except you

3) Worse, there is obviously no priority system here and that IS a major problem from top down

4) It’s complete chaos because it gives no conclusion on what your boss truly wants you to do.  It leaves the developer with questions, not direction.

We want it fixed, but don’t spend too much time on it”.

If that’s not one of the worst contradiction a human can make, you tell me what is worse than this.  “We want it fixed”.  It’s the blind leading the blind because notice that your boss did not say when.  And he did not say now.  And yesterday when that came in he also did not say when it needs to get done.

If you want it done but you don’t want me to spend time on it then YOU put it in a bug request and put a priority on it for me Mr. Manager.  Otherwise let me develop and work on the tasks you specified that are already being worked on.

Isn’t it not the job of a manager to give direction?  Stating something like this just gives a developer indirection and that developer is left to figure out what the hell that manager REALLY means.  Or spend all day and night working overtime to do it ALL.  Whoops, there went your “work life balance”, nice.


Side Note:

And I find it unbelievable that it’s usually these types of “people” are the ones who are rushing you to get something done with an unrealistic timeframe. And then when you do get something done, you don’t hear from them for days, and you’re now sitting there with nothing to do!  So you’re being screwed on both sides of the coin.  On first hand, that statement tells you to rush to get it done “don’t take too much time on it” and then the other situation (sitting for a few days with no new work being passed onto you) puts you in a mindset “wtf, screw you”.

I say “people” because these “people” are not good enough to be “managers” because they operate in carelessness like this.


So when this happens, you put that task asideDo not spend time on it.  Because in my eyes, that statement is careless and so you should treat it as so.

See your existing tasks through till completion.  Work on them and get them done.  Because if you do not produce results and you focus on that new task instead that your boss did not originally give to you and furthermore gives you contradicting statements on, you will not be producing results and ultimately your boss will not be happy in the end no matter what he had said about that “other” task. 

Unfortunately in code & run shops, sometimes you simply have to make your own decisions when you’re tossed chaos into your lap and constantly working in non-professional environments like this.  You have to be the manager because your boss is not capable in these situations.

This kind of thing happens a lot in IT shops which have no planning, organization, realistic deadlines or priorities.  This is code & run and most likely a shop you do not want to work in.

Go home and live your life, spend time with your kid, your spouse and stop worrying about it.  Spend time on it another day when your boss finally clears his head on that task and tells you to spend time on it, making it a priority in his disoriented mind.


posted @ Monday, August 17, 2009 10:36 PM | Feedback (2)  

Sunday, August 16, 2009 #

Rate Your Employer Sites – It’s About Damn Time

office-space

I’ve noticed lately a lot of new sites cropping up allowing developers to rate their employers.  I say it’s about damn time.  The state of IT and development shops is in pretty bad shape and money isn’t everything.  If your boss is an ass or can’t even manage himself, your department is in chaos mode 24x7, there is no planning and just run & code, or you’re being scolded for things that are just crazy or made up then there’s a little more than just money that can ruin your job, career, and family life.

Obviously there are good shops and these sites help to highlight that as well.  But the problems with bad management, lack of process, code & run, overworking their employees are something you do not know about until you’re inside the organization.  Then it’s too late.  We need resources like this to help us in our job searches.  And the more we contribute to reviews, the more useful these sites will become.

I highly urge anyone reading my blog to contribute.  Sincerely rate your development shop, managers, etc.  Talk about the problems in some kind of detail so others can really get an inside glimpse of the issues involved so that other developers don’t make the mistake of working in a bad environment.  The more details the better to make your rating legit.  Do not name names, but give enough detail to let everyone know thumbs up or thumbs down.

Here are some sites you can contribute to and rate your development shop or organization as a whole:

http://coderific.com

http://www.jobvent.com

http://www.rateitall.com/s-100-employers.aspx

http://www.gamewatch.org/phpbb3/

http://www.ratemyemployer.ca/ (Canada)

If you need company profiles to help you enter in the information for your company, just search them on LinkedIn and you get a nice profile.


posted @ Sunday, August 16, 2009 4:35 PM | Feedback (4)  

Thursday, July 30, 2009 #

Cannot See Service Reference Proxy Class File in Solution Explorer

del.icio.us Tags:
Technorati Tags:

Today I had added a Service Reference to my Web Project and after creation, I did not see the Proxy class file.  This was my first time creating a Service Reference which is the new way to do it in .NET 3.5 vs. the older Web Reference option that uses an .asmx when you right-click your web project.

Anyway, it turned out that duh, I simply needed to simply show all files in Solution Explorer.  I’m not quite sure why it’s hidden in the first place but as soon as I did that I could clearly see the proxy class called Reference.cs:

autogenclasses

Inside this Reference.cs is all the partial classes making up the objects based off the WSDL.  This was based on the PayPal Sandbox WSDL:

https://www.sandbox.paypal.com/wsdl/PayPalSvc.wsdl


posted @ Thursday, July 30, 2009 9:30 PM | Feedback (0)  

Sharing Folders in Vista OS Instance with Sun VirtualBox

Technorati Tags:

del.icio.us Tags:

Sun’s VirtualBox virtual application just blows away Microsoft’s Virtual Machine and it’s free also.  And its so packed filled with features, much more than Microsoft’s VM solution.

After you’ve installed Sun VirtualBox and got an OS running on it make sure you install the guest add-ons or else you’ll have to click Ctrl to escape out of your virtual machine when in it.

addons

Then to share a folder you can do it 2 ways.  You can do it via the settings when the VirtualMachine is turned off:

settings

(setting www on my hosts’s C to be shared to this virtual PC)

setshared

Or you can do it when the VirtualMachine instance is turned on through the Shared Folders option in the Devices menu:

shared

(setting software on drive E to be shared to this virtual PC)

setshared2

Either way, you can add a shared folder and share anything from any of your Host’s drives (C, etc.).  But you’d want to use the first method when your Virtual PC is shut down because otherwise your shared folders will not stay each time you stop and restart that virtual machine that you’re sharing to.

To access the shared folder on your VM in Vista specifically, type \\vboxsvr\SharedFolderName in explorer and hit enter, then it should map a drive to it:

mapdrives

there is how you’d share folders in Vista running on a Sun VirtualBox.  It’s a joy to use this Virtual Machine software, especially when it’s free!

Another great thing about it is you can truly set as much ram as you want and really configure your machines to run blazingly fast if you have a ton of ram on your Host.  I have 8 gigs ram so I can easily specify 4 gigs for a Virtual machine:

memory


posted @ Thursday, July 30, 2009 8:10 PM | Feedback (3)