|
No, i didn't.. Sad but true
I've translated names and wrote the few comments...
¿Eres tu John Wayne? ¿O soy yo?
modified on Wednesday, June 8, 2011 12:59 PM
|
|
|
|
|
And I thought I was bad with comments... wow!
|
|
|
|
|
comments is the least of this codes problems.
|
|
|
|
|
D'oh! My Usual comments are not like this -_-'... Those were fast ones just for this post
¿Eres tu John Wayne? ¿O soy yo?
|
|
|
|
|
Wow this is very nice code.
I´ll zeropad it to fixed line length copy an inversion of it to the front, rotate counterclockwise 90 degrees, apply a color index substitution. Et voila, we´ve got a sprite for a space invaders clone.
|
|
|
|
|
I just went in to fix a compatibility issue in some code and ran into this beautiful 27 lines long list of variables set to an empty string. Then the code has a loop going through the provided data, which has a list of if statements in it, of which you can probably guess the length. All but 5 or so of these ifs have duplicate code. After the loop all these variables are passed to a constructor, which holds another nice long list of if statements...
Code: http://pastebin.com/uz3uMy0g[^]
It's GPL v2, so do feel free to use it!
|
|
|
|
|
... art... it's art...
<br />
public function SMWBibTeXEntry( <br />
$type, <br />
$address, <br />
$annote, <br />
$author, <br />
$booktitle, <br />
$chapter, <br />
$crossref, <br />
$doi, <br />
$edition, <br />
$editor, <br />
$eprint, <br />
$howpublished, <br />
$institution, <br />
$journal, <br />
$key, <br />
$month, <br />
$note, <br />
$number, <br />
$organization, <br />
$pages, <br />
$publisher, <br />
$school, <br />
$series, <br />
$title, <br />
$url, <br />
$volume, <br />
$year ) {<br />
<br />
if ( $type ) <br />
$this->bibTeXtype = ucfirst( $type ); <br />
else <br />
$this->bibTeXtype = 'Book';<br />
<br />
$fields = array();<br />
<br />
if ( $address ) $fields['address'] = $address;<br />
if ( $annote ) $fields['annote'] = $annote;<br />
if ( $author ) $fields['author'] = $author;<br />
if ( $booktitle ) $fields['booktitle'] = $booktitle;<br />
if ( $chapter ) $fields['chapter'] = $chapter;<br />
if ( $crossref ) $fields['crossref'] = $crossref;<br />
if ( $doi ) $fields['doi'] = $doi;<br />
if ( $edition ) $fields['edition'] = $edition;<br />
if ( $editor ) $fields['editor'] = $editor;<br />
if ( $eprint ) $fields['eprint'] = $eprint;<br />
if ( $howpublished ) $fields['howpublished'] = $howpublished;<br />
if ( $institution ) $fields['institution'] = $institution;<br />
if ( $journal ) $fields['journal'] = $journal;<br />
if ( $key ) $fields['key'] = $key;<br />
if ( $month ) $fields['month'] = $month;<br />
if ( $note ) $fields['note'] = $note;<br />
if ( $number ) $fields['number'] = $number;<br />
if ( $organization ) $fields['organization'] = $organization;<br />
if ( $pages ) $fields['pages'] = $pages;<br />
if ( $publisher ) $fields['publisher'] = $publisher;<br />
if ( $school ) $fields['school'] = $school;<br />
if ( $series ) $fields['series'] = $series;<br />
if ( $title ) $fields['title'] = $title;<br />
if ( $url ) $fields['url'] = $url;<br />
if ( $volume ) $fields['volume'] = $volume;<br />
if ( $year ) $fields['year'] = $year;<br />
<br />
[...]<br />
<br />
jep... it is...
(yes|no|maybe)*
|
|
|
|
|
Ohh that makes my brain hurt. He uses arrays but cant pass an array. Either the language limits passing arrays or he is a moron. Let me just assume the answer to that and we will move on
Brad Barnhill
|
|
|
|
|
See this piece of code:
class Person
{
private string name;
private string sname;
public Person(string argName, string argSName)
{
name = argName;
sname = argSName;
}
public string getName()
{
return name;
}
public string getSName()
{
return sname;
}
public override string ToString()
{
return name + " " + sname;
}
}
Now consider these few facts:
- the code is in C#, not Java
- in case you haven't noticed, this code violates some basic good-style C# coding guidelines
- the person who wrote this code teaches C# programming at university
- this piece of code was given to his students as a do-it-like-this example
- he never, ever uses properties (Java-style getXXX() and setXXX() methods seem to be good enough for him...)
- he sometimes names his classes and methods in Czech using diactitics (yes, it compiles fine since VS is Unicode-based, but... WTF?)
- And more!
|
|
|
|
|
Kubajzz wrote: - in case you haven't noticed, this code violates some basic good-style C# coding guidelines
I haven't noticed. Can you provide an explanation with an example? Thanks.
Chris Meech
I am Canadian. [heard in a local bar]
In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]
posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]
|
|
|
|
|
Sure
First of all, properties should be used in C# instead of get() and set() methods wherever appropriate.
Public member names should start with a capital letter.
Prefixes such as "arg..." are evil. The constructor parameters should be simply "name" and "sname".
The name "SName" is a great example of an unclear and unneccessary abbreviation that should be avoided.
I was too lazy to search for reference links, this is what I remember from the guidelines. Somebody correct me if I'm wrong...
|
|
|
|
|
Thanks. I understand your points. In this day and age, using "SName" instead of say "Surname", whilst seemingly picky is a good point. Sometimes it's all about the attention to details.
Chris Meech
I am Canadian. [heard in a local bar]
In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]
posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]
|
|
|
|
|
Oh dear god no!
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
CCC Link[ ^]
Trolls[ ^]
|
|
|
|
|
It happens. At University we had teachers that tought us, and teachers that we tought
I may or may not be responsible for my own actions
|
|
|
|
|
Congratulations. You have found the main source of the content in hall of shame: shameful teachers.
|
|
|
|
|
I like the way they explicitly declare methods as public when the class is implicitly internal.
BTW I am a teacher so if you want to pass, hand in your assignments
"You get that on the big jobs."
|
|
|
|
|
RobCroll wrote: I like the way they explicitly declare methods as public when the class is
implicitly internal.
I can't really see anything wrong with that
RobCroll wrote: if you want to pass, hand in your assignments
I have already got an A, but thanks for the offer
|
|
|
|
|
Kubajzz wrote: RobCroll wrote: I like the way they explicitly declare methods as public when the class is
implicitly internal.
I can't really see anything wrong with that
The methods are public which would suggest they are available to the world but the class is internal and only accessible within the assembly. Explicitly declaring the "Access Modifier" as public is misleading because it can only be private, internal or protected.
Congratulations on the A by the way.
"You get that on the big jobs."
|
|
|
|
|
Seems like a fine pratice to me. If the class is later changed to public, all the properties would then become visible outside the assembly. This may be the intention. There is also the case of when implementing an interface (the members would have to be public, even on an internal class). While neither of those appear to be the case here, I don't see a downside to making the members public.
|
|
|
|
|
If the assembly has more than just this internal class then the members should be public if you want the other classes in the same assembly to access them. Internal is assembly in scope, public is class in scope. Internal limits public access only to that assembly for that internally declared class, all other classes can still acess the internal class.
|
|
|
|
|
I know. My point was that if you change the class down the road (e.g., by changing it from internal to public) for whatever reason, then it may be advantageous if you had marked all the class members public in the first place (assuming your change of making the class public implies that you also want the members to be public once that change has been made).
|
|
|
|
|
And he should be shot for concatenating his strings...
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Manfred R. Bihy: "Looks as if OP is learning resistant."
|
|
|
|
|
After x iterations of .NET it would be nice to have a constant for space String.Space or String.Character.Space . I guess you could encapsulate the statement getFName() but other than that, what is the problem?
"You get that on the big jobs."
|
|
|
|
|
It should be
return string.Format("{0} {1}", name, sname);
|
|
|
|
|
Got a citation for that? It would seem to me that string.Format is a lot heavier than concatenation, since it has to parse the format string, work out what the arguments are and then substitute them in.
Usually the advice is to use StringBuilder but for such a small example I don't see what's wrong with the concatenation, and Format seems worse.
|
|
|
|