Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
M

Michael A Cochran

@Michael A Cochran
About
Posts
47
Topics
4
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • for(int i=0; i<size; i++)
    M Michael A Cochran

    In my mind, it was because of FORTRAN. Back in the day, we didn't have all that many languages to choose from and most of us wrote in 360 assembler, FORTRAN, or COBOL. As others have said, while FORTRAN did have typing, variables starting with i-n were defaulted to integers so we just used i - followed by j, k, l in nested loops - for simplicity. We also used foo, foobar, and jane for "temp" variables. foo and foobar were common for IBM programmers and jane was common in DEC code.

    The Weird and The Wonderful csharp c++ java question

  • Hooah! Office 365 subscription for MSDN subscribers.
    M Michael A Cochran

    Visual Studio Premium with MSDN. Based upon this[^], it looks like it's only for Premium and Ultimate level subscriptions.

    The Lounge sharepoint

  • Hooah! Office 365 subscription for MSDN subscribers.
    M Michael A Cochran

    Since Office 365 was first introduced, I've wondered why an MSDN subscription didn't include an Office 365 subscription. Suddenly, there it is - got an email notification yesterday. Nice!

    The Lounge sharepoint

  • Shouldn't programmers know how to fix computers?
    M Michael A Cochran

    This is a huge pet peeve for me. And the second biggest reason I don't have adobe reader installed on my pc anymore. (the first being that it is a major attack vector)

    The Lounge help tutorial question

  • Poetry Written in Code Contest
    M Michael A Cochran

    How about SQL? DECLARE @ROSE CHAR(1); SELECT @ROSE=IS_ROSE FROM GARDEN WHERE NAME IN (SELECT @NAME FROM NAMES); DECLARE @IS_SWEET CHAR(1); SELECT @IS_SWEET=@IS_ROSE;

    The Lounge tutorial

  • The dev was fired but the havoc is left for us to fix...
    M Michael A Cochran

    Yes, the unintentional side-effect is definitely an issue. I guess I'm just being magnamous today but I would want to see more of the code before I fired the developer over it. :-D

    The Lounge help question

  • The dev was fired but the havoc is left for us to fix...
    M Michael A Cochran

    I'm sure I'll take heat for this but, honestly, I don't think it's that bad. One boolean is (almost) as good as another. Without seeing the rest of the code, it's hard to tell what the intention was. Certainly I would try not to do this but perhaps the developer was attempting to avoid a global variable to hold control state? Or perhaps there are a number of controls who's state has to be managed and the dev wanted to avoid an array or a hash? Perhaps the control state is set from a disconnected object and there is no mechanism to transfer state? I dunno? But it's pretty common to do things like if $('#myid').hasClass('enabled') { // do something }. Other than string processsing to get a boolean, it doesn't seem that far different to me. shrug.

    The Lounge help question

  • Quick Programming Quiz
    M Michael A Cochran

    It was a trick quiz. We all failed for having Flash installed in the first place! :laugh:

    The Lounge question announcement

  • What mobile phone OS you like?
    M Michael A Cochran

    WP7-7.5 is the best, IMHO. I don't give a thought to mobile OS's other than iOS, Android, RIM, and WP7. WebOS is pretty much dead and everything else runs on devices that neither I or my customers would use due to lack of feature function. I dislike the closed iOS ecosystem. All other manufacturers have a variety of handsets to choose from. Once you've used the live tiles in WP7 you'll hate the tiny, uninformative buttons in iOS. Enterprise app deployment is difficult and costs more as you have to get another license. Objective-C is one of the more difficult development environments (compared to JavaME or .Net, for example). I am also turned off by rampant Apple fanboism. I dislike the open source nature of Android. Too much forking and fragmentation going on. Google offers zero patent protection to its developers. It seems to be very insecure with as much as 30% of the apps in the marketplace being malware. Like iOS, the buttons are small and uninformative. Fairly easy to code to but the enterprise app deployment story is mostly MIA. Frankly I don't know much about RIM and I've never owned a BB device. It's my understanding the browser experience is very lacking. By many accounts RIM is sure to disappear in the next year or so anyway. So, while I still pay them some attention, it will be from the sidelines. WP7 is very easy to code for if you're a .Net developer already. It's a fast and clean OS. There are numerous devices to choose from and more are coming to the market this month - and many more are sure to arrive in the next year or so from Nokia. The user experience is snappy and easy to use both one or two handed (in landscape). The live tiles frequently give you information you need up front so you don't have to actually run the app. Notifications are great and can be presented in several ways. When using Exchange, email and contacts sync are fantastic. Without Exchange, you have to use windows live - a bit more cumbersome but still works perfectly well. I have all the apps I need and there are thousands more on the marketplace. Enterprise app deployment is through a "private" marketplace. This is new in Mango so I'm not sure yet if this is a plus or a minus but at least they have a story. I've also heard whispers they will offer enterprise device support and provisioning via System Center. And the coup de grace for me is the fantastic social integration to facebook, twitter, linked in, windows live, etc. So, for me, WP7, definitely, I'm very excited about it and thi

    The Lounge html android ios com graphics

  • Beginning to lose interest to code for fun
    M Michael A Cochran

    I've been coding for 30+ years now and I still enjoy it. Certainly at times it can get tedious but probably most of the tedium comes from dealing with office politics rather than the coding itself. I try to always find time to write something I find interesting. It's the mobile apps of late but really there is so much cool stuff out there it's hard to be really bored. Try getting a micro-processor (parallax basic stamp or netuindo). It's a lot of fun writing code that has real world interactions like turning managing lighting, security alarms, unlocking doors, etc., ... Plus, you'll learn a lot about how your code interacts with the hardware.

    The Lounge

  • The PC is dead. No! Don't listen to him, the Tablet is dead.
    M Michael A Cochran

    I picked up an iPad2 for development purposes. Other than for testing my mobile apps and web apps, it mostly sits collecting fingerprints (as it gets moved out of the way) plugged into the macbook that I also picked up for development purposes and is also mostly gathering dust. I hate having to use iTunes to sync it and I refuse to put iTunes and its associated bloatware on my Windows systems; so I'm glad I picked up a macbook. ;P And, I hate the whole closed ecosystem apple has created. Shortly after BUILD closed, a blogger wrote (we want) "A tablet that can be as fluid and user friendly as the iPad but as capable as a Windows laptop". http://www.bgr.com/2011/09/13/sorry-apple-windows-8-ushers-in-the-post-post-pc-era/[^] I don't agree with everything he wrote but he hits the nail on the head with that comment. When I get that, I will certainly embrace tablets more than I have the iPad2. That said, as a developer and business person that creates a lot of content, it will be a long time before I give up my PC. Oh, one thing the iPad2 does very nicely is the DIRECTV NFL Sunday Ticket To-Go. The app is nice and the video streaming yields fantastic video. GameMix or RedZone on the TV plus streaming your favorite game on the iPad is a cool NFL experience.

    The Lounge mobile com question announcement

  • Name windows 8?
    M Michael A Cochran

    Really? Dang! Should have known I wasn't going to be the first to come up with that. :laugh: Oh well, sorry for the repost.

    The Lounge performance question

  • Name windows 8?
    M Michael A Cochran

    Hummm... If Windows 7 was "weven", is Windows 8 "wait" or is it "weight"? Either way the performance considerations are thought provoking. :laugh:

    The Lounge performance question

  • How do I generate a number divisable by 5, and check it?
    M Michael A Cochran

    Why didn't I think of that? :rolleyes: Too much business programming, I guess. We don't use modulus in business programming much - at least I haven't had the need. Correct, of course. Much more elegant. If Stephen is still listening, in C# it becomes;

    // To generate as random numbers as possible, this variable must only
    // be initialized once and then reused as much as possible.
    Random rand = new Random();

    /// <summary>
    /// Generates a random number between 0 and 99995 that is always divisible by 5.
    /// </summary>
    /// <returns>Returns a random integer up to 5 digits long that is evenly divisible by 5.</returns>
    private int GetDivBy5()
    {
    // Get a random number between 0 and 99999.
    int divBy5 = rand.Next(0, 99999);
    // Subtract the remainder of (n/5) to make n divisible by 5.
    return divBy5 - (divBy5 % 5);
    }

    private void button1_Click(object sender, EventArgs e)
    {
    this.textBox1.Text = this.GetDivBy5().ToString("00000");

    }

    C# question lounge

  • How do I generate a number divisable by 5, and check it?
    M Michael A Cochran

    You're welcome, Stephen. Please keep in mind that mad geniuses as many programmers may be, few people tend to lump us programmers into the "high social skills" cliche. It's been a while since I worked with scientists but I seem to recall from my university days they can be somewhat socially lacking too. I remember this one physicist... Ahem... :omg: Uh, anyway, its probably best to just take the "water off a ducks back" approach - no one really means to insult - especially if you want any of us social deviants to actually help you. :laugh:

    C# question lounge

  • How do I generate a number divisable by 5, and check it?
    M Michael A Cochran

    // To generate as random numbers as possible, this variable must only
    // be initialized once and then reused as much as possible.
    Random rand = new Random();
    /// <summary>
    /// Generates a random 5 digit number that is always divisible by 5.
    /// </summary>
    /// <returns>Returns a random integer 5 digits long that is evenly divisible by 5.</returns>
    private int GetDivBy5()
    {

    // rnd.Next(minValue, maxValue) returns a random between minValue
    // and maxValue, inclusive. Use min/max values of 1000 and 9999 to
    // yield a random 4 digit number between 1000 and 9999 then multiply
    // by 10 to get a 5 digit number.  This number will always be
    // divisible by 5 but will always end in 0.
    int divBy5 = rand.Next(1000, 9999) \* 10;
    
    // To get more random and double the possible result set, randomly
    // add on 5.  This will yield the total possible set of integers
    // between 10000 and 99995 that are divisible by 5.
    if (rand.NextDouble() < 0.5)
        return divBy5;
    else
        return divBy5 + 5;
    

    }

    Stephen, you mention you are a coding noobie. So, a short word about random number generators - they're not really very random.
    All they do is take a seed (beginning) value and run it through a mathmatical algorithm that generates a new number. If you use the same seed value every time, you will get the same "random" number every time. Most random number generators can either self-seed - generally using the current clock value - or you can pass them a seed value when you initialize them. This is why you only want to initialize your random number generator once and reuse it over and over. Once you get past that, the rest is pretty easy. Just use the math several others have already provided. See the comments in the code... <edit> Um, just looked at the thread in the other forum where you defined your requirements a little better. It seems you would like to include 0-9999 in your result set too. You can do this easily enough by changing the min value passed to rand.Next(minValue, maxValue) to 0 instead of 1000. This last bit, is a bit tricky in that in programming terms "00005" is actually not a number but is really a string. To get the leading zeros, you need to convert your final value to a string and use a formatting mask to append the leading zeros. This also assumes "00000" is valid. If it's not, test for it with an "if" and call GetDivBy5 again. So, to get a string with leading ze

    C# question lounge

  • How do I generate a number divisable by 5, and check it?
    M Michael A Cochran

    This would work as an alternative but the math approach is better (more performant) unless you want the final value to be a string. And, even then the math approach would be faster. (nnnn*10)=nnnn0 It's the same as appending a "0" to a four-digit number but it's much faster.

    C# question lounge

  • Beat the GPS
    M Michael A Cochran

    Say what? What are you guys drinking over there? (And can I have some?) :laugh: http://www.smartplanet.com/blog/transportation/half-of-uk-drivers-race-to-beat-their-gps/742?tag=nl.e550[^]

    The Lounge com question

  • Does the Internet make software developers lazy?
    M Michael A Cochran

    hehehe... I had to sign in just so I could plus 5 that one.

    The Lounge tutorial question career

  • Don't mess with Steve's desk!
    M Michael A Cochran

    Wow, lotta people seem to dislike pranking. I've been working from a home office for nearly 20 years now so I guess I'm out of touch. Seems like it's all in good fun to me. If someone trusts you enough to think they can prank you without you getting all upset with them, well, that's a friend I want to have. I say, prank 'em back! If you wrapped my office in blue towels, you'd find your mouse hot glued to your desktop one day soon after. (Removable glue of course!) So long as it doesn't get hurtful, spiteful, or dangerous, it just sounds like good office fun and comraderie to me. Humm, too bad I only know one guy named Steve and he's a couple thousand miles away.

    The Lounge javascript question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups