Raised This Month: $51 Target: $400
 12% 

Writing good code, solving problems.


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
I am inevitable
Member
Join Date: May 2019
Location: 0xA6DA34
Old 07-14-2019 , 11:04   Writing good code, solving problems.
Reply With Quote #1

Hi.

Reading code off the internet sometimes triggers me. I immediately start thinking: "hmm, why didn't you that, or that?". (I'm not trying to be that smartass or anything, and I'm by any means not the best, just wanted to make things a little clearer, okay, good).

Before we dive in, when writing something, always ask yourself these questions:
- What do I want to know?
- What do I already know?

Trust me, it's extremely helpful.

Here're a couple of dilemmas with examples, and more compact solutions:

1. A guy named Jerry wants a specific command to output the client's team. This is how he did it:
Spoiler


Now, this code is perfectly fine, but. We can shorten it... a lot:
Spoiler


2. This one day I was writing a stats plugin and there was this one command that was supposed to create a menu, showing you the top players on the server, based different categories. Here's how I first did it:
Spoiler


And this too is just fine, but, we can be even more efficient with our lines, and here's the solution I found:
Spoiler


I believe that programming isn't just about making things work, it's about making it nice aswell.

With that being said, you can almost always make your code just a little bit better.

(Also, I don't even know if this page is useful, but, meh).
__________________
I do make plugins upon requests, so hit me up on discord if you're interested: Stefan Milivojevic#5311

Last edited by I am inevitable; 07-14-2019 at 13:43.
I am inevitable is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 07:22.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode