coding style discussion
#41
Posted 25 March 2011 - 02:33 PM
#42
Posted 25 March 2011 - 06:46 PM
Any thread titled "coding style discussion" is never going to get anywhere near Netduino or MFAlthough that is an interesting match, I think we're going off the real problems of Netduino and the MF.
And it's always going to be controversial.
Regards,
Mark
To be or not to be = 0xFF
Blogging about Netduino, .NET, STM8S and STM32 and generally waffling on about life
Follow @nevynuk on Twitter
#43
Posted 25 March 2011 - 07:35 PM
Doesn't that contradict your original statement Situations where it is absolutely required (there is no way to avoid it) ?That's correct -- so long as it has a proper implementation of Equals() and GetHashCode(), which turns out to be a quite a bit of typing. You have to be a bit of an expert just to get .Equals() right.
I agree with you that in complex libraries it is undesirable to have to write the additional code but there are very few compiler writers in the world. These forums are here to discuss Netduino and MF. One of the challenges with MF is that we are looking at a minimal environment. I believe that in this case it is crucial that the programmer takes control and that means understanding what is happening with their code. To me var hides too much and as such can lead inexperienced programmers into problems.
Standard disclaimer: All opinions here are mineIt would be interesting to hear your/your company's
As I mentioned earlier, there are few people working on really complex pieces of software. Most of are writing code processing data and throwing it around from one class to another or to a database and so the boiler plate code can be generated using a good set of macros and some minor modification to the generated code. I agree there are cases where this will not fit.take on this argument, as I would assume their interest is in minimizing the amount of code they need to test and maintain. i.e. why not let the compiler automatically supply these classes and their methods rather than put your programmers through all this busywork?
There are compilers out there which can trap this sort of stuff when working with generic C/C++.I'm pretty surprised, as this would open the door to uninitialized variable bugs in C/C++.
And if you see most of the code I work on there are few comments in these cases - only where it is not obvious. The code is the comment unless the algorithm/solution is tricky to understand.The desire to leave space for commenting does not strike me as particularly compelling, as there are lots of ways to format code which allow for copious commenting.
There is never a perfect solution and coding styles/rules vary from one organisation to another. My own style has changed over the years through my experience and also taking elements from the companies I have worked for. I have not always agreed with the house style but my job is to write code which they accept - I like putting food on the table.
There may come a day when var and I become good friends but these days I work in a programming world which is not as complex as those I used to work in and so to me it is not necessary at this time. I spend a lot of time these days with inexperienced programmers and to me it is more important to get them to understand what is happening with their code so that they can work with .NET 1.1 through to 4.0.
Regards,
Mark
To be or not to be = 0xFF
Blogging about Netduino, .NET, STM8S and STM32 and generally waffling on about life
Follow @nevynuk on Twitter
#44
Posted 30 March 2011 - 12:13 PM
The great Eric posted a good article about compound operators, that involves structures also.
http://blogs.msdn.co...t-part-one.aspx
Just on this thread, I guess, we have discussed about the use and misuse of "ref" that the only way to alter struct "by-reference".
The article touches also this kind of aspect, and the hypothetical syntax introduced by Corey:
Point p1 = new Point(1, 2); Point p2 = p1; p2.X = 5; //p2 changes, but p1 don't ref Point p3 = p1; p3.X = 10; //p3 mutes p1, because is an alias (reference)Good to know that is a limitation of C#, not CLR!
Maybe some day...
Cheers
#45
Posted 20 April 2011 - 06:29 PM
Eric The Great has just published an article on 'var': Uses and misuses of implicit typing.The great Eric posted a good article about compound operators, that involves structures also.
#46
Posted 20 April 2011 - 08:32 PM
Great article! Thanks for mentioning it.Eric The Great has just published an article on 'var':
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users