|
Elegance is my #1 goal, but it doesn't correspond precisely with any of the items on the list.
I'm not interested in readable code if it's not elegant. Contrast with brute force methods which are very easy to understand, and possibly are bug-free as well. But they are not elegant.
Elegance almost always brings maintainablity, extensibility, readability, and speed, but these are side-effects, not the goal.
|
|
|
|
|
What exactly are you meaning by elegant?
|
|
|
|
|
>What exactly are you meaning by elegant?
Hard to describe exactly, but it's the opposite of 'clumsy', or 'quick and dirty'.
It's code where anyone that reads it will look at it and say 'nice!' There's something intellectually satisfying about elegant code. It achieves a lot in a few lines of code.
How much of my code is actually like that? Not much. But it's still the goal. Every time I refactor my code, I'm trying it make it more elegant.
|
|
|
|
|
yeah .. bug free then elegant is my style too, so no shame to the customer .. right ?
Hell demands contribution and Prime will deliver it
Not bad eh ....
<marquee scrollamount="2" scrolldelay="50" align="middle" behavior="alternate">-=[ Prime ]=-
|
|
|
|
|
It seems a bit odd that a goal which is almost universally regarded as being practically impossible for non-trival applications (Writing Bug-Free Code - currently at 27.05%) is number two on this survey.
Shoot for the sky, I suppose...
Charlie
if(!curlies){ return; }
|
|
|
|
|
I can write bug free code!
Sub New()
End
Exit Sub
Aaron Eldreth
TheCollective4.com
My Articles
While much is too strange to be believed,
Nothing is too strange to have happened.
- T. Hardy
|
|
|
|
|
Yep. That certainly qualifies as non-trivial.
Charlie
if(!curlies){ return; }
|
|
|
|
|
Hm, it won't compile in MSVC++ 6.0
|
|
|
|
|
By the way, your signature produces bug-free code but I think it's more maintainable this way:
if (!curlies)
return;
Regards,
Alvaro
Give a man a fish, he owes you one fish. Teach a man to fish, you give up your monopoly on fisheries.
|
|
|
|
|
I opted for extensibility in this case. I spent two extra keystrokes on the infrastructure so it'd be easier to add statements later.
Charlie
if(!curlies){ return; }
|
|
|
|
|
Yes, but anyway you'll have to then change your code to:
if(!curlies)
{
...
return;
}
Unless you want to keep it all in one line. And that was my main point, from a debugging stand-point (maintainability), it's better to put if statements in 2 or more lines... although I think some of today's debuggers highlight the instruction to be executed rather than just the line they're on.
Also, I like the space between the if and the opening parenthesis since it helps to distinguish it from a regular method (for better maintainability).
Regards,
Alvaro
Give a man a fish, he owes you one fish. Teach a man to fish, you give up your monopoly on fisheries.
|
|
|
|
|
It needs to work, therefore be bug free. Number two it needs to be easy to maintain and read in case it is ever useful or used by someone else.
Those are my points and my reasons for my choice.
C++ - Pure, Simple, Makes Sense.
C# - Microsoft's idea of Pure and Simple
|
|
|
|
|
Bugs are a thing that is very common when writing code, so I think number two is indeed the best option to choose first. If your code is easily maintained, you can fix the bugs fast and optimize it easily too.
"Every rule in a world of bits and bytes can be bend or eventually be broken"
|
|
|
|
|
Not only that, it will also be easily extended. And - in response to user feedback - it stands a chance of being a usable piece of software sooner or later
|
|
|
|
|
diilbert wrote:
It needs to work, therefore be bug free.
Experience has taught me, that working software and bug free software aren't the same thing. Bug free real-world software is impossible, unless you have a rather narrow definition of what a bug is.
Michael
CP Blog [^]
|
|
|
|
|
I suppose there will never be a bug free product. It just depends on how you look at it. I look at bugs as something an average user will come across when using the software. If the average user finds a problem the software is not working the way it should.
C++ - Pure, Simple, Makes Sense.
C# - Microsoft's idea of Pure and Simple
|
|
|
|
|
diilbert wrote:
C++ - Pure, Simple, Makes Sense.
C# - Microsoft's idea of Pure and Simple
I like your signature, but in all fairness, C++ is not exactly pure, and is anything but simple.
|
|
|
|
|
Nemanja Trifunovic wrote:
C++ is not exactly pure
class C {
C operator++(int) = 0;
}; How about now?
Software Zen: delete this;
|
|
|
|
|
Definitely not simple.
Regards,
Alvaro
Give a man a fish, he owes you one fish. Teach a man to fish, you give up your monopoly on fisheries.
|
|
|
|
|
Pure: free from what vitiates, weakens, or pollutes
Simple: free of secondary complications
Sense: implies a reliable ability to judge and decide with soundness, prudence, and intelligence
Makes sense to me anyway
C++ - Pure, Simple, Makes Sense.
C# - Microsoft's idea of Pure and Simple
|
|
|
|
|
It all comes down to the fact that I hate writing C#, and do only when I have to.
C++ - Pure, Simple, Makes Sense.
C# - Microsoft's idea of Pure and Simple
|
|
|
|
|
Why do you hate writing C#?
If it's because you still love C++, I have to tell you that I don't miss it much. I don't miss the pointer/reference notation (->, *, **, &, &*), or dealing with character strings, or double-wide character strings, or BSTRs, or header files, or _tcslen, or push_back, or memory leaks, or not being able to initialize member variables where they're declared, or not being able to invoke a constructor from another constructor of the same class.
What I do miss are templates (a lot), multiple implementation inheritance (a little), and default parameters (sometimes). But templates (known as generics) are coming in .NET 2.0 and they'll fill in the void for most cases.
Regards,
Alvaro
Give a man a fish, he owes you one fish. Teach a man to fish, you give up your monopoly on fisheries.
|
|
|
|
|
Alvaro Mendez wrote:
What I do miss are templates (a lot), multiple implementation inheritance (a little), and default parameters (sometimes).
I miss all of these, but most of all I miss RAII[^]. And keyword using is not filling the void.
|
|
|
|
|
Nemanja Trifunovic wrote:
And keyword using is not filling the void.
Really? It fills the void quite nicely for me.
You implement IDisposable, put your cleanup code inside the Dispose method, and let using write all the try/finally code for you. It's probably as close as you can get to RAII in a garbage collected language. I use it extensively, especially for things like showing a wait cursor:
using (Cursor.Current = Cursors.WaitCursor)
{
}
Regards,
Alvaro
Give a man a fish, he owes you one fish. Teach a man to fish, you give up your monopoly on fisheries.
|
|
|
|
|
The answer depends on the "mission-criticalness" of the project. MS can get by with still having bugs when the software is released. NASA, Boeing, or some place like that can not because someone's lives could depend on the successful execution of the code. They do not get to release "service packs" that make everything ok.
|
|
|
|