Interrupting your user

8 10 2010

When designing user interfaces a lot of thought needs to go into when you are going to interrupt a user.  I am going to walk you through an example of what not to do.  My example deals with messing around with CSVs in excel.  I recently have been doing a lot of data loading via CSV and found myself getting consistently interupted by Excel when trying to save.  Pretty simple concept, once I have changed a document I should be able to click save ( yup thats it, nothing else.. pretty simple request huh?). 

 

Well take a walk with me…

Step 1.  Right click your desktop->new->Text Document

Step 2.  Change the name to Test.csv

Step 3.  Double Click Test.csv and it will open in Excel.

Now you will have an empty spreadsheet.  I am going to enter(| indicate next cell) : This | Is | A | Bad | UI | Interaction

 

Excel_CSV_PreSave

Step 4.  Click Save.

Kaboom.  Greeted with a Sound AND Messagebox:

Excel_CSV_ClickSave

So I dont understand?  I just entered text why is it complaining about tabs?  Oh well I want to Save my csv format… so i click yes.

Step 5. Click Yes

Step 6.  Close

I then go to close the workbook and am greeted with:

Excel_CSV_NoChanges_Close

Hmm.. I didn’t change anything so NO!

Step 7. Click No.

So lets open it back up and see what’s going on.

Step 8. Double click Test.csv

Excel_CSV_NoChanges_Close_ClickedNo

Really?  I guess that first warning was justified. Apparently, when I clicked yes to keep the format it meant, collapse into one cell and insert ? character…hmm.

Note: If you are on Windows 7 you might just see ThisIsABadUIInteraction either way it collapsed the text into one cell

Lets get out of here

Step 9.  Close

Excel_CSV_NoChanges_Close

GAH!  Again!

Step 10.  Click No

So now I am just going to take over, I am going to open up the raw text and fix the CSV myself. 

Step 11.  Edit text and place “,” between each word and remove the TABs.  Save and Close.

Excel_CSV_Fixing_WithVim

Step 12. Open this thing back up(in Excel).

Ah.. much better.

Step 13.  Add a new row

EXcel_Csv_Take2

Step 14.  Save (yes)

Here comes that warning again… click yes.

Excel_CSV_Changes_Y_SaveAs_Exist_Y_NonCompatx2 (1)

Step 15.  Close

Nooooo not again.  I don’t think I changed anything….

Excel_CSV_NoChanges_Close

Step 16.  Lets click yes for the fun of it…

Woah…. Save As?  Really?

Excel_CSV_Changes_Y_SaveAs

Well I don’t want to change the name… so I click

Step 17. Click Save

Noooo tooo many decisions…

 Excel_CSV_Changes_Y_SaveAs_Exists

Really?

Step 18.  Click Yes.

We have to be done right…?

Excel_CSV_Changes_Y_SaveAs_Exist_Y_NonCompatx2 (1)

Brain explodes… get a friend to click yes…

Step 19.  Click Yes.

 

FINALLY it closes.

 

So just take that for what its worth. There are really only 3 issues that reoccur that makes the process painful.   One if I open up a document and click save:  Save it, pretty simple.  Excel offers a “Save As” option, if i want to specify a different name or change the type I will select “Save As”.  Second, when its time to close prompt me to save changes (if I have actually changed anything) and then accept my answer and close.  In our situation it took 5 clicks to close… ?

 

Another thing I notices was the dialog that says “filename may contain features that are not compatible with ..(CSV or TAB).  What does that mean?  I didn’t do anything more than enter csv stuff.  I didn’t use formulas, charts, etc so what is it complaining about?  The first time I opened a CSV, it was completely empty.   But for some reason it decided it was a TAB delimited format?  Who knows.  Its almost like they are trying to scare you into the “lastest Excel format.”  Oh well, if you take anything away from this entry:

 

Americans are indecisive by nature, so don’t overwhelm  with unnecessary, and very word prompts.  Code to the things that the majority of people will want/need to do, and only interrupt people when it is completely necessary.





.NET 4.0 Dynamic

30 09 2010

