Showing posts with label Programming. Show all posts
Showing posts with label Programming. Show all posts

Friday, July 21, 2017

Too Much Codez!!! WHY?!?!?

Why must some programmers place as much code into a single file as they can?  Seriously?  Is this some sort of challenge?  Is there some advantage unknown to me by shoving all of a program's code into a single file?

Really, I am not a huge fan of the MVC pattern.  It places, sometimes, arbitrary guidelines regarding what should be placed in the Model, the View and the Controller.  However, it is better that the SEIOF pattern!  (Shovel Everything Into One File)

In my opinion, a logical separation of interests is best and basic.  One file for the GUI, one or more files for the application or business logic and one or more containing global types, classes, utility code, etc...

Placing all that into one large bucket can be confusing.  Please...  If you are a programmer, please, please separate your code a little bit.  Help save the next programmer's sanity.

Oh...  And those long methods/functions/procedures...  While in college I was taught that a method, function, procedure, subroutine, what-have-you, should be less than a page of printed code.  While that isn't always possible, it is still a guideline that I try to observe, and firmly believe other programmers should as well.

Happy Friday!!!

Tuesday, July 18, 2017

This is one HOT little post!

Sooo...  What exactly are you expecting???

Dirty minded people...

It's HOT here...  88F with a humidity that would make any jungle animal quite comfortable.

Anyway...  My mind turned to this blog again.  You know, I really SHOULD post more here.  I mean, with my newfound projects and all.

Projects, you ask?  Yes, I have a few new ones...

  1. Learn C.  I mean, more than the typical advanced, scrolling, multicolored "Hello World" sort of level.  I mean, really learn it.  I really thought long and hard about whether I wanted to learn X86 Assembly or C.  My brain is still on the fence just a bit, but when I sat down, wrote a "Hello World" program in each, the C version compiled and ran the first time.  My Assembly version required some research to understand some of the assembler switches on NASM.  Sure, I got my assembly program to, er...  assemble but was a pain.
  2. I found my favorite college textbook, "An Introduction to Data Structures With Applications" by Tremblay and Sorenson.  There may be better text books out there that cover this subject, but this is the one I have...  And from my days at WIU, it is my favorite.  What am I going to do?  Well, when I used this book, all of our projects were written in USCD Pascal.  What I would like to do is use several languages to write all the projects in the book.  I am thinking of using C, Free Pascal, Modula III and Lua.  Maybe a few others like Assembler, C++, Python, Java or Rust.  Not certain, but it sounds interesting.
  3. Maybe...  maybe find an open source project to contribute my time.  
  4. Sailing...  boating... sailing...  OMG, I am a sailor!  Yes, my significant other gave me sailing lessons for my birthday.  Finished class about a week ago and bought a little sailboat built in the early 1970s by a company in Missouri called Advance.  She is 16 feet long, and also known as the "Sweet 16".  Great little boat, but is just for me.  Our 18 foot cruiser is currently in the shop for repairs and HOPEFULLY will be home before there is ice on the lake.
  5. Project StarStare, my little project to automatically detect meteor streaks in night sky photos is on a temporary hiatus but my be revived this winter.
  6. RuralRuins will see some new photos, I promise.
Anyway...  Probably a few things to blog about here.

And...  There is plenty to bitch, moan and complain about...  So...  Be back soon. 

Thursday, March 23, 2017

Implementing a Simple Weather ScreenSaver in Linux

