|
Greetings. This is the first time I've ever posted here, so I supposed introductions are in order. The name is SawmillTurtle. Sawmill because I used to live on a street with that name, and Turtle because my friends used to say I look like Franklin the Turtle. I don't see the resemblance, but it makes for a good screen name.
For the past few months, I've been writing a program in C# for my landlord that keeps track of her rental properties, accounting and maintenance issues. It's an all-in-one kind of thing. I've been using SharpDevelop because of my intense hatred for any and all things Microsoft. I actively avoid using anything they make, so that means I don't use Visual Studio. A good alternative, some say, would be MonoDevelop but Microsoft owns that, too.
Up until I started on this project, I'd only tinkered with C# while playing with Unity. My IDE of choice was Game Maker because of the ease of use and the speed at which a program can be written using it. You can go ahead and laugh. It's funny. Game Maker is a good tool for learning programming concepts, but once you have it down it is really best to leave it behind you. I thought I could take everything that GM taught me and use it when I made the transition to C#.
Keep laughing. It's still pretty funny.
What I thought I knew going into this project and what I actually knew are two very different things. I've learned so much over the past few months. Looking back at the early sections of the code is like looking at a car with square wheels. Looking over it, I keep going, "Now why did I do that" and "What in the world was I thinking". One of my biggest mistakes-- and I just figured this one out yesterday-- was creating classes and then creating separate forms for those classes. It never occurred to me to make them one and the same.
Take this, for instance:
public void edit(BindingList h)
{
saved=false;
int i=-1;
HouseholdForm editHousehold;
editHousehold=new HouseholdForm(members,householdName,account,
rentOverride,overrideAmount,
dueDate,gracePeriod,penaltyAmount,penaltyDate);
foreach(HouseHold house in h)
if (house.householdName==householdName)
i=h.IndexOf(house);
editHousehold.setHouseholdList(i);
editHousehold.ShowDialog();
if(editHousehold.saveMe)
{
//members.Clear();
members=editHousehold.listOfMembers;
householdName=editHousehold.householdName;
rentOverride=editHousehold.overridedefaultRent;
overrideAmount=editHousehold.oRideAmount;
dueDate=editHousehold.dueDate;
penaltyDate=editHousehold.penaltyDate;
gracePeriod=editHousehold.gracePeriod;
//memberList=editHousehold.members;
saved=true;
}
}
What you are looking at is part of the "Household" class. What this does is take all the necessary variables and pass them as arguments to HouseholdForm. If the user clicks the "Save" button, it passes back "saveMe" as true, which makes the class retrieve the edited values from the form. Then it switches its own "saved" flag, which MainForm uses to determine if it needs to update something.
Do you see how stupid that is?
Would it not have been easier to build the "Household" class as PART of "HouseholdForm"? Then I wouldn't have had to pass a bunch of variables and then retrieve them. Chalk that one up to inexperience. I'm planning a major overhaul where I correct this error, but that is going to be a tedious process. Since the program is functional-- albeit sloppy-- the way it is, my priority is getting my landlord the program she's been waiting for. The first update will include the cleaned up code.
Going into this, I had no idea what I was getting myself into. I've had to ask Google a LOT of questions, and most of those have pointed me to Stack Overflow. There have been days I've wanted to rip my hair out, and there have been days where I've had a lot of fun. Today was NOT one of the fun ones. I spent the better part of three hours trying to eliminate a bug that didn't seem to exist at the first, second, third... and hundredth glance.
I found it here, in this section of code:
foreach(bool paid in h.account.payment)
{
int ind=h.account.payment.IndexOf(paid);
double amount=h.account.amountOf[ind];
if (paid)
{
switch(h.account.typeOf[ind])
See, I was creating a DataGridView that displays all households that owe rent. The "HouseHolds" class has a class called "Account", which has several Binding Lists. Like this:
public BindingList<datetime> dateOf=new BindingList<datetime>();
public BindingList<double> amountOf=new BindingList<double>();
public BindingList<string> description=new BindingList<string>();
public BindingList<string> displayName=new BindingList<string>();
public BindingList<bool> payment=new BindingList<bool>();
These lists are all created, edited or erased at the same time. The "payment" Binding List is used to determine is someone OWES rent or is PAYING rent. So in the Switch statement at the top, I was using IndexOf and passing the number. It kept double or triple charging things. Sometimes it wouldn't charge them at all. I figured out that using IndexOf this way was wrong, because it was looking for the first Boolean value that it found in "amountOf" that matched what it received from "payment". Obviously, not a good idea. At one point, the program reported a household as owing over 1800 dollars in back rent. Oops.
So it's been an interesting journey. I think after I finish this, I'm going to try my hand at MonoGame. Eventually I'd like to work my way up to Unity. Maybe next time I'll actually be able to use it without having it go haywire.
First, though, I really need to figure out what casting is, because I have no idea what people are talking about when they mention that.
Thanks for listening.
Hope to talk to all of you very soon.
-Turtle
|
|
|
|
|
If you hate all things microsoft then why are you using C#?
|
|
|
|
|
... and Windows?
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
I can answer both questions at the same time:
My preferred operating system is Linux. Ubuntu, as a matter of fact.
However, she wants me to write a computer program, and it has to run on her OS of choice.
Trust me, if I had a choice, this computer would be wiped and Linux would be on it. Since it belongs to her, I'm stuck with it.
And if I'm writing a program that runs on Windows, what else would I use? I suppose I could use Visual Basic or Visual C++ but-- surprise! -- both Microsoft products.
|
|
|
|
|
SawmillTurtle wrote: Visual C++
There's still some options:
- Java
- C++ (Qt as framework, for example)
Just saying
I only have a signature in order to let @DalekDave follow my posts.
|
|
|
|
|
SawmillTurtle wrote: And if I'm writing a program that runs on Windows, what else would I use?
I'd suggest Python. You can code it on Ubuntu and use Tk or similar for the UI.
Latest Article - A Concise Overview of Threads
Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny
Artificial intelligence is the only remedy for natural stupidity. - CDP1802
|
|
|
|
|
Blind, ignorant hatred is stupid; it leads to extremism.
And your "intense hatred for any and all things Microsoft" is extreme already: it has blinded you to the best IDE on the planet, bar none: Visual Studio. In all seriousness, it is extremely good.
And C#: that's a Microsoft product as well. And so is .NET, which C# is reliant on. And Windows, on which .NET runs. And SharpDevleop, which runs on Windows only.
And to be brutally honest, if you have got up to DataGridViews, BindingLists, and Generics - but you have no idea what "casting" is then you need to go right back to the beginning and learn C# properly this time!
I suspect it would save you a lot of time in the future ...
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
My dislike of Microsoft comes from many years of opposing their policy of "Do their thinking for them. Microsoft knows best." It's not blind hatred. It's a lifetime of being told that I'm not smart enough. Take the Firewall in Windows 10. I use my own firewall most of the time, but for the longest time (not sure if it still does it anymore), if you turned it off, Windows would remind you that if you leave it off too long "we'll turn it back on for you."
Excuse me? I don't want other people doing my thinking for me. I'm capable of setting up my own firewall. I can even tie my own shoes and I can brush my own teeth, too. Know what I mean?
As for casting, did I really miss something that was such a monumental foundation stone? Oh dear. Guess I'll need to do some more Googling and figure out how I could make my life easier.
Thanks for the advice.
|
|
|
|
|
As a former UNIX developer, I have to agree with Griff - VS is wonderful, C# is a damned fine language and SQL Server is as good as, if not better than any other RDBMS out there.
.NET is a steep learning curve, a lot of what seems odd or irrational at first makes perfect sense when you get deeper into the platform.
Whenever you find yourself on the side of the majority, it is time to pause and reflect. - Mark Twain
|
|
|
|
|
PeejayAdams wrote: C# is a damned fine language It is, yet it has some "features" that make me want to stick with C++.
Mostly I dislike the impossibility of separating function definitions and declaration in different files (like header and cpp). I use the header as index into the cpp and I really find C# messier in that regard.
Second thing I don't like is the difficulty of casting between basic data types: I may want to load a byte stream, read some header and decide to treat the content as a short int stream. Easy to do in C/C++, not that much in C# without using the unsafe block - I don't really like it as it puts a nice hole in the reason I'm using C# in the first place.
Third thing, it makes the usage of the native resources harder instead of simpler - that is not a problem except that my line of work requires native resources so C# actually hinders me more often than not.
PeejayAdams wrote: .NET is a steep learning curve, I agree, it is much much steeper than Windows API... especially considering the utter crappy quality of documentation.
I don't need a list of the members of a class, I need to know what it's supposed to do, what problems does it solve and how it is meant to be used/integrated in the code: is it to be instanced? Is it to be extended? Shall I use its children instead of it? How does it differ from a similarly named class in another Microsoft namespace and how can they work together, if they can?
All of this is missing from most of the framework documentation, leaving beginners with dozens of chunks of unrelated knowledge, there is no sense of unity, it is a disruption of the Force.
GCS d--(d+) s-/++ a C++++ U+++ P- L+@ E-- W++ N+ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- r+++ y+++* Weapons extension: ma- k++ F+2 X
|
|
|
|
|
I certainly agree that the documentation is about as much use as a chocolate fire-guard.
You always know you're really struggling when you have to resort to the MS docs!
Whenever you find yourself on the side of the majority, it is time to pause and reflect. - Mark Twain
|
|
|
|
|
And yet Win32 and CRT (older versions are increasingly better) documentation is as fine as it can be, to the point that when looking for documentation on CRT functions I very much refer to MSDN because of its overall better quality.
I think .NET has not been thought out properly and pushed out into production before it was ready. That's the reason of the many conflicting classes and namespaces, half baked hierachies and it lead to a dreadful documentation: how can anyone document something that is held together by duct tape, spit and faith?
GCS d--(d+) s-/++ a C++++ U+++ P- L+@ E-- W++ N+ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- r+++ y+++* Weapons extension: ma- k++ F+2 X
|
|
|
|
|
Not a problem here, I just ask Siri!
If you can keep your head while those about you are losing theirs, perhaps you don't understand the situation.
|
|
|
|
|
The documentation is reference documentation, not tutorials. For the latter you have to go elsewhere.
|
|
|
|
|
Windows API documentation does a much better job of explaining what has to be done. Therefore it is not a problem in the concept of documentation nor a MS design choice, it is simply crappy documentation.
Tutorials are dreadful, they are "how to do X: step A, step B, step C". Good, but if I need to do X' I'm screwed, because I still don't have the knowledge on how the system is supposed to work and how the pieces I am given interact between each other. With a tutorial I have a recipe that I can blindly follow and no more. I hate tutorials.
Besides, it is the producer's duty to explain how to use its product - when you buy a home appliance you have a manual explaining you how to use the product, you're not requested to find a tutorial written by a third party (which can be grossly wrong with no repercussions, by the way).
GCS d--(d+) s-/++ a C++++ U+++ P- L+@ E-- W++ N+ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- r+++ y+++* Weapons extension: ma- k++ F+2 X
|
|
|
|
|
And, of course, anyone and everyone is free to post their useless tutorials on the internet.
|
|
|
|
|
I appreciate that but when you come across an ambiguously named property, you really need something more useful than "X has a property called SomethingWhichCouldMeanSeveralDifferentThings" - Intellisense has already told us that.
Whenever you find yourself on the side of the majority, it is time to pause and reflect. - Mark Twain
|
|
|
|
|
True, but I think that is the exception rather than the default.
|
|
|
|
|
den2k88 wrote: Mostly I dislike the impossibility of separating function definitions and declaration in different files (like header and cpp). ... and to me, that is one of the essential improvements . I grew up with database normalization (and as normalization grew up - my first database course was on CODASYL bases, not relalational ), so it is in my genes: Don't represent the same information in two places - that is bound to one day lead to inconsistencies.
Quote: Second thing I don't like is the difficulty of casting between basic data types: I may want to load a byte stream, read some header and decide to treat the content as a short int stream. Again, to me a stricter type system is an improvement. C things like "while (1)" makes me shiver. This "implicit casting" (or rather: lack of type checking) is the source of a lot of bugs and problems.
|
|
|
|
|
den2k88 wrote: Mostly I dislike the impossibility of separating function definitions and declaration in different files (like header and cpp). I use the header as index into the cpp and I really find C# messier in that regard.
There's a class browser that lets you view all properties and functions of a given class, without showing the actual implementation, if that's all you're really after. There's also a dropdown at the top of the screen that's very similar. IMO, if you need a separate file as an "index" into the class, as you put it, then it's high time to refactor the class into something simpler.
I've done C++ for well over a decade before committing to C#, and I've never looked back. I don't miss headers at all. IMO headers just make you duplicate work that you can leave to the compiler to figure out.
|
|
|
|
|
SawmillTurtle wrote: My dislike of Microsoft comes from many years of opposing their policy So, blind hatred then.
I have used Microsoft products for years and it has always been my free choice. And they have never done my thinking for me; they offer options which I can accept or reject.
|
|
|
|
|
SawmillTurtle wrote: Do their thinking for them. Microsoft knows best. I find that interesting. They are the most open major software vendor. I've made a good career out of using their tools to make their own products much better. I feel like they give me more freedom than any other vendor. You have much fewer choices using apple than you do using Microsoft.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
Quote: You have much fewer choices using apple than you do using Microsoft
I'll give you that. Apple is one of the most dominating, controlling and unreasonable companies I've ever seen. You're going to spend, what, upwards of a thousand dollars (for the sake of brevity, let's say 1200) on an iPhone, yet Apple is going to tell you what you can and can't do with it? Can't download. Can't install unapproved software. Can't do this. Can't do that. And if you try to jailbreak it to open up your options, you risk bricking it and turning it into a 1200 dollar paperweight.
If I pay 1200 dollars on something, who are you to tell me what I can and can't do with it? For 1200 dollars, it had better be able to perform oo-mox on me while simultaneously pouring me shots of Kanar and singing "Bohemian Rhapsody" in Klingon (or any other language in which I order it to sing).
Apple is definitely the greater of the two evils.
|
|
|
|
|
SawmillTurtle wrote: who are you to tell me what I can and can't do with it? That actually does not bother me. It is their product, I think they should be able to make it be however they want.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
SawmillTurtle wrote: Take the Firewall in Windows 10. I use my own firewall most of the time, but for the longest time (not sure if it still does it anymore), if you turned it off, Windows would remind you that if you leave it off too long "we'll turn it back on for you."
Then use the tools for the big boys. They're called group policies.
Windows tries its best to protect users from themselves--remember, there's no worst threat to a computer's security than its users, and Windows is written for the unwashed masses. Remember what Windows was like before a default firewall was added to XP SP2. And remember what prompted the addition of a firewall.
|
|
|
|
|