Code should be 5 or anything above 7 long...
-
Before people start... The horror is NOT that this is VB code... Now with that out of the way... A bit of weird code a colleague found recently...
' This code should always be 5 characters long.
If code.Length < 5 Or code.Length = 6 Or code.Length = 7 Then
Throw New Exception("Code should be 5 characters long.")
End IfMy guess is that the programmer assumed it would be 5 characters long or less. Then it turned out it could be 6 too so the
Or code.length = 6
part was added, then the code was 7 at some occurrence... The users weren't stupid enough to enter an 8 character code so that one hasn't been added (yet) :laugh: Why not simply check ifcode.Length <> 5
? :rolleyes:It's an OO world.
public class Naerling : Lazy<Person>{
public void DoWork(){ throw new NotImplementedException(); }
} -
Indeed...
Dim counter As Long ' This could be a REAL long code!
For Each c As Char In code
counter = counter + 1
End If
If counter < 5 Then
Throw New Exception("The code is to short!")
ElseIf counter = 6
Throw New Exception("The code is to long!")
ElseIf counter = 7
Throw New Exception("The code is to long!")
Else
' Some code here :)
End IfIt's an OO world.
public class Naerling : Lazy<Person>{
public void DoWork(){ throw new NotImplementedException(); }
} -
Indeed...
Dim counter As Long ' This could be a REAL long code!
For Each c As Char In code
counter = counter + 1
End If
If counter < 5 Then
Throw New Exception("The code is to short!")
ElseIf counter = 6
Throw New Exception("The code is to long!")
ElseIf counter = 7
Throw New Exception("The code is to long!")
Else
' Some code here :)
End IfIt's an OO world.
public class Naerling : Lazy<Person>{
public void DoWork(){ throw new NotImplementedException(); }
} -
The happy face is a hidden VB feature in .NET 4 ;p
It's an OO world.
public class Naerling : Lazy<Person>{
public void DoWork(){ throw new NotImplementedException(); }
} -
Are you a member of Obfuscators Anonymous. :)
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]
Yeah, at the Novice rank. I hope to go up to Apprentice this year.
-
Maybe the comment and the error message should have been ' This code should always be 5 characters or more than 7 characters.
-
Before people start... The horror is NOT that this is VB code... Now with that out of the way... A bit of weird code a colleague found recently...
' This code should always be 5 characters long.
If code.Length < 5 Or code.Length = 6 Or code.Length = 7 Then
Throw New Exception("Code should be 5 characters long.")
End IfMy guess is that the programmer assumed it would be 5 characters long or less. Then it turned out it could be 6 too so the
Or code.length = 6
part was added, then the code was 7 at some occurrence... The users weren't stupid enough to enter an 8 character code so that one hasn't been added (yet) :laugh: Why not simply check ifcode.Length <> 5
? :rolleyes:It's an OO world.
public class Naerling : Lazy<Person>{
public void DoWork(){ throw new NotImplementedException(); }
}These instances of code changes were not done by a programmer. A developer maybe, but not a programmer.
-
These instances of code changes were not done by a programmer. A developer maybe, but not a programmer.
Perhaps we could debate a bit on the difference between programmer and developer? :) Anyway, whoever made those changes had no clue what they were doing so it seems ;)
It's an OO world.
public class Naerling : Lazy<Person>{
public void DoWork(){ throw new NotImplementedException(); }
} -
Perhaps we could debate a bit on the difference between programmer and developer? :) Anyway, whoever made those changes had no clue what they were doing so it seems ;)
It's an OO world.
public class Naerling : Lazy<Person>{
public void DoWork(){ throw new NotImplementedException(); }
}I certainly agree that the coder was inept. On the subject of developer vs programmer. Even though my title is,"Sr Developer Architect" I consider myself a programmer. I'm as comfortable using VI and make as I am Eclipse or Visual Studio. Therein lies the difference to me. I feel the word developer connotes one who requires the modern IDE with all it's pop-up hints, which 95% of the time just get in my way. Then there is VI where one never has to take their hands of the keyboard to do virtually everything possible when it comes to the programming process. I live in both worlds in my efforts. Now all of that is entirely subjective observation so it's really not debatable. But I would be interested in your thoughts. I'm going to destroy the Earth with my Illudium Q-36 Explosive Space Modulator! - Marvin Martian
-
I certainly agree that the coder was inept. On the subject of developer vs programmer. Even though my title is,"Sr Developer Architect" I consider myself a programmer. I'm as comfortable using VI and make as I am Eclipse or Visual Studio. Therein lies the difference to me. I feel the word developer connotes one who requires the modern IDE with all it's pop-up hints, which 95% of the time just get in my way. Then there is VI where one never has to take their hands of the keyboard to do virtually everything possible when it comes to the programming process. I live in both worlds in my efforts. Now all of that is entirely subjective observation so it's really not debatable. But I would be interested in your thoughts. I'm going to destroy the Earth with my Illudium Q-36 Explosive Space Modulator! - Marvin Martian
MarvinMartian wrote:
I'm going to destroy the Earth with my Illudium Q-36 Explosive Space Modulator! - Marvin Martian
Ehhh... What's up doc? ;p I always felt a programmer to be more like someone who writes code that he is told to write while a developer thinks of how the code should be written and can write it too (somewhere between a programmer and an architect maybe?). I think my contract says I'm a software developer just like all my colleagues, but when it comes to coding new libraries and thinking about architecture I am a lot better than my colleagues who couldn't name a single Design Pattern or SOLID principle. And when it comes to that you are, judging from your title, far more skilled and knowledged than me even though you consider yourself a programmer. I think everyone who writes code should have a basic, but solid understanding of architecture no matter their title. I think programmers and developers work at a small part of software while architects overlook the entire project. But then again, I work at a small company that doesn't have architects :)
It's an OO world.
public class Naerling : Lazy<Person>{
public void DoWork(){ throw new NotImplementedException(); }
} -
MarvinMartian wrote:
I'm going to destroy the Earth with my Illudium Q-36 Explosive Space Modulator! - Marvin Martian
Ehhh... What's up doc? ;p I always felt a programmer to be more like someone who writes code that he is told to write while a developer thinks of how the code should be written and can write it too (somewhere between a programmer and an architect maybe?). I think my contract says I'm a software developer just like all my colleagues, but when it comes to coding new libraries and thinking about architecture I am a lot better than my colleagues who couldn't name a single Design Pattern or SOLID principle. And when it comes to that you are, judging from your title, far more skilled and knowledged than me even though you consider yourself a programmer. I think everyone who writes code should have a basic, but solid understanding of architecture no matter their title. I think programmers and developers work at a small part of software while architects overlook the entire project. But then again, I work at a small company that doesn't have architects :)
It's an OO world.
public class Naerling : Lazy<Person>{
public void DoWork(){ throw new NotImplementedException(); }
}It's interesting that we have the exact opposite view of what it is we think we are. LOL It may be that when I started, there were no developers, only programmers. While in high school in the late 60's I wrote my first FORTRAN programs. They did nothing but they did spark an interest. I became a mechanical engineer, primarily for the $$, however I continued programming my stress analysis in FORTRAN and gradually began to like that more than building amazing things out of steel etc. I now occasionally do electronic design, embedded coding, real time data collection from operating room instrumentation all while "architecting" financial solutions using SOA at a large life insurance company. I'm not boasting by any means. There is much I don't know. That's why I'm about to take a crash (8 week) course "Advanced Java Programming". Just so I can put it on my resume. (And take the official certification. You gotta know all the buzz words and acronyms.) In fact I learn something from every project I work on. I'm currently discovering Android development having just installed everything I need. No iOS for me, I've seen "objective C", it ain't C! Also there is that $100 here and there and you can only develop on a Mac. (You can run iOS in VMWare but it crashes if the app you're running wants to identify the Mac you're running on!) I am also proud of the fact that at age 63 I still have the urge to do this and learn more. Now that is the boast! LOL I'm going to destroy the Earth with my Illudium Q-36 Explosive Space Modulator! - Marvin Martian
-
It's interesting that we have the exact opposite view of what it is we think we are. LOL It may be that when I started, there were no developers, only programmers. While in high school in the late 60's I wrote my first FORTRAN programs. They did nothing but they did spark an interest. I became a mechanical engineer, primarily for the $$, however I continued programming my stress analysis in FORTRAN and gradually began to like that more than building amazing things out of steel etc. I now occasionally do electronic design, embedded coding, real time data collection from operating room instrumentation all while "architecting" financial solutions using SOA at a large life insurance company. I'm not boasting by any means. There is much I don't know. That's why I'm about to take a crash (8 week) course "Advanced Java Programming". Just so I can put it on my resume. (And take the official certification. You gotta know all the buzz words and acronyms.) In fact I learn something from every project I work on. I'm currently discovering Android development having just installed everything I need. No iOS for me, I've seen "objective C", it ain't C! Also there is that $100 here and there and you can only develop on a Mac. (You can run iOS in VMWare but it crashes if the app you're running wants to identify the Mac you're running on!) I am also proud of the fact that at age 63 I still have the urge to do this and learn more. Now that is the boast! LOL I'm going to destroy the Earth with my Illudium Q-36 Explosive Space Modulator! - Marvin Martian
I started programming... about one and a half year ago :) Started at a small company where SOLID and Design Patterns were unheard of and where Interface was a curse word! On CP I learned about these things and I could convince my employers to work more Object Oriented (which led to quite some fights between me and my employers who probably felt attacked that someone who just started told them what to do). So we had the junior (me) telling the big senior (my boss) what to do. Since then I don't care much for titles anymore. If my boss is a senior (even self-proclaimed) then I must be the über-senior... After a year :) I guess it all depends on where you work and who you work with. If I moved to a big company now I'd be the junior again with no education or certification whatsoever. In the end it's not about your title or education, it's about what you know and what you can do that counts. Unfortunately it sometimes seems title and education are more important in this society... Luckily I do still hold an MA title in Media and Journalism, although that doesn't get me very far in programming :)
MarvinMartian wrote:
I am also proud of the fact that at age 63 I still have the urge to do this and learn more. Now that is the boast! LOL
And rightfully so! :) Many people of that age await their retirement and shun all kinds of change because it's easier for them to stick to what they know (I know a few)...
It's an OO world.
public class Naerling : Lazy<Person>{
public void DoWork(){ throw new NotImplementedException(); }
} -
Before people start... The horror is NOT that this is VB code... Now with that out of the way... A bit of weird code a colleague found recently...
' This code should always be 5 characters long.
If code.Length < 5 Or code.Length = 6 Or code.Length = 7 Then
Throw New Exception("Code should be 5 characters long.")
End IfMy guess is that the programmer assumed it would be 5 characters long or less. Then it turned out it could be 6 too so the
Or code.length = 6
part was added, then the code was 7 at some occurrence... The users weren't stupid enough to enter an 8 character code so that one hasn't been added (yet) :laugh: Why not simply check ifcode.Length <> 5
? :rolleyes:It's an OO world.
public class Naerling : Lazy<Person>{
public void DoWork(){ throw new NotImplementedException(); }
}Can see this happening in Python:
if code.length in [0,1,2,3,4,6,7]:
....Don't forget to rate my post if it helped! ;) "He has no enemies, but is intensely disliked by his friends." "His mother should have thrown him away, and kept the stork." "There's nothing wrong with you that reincarnation won't cure." "He loves nature, in spite of what it did to him."
-
In order to write secure code... whatever how important is your input, do Not trust the client, validate input data even @ back-end think about client Validation just like good interface, to ease user life, to reduce hits on the server... no more :)
Last Egyptian Physicist www.ameen.rr.nu
-
Before people start... The horror is NOT that this is VB code... Now with that out of the way... A bit of weird code a colleague found recently...
' This code should always be 5 characters long.
If code.Length < 5 Or code.Length = 6 Or code.Length = 7 Then
Throw New Exception("Code should be 5 characters long.")
End IfMy guess is that the programmer assumed it would be 5 characters long or less. Then it turned out it could be 6 too so the
Or code.length = 6
part was added, then the code was 7 at some occurrence... The users weren't stupid enough to enter an 8 character code so that one hasn't been added (yet) :laugh: Why not simply check ifcode.Length <> 5
? :rolleyes:It's an OO world.
public class Naerling : Lazy<Person>{
public void DoWork(){ throw new NotImplementedException(); }
}Naerling wrote:
Throw New Exception("Code should be 5 characters long.")
Well, shouldn't error change accordingly?
Throw New Exception("Code should be 5 characters long or should exactly not be 6 characters or oh wait, not exactly 7 characters too, anything other than that.")
- Just that something can be done, doesn't mean it should be done. Respect developers and their efforts! Jk
-
Indeed...
Dim counter As Long ' This could be a REAL long code!
For Each c As Char In code
counter = counter + 1
End If
If counter < 5 Then
Throw New Exception("The code is to short!")
ElseIf counter = 6
Throw New Exception("The code is to long!")
ElseIf counter = 7
Throw New Exception("The code is to long!")
Else
' Some code here :)
End IfIt's an OO world.
public class Naerling : Lazy<Person>{
public void DoWork(){ throw new NotImplementedException(); }
}Surely "The code is tOO short" It's an OO world, remember.
-
Surely "The code is tOO short" It's an OO world, remember.
Indeed, not enough Objects... ;p
It's an OO world.
public class Naerling : Lazy<Person>{
public void DoWork(){ throw new NotImplementedException(); }
}