Starting with that first real-life tornado experience as a seven year old, I have been intrigued with the weather.  Going back to my college days I would watch the Weather Channel for hours-on-end when not doing school work.  After my freshman year (1985 or 86 or 87; don't remember completely), I passed my ham radio Technician test and was able to participate as a weather spotter.

Wanting to watch the weather on my computer while at work, many years ago I wrote a little program that would rotate the Windows background image through several current weather maps downloaded from NOAA and NWS websites.  Honestly, it worked OK, but not stellar.

Living Las Vegas gave me very little drive to be informed with the weather; it was simply depressing.  Hot... Hot...  OMG Hot... WTF Hot... oh... one nice day.  meh...  FUUU HOT!  I did NOT like the weather there.

Now, living back in the mid-west, I have been gaining interest in watching the weather again.  Since watching any cable weather outlet while working is quite distracting, a weather screen saver is the next best thing.  In this post I will detail how to setup a desktop Linux distribution (Debian "Jessie" to be exact) to download maps and radar images from the NWS and have the screen saver cycle through the images.  Personally, this runs on my spare Linux box next to my work computer.

Friday, February 3, 2017

What to do with all that speed???

So, computers based on quantum physics are already being planned, designed and in some cases even being created.  The electronics used in quantum computing do not rely on relatively slow semiconductors; they use near instantaneous quantum technology.  No, I don't know the details, but I do know that once some developers get access, there will be abstractions upon abstractions upon abstractions built, to the point where a quantum computer will perform about as well as a 80386 running OS/2.

Monday, November 14, 2016

A Base-64 Decoder That Works!

Let's face it...  debugging ASP.NET production websites can be challenging.  HTML sessions are 'stateless', meaning from one post to the next, the server has no idea what post came first.   For example, let's say there is a website that prompts the user for their name on one page, and on the subsequent page the user is prompted for their address.  Well, the server has no intrinsic way to join the data together from those two pages to save it all in a table somewhere.

Web scripting language use various methods to store this state information.  Some use cookies to store the data from one page to another.  Some use a unique key, placed into a cookie, or in the URL as a parameter to retrieve the data from an internal 'session store' on the server.  ASP.NET can save the session state several ways.  One way to save part of the session state is in something called a ViewState.  This is basically the state of a page; just part of the entire session state.

Well, this ViewState is stored right in the web page as a 64 bit encoded string.  It's not encoded but definitely looks that way.  It's unreadable without a decoder.  Anyway...  If something is stored in the ViewState, programmers can have a bitch of a time trying to pull it apart and see the data.  But...  This information can be invaluable to debugging a production problem.   There are varied ViewState tools on the web for decoding this gobeldygook into something that is somewhat coherent.  I use Base64 decoder and encoder at motobit.  It's simple and works.

Sunday, November 6, 2016

Simple Is Still Simple

Yes, contrary to the conventional state of technology and computer programming, simple is still simple.  Well, at least it should be.

Quite frequently I read different articles about programming in an attempt to maintain professional relevance.   Some are well written articles on good programming techniques.  Some are poorly written but the core material is still good.  Some are well written pieces about some fluff fad and then there are occasionally the poorly written article about some programming technique or library or concept  that has 'bad idea' written all over it.

Thursday, September 22, 2016

Getting a 500 Error When Trying to Access a REST API from C#?

This just might be the solution.

Here's the deal...  I need to write a simple C# client to access data from a REST API served up by an Apache Tomcat server.  Not a big deal at all...  should be pretty simple...

Should be...

For some unknown reason, my attempts generated nothing but '500' errors from the server.  Myself and our resident network wizard captured my traffic and we compared the headers of a successful GET using CURL and the non-successful attempt using my simple C# program.

After trying a few things with no success, I noticed the CURL capture showed an 'Accept: */*' header.  My C# program did not.  So, I added this...

request.Accept = "*/*";

SHAZAM!!!  No more 500 errors.

No search results from Google helped.  None mentioned this as being a possibility.  But, heck...  it worked.

By the way, this Apache server is what I like to call LegalWalled.  Yes, it's our server but if we touch it, or even log onto it using SSH without the guidance and approval of the vendor's support group, we could violate our support contract...  so opportunity to dig into why that specific error was generated.

Wednesday, August 17, 2016

Webcollage bug/irritation repair

So, I am enjoying my little Linux build with that little AMD APU detailed in my last post...  Something is missing...  YES!  A good screensaver.

Oh...  Yes it has been a while since my last post, so what?  I've been boating and working on the house and generally enjoying the outdoors while the weather is agreeable.  So...  pfft...

Anyway, I installed the XScreenSaver package with several additional screensaver packages.  One looked intriguing...  webcollage by Jamie Zawinski.  Webcollage uses dictionary files (just lists of words) to seed simple searches on several internet search engines.  When the screen saver is activated, a random image (or part of an image) from a random webpage from the results of searching a random word is placed on a the screen like a collage, one image over the other.

Needless to say there is a lot of online bitching about this because quite simply, it can display porn and other NSFW images.  OK, so some people don't like it.  Personally, I find it intriguing.  But...  occasionally the following text would show up on the screen...  sometimes several times before a screen redraw covered the text:

Use of uninitialized value $vals in index at /usr/share/perl5/HTTP/ line 264
Use of uninitialized value $vals in concatenation(.) or string at /usr/share/perl5/HTTP/ line 267

After trying a few repairs to the webcollage Perl source, I just went into and fixed it there.  Here's the repair:

sub as_string
    my($self, $endl) = @_;
    $endl = "\n" unless defined $endl;

    my @result = ();
    for my $key (@{ $self->_sorted_field_names }) {
next if index($key, '_') == 0;
my $vals = $self->{$key};
if ( ref($vals) eq 'ARRAY' ) {
   for my $val (@$vals) {
my $field = $standard_case{$key} || $self->{'::std_case'}{$key} || $key;
$field =~ s/^://;
if ( index($val, "\n") >= 0 ) {
   $val = _process_newline($val, $endl);
push @result, $field . ': ' . $val;
else {
          if ( defined $vals ) {
   my $field = $standard_case{$key} || $self->{'::std_case'}{$key} || $key;
   $field =~ s/^://;
   if ( index($vals, "\n") >= 0 ) {
$vals = _process_newline($vals, $endl);
   push @result, $field . ': ' . $vals;

    join($endl, @result, '');

My changes are in red.  Not sure if the bug is in webcollage or if it is in but here ya go.  This is the fix.  Damn, I love open source!

**Disclaimer:  I am NOT a Perl programmer, I only know enough to successfully poke around Perl source and figure things out.
**Suggestion: Anyone running webcollage might want to consider two things: 1) it uses internet resources to perform searches and retrieve images; 2) some of the images shown on the screen could really get a person in trouble at most companies, not to mention what might happen should certain significant others see certain images.

Tuesday, March 29, 2016

OMG .NET, You Are Crazy!!!

OK, so I am doing something simple...  adding a ControlParameter to a SQLDataSource.  I just want to add it as an optional filter.  The ControlParameter points to a TextBox.  Like this...

<asp:ControlParameter ControlID="txtFiltCC" Name="TCity" PropertyName="Text" Type="String" DefaultValue=""/>

Not only does the result return nothing, according to the Microsoft SQL Server Profiler, the query is never even sent to the server!!!  

What the HELL!?!?!?!?

I change the SelectCommand to not use the @TCity paramater and still...  no query sent.  The GridView bound to the SQLDataSource reports that no records were retrieved.   Hmmm...  makes sense since according to SQL Server Profiler, no query was sent.

Then I find the ConvertEmptyStringToNull property on the ControlParameter.  It's default is 'True'.  Hell, I don't want it to be null, so I change it to False.  Friggin SHAZAM!  The SQL query is sent and I get a result set.  Why the HELL would the ConvertEmptyStringToNull cause a query to not be sent, especially if the parameter isn't even used in the query????  This works fine...

<asp:ControlParameter ControlID="txtFiltCC" Name="TCity" PropertyName="Text" Type="String" ConvertEmptyStringToNull="False" DefaultValue=""/>

Really, Microsoft...  This is a crazy little piece in ASP.NET

So...  For anyone scratching their head about a GridView not being populated from a SQLDataSource that is using a ControlParameter pointing to a TextBox, this just may be the solution.

Wednesday, March 2, 2016

Oracle VM VirtualBox - Just a Misleading Error Message

Three weeks of fighting a "cold from hell" gave me time to think about my little project to automate a search for meteor photos.  Sure, I have a PINE64 on order.  Sure, it may be delivered later in March.  Sure, there may be a flavor of Linux available for it sometime soon.  Sure, I may be able to build ImageMagick and other tools I need for the Pine64.  Sure, the performance may be acceptable for my goal.  Crap, no planned PXE/net-boot planned.

What if...  Let's see...  a complete Pine64 compute node with 1GB Ram and the OS on an 8GB flash drive will cost roughly $35 accepting a lot of "maybe" assumptions.  Let's remove the assumptions and calculate the cost of a good old AMD or Intel processing node.  Looks like a 64 bit AMD based system with 4GB RAM, with PXE boot will run about $85.

So...  I decide to emulate a 32 bit Debian text-only install on an Orable VM Virtual box using 4GB Ram to sort-of emulate the AMD solution.  Which gives me an idea for a new word...

umulate - An emulation that is not exact; allowing certain differences for the sake of brevity or simplicity.  "I am going to umulate this Debian install; the real machine will not have a hard drive, but will boot from a flash drive."  But...  I digress...

BUT SMACK...  An error pops up from Oracle Virtualbox when I try starting the virtual machine...

Failed to open a session for the virtual machine DebianPNode.

Under "Details" it read...

VT-x is disabled in the BIOS for all CPU modes (VERR_VMX_MSR_ALL_VMX_DISABLED)

Well, after some research and comparing this virtual machine with the operational virtual version of Debian, I arrived at a repair that seemingly has nothing to do with the error.  I changed the Base Memory for this Virtual machine to 3072 GB and SHAZAM.  No more error.  Keep in mind, my machine has 8 GB and runs a pretty lean install of 64 bit Windows 7.  Why this misleading message popped up, I have no idea...  but reducing the Virtual machine's Base RAM fixed the problem.

Friday, February 19, 2016

Teaching an Old Dog New Tricks.

Regardless the age of an old programming dog, new tricks are pretty important to learn.

My initial success with night sky photography with my Canon EOS Rebel T3 tumbled in my mind over the last few days.  Recorded remnants of a thought from a few years ago popped up when searching an old personal hard drive...  An automated search for meteor photos.

Well, I was nearly there.  After spending a few nights with ImageMagick and some meteor photos, I built a basic recipe to find meteor strikes in night sky photos.

Hey, I thought...  I have a PINE64 on order.  Wouldn't that be cool to make one of these tiny ARM based computers comb through photos for meteors?  Ohhh...  With a little thought this could be easily scalable.  What about controlling my camera with one of these PINE64 computers?  Maybe a loosely coupled cluster of these $15 computers to search these photos in different ways?

I needed a control language for this; something interpreted and not terribly complex.  It only needs to be able to run shell commands, copy files and talk to MySQL.  Lua had my vote until I tried MySQL.  After two hours of trying to make it work on my Windows 7 computer, the necessity for a different language became apparent.  Sorry Lua.

A buddy of mine at work likes Python.  My daughter learned a little Python at college last year.  Python is a language specifically being ported to the Pine64.  The memory footprint of Python is larger than that of Lua but should work fine in the constrained environment of the Pine64.  MySQL Connector was easy to install and setup.  After a running a few little trial scripts, I was convinced Python would be my control language for this little project.

So, over the last week or so, this old dog has learned a few new tricks; and he is enjoying it!

Friday, November 6, 2015

C# Background Workers Using Shared Memory

It doesn't happen often in my particular coding shop, but once in a rare while the requirement for different threads in a program to use a shared memory variable rears it's head.  It really isn't difficult to handle this requirement in C#; actually, it is surprisingly easy if you are careful to avoid deadlock situations,

The key to this solution is a simple static class:

using System;
using System.Collections.Generic;
using System.Text;

namespace ThreadCom
    static class StaticShare
        public static object MsgLock = new object(); // Functions as a lock when accessing Messages.
        public static string Messages = ""; // This is what is shared and used in all threads of this sample program.

Basically, this snippet of C# code creates a static class with two public properties: MsgLock and Messages.  MsgLock is used to control access to Messages; a string that contains the data shared among the different threads.  Remember, performance is important; keep the shared static variable terse and small.

Here is how a thread (specifically a BackgroundWorker) might use the StaticShare class to lock, access and change the shared data without causing noticeable contention or throwing exceptions:

                lock (StaticShare.MsgLock)
                    ReportProgress(0, "From " + BWName + " -> " + StaticShare.Messages);
                    StaticShare.Messages = BWName + " current time: " + DateTime.Now.ToString();

The first line locks MsgLock, or causes the thread to wait until another thread's lock is released.  The ReportProgress() line is a method belonging to a BackgroundWorker, that line, in this case is accessing our shared variable Messages.  The last line in the Lock() block assigns something to the shared variable.

One big caveat here...  Make the code within the lock() block short, concise, to the point and fast.  If the code there is time-consuming or performs poorly, the lock() could cause other threads to be blocked.

Remember...  thread blocking is not cool!

You can download the entire c# project from my Google Drive here.  Standard code disclaimer: This code is for education, information and perhaps a few laughs.  It may not be perfect but does demonstrate a valid implementation of using shared storage with a multi-threaded C# application.


Monday, July 13, 2015

C# Battle - Dynamic Array -versus- Generic Collection

In a previous post I insinuated that using a dynamic array in C#, rather than a dynamic structure might show a certain lack of basic programming skills.  Well, after getting my daughter off to work early Saturday morning, a storm rolled in, throwing out my plans to perform a little yard maintenance.  So...  what to do?  How about a little computer play while drinking my morning coffee.

After all, drinking coffee while practicing my guitar has far too many times caused scares due to the possibility of spilled coffee!

So, I set out to prove that Dynamic Arrays are worse performers than Collections in C#.  Well...  For my tests, my presumptions were proven incorrect.  My little test showed that when loading image bitmaps from PNG files into a Dynamic Array, there is only a marginal difference loading into a C# Collection.

Machine Baseline...
CPU: Intel Core i3-3240 @ 3.4 GHz
Windows Version: 7 Ultimate 64 bit.
Hard Drive: ADATA SP920 512MB SSD drive
Number of images to load: 9727
Image size: All are 640 x 480

Read on for the code and specific results...

Saturday, July 11, 2015

Basic Skills, Please People!


Programmers really should know the basics of a language and platform before coding something that is used in a production environment.  Knowing the cool tricks of a language is nice but not knowing how the basics work is just irritating.

Take for instance a little optimization I just finished...  A SQL query was returning about 800,000 rows where about 799,700 were duplicates.  Adding a distinct to the SQL made the page load about 80% faster.  Why did the programmer not use that distinct keyword???  Maybe because they didn't know the basics.  Maybe because the programmer was sloppy.  Maybe the programmer didn't completely understand what was requested.  Don't know.

Then, while looking at the rest of the code I saw several string arrays defined; arrays that, after populated, contained hundreds of items.  To build these arrays, Array.Resize was used to add items.  Now THAT just might be inefficient.  Array.Resize copies the entire array and adds another element.  The programmer probably should have used a List<> or some other dynamic structure.

Hmmm...  now I am curious...

Wednesday, July 8, 2015

8 Reasons for a New Operating System

Many years ago you could find me sitting in front of my computer wearing one of my well-worn Linux t-shirts or baseball caps, just programming my brains out, secretly wishing the universe of computers ran on one flavor of Linux or another.  Today, well, I am happy to simply have my Windows 7 machines humming along in front of me for at least a week without pause or crash.  Anyway...  over time I believe Linux has migrated from an OS that performed well & was fairly simple to install and operate, intended to make any computer geek giggle with delight, to something somewhat sloggy and overly complex that now give those same computer geeks headaches and the occasional nightmare.

Anyway, not that I have the technical ability in my current state, I would love to write a new operating system.  Why?  Here are eight reasons:

  1. Performance gains from increased hardware capabilities have been severely strangled by poorly performing code and the belief that the faster hardware will compensate for less than stellar code.  A new operating system should centrally focus on core performance at the expense of general purpose functionality.  
  2. Malware...  Viruses...  Keystroke Loggers... Spyware...  One of the key reasons this crap is proliferating is because we have the same-old operating systems and code and utilities.  A new operating system should have some basic security in mind when designing basic low-level functionality.  And, simply by nature, a new OS would be impervious to these nasties for a while.
  3. Current OSs are COMPLEX!!!  They try to be the do-all, know-all solution to everything.  Someone (or something) that tries to do everything will never do anything specific very well.  A new operating system should focus more on doing computery things, rather than everything under the sun.
  4. Developer environments and tools for Windows and Linux are fragmenting so badly, researching solutions and problems, depending on the situation, can be a near-futile exercise.  A new operating system could provide a new & clean slate.
  5. The windowing OS paradigm is dying.  Yes, I said it.  Don't get me wrong, the windowing paradigm will be around far longer than I.  However, it is my firm belief that virtual reality, tactile and audio human/computer interfacing will be the future.  A new operating system should have a low level text base interface for baseline operations, maintenance and debugging, and perhaps a windowing interface for coding, but should focus at these newer human/computer interfaces.  And, just as a note, all functions capable of being performed by the computer, should be allowed through the text interface.
  6. The Keep It Simple and Stupid concept has been, for the most part, thrown out by most modern operating systems and development tools.  A new operating system should embrace the KISS concept.
  7. Ever notice the slow access to directories with thousands of files?  OK, there may be solutions but it just peeves me off when I have 10,000 or 20,000 files in a directory and handling this many files is so slow (in both Windows and Linux) I can take an afternoon of coffee & smoke breaks.  A new operating system should minimally have the ability to support fast handling of large number of files.
  8. Provide a more rich computer eco-system.  Sometime I think Apple and Windows and Linux devs are getting lazy, just hunting for and polishing the low-hanging fruit.  A new operating system that performs well, has a vibrant development environment will place pressure on existing ecosystems and provide evolutionary pressure.
What are you waiting for???

Sunday, January 18, 2015

Making Glade run on Precise Puppy

Being a Crazy Old Programmer, there are times when Crazy Old Programmer Thoughts create little fires in far-flung reaches of my brain.  About a year ago I started collecting night sky images with the thought I would write a C# program to watch for odd things up in the heavens.

Specifically I wanted to look for meteorite trails and bolides.  It was not a success but not a failure.  The proof-of-concept was to make one second exposures and save 24 hours of these images.  Exposure time on day sky images would be adjusted accordingly.  That would yield about 86400 files for each 24 hour period.

Windows choked horribly.  Copying that many files from one directory to another required more than an hour of the computer's time.  Processing the images were slow, likely due to the file system and that C# doesn't compile to the hardware, rather to an intermediate CLI.

Anyway, I started looking and thought I would experiment with minimal Linux distributions.  First one up is Precise Puppy.  Install on my little HP mini was fairly painless and overall the OS is extremely responsive for such minimal hardware.

Next step is getting the DEVX package installed and running. 

Thursday, December 18, 2014

KIFS - A New Software Development Paradigm

KIFS is a new software development paradigm or philosophy that emphasizes simplicity above all other factors.
KIFS is an acronym for Keep It Freakishly Simple.

KIFS is not enumerable or objective.  It is sensitive to the context with which it is to be applied.  It is similar to the KISS philosophy but more specific. The goal of any software project developed using KIFS is simplicity in all aspects without affecting intended functionality.

KIFS is not exclusionary.  It may be used within the user interface where something large, overbearing and wasteful like an MVC design pattern can be used for other aspects of a particular project.  KIFS is there to help when needed.

Some advantages of KIFS are...

Saturday, November 22, 2014

Brain What???

Many years ago as a hobby I collected computer languages.  I would be up all hours of the night downloading source code, reviewing documentation or trying to contact programmers involved with defunct languages.

Well, I saw the name of this language and had to laugh...  BrainFuck

Apparently this is an older language and, well, a very simple one.  The word terse simply does not do it justice.  Take a look at the above link to it's Wikipedia page.  Just WOW :-)

Wednesday, November 12, 2014

Z80 Blast From The Past

A few weeks ago while putting things away for winter; an 'autumn cleaning' if you will, I found my old project computer notebook from the late 1980's.  In it were notes and plans and photo-copies of more than enough information to build my own Z8000 computer.  Back then, my personal projects were based more on 'coolness' than having a purpose.  Ahhhh the good old days.

This morning I was poking around on the internet and what do I find???  A military paper on 256 Z80 autonomous computers clustered into a single highly parallel computer called ZMOB.

ZMOB had more of a conceptual point of origin rather than a purpose: "The ZMOB idea sprang originally from needs of the Computer Vision Lab at Maryland."  Ahhh...  To build something for the simple sake of building it.

Monday, November 10, 2014

C# Programming Tip - ViewState

A C# page's ViewState is a real cool place to put state information and variables you want to stick around for the lifetime of a web page.  Actually, most ASP page components save their state information in the ViewState.

Saving stuff in the ViewState is easy.  Here is an example:

ViewState["mode"] = "A"

Accessing it is easy as well:

if (ViewState["mode"].ToString() == "A") {...}

You can also do cool things like put more complex items in the ViewState like:

SomeComplexClass ComplexObject = new SomeComplexClass();
ViewState["ComplexObjectVS"] = ComplexObject;
SomeComplexClass ComplexObjectCopy = (SomeComplexClass)ViewState["ComplexObjectVS"];

So long as the object is seralizable (more on that later), you can save it in the ViewState.  There is a big drawback... space and bandwidth.  A page's ViewState is stored in the page!  So, each time the page loads, is posted or there is a postback, the entire ViewState is sent over the network.  If you want to maximize the efficiency of your page, minimize your ViewState usage.  The size of a ViewState can grow quickly if you have a large and/or complex page.

Also...  ViewStates are NOT secure.  With enough smarts a person can decode them, so don't put anything in the ViewState that you want to keep secure.

For those curious, here is what a simple ViewState looks like in a simple page:
<input id="__VIEWSTATE" name="__VIEWSTATE" type="hidden" value="/wEPDwUJNzkzMjk1ODg4D2QWAmYPZBYCAgEPZBYCAgsPDxYCHgRUZXh0BQgxLjAoZGV2KWRkGAEFHl9fQ29udHJvbHNSZXF1aXJlUG9zdEJhY2tLZXlfXxYBBSZjdGwwMCRNYWluQ29udGVudCRMb2dpblVzZXIkUmVtZW1iZXJNZbVBilGyAMpTuiSmFozdPPwfgNyhxhHXWwhU4O2NRdBd" />