If your code has a lot of 'technical debt' it is probably not well written code, and thus arguing if well written code should be documented commented or not is irrelevant for that particular case. --- I agree with a lot of the philosophy you don't like... I have been anti-comment and pro var
for a long time. I believe comments should not say what (names are for that) or how (instructions are for that)... yet, I think comments that explain why and for what are good. At the end the motivation for having less comments is that comments are not checked, and could be forgotten in refactoring, and thus there is a risk that they will be outdated... sure, we can argue dicipline, yet we use strictly typed languages for a reason. Thus, instead we want to express what we would have said in comments in code. With that siad, I can tell you that using var
as an extension of a no-comments philosophy is retrograde. The idea is to make the code express as much as it can (so it is explicit, that is what they mean by well written code, please do not confuse with verbose), so that we do not have things to communicate in comments... from that point of view, var
is counterproductive. Let us be clear, var
is not dynamic typing. Yes, names can help with knowing the type※... yet, no, I am not advocating for hungarian notation either. So how can I be anti-comment and pro var
if they are at odds? I belive in the use of var
as a way to protect the code from reasons to change. Same goes for auto
. And yeah, I use it virtually everywhere. It eases refactoring (If I change the return type, using auto
avoids a maintenance ripple of updating types everywhere the code is used), thus increases maintainability. Addendum: You know what, I do realize it goes both ways, because if I did a poor job and returned something bad, auto will not complain. Although, I would expect it to break where we actually try to use the value. If the code follows the robustness principle ("Be conservative in what you send, be liberal in what you accept"), we will not be using auto
for the return type, instead the return type should be as specific as posible (without breaking encapsulation, if any). On the other hand, we want to assign the return value to a variable, and the return type is probably much more specific than you actually need in client code. In that situation we pro
Theraot
Posts
-
Modern C++ auto -
Do we, as developers, have a UI responsibility?One school of thought says that I should use the default format because the platform should take it from the OS preferences. In addition, if those are wrong, it is not my fault... right? Well, no. I should take the default date format as another external input, and as any external input, I should not trust it. Thus, I decided a while ago to use the one and only true date format standard: ISO 8601. For the date format that would be yyyy-MM-dd... ... Unless the client asks for something else, that is. They rarely do. Why may they ask for something different? Here are a few possible reasons: - The software needs to interact with a software made by third party that expect default date format. - The above can happen because of legal reasons. For instance, in my country there is a file format designed by the goverment that uses dd/MM/yyyy. At least it doesn't use two digits for the year. - The client wants a date forma that the date to spell out the month name. Translating those is another issue, so at this point I will probably be using a library that supports this, instead of the default format functions.
-
Microsoft - Please Bring Order to the Chaos that is Client-Side Web Development!!There has been a series of solutions for .NET on the web, those include the infamous Silverlight[^]/Moonlight[^], Unity Web Player[^], JSIL: .NET to Javascript compilation[^], and even an implementation of WPF for JavaScript[^] based on that. What stops JSIL is porting .NET to javascript, if I remember correctly threading and multimedia were particulary problematic - that only bothers you if you want to run .NET apps on JavaScript without modification. The current maintainer said they need funding. Regardless, the implementation is good enough for many solutions, including some games, such as their platforming demo[^]. you try the compilation online in their test page[^]. There was also effort put into running .NET on NaCl. Which is what Bastion used to run on the browser, see How Bastion Can Run in a Web Browser with Google's Native Client - Tested[^].
-
What the NaN?It is not just a C#, it is IEEE 754 And this is how you represented:
7ff0 0000 0000 000016 = Infinity
fff0 0000 0000 000016 = −Infinity
7fff ffff ffff ffff16 = NaNThose first 12 bits correspond to the sign and exponent, and the values 7ff and fff are reserved constants with special meaning. Why? I don't freaking know, I didn't invent IEEE 754. But anywhere you find double it is like that because it is standard, and it is even implemented in the CPU. It is very easy to show it is not C#, see this JSFiddle[^]. Does it make mathematical sense? No. A number system that has a representation for not-a-number makes no sense. --- Although I can argue that a number system with 1/0 = Infinity is possible, it would be a two-point compactification[^] of the real numbers to include -Infinity and Infinity*. Another system with 1/0 = Infinity is the Rieammn Sphere**, but that number system has only one Infinity and include the complex numbers. *: To be clear, that means that you create a topological space where the infinite number line is embedded by a projection in a finite segment. Then the points at the extremes of the segment can't ever be reached, there is no real number low or high enough to reach those points. Then you label then "-Infinity" on the negative side and "Infinity" on the positive side. Clearly those points aren't real numbers, and they break traditional algebra, but they are numbers. Why would you want them? I don't know. **: But I know for the Riemman Spehre, you can extend the real numbers to add the complex infinity point. This is embedding the complex plane in the surface of a unit sphere, such that the opposite point from 0 is never reached by any complex number. Then you label that point "Complex Infinity". Then you go to say that 1/0 = Complex Infinity, and 1 / Complex Infinity = 0 - now you can divide by infinity and solve integrations the old way. Yet, it also breaks algebra. Of course, this is problematic, and mathematicians left the idea in favor of Limits. The modern well-behaved solution (that doesn’t break algebra) is Hyperreals.
-
Connectivity testIf the only solution is to check for a web, check for internic.net if internic.net fails then it is as good as the end of the (internet) world. I have made a web search to the subject and there are examples taking the same approach you describe. Sure there are APIs to test for network connection. Then again what exactly do we call Internet? (in particular with ACTA around the corner). It may be better idea to identify the ISP server address and check for that, then again there is the risk of a broken suboceanic cable or a satelite failure... although I understand that USA will probably not notice that, I'm not in USA. You could check for some national, institutional .gov website, until it got attacked with denial of service. By the way, will that software work properly in china or under other government firewall that decides that google is no good? Allow be to doubt it (there is always the risk that another party will use that name, and "poison" the DNS... may be on government's behalf). Talking about DNS, you could have a host files, or local DNS server that says that google is localhost, and the same goes for internic.net. Which is good, because you may want to mock Internet for testing (and survive the so claimed Maya's predictions). The best solution is not to test for Internet, but test for what you need on Internet, for example microsoft products will check for microsoft.com, not because their developers think microsoft.com is the Internet, but because it is the part of the Internet they need to work. For the case of P2P or similar solutions don't even test, let the connection fail.
-
You Know You're a Web Developer When...Charles S. Sandler is an unique child, his parents always told him he had to select a girl with class, but girls always throws him out from their eviroment and memory. C.S.S though they had too much constraints... soon decided to refresh and upgrade his style and resources. He put his life time span to get cachet, select the right girl from the group by having constraints of his own. It was an unsafe method to isolate him self, until his friend Sam Q. Langley told him that style was about the interface and not the implementation. S.Q.L is correct, Charles soon learned to be more dynamic, more semantic, and open to the public, this commited him to new enviroments, to meet new people. Lastly he met Paula h. Page, an feature rich woman who gave him the right implementation to his type, she seems to have magic methods to make him happy. Now they are married, Charles will query her to name his first inheritor Wiki.
-
How come I get a rounded number when I multiply doubles?? [modified]According to ECMA-334 9.4.4.3 Real literals Paragraph 2: "If no real-type-suffix is specified, the type of the real literal is double."* *: in ECMA-334 9.4.4.3 a grammar form that excludes any number without a real-type-suffix or decimal-digits after the dot to be a real literal. If you are on a non ECMA compilant implementation of C#, move to another compiler/interpreter.
-
32 bit IDE, 64 bit OS..,Sorry, it seems to be
singleton
. -
Where Is IntelliSense For "goto" statements?That was a good point, and that's why we use pokémon error handling: to put a limit to that who knows where. The gotta catch'all approach is good when calling third party code in particular when it has the potential to be wrote letter by who knows who. By the way, I browsed my more relevant solution for an use of goto, and found only one, and I'm proud of it:
\[DebuggerNonUserCode()\] private static int Sqrt(int number) { //Newton's method aproximation for positive integers //if (n == 0) return 0; int x, \_x = number >> 1; back: x = (\_x + number / \_x) >> 1; if (x <= \_x) return \_x; \_x = x; goto back; }
I did my best at that time to increase performance of that code without going to a non-portable solution. I wonder if anybody will find a better way to write it.
-
Where were you when humans first landed on the Moon?Gregory.Gadow wrote:
If you weren't born yet, you can just move along
Thnak you, you made feel young again.
-
C is better !!!!C better?, sometimes I have to admit, but with no standard way to clear the console / terminal and no standard way to set the cursor position in that console / terminal, and no standard windows / frames API... I can only find place for C or C++ to make libs for calculations, libs for real time operations and for video games (with OpenGL). Making enterprise solution? I would rahter go standard and portable with Mono / .NET and C# 2.0. Not that you can't in C, just saying that my opinion is that C# is better, I think people will also say Java, well, I prefer C# over Java, but again, it's my opinion.
-
Ice dancing / figure skating is not sportRyanEK wrote:
I believe a sport is where two or more people are in competition
Yeah, I like warcraft, unreal tournament, and even mario kart! now, those are nice sports, don't you agree? Ah, and I did like that on the judges, now I can talk about football (soccer), in fact between more judges a game requires the less you can trust it, why do they need the judges otherwise?. And style points? what's that?!? my life is free from anything with style points. I often find hard to tell if something is art, sport, game or just a kill-time. But for game and kill-time there are more formal definitions, as the in game it has two or more people and one wins at the end. In the kill-time, it's wathever you do alone for your joy... I think :rolleyes:. Ahem... So most sports are games, but are games sports? Now, what about chess, they say it's a sport, isn't it?
-
My problem with infinityIt's Cantor work. If you have a casino roulette and you divide it to all the real numnbers in [0, 1), that is from 0 to 1 not including 1. Then the probability of getting any given number in this roulette is 0. that is: 1/infinity = 0 (By extension, any number divided by infinity is 0, Cantor, was the first to use it outside a Limit). So, one can say, "hey if go ahead and clear it for infinity then I get: infinity = 1/0". Sadly, it's not defined (undefined) in real numbers, but it's currentrly accepted that 1/0 = infinity in riemman sphere (that is complex numbers plus infinity) So today saying that 1/0 is undefined (in the reals) is like saying that 5 - 9 is undefined (in the naturals). http://www.wolframalpha.com/input/?i=1/0[^] http://mathworld.wolfram.com/DivisionbyZero.html[^] And yes infinity is a number, it's a number defined as the quantity of natural numbers, and it's the first transfinite number. By the way, I didn't understand that of the clock ;P . But I can tell that zeno's paradox doesn't give me bad dreams. Of course it resembles quantum theory, if something gives me headache is quantum gravitation, but that's another tale. ---------------- Beyond the scope of the conversation (ie. ignore if you don't undestand a bit) To save some of the load of the lounge... I wrote more in my member's blog... here the permalink: http://www.codeproject.com/Messages/3322477/Infinity-and-paradox.aspx There I wrote there a paradox, I don't know the name of that paradox, or where in Internet (other than there) I can get a cite to it? I got it in a book, I don't recall the name, and I was unable to find it... so I wrote it down there. Theraot