Hack Forums
[.NET] Chuck Norris Joke Generator - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [.NET] Chuck Norris Joke Generator (/showthread.php?tid=4922712)



Chuck Norris Joke Generator - Uzi London ++ - Jul 26, 2015

I got bored.

[Image: TG7HZRH.png]

Idk why, but the theme I used got fucked up halfway through and I couldn't change the groupbox. I'm too tired and just woke up so I didn't feel like trying to fix it. Have fun with your chuck norris jokes :D now you can be a real mlg with quick Chuck Norris jokes. glhf
Download sauce + bin.



Wtf I totally changed Form1 to "Chuck Norris Joke Generator. Whatever. Kek. GETTING coffee now ;D


Oh. And I know it can be optimized. Once again, I just got bored and I just woke up. Optimize it if you like, it's like 2 lines of code :P


* - Odus - Jul 26, 2015

(Jul 26, 2015 05:35 AM)Johntheawe Wrote:  Optimize it if you like, it's like 2 lines of code :P

Well, if you absolutely insist...

Code
Private Function GetJoke(joke As JokeType) As String
    Using wc As New WebClient
      Return wc.DownloadString("http://api.predator.wtf/joke/?arguments=" & joke.ToString())
    End Using
End Function

Public Enum JokeType
    nerdy
    explicit
End Enum

Edit- Some suggestions:
-You've already imported your namespaces, why continue to qualify them?
-Remember to dispose your requests, responses and streams. Wrap in Using blocks.
-You're mixing between title case and camel case, always the latter for local.
-No use in catching the exception if you're going to do nothing with it.
-Parenthesize methods.

I won't pick up on the Dispose call.


* - Uzi London ++ - Jul 26, 2015

(Jul 26, 2015 06:09 AM)Odus Wrote:  Well, if you absolutely insist...

Code
Private Function GetJoke(joke As JokeType) As String
    Using wc As New WebClient
      Return wc.DownloadString("http://api.predator.wtf/joke/?arguments=" & joke.ToString())
    End Using
End Function

Public Enum JokeType
    nerdy
    explicit
End Enum

I won't pick up on the Dispose call.

I'm sorry. Please don't hit me :<


* - moosa666 - Jul 28, 2015

awsome now i can use a lion to click the mouse like chuck noris


* - NETExplorer - Jul 28, 2015

(Jul 26, 2015 06:09 AM)Odus Wrote:  Well, if you absolutely insist...

Code
Private Function GetJoke(joke As JokeType) As String
    Using wc As New WebClient
      Return wc.DownloadString("http://api.predator.wtf/joke/?arguments=" & joke.ToString())
    End Using
End Function

Public Enum JokeType
    nerdy
    explicit
End Enum

Edit- Some suggestions:
-You've already imported your namespaces, why continue to qualify them?
-Remember to dispose your requests, responses and streams. Wrap in Using blocks.
-You're mixing between title case and camel case, always the latter for local.
-No use in catching the exception if you're going to do nothing with it.
-Parenthesize methods.

I won't pick up on the Dispose call.

Hey, you should keep naming conventions in enums as well
So capitalize those fuckers, and call tolower()