« A Simple Calculator | ^ Main | Buntel Bounces »
SimpleCalculator.exe (Pre-Pre-Pre-Alpha)
Ok. I got started on the calculator and I must say, again, Visual Studio is the best IDE I’ve worked with. It is thoroughly amazing in more than 1 way. Cody B. has always said it is the benchmark for IDE’s and I must publicly agree with him. I wish I had something this smooth for ColdFusion…heck, AS while I’m at it. :-) Let me detail a few things about the app dev so far.
- When editing the Form (the visual elements) the code is automatically updated. If you change a button name to Blah from Eek all of your code is instantly changed as well. How sweet is that?
- Not only can you reposition groups of elements but you can resize them all while keeping them in the same position. This freaked me out and made my heart race into oblivion. I truly thought this was going to be the normal pain of realigning everything after resizing them.
- How about renaming the app form the default Form1 to…oh…how about SimpleCalculator? Ok. This could be a pain since there are about 4 or 5 files named Form1 already. I commence to change the name, hit enter….WHAT? All of my related (Form1) files are updated to SimpleCalculator! Wait! My classes are too! WHOA! :-)
Those are just a few of the things I am really loving about this IDE. There aren’t really any major “Wow” factors for C# on this post though. The app currently does nothing but clear the expression and append 1 or 5 (pending button clicked) to the exppression. Although there isn’t much done, other than setup, I have hit my first bug. :-)
When the app loads I initialize the text field to 0, normal operation for a calculator. After doing so we await button clicks. If you hit one it sets
expression.Text += 1;
That’s all well and good but you end up with 01 instead of 1. I am a HUGE stickler for nixing the repetitive if/else blocks from my code. I didn’t want to do a common function all of the number button event listeners would call before handling their action because…well…I know how to do that and it is sort of a hack. I’d rather have one method for all number buttons to call after being clicked. Once the event fires this expression would determine to either append to the expression value or make the expression equal the number clicked.
I’m absolutely fresh on learning the whole event system in C# but once I learn it I’m sure I’ll be able to work out something dynamic.
We’re looking to launch the SimpleCalculator in the 2nd Quarter for roughly $1. Please preorder by commenting to this entry. :-) Just kddin’…unless you want to buy it. ;-)
Posted by John C. Bland II on February 8, 2006 10:55 PM | Permalink
TrackBack
TrackBack URL for this entry:
http://mt.katapultmedia.com/mt-tb.cgi/23
Comments
I told you that IDE was the best. ;-)
As for your calculator, I would make a single method that each button passes a number to and that method does all the heavy lifting. No sense tying all the events up.
There are two ways you could go about this. The first would be to make a private method and then in the event handler for each of the buttons, just pass off the argument (easiest), or make your own event handler that is really the method that is going to be doing the lifting and assigne each button to that event handler so you would have 10 buttons (0-9) tied to a single event handler and then just grab the number from the Text property of the button.
Just some ideas.
Posted by: Cody | February 9, 2006 7:56 AM
Yeah, the second one (one event handler) is what I was looking to accomplish. I need to figure out a few things about event handling in C# before I’m comfortable with it. Namely, what is included in the EventArgs and the sender object?
Once I get the answers to those I can dynamicize (new word; not even on wikipedia) some of this. :-)
Posted by: John C. Bland II | February 9, 2006 4:24 PM



