|
I've got a class with 12 constructor parameters but the class represents a single row of data from a database so it is a discrete object. I also did full xml comments on everything so I don't forget why I wrote it. Would that be flagged in a code review?
if (Object.DividedByZero == true) { Universe.Implode(); }
Meus ratio ex fortis machina. Simplicitatis de formae ac munus. -Foothill, 2016
|
|
|
|
|
Foothill wrote: I've got a class with 12 constructor parameters but the class represents a single row of data from a database
I don't do that with column data anymore unless I need the object to be initialized a certain way. I just use object initializers.
".45 ACP - because shooting twice is just silly" - JSOP, 2010
- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
mav.northwind wrote: the whole class has exactly 0 comments That's exactly how much comments code should have!
Great code requires no comments.
Most comments are bad anyway. I'm so allergic to comments I even wrote a tip on why you shouldn't comment (and the rare case you should): Write comments that matter[^]
|
|
|
|
|
unless the OP means 8 overloaded constructors with different parameter signatures?
(in which case defaults could definitely help)
|
|
|
|
|
He never said anything about overloads, so I think it's safe to assume there is one constructor with eight parameters.
".45 ACP - because shooting twice is just silly" - JSOP, 2010
- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
he wrote a lot. Compacter is:
Users()
As master Yoda says: "Make it or not. Dont: try"
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
Not to make fun of your signature:
Quote: Black holes are the places where God divided by 0 But:
Yes! And the minds of some of the sunshines in Q&A are where He multiplied by zero!
Get me coffee and no one gets hurt!
modified 2-Apr-16 20:39pm.
|
|
|
|
|
public int val2
{
get
{
return val2;
}
set
{
val2 = 10;
}
}
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
Maybe there was a requirement to not use const ?
|
|
|
|
|
No, the requirement was to create a public get/set property named Value2 for a private field named value2 and to use that property to set value2 to a value of 10 - but from outside the containing class..
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
I'm surprised this code compiles, as there is a circular reference in the getter.
You always obtain more by being rather polite and armed than polite only.
|
|
|
|
|
Yep, the compiler will let you run into a SO-exception without turning a hair
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
Alas it does, I've lost many an hour to it 
|
|
|
|
|
there's one in the setter too.
|
|
|
|
|
I strongly suspect that nugget of joy was written by someone who typically writes in JavaScript.
Or maybe a cat walking across the keyboard.
Any other answer would be insane...
|
|
|
|
|
Or someone who has no idea what he is doing and is playing games in class and not paying attention to the professor.
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
|
|
|
|
|
I think this just speaks for itself...
(I apologise in advance for the pain caused)
How many bad practices can y'all spot in this?
Function InvokeMember(MethodName As String, _
Optional ByRef P1 As Object = "!%$", Optional ByRef P2 As Object = "!%$", _
Optional ByRef P3 As Object = "!%$", Optional ByRef P4 As Object = "!%$", _
Optional ByRef P5 As Object = "!%$", Optional ByRef P6 As Object = "!%$", _
Optional ByRef P7 As Object = "!%$", Optional ByRef P8 As Object = "!%$", _
Optional ByRef P9 As Object = "!%$", Optional ByRef P10 As Object = "!%$", _
Optional ByRef P11 As Object = "!%$") As Object
Dim Parms(0) As Object
If P1.GetType Is GetType(String) Then If P1 = "!%$" Then GoTo a150
Parms(0) = P1
If P2.GetType Is GetType(String) Then If P2 = "!%$" Then GoTo a100
ReDim Preserve Parms(UBound(Parms) + 1) : Parms(UBound(Parms)) = P2
If P3.GetType Is GetType(String) Then If P3 = "!%$" Then GoTo a100
ReDim Preserve Parms(UBound(Parms) + 1) : Parms(UBound(Parms)) = P3
If P4.GetType Is GetType(String) Then If P4 = "!%$" Then GoTo a100
ReDim Preserve Parms(UBound(Parms) + 1) : Parms(UBound(Parms)) = P4
If P5.GetType Is GetType(String) Then If P5 = "!%$" Then GoTo a100
ReDim Preserve Parms(UBound(Parms) + 1) : Parms(UBound(Parms)) = P5
If P6.GetType Is GetType(String) Then If P6 = "!%$" Then GoTo a100
ReDim Preserve Parms(UBound(Parms) + 1) : Parms(UBound(Parms)) = P6
If P7.GetType Is GetType(String) Then If P7 = "!%$" Then GoTo a100
ReDim Preserve Parms(UBound(Parms) + 1) : Parms(UBound(Parms)) = P7
If P8.GetType Is GetType(String) Then If P8 = "!%$" Then GoTo a100
ReDim Preserve Parms(UBound(Parms) + 1) : Parms(UBound(Parms)) = P8
If P9.GetType Is GetType(String) Then If P9 = "!%$" Then GoTo a100
ReDim Preserve Parms(UBound(Parms) + 1) : Parms(UBound(Parms)) = P9
If P10.GetType Is GetType(String) Then If P10 = "!%$" Then GoTo a100
ReDim Preserve Parms(UBound(Parms) + 1) : Parms(UBound(Parms)) = P10
If P11.GetType Is GetType(String) Then If P11 = "!%$" Then GoTo a100
ReDim Preserve Parms(UBound(Parms) + 1) : Parms(UBound(Parms)) = P11
a100:
On Error GoTo a200
InvokeMember = DLLClass.InvokeMember(MethodName, _
Reflection.BindingFlags.InvokeMethod, Nothing, DLlInstance, Parms, Nothing)
Dim x As Integer
For x = 0 To UBound(Parms)
If x = 0 Then P1 = Parms(x)
If x = 1 Then P2 = Parms(x)
If x = 2 Then P3 = Parms(x)
If x = 3 Then P4 = Parms(x)
If x = 4 Then P5 = Parms(x)
If x = 5 Then P6 = Parms(x)
If x = 6 Then P7 = Parms(x)
If x = 7 Then P8 = Parms(x)
If x = 8 Then P9 = Parms(x)
If x = 9 Then P10 = Parms(x)
If x = 10 Then P11 = Parms(x)
Next
Exit Function
a150:
On Error GoTo a200
InvokeMember = DLLClass.InvokeMember(MethodName, _
Reflection.BindingFlags.InvokeMethod, Nothing, DLlInstance, Nothing, Nothing)
Exit Function
a200:
Dim m As String = ""
m = m & "Error invoking Method: " & MethodName & vbCrLf
m = m & "Either the Method Name is incorrect (Check Case Sensitivity)" & vbCrLf
m = m & "Or The Parameter sequence does not match the Methods signature"
InvokeExitSystem(m)
End Function
(PS - this is actually VB.NET code).
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
Alan Kay.
|
|
|
|
|
I gave up counting them after reading optional byref p2 as object
just luckily its the practically weekend at 5:30 today (long live the long weekend )
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
Luckily I've got two weeks vacation - I think I need it. My eyes are bleeding.
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
Alan Kay.
|
|
|
|
|
My needs for daily wtf are covered.
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
WTF? Whoever wrote that needs to be strung up by his pinky fingers!
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
|
|
|
|
|
Sadly, its 3rd party code I have to interface to.
It kinda works, but !
(At least it works 'til it fails horribly, when someone calls a function with one too many parameters, when it fail ungracefully)
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
Alan Kay.
|
|
|
|
|
Have somea lot of .
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
|
|
|
|
|
Oh, and the person who created this needs to be bashed over the head with a solid iron clue bat. Several times.
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
|
|
|
|
|
Rob Grainger wrote: How many bad practices can y'all spot in this?
....
(PS - this is actually VB.NET code).
Kind of you to start the list for us. 
|
|
|
|