There is a built in type now in .NET 4.0 called “dynamic.”  Just as its name implied its a lose type, it has an infinite amount of properties and methods…(reminds me of python)  This should not be confused with “var” which is a strongly typed lazy-man’s variable. 

 

Dynamic is whatever you want it to be quick example… 

 

The below code illustrates the use of dynamics.   I have declared a simple class that has two properties (Name and Description) and one method PrintUsingReflection…

 

using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Reflection;

namespace BlogTests
{
    public class Test
    {
        public string Name { get; set; }
        public string Description { get; set; }

        public void PrintUsingReflection(object test)
        {
            string name = test.GetType().GetProperty("Name")
			    .GetValue(test, null) as string;
            string Description = test.GetType()
			   .GetProperty("Description")
			   .GetValue(test, null) as string;

            Console.WriteLine("Hello there " 
			    + name + " description"
				+ Description);
        }
    }

    [TestClass()]
    public class DynamicExample
    {
        [TestMethod]
        public void ThisIsATest()
        {
            object test = new Test()
            {
                Name = "Nick",
                Description = "Nicks Dynamic Variable!"
            };

            PrintUsingDynamics(test);
        }

        private void PrintUsingDynamics(object test)
        {
            dynamic dynamicTest = test;
            Console.WriteLine("Hello there " + 
			   dynamicTest.Name + " description" +
			   dynamicTest.Description);
            dynamicTest.PrintUsingReflection(test);
        }
    }
}

 

Lets start with the test method called ThisIsATest()..

I am going to start by initializing a class called Test and then cast it to an object…

object test = new Test()
{
    Name = "Nick",
    Description = "Nicks Dynamic Variable!"
};
PrintUsingDynamics(test);

I then pass the object to PrintUsingDynamics() within the method you will see:

dynamic dynamicTest = test;
Console.WriteLine("Hello there " + dynamicTest.Name + " description" + dynamicTest.Description);

I take the provided object(which is really a “Test” class) and assign it to the “dynamicTest” variable.  At this point it is now a lose type…

In case you don’t believe me.. lets see what intellisense has to say about “dynamicTest.”

 

Dynamic_AutoComplete

 

Inside my Console.WriteLine i then attempt to access the Name and Description properties… then the black magic of dynamics takes over.  Volia! 

“Hello there Nick Nicks Dynamic Variable”.. displays. 

 

Back in the day we would have had to have done some really code heavy reflection:

private void PrintUsingReflection(object test)
{
    string name =  
	   test.GetType()
	     .GetProperty("Name")
		 .GetValue(test, null) as string;
    string Description =    
	   test.GetType()
	     .GetProperty("Description")
		 .GetValue(test, null) as string;

   Console.WriteLine("Hello there " + name  + 
                    " description" + Description);
}

Now if you look at the line after we print out "Hello there..” you will see dynamicTest.PrintUsingReflection(test);

dynamic dynamicTest = test;
Console.WriteLine("Hello there " + dynamicTest.Name + " description" + dynamicTest.Description);
dynamicTest.PrintUsingReflection(test);

Which is an example of accessing a “method” on a dynamic type.  At runtime the compiler crosses its fingers, and then calls the method PrintUsingReflection and hopes that the method exists… and volia!  Once again

“Hello there Nick Nicks Dynamic Variable”.. displays. 

 

This has been around for a while… but its incredibly useful!

 

Which one is easier (correct answer is dynamics)….?  The basic premise is whatever you type has to exist.. the compiler basically skips compile time checking.. and at runtime will resolve any property/method calls so be careful!

 

This comes in handy when doing things with “DataItems” that are anonymous types… avoids you having to create some type of “internal” type just so you can get to the data you need..





Clearing Unwanted Chrome History Entries.

15 09 2010

I will say this article is not for the faint of heart, or useful to 99% of the people out there but for me it was a major pain in the arse.  Anytime you find your self hacking around with files that you have no clue what they do, you know you are in an extreme situation.

So here is how it went down.  As all American men know its Football season, and that means its Fantasy Football Season.  I know we don’t visit the Fantasy Football League home page that often, wink wink and using a bookmarking to the page is tooo slow for me.

I just want to type  in the chrome address games enter and voila!   For those familiar with ESPN Fantasy Football the league address is something like:

games.espn.go.com/ffl/standings?leagueId=XXXXX

Unfortunately as most non-Americans know this was a World Cup year, and as a result some of us might have done some WC Bracket entries. This poses an issue for me because the URL for the ESPN bracket entry is some what similar

games.espn.go.com/bpredictor/en/entry?entryID=XXXXXX

As a result I type in “games”…

Games_History_ESPN_Bracket

Just got a nervous tick thinking about it… When I type games the bracket predictor shows up first (because of alphabetical sorting of URL), as result I can’t type “games” enter, I have to type games down down  down enter.  Completely unacceptable when you are theoretically doing this 20 times a day.

Now the simplest solution is to clear all history.  I don’t want to do this because I like the history, and ease of going to sites I visit frequently.

Tools you will need:

1.  Utility to browse SQL Lite files.  Simple easy one:  http://sourceforge.net/projects/sqlitebrowser/

2.  SQL Knowledge.

Step 1 Close Chrome.  That might prove challenging if you are reading this… ;)

Step 2. Open up “SQLite Database Browser” and then navigate top the History file located:

- C:\Users\<Your user name>\AppData\Local\Google\Chrome\User Data\Default\History

Note history is actually the file name not the directory name.

Once you have opened the file you should see:

SQLLite_History

Click the Execute SQL Tab and enter

select count(1) from urls where url like '%bpredictor%'

In my case I had 27 entries.  The like condition in my scenario was bpredictor, you can change this to be whatever you want.  Now the magical part that will allow me to sleep well tonight.

delete from urls where url like '%bpredictor%'  ;
delete from segments where name like '%bpredictor%' ;

If you were to run your SQL Count command again you will now see 0.

Now you are done, go to File->Save Database.

SQL_Lite_SaveDB

Open up chrome type in “games”… wohooo! Now hit enter!

Games_History_ESPN_FF

Notice my shameless plug for StackOverflow.com  if you don’t know what it is, and you are a developer you should!

I am finding some pretty cool things in these SQL Lite DBs.. if i find anything else useful.. you know I will share it.





A pessimist is never wrong.

27 08 2010

I got into trouble a while back because I wrote a method that does exactly what I said it would do.  Strange huh?  I missed one important step, I trusted that the end user would respect the input requirements of my routine. 

Simply stated, if you provide me this input(preferably Hairy Potter or Genie) , my method will solve world hunger.

Unfortunately my end user provided me with a red headed step child, and as a result I returned a pyramid scam. 

 

Before I dive into code, I want to justify the title of the post.  One important lesson learned in software development is that you can’t trust anyone, and that no field tests Murphy’s Law more, than large scale system development.  When I develop I ask myself how can someone break this?  And I then make every reasonable effort to prevent a user from doing something that they shouldn’t. If I write my code to assume that everyone is illiterate, or refuses to read the documentation in my code, then I will protect myself from evil programmers.

 

Simple example which also shoes a fancy .NET 4 way of checking method pre/post conditions.

 

ConvertToCaptish_withComments

 

So my documentation clearly states a NON NULL English word,  but deush-bag Larry decided that he wanted all words so he passed null.  When he ran his program he was very angry to find out that null translates to an “Object reference” exception, which was not included in my documentation.

 

What you can’t see here is that my code assumes that the user will follow my simple request, pass me a NON-Null value.  So in my code I don’t assert that the user passed a non null value, I just TRUST that the user will follow my orders. 

So my code:

        /// <summary>
        /// This method will convert any plain english word to the Capitish language.
        /// </summary>
        /// <param name="englishWord">A non-null english word</param>
        /// <returns>Capitish equivelent word/words</returns>
        public static string[] ConvertToCapitish(string englishWord)
        {
            //1 known trouble word
            string[] matches = null;
            List<Func<string, string[]>> translators = new List<Func<string, string[]>>()
            {
                (string x)=>x.GetHomonyms(),
                (string x)=>x.GetKnownPermutations(),
                (string x)=>x.WildGuess(),

            };
            int index = 0;
            do{
                matches = translators[index++](englishWord);

            }while(matches == null || matches.Length == 0);
          
            return matches;
        }

Gracefully crashes upon null strings.  Now, this is only a simple example that I created to show you why you should always ASSERT that people are following your orders.  Pre .net 4 this was painful, you either had to use an external library, or you had to use asserts.  Either way it was painful.  Well now.. .NET 4 gives you “Code Contracts” which makes this much easier.

 

Just an aside I use mock string  Extension methods to do the actual translation:

    public static class StringExtensions
    {
        public static Dictionary<string, string[]> MagicDictionary = new Dictionary<string, string[]>();

        public static string RANDOM_WORD { get; set; }

        public static string[] GetHomonyms(this string word)
        {
            return MagicDictionary[word];
        }
        public static string[] GetKnownPermutations(this string word)
        {
            return MagicDictionary[word];
        }
        public static string[] WildGuess(this string word)
        {
            return MagicDictionary[RANDOM_WORD];
        }
    }

A quick blurb about code contracts:

Code Contracts allow me to enforce my assumptions in an easy fashion.  They provide you with static and dynmaic checking and also allow you to easily append your assumptions in auto generated documentation.  So the first cool part is that when I add code contracts it will extend my signature to enforce my constraints.  So in the above example if I add a contract that states string must be non null, and Larry tries to pass a null it wont compile!  The second piece is at runtime, if Larry decides to set a string to null and pass it, to try to get around my “check” it will also kill is attempt to foil my method.  The last piece is there are tools you can run that allow you to extract both the “method documentation” and the assumptions (pre/post conditions) that you used.    Enough words, and lets let the code speak for a bit!

An example:

I lied earlier  ;) you need to download the “static” checker for Visual Studio 2010.  All the .NET classes are there, but if you want to IDE integration/checking then you need to download from here:

http://msdn.microsoft.com/en-us/devlabs/dd491992.aspx

So I added some contracts:

        /// <summary>
        /// This method will convert any plain english word to the Capitish language.
        /// </summary>
        /// <param name="englishWord">A non-null english word</param>
        /// <param name="iReadYourPreConditions">Pass true to prove you read this</param>
        /// <returns>The possible set of capitish words</returns>
        public static string[] ConvertToCapitish(string englishWord, Boolean iReadYourPreConditions)
        {
            // Assumption
            Contract.Requires(iReadYourPreConditions == true, "Please read the pre conditions..");
            //Requirement
            Contract.Requires<ArgumentNullException>(englishWord != null, "word cannot be null");

            //1 known trouble word
            string[] matches = null;
            List<Func<string, string[]>> translators = new List<Func<string, string[]>>()
            {
                (string x)=>x.GetHomonyms(),
                (string x)=>x.GetKnownPermutations(),
                (string x)=>x.WildGuess(),

            };
            int index = 0;
            do{
                matches = translators[index++](englishWord);
                (null as String).GetHomonyms();
                englishWord.GetHomonyms();

            }while(matches == null || matches.Length == 0);
          
            return matches;
        }

And as you will see i now have 2 contracts.  A is that you read my method description, and B is that you passed me a non null English word. 

So first I thought it was neat I compiled and got a “warning” that basically said hey you wrote bad code!  I didn’t even ask for any advice!

ConvertToCaptish_withCodeContract_warning

I purposely created this issue but, obviously I should do a null check on “english word.”  What the compiler sees is (assuming englishWord is null):

 (null as String).GetHomonyms();

Which obviously will result in a crash.

 

But back to my contracts.  So assume Larry doesn’t read and just tries to use my method:

ConvertToCaptish_withCodeContract_1

Fail!  So he reads my pre conditions, and then tries:

ConvertToCaptish_withCodeContract_1_a

Then he gets bold and attempts to really trick my code:

ConvertToCaptish_withCodeContract_2

 

And fails yet again.    Well lets just say he found a way to get a null in there.. what happens then?  Well at runtime I would slap him on the wrist with a ArgumentNullException:

