Tuesday, May 29, 2007

Who wants to party?

 
Posted by Picasa

Math.Ceiling Error

Reviewing a string splitting function that was throwing an index out of range error proved to be a *problem* with Math.Ceiling.
The said function simply takes any sized string and the length that the caller wants each line to equal and returns a new string array with each row holding a line of the specified length.

---------------------------------------------------------------
public static string[] SplitStringToLines(string s, int lineLength)
{
  int sLength = (s == null ? 0 : s.Length);
  int totLines = Convert.ToInt32(Math.Ceiling(sLength/(lineLength <= 0 ? sLength : lineLength)));
  string[] lines = new string[totLines];

  int line = 0;
  int length = 0;
  int startIndex = 0;
  while (startIndex < sLength)
  {
    length = Math.Min(sLength-startIndex, lineLength);
    lines[line] = s.Substring(startIndex, length);
    startIndex += length;
    line += 1;
  }
  return lines;
}
---------------------------------------------------------------

The cure came when I casted the variables being fed to Math.Ceiling, which makes sense when viewing the overloaded details provided by microsoft.
Changing the Math.Ceiling line to:
Convert.ToInt32(Math.Ceiling((double)sLength/(lineLength <= 0 ? (double)sLength : (double)lineLength)));

remedied the index error.

Sunday, May 27, 2007

Coworking community and the company.

I bumped into a new idea today which can be a great asset to a developer in my shoes trying to get a business off the ground. The coworking community with their combined knowledge can fill in the blanks that are missing from my business experience.
I've developed in software projects for the past few years ranging from small business to a world-wide, market-leading corporation. What I haven't had experience with, is what takes a company from a small business to a world-wide, market-leading corporation. The combined knowledge of the coworking community has.
I'm just getting my feet wet with coworking, but I believe this is the route to move an idea to a virtual business and beyond.
I'd like to hear from coworkers who have experience in this atmosphere to validate my ideas of collaborative business growth.