Search: in  

Rob Kennedy's Blog

Rob Kennedy is an avid and active .NET software developer who tends to have an opinion about everything. In the windows developer community for over 10 years, he has grown his career and opinions through experience.
  • 4 Week Vacation

    So I've begun my 4-week vacation and thus far it's seemed like a weekend. I am sure once a week has passed though I will start to feel like I'm off work. I've not done much but it does feel nice to be able to not think about programming websites for a change. For instance today I went to the firing range and popped off 50 rounds. Paid my storage shed bill and now I'm back home. I am going to the gym later and I feel like having no schedule (set times) is odd...I'm sure it'll change eventually. Anyway, that's all for now. I think I'm going to be writing a lot here on this site now though. smile_regular

    Share this post: E-mail 4+Week+Vacation | Submit 4+Week+Vacation to Technorati | Submit 4+Week+Vacation to del.icio.us | Submit 4+Week+Vacation to digg.com | Submit 4+Week+Vacation to reddit.com | Submit 4+Week+Vacation to DotNetKicks | Add 4+Week+Vacation to Live Bookmarks
  • X-bit labs - Microsoft Denies Plans for Add-On Blu-Ray Drive for Xbox 360.

    All the more reason why I plan on buying a Playstation 3 tomorrow. Microsoft fails again.

    X-bit labs - Microsoft Denies Plans for Add-On Blu-Ray Drive for Xbox 360.

    Share this post: E-mail X-bit+labs+-+Microsoft+Denies+Plans+for+Add-On+Blu-Ray+Drive+for+Xbox+360. | Submit X-bit+labs+-+Microsoft+Denies+Plans+for+Add-On+Blu-Ray+Drive+for+Xbox+360. to Technorati | Submit X-bit+labs+-+Microsoft+Denies+Plans+for+Add-On+Blu-Ray+Drive+for+Xbox+360. to del.icio.us | Submit X-bit+labs+-+Microsoft+Denies+Plans+for+Add-On+Blu-Ray+Drive+for+Xbox+360. to digg.com | Submit X-bit+labs+-+Microsoft+Denies+Plans+for+Add-On+Blu-Ray+Drive+for+Xbox+360. to reddit.com | Submit X-bit+labs+-+Microsoft+Denies+Plans+for+Add-On+Blu-Ray+Drive+for+Xbox+360. to DotNetKicks | Add X-bit+labs+-+Microsoft+Denies+Plans+for+Add-On+Blu-Ray+Drive+for+Xbox+360. to Live Bookmarks
    Posted Oct 12 2008, 11:39 PM by RobK410 with no comments
    Filed under: ,
  • My thoughts on mobile operating systems...

    Sick and tired of Windows Mobile on my Mogul. It's slow. It's designed for a stylus, not my thumb. On the plus side, I like the fact I can write applications for the phone in a very advanced development environment (e.g. Visual Studio 2008), do microsoftie stuff, etc. I haven't used an iPhone but from what I can see it has an exponential amount of more class and style over Windows Mobile. It's designed for the user's thumb to navigate. The same thing goes for Google's Android mobile platform. Although I've only used it in a virtual machine, it is a lot more intuitive for the user to use; A lot less like windows, and more like an operating system designed for a phone. That I think is the problem with Windows Mobile. It's roots are in the PDA where Windows CE was king and using a stylus to write notes was the norm. It doesn't apply to a touch-screen phone. I can't get my thumb to press the X buttons. I find it difficult to use a lot of applications where lists and buttons are so small, only a midget or stylus will be able to select them.

    Some might say I should stop my complaining, since I bought a Mogul which is designed for the stylus. I say hogwash! A mobile OS with touch screen capabilities should assume the user will want to use their thumb since it's more efficient. Otherwise one has to use both hands (NO!) holding the phone and retrieving and using the stylus. Not an easy task to do while walking might I add.

    Needless to say, Google seems to see the big picture with Android. I think when they release the source code for Android in Q4 of 2008, we'll see a slew of kernels and drivers being ported to the HTC lineup of phones. Unless Microsoft does a drastic update to Mobile 6.x, they will lose my loyalty and I'll be forced to move to Android. I've seen Mobile 7 screen captures, but I also see those blasted X buttons, which means Microsoft still doesn't get it.

    Share this post: E-mail My+thoughts+on+mobile+operating+systems... | Submit My+thoughts+on+mobile+operating+systems... to Technorati | Submit My+thoughts+on+mobile+operating+systems... to del.icio.us | Submit My+thoughts+on+mobile+operating+systems... to digg.com | Submit My+thoughts+on+mobile+operating+systems... to reddit.com | Submit My+thoughts+on+mobile+operating+systems... to DotNetKicks | Add My+thoughts+on+mobile+operating+systems... to Live Bookmarks
  • Finally picked up a new laptop

    hplaptop Well I found it was about time to get a new laptop so I went on a spending spree today. Picked up a new HP DV5-1004NR. It's a pretty decent laptop for the price tag, and it certainly has some nice features included. It was mandatory I get a 64-bit cpu and I liked the AMD64 better than the Intel line. This laptop sports 4gb of memory as well so it'll give me some space to let my apps breath so to speak. Disk space is loaded, and although it comes with Vista, I've installed VirtualBox vm. I'm installing Ubuntu 8.04 right now and will be installing XP as well. Overall I'm pretty pleased with the purchase. We shall see how well this holds up.

    Share this post: E-mail Finally+picked+up+a+new+laptop | Submit Finally+picked+up+a+new+laptop to Technorati | Submit Finally+picked+up+a+new+laptop to del.icio.us | Submit Finally+picked+up+a+new+laptop to digg.com | Submit Finally+picked+up+a+new+laptop to reddit.com | Submit Finally+picked+up+a+new+laptop to DotNetKicks | Add Finally+picked+up+a+new+laptop to Live Bookmarks
  • My Computer Runs faster after ditching Norton Anti-virus

    It's no surprise that running an anti-virus program will put a performance hit on your PC. However, I was recently really getting fed up with Norton Anti-virus as it's resident programs were always bloated using up to 50mb of ram and my system had taken a significant performance hit on disk access; enough so to notice. I kept it installed though because the corporate edition was provided to me by my work (non-subscription based software) for free and it was what I was used to.

    trash Well after waiting minutes for an application to load I flipped out and started removing applications. After ensuring my disk was defragged, files were cleaned up, etc. I noticed very little difference in performance. Why the speed slow down? I remember a speedy system when I first installed XP, I doubted that the "OS rot" was that bad. I knew it was that bastard Norton, so I searched for a free replacement. I came across Clam AV, but it looked incomplete. AVG makes a free system too, but again just anti-virus. Then I found Avast! which was rated well, claimed a large user base, and anti-malware support. I promptly uninstalled Norton and installed Avast.

    After the uninstall of Norton AV the system seemed more responsive, so again there was physical proof in my mind that the problem was Norton AV. I installed Avast and after a registration, the application installed and started up. Amazingly, the noticeable system speed increase I received after uninstalling Norton AV was still there! Between three programs running in the background, Avast takes up 30mb of memory. A savings of 20mb of memory from Norton AV. It automatically has been updating itself daily, and thus far seems unobtrusive and easy to use.

    If you are currently running Norton Anti-Virus, paying for a yearly subscription for it, etc. I highly suggest you uninstall it and try Avast. You may just see a significant performance increase like I did.

    Share this post: E-mail My+Computer+Runs+faster+after+ditching+Norton+Anti-virus | Submit My+Computer+Runs+faster+after+ditching+Norton+Anti-virus to Technorati | Submit My+Computer+Runs+faster+after+ditching+Norton+Anti-virus to del.icio.us | Submit My+Computer+Runs+faster+after+ditching+Norton+Anti-virus to digg.com | Submit My+Computer+Runs+faster+after+ditching+Norton+Anti-virus to reddit.com | Submit My+Computer+Runs+faster+after+ditching+Norton+Anti-virus to DotNetKicks | Add My+Computer+Runs+faster+after+ditching+Norton+Anti-virus to Live Bookmarks
    Posted Sep 27 2008, 03:05 PM by RobK410 with no comments
    Filed under:
  • 10 Things I want in a Job

    I've had it. I quit. I'm done. It can't be done here. I'm tired. Help!

    All of the previous statements have been said by me in the past few years here at my current job as a Sr. Software Engineer at a local government contractor. Our company attrition rate has gone almost into double digits. Even the morale boosting plans of the office Olympics day (non-chargeable time of course) can't boost morale here since after the fun, employees come back to the reality that we all still work here. It's the same old story once again and it's not making things any better. In fact, things are pretty much the same since I started here almost 5 years ago. That is in my opinion why the attrition rate will remain steady in the near future. Aside from the company finally adjusting salaries to match the cost of living here (too little, too late for most), I personally feel there is still something wrong; I feel like I'm stuck in a job rut. Like I'm a mouse in a maze and I'm looking to get out; looking to find a better path, but always coming up short. Staying in one area of the maze is comforting almost because I know that part of the maze there is a "steady pay check" or what appears to be a steady amount of cheese so to speak. In fact, this whole maze blabber reminds me of the "who moved my cheese" book. I've become the mouse with the dwindling cheese pile. In fact, everyone here seems to be a mouse with a dwindling pile of cheese.

    Well I'm not fearing change anymore! I'm going to embrace it!

    In the standard way of doing things I wrote down what I didn't like about my current job and what I did like about it. It seemed that I liked the people but disliked the work itself. So below is a list of things I want to have in the next place I work with examples of why I want them and/or examples of what I have now.

    The Environment

    1. Open Air: I want to work in a place where I can see what everyone is doing within the general area whether they are at their desk or not, etc. I want it to be a relaxed environment with lots of windows. Currently, the work environment I am in is not conducive to collaboration or working together. Managers are stowed away in individual offices with doors, and each developer is located in a 7x7 cube with 5 foot tall walls. There's a "seniority complex" with management and other employees around me who think that they "deserve" to be located near the office windows as apposed to those employees with less tenure. The idea of being in an enclosed cube near a window as some sort of job perk is asinine.
    2. A real Cafeteria: I want to work in a place that has or is near a real cafeteria; one where meals are prepared daily. The food is affordable (free preferred) and healthy. Currently, we have a small room called a "cafeteria", with no prepared food, only a couple of candy vending machines. Two refrigerators and three microwaves are in the kitchen area where we are to prepare our own microwave meals. Because the cafeteria is on the other side of the building, fridges are strategically placed throughout to make storing our own food easier on us, but the extremely lazy are not allowed to have their own microwave for reasons that they cause "power draining" issues.
    3. Dress Code: I want to work in a place that would let me wear a t-shirt if I felt like it. Currently, we have a casual business dress code. This dress code is pretty flexible as a few of us are on the cutting edge wearing blue jeans each day. If we even thought of coming in wearing even a company-logo'ed t-shirt, we'd be pointed out as pariahs. I'm not totally complaining because I know there may be a customer walking through, but I want to work in a place where the customers don't mind the attire. A person shouldn't be judged on whether they are dressed in a suit but on the results of their work. To say a t-shirt is going to make me look like less of a business person or less reliable is old-school thought and should be abandoned.
    4. Mixing of management and workers: I want to work in a place where I have access to upper management. We currently have managers who I've never met, or see only in the hallway. They will never go out of their way to ask what I'm doing to make the company profitable, nor would they attempt to go out of their way to say hello. I want to work in a company where I can eat lunch with the CEO (at least in the same room) and let him know what kind of a job I think he's doing. A CEO or boss who doesn't have time to meet with the troops at least once a week or month is a boss who's out of touch. If I were in charge, I'd want to know what my employees were thinking first hand. This may be tough to do if you have many remote offices, but the leadership of each office location should be doing the same thing to know exactly what's going on in the minds of their people. We used to have a managers luncheon but it made no sense because they would randomly choose a group of 3 to 4 people and a manager from a division they weren't even associated with, then send them all out to lunch. This was so random that it wound up being a meet and greet other employees as apposed to talking to your own managers about the company in a relaxed setting. I believe they stopped these lunches as a cost cutting tactic.
    5. Embraces and acknowledges Ingenuity: I want to work in a place where research and development are the primary goals of the company. Researching and developing new ways of doing things and writing applications that implement these new ideas. Currently I work in a situation where all development being brought in is for a standardized "cookie-cutter" web-based data entry and retrieval application. The only innovation is only really made by a few of us and even then there is no money or input in allowing us to build on those innovations allowing them to grow. It's left up to us to use our own personal time to make any progress with the innovations and in turn the ideas become quickly outdated. The company is not looking to write the next killer application as they usually only spend the money they win on a contractual basis. I've only been subtly acknowledged for innovation here either through un-announced awards or e-mail letters saying "good job" from my boss. The reasoning being that others would be upset if they saw one person winning awards or being acknowledged constantly. I want everyone innovating and being awarded publicly. This furthers innovation and/or competition to achieve in the minds of those who want to be acknowledged amount their peers.
    6. A "hip" culture: I want to work in a place where I'm not the youngest or the oldest person on the team. There needs to be a balance of tech-savvy individuals. I want to work with people who are smarter than me. Who are a wealth of knowledge but are friendly enough to share it with others. Ideally people with similar thoughts on business and worldly events. Who are active and have an appreciation for the outdoors. Currently, I'm surrounded by a 50-something who sounds like he's dying from some sort of lung ailment, and a 40-something who's more concerned about her kid's sports team than the work she's tasked to do. There are a few of us here who are "hip" but that's not enough to change the hearts and minds of the entire group. I need to be among like-minded individuals who are all in the know, have a grasp on what's cool/fresh, and can bring that knowledge into the work they produce.


    Adoption of Technology

    1. Proper Use of Security: I want to work in a place that has a IT-security department that isn't run by the gestapo. They would be knowledgeable of best security practices but wouldn't dare think of wholesale blocking all outbound traffic for all users. Currently where I work we can't do much of anything when it comes to connecting to a resource outside of the company network. Web traffic is filtered using Websense, but not fairly; in fact very disproportionately. My personal blog is blocked (in fact my server IP and all it's websites are blocked), as are several blogs that are labeled as "personal", but YouTube.com and other mind-numbing time-wasting sites are not. I want to work for a company who has faith in their employees that they will do their job because they love their job. If an employee feels that what they're doing is going to make a difference in the world, they're going to pour every ounce of time they have into it; not surf YouTube. Since I work for a Government contractor I can understand why they would want to operate at a heightened state of security; not trusting their employees to be smart enough to not visit certain sites, but that's only part of a problem. My website expresses my opinions (99% technical) and provides software tools that developers can download and use. However, my co-workers could get the same opinions and tools directly from me, so what's the point of having my website blocked? You can't force people to be productive by blocking websites (I understand blocking nefarious sites) because you usually wind up throwing the baby out with the bath water. Besides, I sit next to a woman who will talk for an average of 2 of her 8 scheduled hours a day on non-work related topics. How do you filter her to make her productive?
    2. Allow a worker to work remotely: I want to work in a place where I can work from home. Maybe not 100% but at least have the option not looked down upon as being a money waster. If a company has invested correctly in the technologies allowing their employees to telecommute, then I propose they would see no difference (perhaps even a savings) in costs than if the employee was taking up a space in the corporate building. A Virtual Private Network, video conferencing, and/or video/voice/text instant messaging along with standard e-mail all would provide the equivilant capabilities of having an employee on location. The only exception would be meeting a client outside of the corporate network infrastructure... but even then a conference call could be made. Studies I have read show that employees who work from home tend to work harder and longer hours rather than the perception that they don't do any work at all. Again, if the employee's heart is in the work, they will do the work no matter where they are. Where I currently work we do have VPN and conferencing capabilities, but the managers will only allow telecommuting for those who have moved away to another state. They don't embrace the concept of having people work at home. Even if it's proven that doing so saves the company money via less power, resources, and consumables usage at the corporate office. I want a company who can appreciate these concepts, embrace them, and not be fearful that their employees are off shopping for pampers or fishing on some lake while on the clock.
    3. Bleeding edge technologies: I want to work in a place where we are not only using the latest technologies but we are creating them. I want to develop code that is new, or at least is going to be integrated into something that's new. Create a product that has never been seen before or has innovations that leap over the previous versions. Currently where I work, we have slow adoption of new technologies and development concepts mainly because of developer learning curves and restrictions on the technologies we are allowed to implement for our (mainly government) clients. I don't want to have to be the one constantly pushing management to have employees learn new technologies or adopt new theories. I want to work for a company that embraces the concept that their employees need to be always learning the latest consumer trends and technologies. This allows the employees to use the latest technologies to better their own processes, capabilities, and/or development results.
    4. Encourages community outreach: I want to work in a place where I'm encouraged to communicate with others and help them in using our products. A company should embrace the concepts of blogging and message forums. Currently we are prohibited from running any sort of public message forum or blog; period. I assume it's considered as a task of the marketing department, and frankly there really is no need for me to do so since the company I work for is a government contractor. I however want to work in a place where I can talk directly to the customers, get their uncoated-sugar-free feedback and let them know they're important. Having the ear of the folks creating the product they spent a fortune on is a big plus in the minds of customers. Currently, I don't even know why I'm coding a website or who is going to be using it, I just do it.

    So there's a few things I would like in my next job. If anyone can comment and let me know of a place where they need an expert C#/.NET/C++ developer, I'll gladly consider their recommendation as my next (and probably final) job. As for my current company, I don't expect them to change their policies any time soon or spend the money to make the necessary upgrades in environment or technologies. They are a steady paycheck that is for sure as are most government related jobs, but remember that the pile of cheese eventually runs out.

    Share this post: E-mail 10+Things+I+want+in+a+Job | Submit 10+Things+I+want+in+a+Job to Technorati | Submit 10+Things+I+want+in+a+Job to del.icio.us | Submit 10+Things+I+want+in+a+Job to digg.com | Submit 10+Things+I+want+in+a+Job to reddit.com | Submit 10+Things+I+want+in+a+Job to DotNetKicks | Add 10+Things+I+want+in+a+Job to Live Bookmarks
  • C# Best Coding Practices

    Below is the bulk of the content from a standard procedure I recently wrote for my open source project .Mail Server Suite. Often when you have a group of people working on a single project, it makes sense to have an expectation of consistent code design from each developer. A standard procedure document is just that; a standard way of doing something. Thus many projects should develop a standard procedure document to instruct their developers on the best practice for developing in the language used. I am partial to C# in all my projects these days, and thus wrote the SP for C#. Enjoy.

    C# Coding Standards

    1.0           File Naming Conventions

    1.1 Namespace Folders

    For each namespace, a sub-folder shall exist within the main project folder with the same name as the namespace. Source files for each class that resides in the namespace shall reside in the appropriate namespace sub-folder.

    1.2 C# Source Files

    a.       Files will be named by the class object that they implement.

    b.      The source file will be labeled as “ClassName.cs”

    c.       Classes should be given meaningful names.

    d.      Class names should follow UpperCamelCase naming convention with the first letter of the class in uppercase.

    e.      Interface class names should begin with the capital letter “I

    1.3 XML Configuration Files

    a.       Configuration files shall reside in either the root project folder or a designated configuration files sub-folder; e.g. \Config\

    b.      Configuration file names shall have the extension “.config”

    c.       Configuration files shall follow the XML schema standard designated by the developer.

    1.4 Documentation

    a.       All documentation shall be written clearly and in a format designated by the Software Task Manager or designee.

    b.      Documentation should be stored in a format easily accessible from any machine. If rich text/content is required, the document should be stored in Microsoft Word format or Adobe Acrobat PDF format for final documents.  Otherwise, documentation should be stored in a text file with standard ASCII CR-LF line breaks.

    1.5 Database Scripts

    a.       All scripts to update related database systems shall be stored is a project sub-folder named “SQL”. Under this sub-folder, a sub-folder shall be created for the particular build version.

    b.      SQL script files shall be in a standard ASCII text file format with CR-LF line breaks. A script file should be created for each relevant database management system (e.g. SQL Server, mySQL, Oracle, etc.)

    c.       SQL script files should follow standard commenting practices as well as a standard SQL-92 format unless a specific requirement must be made for a particular database management system.

    1.6 Optional Resources

    a.       Any additional resources such as internal resx files or images shall be stored in a sub-folder named “Resources” under the project root folder.

    b.      Either any files that will not be compiled or distributed should reside in the Documentation sub-folder or a separate sub-folder named “Misc”.

    2.0           Source Comments

    All source code files shall contain a “page-level” documentation block at the top of each file and “class-level” documentation block(s) immediately above each class. Block-level comments should be liberally used throughout the code where needed.

    2.1 Page-Level Comments

     

    2.2 Class-Level Comments

    This comment header will be placed above every class:

     

    2.3 Class-Property & Method Comments

    Additionally, at a minimum a summary comment header should be placed before every public property and method within a class:

    2.4 Trailing Comments

    Very short comments can appear on the same line as the code they describe, but should be shifted far enough to separate them from the statements. If more than one short comment appears in a block of code, they should all be indented to the same tab column. If a comment is lengthy in wording it should always be placed above the block or line of code it is describing.

    Desired – Easy associate follow comments

    // The following code shall add two numbers

    // and passing the result into an integer.

    iResult = iNum1 + iNum2;

     

    Not Acceptable – Comments can get winded and scroll off screen

    iResult = iNum1 + iNum2; // The following code shall add two numbers...

    2.5 Single-Line Comments

    Short comments can appear on a single line indented to the level of the code that follows. If a comment cannot be written in a single line, it should follow the block comment format. A blank line should precede a single-line comment.

    Desired – Easy associate follow comments

    if (bCondition)
    {
        // and passing the result into an integer.
    }

     

    2.6 Multi-Line Comments

    The // comment delimiter should be used for multi-line comments that do not precede a large block of code. To facilitate commenting out lines of code during debug and test phases of software development, the /* ... */ comment delimiters should not be used for multi-line comments unless at the beginning of a large block comment. A blank line should precede multi-line comments.

    Desired – Easy associate follow comments

    if (bCondition)
    {
        // The following if statement will compare the
        // value of bar to 1 and if it’s greater then it will
        // execute additional code.
        if (bar > 1)
        { ...
        }
    }

    3.0           Code Layout

    3.1 Code Block Indenting

    a.       When indenting blocks of code use a tab character or 4 spaces per sub-block of code.

    b.      Opening and closing parentheses should be lined up at the same indentation level.

    Desired – Easy associate brace with if statement

    if (bEvaluate)
    {
        if (bEvaluate2 >= 1) // operators are neatly spaced
        {
        }
    }

     

    Not Acceptable – Not easy to associate braces with if statement, no space after if

    if(bEvaluate)
       {
         if(bEvaluate>=1){ // operators are not neatly spaced :(
         }
       }

     

    c.       Single-line code executions do not require braces but cannot exist on the same line.

    Desired  – Easy to process, can easily add more code lines in an if-result

    if (bEvaluate)
    {
        Console.WriteLine("The value was true");
    }
    else
    {
        Console.WriteLine("The value was false");
    }

     

    Acceptable – Easy to process braces, compact

    if (bEvaluate)
       
    Console.WriteLine("The value was true");
    else
       
    Console.WriteLine("The value was false");

     

    Not Acceptable – Not easy to process braces or execution

    if (bEvaluate) {
         Console.WriteLine("The value was true");
    }
    else Console.WriteLine("The value was false");
     

    3.2 Statements

    3.2.1       Simple Statements

    Each line should contain at most only one argument.

    Desired

    iVariable++;  // Correct
    iVariable2++; // Correct

     

    Not Acceptable

    iVariable++; iVariable2++; // Not-Correct

    3.2.2       Compound Statements

    Compound statements are statements that contain lists of statements enclosed in braces “{ statements }”.

    a.       The enclosed statements should be indented one more level than the compound statement.

    b.      The opening brace should be on a new line below the compound statement; the closing brace should be on a separate line and be indented to the the opening brace.

    c.       Braces are used around all statements, even single statements, when they are part of a control structure, such as an if-else or for statement. This makes it easier to add statements without accidentally introducing bugs by forgetting to add braces.

    3.2.3       Return Statements

    Return statements should usually only occur once and should reside at the end of a method or property call. Placing them in multiple locations in the body of methods makes code execution paths harder to follow.

    Desired – single return point, easy to process code flow

    virtual public bool CanUserDoSomething
    {
        get
        {
            bool returnResult = true;
            if (evaluate)
            {
                returnResult = false;
            }
            else
            {
            }
            return returnResult;
        }
    }

     

    Not Acceptable – multiple return points can cause confusion, possible unused code.

    virtual public bool CanUserDoSomething
    {
        get
        {
            if (evaluate)
                return false;  
            else
            {
                return true;
            }
        }
    }

    3.2.4       If/Else If/Else Statements

    If/Else If/Else statements should use braces following the operator to delimit their block of code. Operators should be neatly separated by a single space. See 3.1.c for examples.

    3.2.5       Switch Statements

    A switch statement that allows one of its cases to fall through to the next case should be commented as such. A default case should always be implemented even if it contains no further statements.

    3.2.6       Do/While/For Loop Statements

    Do/While loop statements are similar to if-statements in that braces should be used following the operator in all cases. Use of similar indentation and brace usage should be also be adhered to. A while-statement should be used when continually looping (checking a Boolean status for break). A foreach-loop should be used on collections and arrays where an index is not required. For-loops should be used where an element index is required.

    Desired – Easy to process braces

    while (evaluate)
    {
       ...
    }

     

    Acceptable – Post-test loops are not desirable

    do
    {
       ...
    }
    while (evaluate)

     

    Not Acceptable – Not easy to process braces or execution

    do {
        ...
    } while (evaluate)