ConvertToCaptish_withCodeContract_runtime

 

Conclusion:

Well there is your intro guide to CodeContracts.  I didn’t really show you any truly cool stuff.  But hopefully it hints on the potential of code contracts. Unfortunately there aren’t that many good resources out there yet on CodeContracts so you have to get your hands wet… the true moral of this blog is to be defensive in your programming!  Code with a purpose, and make sure you hold people responsible for adhering to your contract.

 

PS if you are wondering what Capitish is?  Well people that know me know I sometimes have issues with mixing up common words, or just spelling things as they sound… details.. but over the years people that know me, know how to translate what I say, and what I really mean.

Take care.





Today’s most important software principles.

18 08 2010

These vary from year to year as well as the type of software you are writing, but this day in age the following principles are directly related to large scale software development  I have seen a lot of large systems, a lot of over design, as well as some designs that were right on point.  Our engineering field is always about a balance.  This balance is between timeline, functionality, and design.  There is no golden rule, its about knowing what to implement, how to design, and when to stop polishing.  The two most common mistakes are over design and too much furniture polish.

If I could only teach 3 principles to a new hire they would be

  1. Kaizen
    I read this once, and it pains me I can’t remember where, but they related Kaizen to bug fixing. Any time you find your self fixing a bug, it talked about fixing the other code around it. A lot of times bugs are a direct result of bad code. When it comes time to stop the bleeding, people just stick on a band aid.. they don’t think about disinfecting the areas around it.
  2. Good Enough
    I once worked at a client that had multiple projects all lead by different consulting companies.

    Our company produce a “good enough” designed product that balanced: leveraging bleeding edge technologies, functionality, and most importantly the project plan. We delivered a functional product, on time. It did everything that was asked, in a basic way. We then worked on beautification.

    Another company, full of Microsoft MVPs, developed a product that was bleeding edge, completely beautiful,and months behind schedule. On top of being late, the use of too new technology and attention to too much UI detailed left a product that was over designed and buggy.

    The concept is to know when to cut corners, and when to get something working correctly, and then going back and polishing it up… if needed of course.

  3. YAGNI – (You aren’t going to need it)
    This one relates to keeping systems simple. Countless times I have seen clients implement things for future use, and by the time the future gets there it is completely wrong, un-maintained, or poorly documented. Sometimes its better to keep things simple and only implement what is required now.

Read the rest of this entry »





When Documentation Goes Bad.

10 08 2010

I’m going to paint you a picture, and when its over I want you to purge your memory.  Imagine being hired at a large company, given access to SharePoint, and then tasked to understand the Contract System.  You do a quick SharePoint search and VOILA!

Requirements_Version

You found the golden ticket, the requirements.  You open the highest version navigate past the corporate logo, table of contents, and make it to the Overview.

Overview

“This document outlines the system requirements for the Contract System.  The OSI 29 Implementation project requires that planet clients be updated manually in the production feed.”

Functional Requirements

CS-EN-001 Populate Clients from Contract System
CS-EN-001 1 Disable Access to non TMA Clients
CS-PR-002 Populate a unique identifier(ContractSystemID) for each record in the ContractSystem table.

System Requirements

CS-SR-001 The process shall only accept authenticated users.
CS-SR-002 The process shall log any attempt to gain access to secure systems.

You slowly start to skim read because nothing is making sense, and before you know it you are at the appendix which contains a Metadata section.

Name Comment
ContractSystemID Unique Identifier for the Contract System table
ContractName Name of the contract
ContractDate Date of the Contract
UpdatedDate Date Updated

You then close the document, having an even worse understanding of the contract system.  You turn back to a SharePoint search and uncover countless other useless documents.

——-

Where do i start?

The most common sign of documents gone bad, is when you have to talk to people to understand a system and those conversations always end up getting lost.  Requirements, database structures, acronym filled process diagrams mean nothing to an outsider.   Start with something that gives a high level picture of what’s going on, in plain English describe what the system provides, who it interacts with, and  any dependencies.

