Complexity is in the Eye of the Beholder#
A remarkable chain of thinking sparked while reading Object Thinking has lead me to a new thinking.  Simple phenomena can be easily classified, studied and repeated.  Think levers, steam engines, motion of planets.  However, complex systems (the human body, computer systems) benefit from empirical research and study.

This is not really new.  The question is, where is the boundary between complex and simple?  I think that this border only exists in the human mind.  In fact the border is movable and depends on the individual mind.

Nothing is complicated to Nature (the universe).  Everything just is.  Confusion and complication only arise in the human mind while trying to understand the universe.

Complexity is a function of our capacity to assimilate, store and process data.  If we were suddenly twice as smart, some complicated problems would seemingly become simple problems.  The problems themselves did not change, only we changed.

For software developers, it means that we struggle against complexity that is often artificial and even worse, is often of our own making. 

This means that managing complexity and striving for simplicity is an important function.  We can't just upgrade our wetware.  Humans have a limit (at least for the near future).  So we can only manage our abstractions and our creations.  We have to tend towards simplicity both in ordinary life (index funds over actively managed funds) and in software creation.

This would tend to suggest using tools that provide the most straight forward implementation route.  We should look for tools that allow for conservation of complexity.

If I as a sole developer running my own business can push complexity somewhere else (using a framework from a reliable source) then shouldn't I do that?

Does that mean that I must avoid unproven or untested frameworks?  The complexities haven't been discovered so I wouldn't know how to deal with them.

Interesting.  It's at least food for thought.

Thursday, October 30, 2008 1:30:00 PM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

Converting Bytes to Human Readable Value#

/// <summary>
/// Round up to the best human readable number
/// (could be kb, mb or gb depending on size of
/// number
/// </summary>
/// <param name="bytes"></param>
/// <returns></returns>
public string BytesToHumanReadable(double bytes)
{
var gig = Math.Pow(1024, 3);
var meg = Math.Pow(1024, 2);

if(bytes > gig)
return Math.Round(bytes / gig, 1) + " GB";
else if (bytes > meg)
return (int)(bytes / meg ) + " MB";
else
return (int)(bytes / 1024 ) + " KB";

}


This is useful for file and memory sizes. 

Monday, October 06, 2008 10:42:20 AM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

How to Shrink Your Sql Server Log Files#
http://blog.sqlauthority.com/2006/12/30/sql-server-shrinking-truncate-log-file-log-full/ Assuming SMS is your database name and sms_log is your transaction log name: USE SMS GO DBCC SHRINKFILE(sms_log, 1) BACKUP LOG sms WITH TRUNCATE_ONLY DBCC SHRINKFILE(sms_log, 1)
Thursday, September 11, 2008 2:48:48 PM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

Find Size of Each Table in Database#
If you need to find the size of each table in the database here is an easy way. EXEC sp_MSforeachtable @command1="EXEC sp_spaceused '?'" I use it to find those pesky tables that are hogging all my disk space. (Usually it's the log file though) Source: http://www.4guysfromrolla.com/webtech/032906-1.shtml
Thursday, September 11, 2008 2:45:13 PM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

Checking if a value is numeric in C# (isnumber or Isnumeric)#

This method indicates whether an object is numeric or not.  Handy in reflection type situations when you need to perform and action based on type.

private static bool IsNumeric(Object o)
{
    if((o is int) || (o is int?) ||
        (o is decimal) || (o is decimal?) ||
        (o is double) || (o is double?) ||
        (o is float) || (o is float?) ||
        (o is long) || (o is long?) ||
        (o is ulong) || (o is ulong?) ||
        (o is ushort) || (o is ushort?) ||
        (o is short) || (o is short?) ||
        (o is byte) || (o is byte?) ||
        (o is sbyte) || (o is sbyte?) ||
        (o is uint) || (o is uint?))
        
        return true;
    
    return false;
}


It's long and a bit ugly but it's the only way I've found.

Wednesday, July 30, 2008 1:24:38 PM (Central Standard Time, UTC-06:00) #    Comments [1]  | 

 

Type Inference Only Works at the Local Level#
http://erikengbrecht.blogspot.com/2008/07/love-hate-and-type-inference.html

Type inference is great, locally that is.  When it's global it's a mess.  That's why large programs are easier to maintain and refactor in C# than in Python. 

Conversely, scripts are much better in Python than in C#.

So when right a short and dirty script, Python is fantastic.  When writing something a little bigger, the statically typed languages start to win.  There is no "Static is better or Dynamic is better"  only what locally optimal.

I think C# 3.0 is blurring the line somewhat with the best of both worlds.  It's locally type inferred (or it can be if you want it that way) and globally static. 


 | 
Sunday, July 13, 2008 8:06:02 PM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

Web Scraping is Hard Because Sites Are Not Valid#
Scraping the web is hard.

Matt Cutts says so:
http://www.mattcutts.com/blog/the-web-is-a-fuzz-test-patch-your-browser-and-your-web-server/

I've found this to be true.

 A couple of implications. 

It's hard to build a web crawler that can suck information out of pages reliably.

Validation doesn't matter b/c google doesn't penalize for it.  And if Google doesn't care, you shouldn't either.


Sunday, July 13, 2008 7:54:28 PM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

Tips for Robust Software#
  1. Reduce dependencies
    Isolate them if you can't remove them.
  2. Log Don't Explode
  3. Don't Handle Errors if You Don't Know How
    Let them raise so they can get identified and fixed
Tuesday, June 24, 2008 3:49:58 PM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

Humanize String in C# (Split String On Capital Letters)#
Occasionally I need to change a a camel case or Pascal case string into a human readable string.  Since I find myself doing this again and again, I figured I better post it here.


private string HumanizeString(string source)
{
StringBuilder sb = new StringBuilder();

char last = char.MinValue;
foreach (char c in source)
{
if (char.IsLower(last) &&
char.IsUpper(c))
{ sb.Append(' '); }
sb.Append(c);
last = c;
}
return sb.ToString();
}

 | 
Thursday, June 12, 2008 3:47:38 PM (Central Standard Time, UTC-06:00) #    Comments [2]  | 

 

Find controls in a page or another control#
Find controls in a page or another control

List<T> FindControls<T>(Control control) where T : Control
{
List<T> list = new List<T>();

foreach (Control c in control.Controls)
{
if (c is T)
{
Global.LogDebug(c.ID);
list.Add(c as T);
}

list.AddRange(FindControls<T>(c));
}

return list;
}


private Control FindControlRecursive(Control root, string id)
{
if (root.ID == id)
{
return root;
}

foreach (Control c in root.Controls)
{
Control t = FindControlRecursive(c, id);
if (t != null)
{
return t;
}
}

return null;
}


 | 
Wednesday, March 26, 2008 9:35:09 AM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

C# Find Compatible Types#
Find the compatible types in an assembly:

public static Type[] FindCompatibleTypes(Assembly assembly, Type baseType)
{
List<Type> types = new List<Type>();

foreach (Type type in assembly.GetTypes())
{
if (type != baseType && baseType.IsAssignableFrom(type))
types.Add(type);
}

return types.ToArray();
}

Wednesday, March 26, 2008 8:43:39 AM (Central Standard Time, UTC-06:00) #    Comments [1]  | 

 

All content © 2009, prag
On this page
This site
Calendar
<October 2008>
SunMonTueWedThuFriSat
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678
Archives
Sitemap
Blogroll OPML
Disclaimer

Powered by: newtelligence dasBlog 1.9.6264.0

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

Send mail to the author(s) E-mail

Theme design by Jelle Druyts