The problem is companies use documents to keep people busy, check project plans boxes, and keep consultants on client sites longer.  The documents should be driving design, but obviously they are not.  If you take anything away from this blog let it be this:  Only keep 1 previous version of a document. If you find yourself working on v1.9 and have to go back to a v1.0 you have done something drastically wrong in your versioning process.

My second issue is polluting SharePoint with useless documents.  All SharePoint administrators should archive documents that aren’t accessed and send them straight the the recycling bin (just don’t empty it).

If you get tasked to write a document, you always should first identify your audience.  If you find that your audience doesn’t exist, or is yourself find another topic with a proper audience.

Instead of wasting time having a consultant write a support document, how about you force them to shadow an employee that is taking over developing or maintaining the system?  And then ask the Empoyee to write the support document, and then ask the Consultant to edit?

My last and final point… Requirements, they exist for good reason, and should always exist, but who says they have to be so vaguely worded and why are there so many!

I never thought i would say this, but the government does do this well, its called DODAF.  Google it, read about them they describe a document framework that works!





LINQ Hidden Gem

4 08 2010

This tip wont be useful to most, but in case you find your self wanting to have a “default” in your query check this out.

So lets suppose you have a table for languages ( I have denormailzed for an easier example, Code should be in a separate table):
Language:

ID Code Description
1 EN English Description
2 SP Spanish Description

Now assume you want to create a method to return the description based on code.  If the code doesn’t exist return English.  Well you would need to either A do two queries, the first to query for the code, and the second to get the default if your results were empty:

  IEnumerable&lt;Language&gt; result = (
     from l in Languages
       where x.Code== Code
      select x
    ).ToList();

   Language languageDescription = result.SingleOrDefault();
    if(string.IsNullOrEmpty(languageDescription )){
     //Get default!
    }

Well there is a better way.. and i can’t find any documentation on it. Here it is it involves using an order by:

    IEnumerable&lt;Language&gt; result = (
          from l in Languages
            where x.Code== Code  || x.Code==&quot;EN&quot;
          order by x.Code==&quot;EN&quot;
         select x
      ).ToList();
  Language languageDescription = result.FirstOrDefault();

It works! So this basically says put EN last. Anything that doesn’t match comes before “EN” so we can now just do a FirstOrDefault. Not the difference this time we want FirstOrDefault because we could have more than 1 entry.

So how does it work?  Well this is what SQL gets generated:

  SELECT
     [Project1].[ID] AS [ID],
     [Project1].[Code] AS [Code],
     [Project1].[Description] AS [Description]
  FROM ( SELECT
     CASE WHEN (&quot;EN&quot; = [Extent1].[Code]) THEN cast(1 as bit) WHEN (&quot;EN&quot; &lt;&gt; [Extent1].[Code]) THEN cast(0 as bit) END AS [C1],
     [Extent1].[ID] AS [ID],
     [Extent1].[Code] AS [Code],
     [Extent1].[Description] AS [Description]
     FROM [dbo].[Langages] AS [Extent1]
  )  AS [Project1]
  ORDER BY [Project1].[C1] ASC

It uses a bit that is 1 if equal and 0 if not. It then orders by that bit thus the reason why “EN” will always be last.





Making Your Conditionals Better

3 08 2010

A recent stackoverflow.com post has lead me to this blog.   In the post someone was asking if a particular block of code was functional equivalent, and inadvertently started a holy war.  Just two quick readability tips.

Do your best to implement “postive” conditional if/else blocks.

Translation don’t negate your conditionals.

Example:


if(!value){
   Console.WriteLine("Logic");
}else{
   Console.WriteLine("Else Logic");
}

It is much more readable if you switch them:

 if(value){
   Console.WriteLine("Opposite Logic");
  }else{
   Console.WriteLine("Else");
  }

It is also a lot easier to add more conditionals into the chain if it is not negated.

Use brackets!
This is a simple one. I know sometimes they take up extra space, but I have seen countless bugs that stem from this:

   if(lazy)
     foreach(string x in listOfStrings)
        Console.WriteLine("Will only ever do this for logic!" + x);

So what happens is someone, that has no clue how to read your code and probably has no real clue what your code is doing, gets assigned a bug and some how tracks it down to that statement. The bug that we need the ability to trace the size of string. So he changes it:

  if(lazy)
      System.Diagnostic.Trace.WriteLine("Size: " + listOfStrings);
     foreach(string x in listOfStrings)
        Console.WriteLine("Will only ever do this for logic!" + x);

And now he has managed to introduce another bug. I know this is a simple case, but it illustrates the need to be a pessimistic programmer. You never know who will be reading or maintaining your code so do your best to limit a users ability to do something stupid.

In case you need it the correct solution would be to use braces around the if AND for:

   if(lazy){
     System.Diagnostic.Trace.WriteLine("Size: " + listOfStrings);
     foreach(string x in listOfStrings){
        Console.WriteLine("Will only ever do this for logic!" + x);
     }
   }





DuckDuckGo

2 08 2010

Is it time for another revolution?

http://duckduckgo.com/?q=simpsons+characters

I am sold ;) .  DuckDuckGo.com is neat but I can’t even describe how it works?  Its currently light on adds, picture friendly, and full of hidden features, all the works for a trendy site.

All I can say is when I search a subject on google and then on duckduckgo I get the same results, but they are presented in two totally differn’t formats.  I tend to like duck better!

I can only hope that someone comes up with a cooler nick name for the site.

I am still learning the ins and outs…. so I will just help you get started with a feature list that can be found here

Tools

DDG also detects

  • ↓ or j  — next result
  • ↑ or k  — last result
  • Enter or l or o  — go to result
  • / or h  — go to search box
  • ‘ or v  — open in new window/tab
    Note: turn off pop-up blockers first.
  • r  — go to related topics (if any)

Try it out… and let me know your thoughts.





Virtualized Eclipse Disappearing Act

27 07 2010

The Virtualized Eclipse Disappearing Act

I ran into an annoying issue yesterday that dealt with virtualized windows 7 and Eclipse.  I loaded a clean VM with Windows 7, Java, and Eclipse.  To test the development machine I simply opened up eclipse and attempted to create an XML document.  Then all the sudden Eclipse disappeared.   After a little investigation, and a  useful suggestion from a colleague, the issue was related to memory.  I had ruled out memory by beefing up my “hardware” memory, but apparently my feeble mind didn’t think about any software settings.

So if you are seeing a disappearing and or locking up eclipse and a log message (hs_err_***.log)

#

# A fatal error has been detected by the Java Runtime Environment:

#

# java.lang.OutOfMemoryError: requested 152 bytes for CHeapObj-new. Out of swap space?

#

#  Internal Error (allocation.inline.hpp:39), pid=620, tid=1628

#  Error: CHeapObj-new

#

# JRE version: 6.0_21-b06

# Java VM: Java HotSpot(TM) Client VM (17.0-b16 mixed mode windows-x86 )

# If you would like to submit a bug report, please visit:

#   http://java.sun.com/webapps/bugreport/crash.jsp

#

It is proudly outside of the depth/breadth of my knowledge the internal details about heap and  permgen usage.

But at a high level permgen holds data about classes that have been loaded and created, and the heap is where objects go to die ;) .  Feel free to do some reading… these are decent sites..

http://www.freshblurbs.com/explaining-java-lang-outofmemoryerror-permgen-space

http://www.brokenbuild.com/blog/2006/08/04/java-jvm-gc-permgen-and-memory-options/

http://www.javaworld.com/javaworld/jw-08-1996/jw-08-gc.html

Onto my simple issue…  Inside the Eclipse.ini I modified

-Xms40m  (I didn’t change this which is the initial java heap size)
-Xmx1024m  (I doubled this… it is the max  java heap size)
-XX:MaxPermSize=512m  ( I added this attribute …)


http://i385.photobucket.com/albums/oo292/PhntmBlackIce/Wizard101%20Wiki/magic-wand.png….I then waved the magic wand and everything was fixed….








Follow

Get every new post delivered to your Inbox.