Becoming a better programmer!

Seriosk

Programmer;
Oct 29, 2016
256
105
Firstly, this has been put in the Habbo Tutorials section because its focused on the development of Habbo Emulation servers.

Hello. I saw one of these a while back done by a very talented developer and I must say it inspired me to be a better developer. I wish I could say many people listened to the thread and stopped with their sloppy coding practices but they really haven't.

This is mainly focused on the C# language but a lot of it can be thought of when coding in other languages (java mainly) as many coding languages follow the same sort of learning stages and you usually hit the same sort of problems no matter what language you're programming in.

Id like to start by saying its not about features.. you could say I am quoting what I've read in the other thread but let me go into a bit more detail. Many of you throw features in and hope they'll work. You need to look at the code, how it runs, and if that's really the best way to do it. During this thread many of you will actually read the first sentence and give up.. being a really good developer takes time and you'll require love and passion for the language you're developing in, if you don't want to do it.. go and carry on coding using sloppy practices, I'm not saying this thread will make you the best developer in the world, god knows there are many better developers than me on this forum alone, but it'll give you a few pointers and set you on the right path hopefully

Code Quality vs Features
Features really don't matter, one of the worst attitudes I see in programming is "If it works its good programming", wrong.. that's a very bad attitude to have. You can have hundreds of features but thousands of bugs, you can fix a bug which can cause many other bugs to occur because its not used to the change and you didn't think ahead about something, sure.. beta testing and even alpha testing can cover a lot of bugs that are found but writing good quality code can eliminate so many potential bugs from the future. When I became a better developer my mess up ratio dropped by a lot, take in to consideration people will appreciate less features and better code over hundreds of more features with badly written code that is possibly broken.

What are the point of Utilities?
A utilities in my mind is something that is often used. Lets say we need to get a persons name for 20 forms, in programming you would store that name somewhere and refer to it when needed, that's a utility.. what many of you do which is bad practice is you store it in multiple places for multiple methods. A whole point of a utility is to store it in 1 place so that if you ever make modifications to it you'll always fix bugs that occur in ever reference to that method. I can't tell you how much bugs you skip by doing this.

I'm sorry if my explanation of utilities weren't the best, I feel like I didn't go into depth enough so here is a few others:

The utility classes are essentially presentational classes in that modify one presentational aspect of an element. These are useful because they are broadly applicable. You may apply a utility class to a variety of components. Since it isn't specific to a particular component, it isn't necessary to create it as a component modifier.

A Utility class is understood to only have static methods and be stateless. You would not create an instance of such a class.


Whats the point of an Interface?
A point of an interface is to declare rules for a class to follow. It's super easy to understand, say we want every class that inherits the IMethod interface to have a method called "Run" other whys it can't be part of our project and will throw an error. This is very useful in situations when you want to group multiple classes to all do something similar with the same method name. Let's say we have lots of classes that contain "athletes" we'll call them that.. and they all need a method called Start and Stop, remember an interface can contain multiple rules not just one.. but lets say the classes need IAthlete and to force two methods called Start and Stop which stop them running, that's the kind of situation where interfaces would be very useful to a project.

The different between asynchronous and synchronous
Heard both of these words in programming? good.. you must of been involved in some what "advanced" programming at some point then. I see a lot of developers programming and they don't even know the different between this. I get asked all the time which performs better.. in coding and programming there usually is no answer to what code runs better, its usually better its usually always different depending on the situation. I'll use a reference from google, but I'll also use my own explanation.. the reason for this is because I feel google give a good explanation that you may understand better than mine.

Synchronous and asynchronous transmissions are two different methods of transmission synchronization. Synchronous transmissions are synchronized by an external clock, while asynchronous transmissions are synchronized by special signals along the transmission medium.

My explanation... Synchronous is the weakest (in my opinion) of both words. Synchronous makes it so that events have to happen in a line, lets take for instance a line of people waiting to enter a movie threat re, the door is big enough for more than 1 at a time (so is a computer) so usually Asynchronous is the best approach. Asynchronous is where you don't have to have 1 at a time, it can overlap to more than 1 at a time. You've probably heard of something similar to this which is called multi-threading as well, I'll possibly talk some on that later.

Call Stack
Let's go into a humanized situation for a second. Let's say we work at a shop and we need to go to the store room to find out how many jars of Jam we have left in stock. Okay.. you're probably thinking but why? Take the below code for example

Code:
int jamPlus23 = 10 + 23;
int jamPlus49 = 10 + 49

Can you see anything wrong with the above example? You're going back twice to check how much jars of Jam you have left, in this situation just keep in mind you have 10 jars of Jam left in stock. Why would you need to go back twice? I make this mistake and a lot of other developers do too.. languages have memory for a reason, use it.. check out the next example and see if you can see what we should of done in the first example instead of hard coding it in multiple areas, wouldn't it be a struggle if we did that a lot more and two times and wanted to change it?

Code:
int jamInStock = 10;
int jamPlus23 = jamInStock + 23;
int jamPlus49 = jamInStock + 49

You see if a lot in Habbo emulators, take this for example:
Code:
string author = Program.GetServer().Author;
string version = Program.GetServer().Version;
string name = Program.GetServer().Name;
string description = Program.GetServer().Description;

Wouldn't it be better to do this? otherwhys its like having to go to the back room 4 times, when you could go 1 time and save it in your mind, not your mind but the computers mind, which we call the computers memory..
Code:
var server = Program.GetServer();
string author = server.Author;
string version = server.Version;
string name = server.Name;
string description = server.Description;

Hopefully that went in...

the "Which code will run better", "Which is better?" argument
Language creators put functionality inside their languages because its used for different reasons. Lets say we had two features that did the same thing in a language (not exactly the same thing, but the same ending lets say that.. we'll call these A and B. If A outperformed B then why would A exist? the logical solution would to be to remove B right? wrong.. A and B do the same thing but for different situations. Code usually does the same thing, but its near impossible to answer a question of which is better just from asking the question... you need to analyze your situation, check out the differences of both of the features and chose which one fits correctly for your project. I see this a lot in timers (System.Timers vs System.Threading.Timers) in C#, the answer is.. nobody knows until you explain your situation.

A quick message to the people who "ask" for help
You don't have to be a genius to be a programmer, far from it.. infact.. anyone can write programs and software if they put their head to it. I just want to say I encourage everyone to learn it as it has so many benefits, it teaches you how to think... it also gives you a great deal of independence, not just in programming. If you can't fix something usually a google search can help you out.. I'm sure out of the millions of programmers that you're not the only one who has had the issue you're having, give it a try...

A few lessons I never got taught
Learn the correct naming conventions for your language.
You're never the best, there is ALWAYS someone better
Never be ashamed to ask for help, everyone starts somewhere.
Don't get cocky, you're still learning..

Sites/Resources for learning:
=> Asking general questions
=> Asking for reviews on your code
=> Asking questions
=> Explaning things..

Shortcuts?
Hang around developers, hang out in the StackOverflow chat (chat.stackoverflow.com) where professionally trained developers talk about programming all day. They have a chat room for pretty much every language, if they don't you can always make one. I'm not saying you'll become an instantly awesome programmer, it just helps, listen to what they say, how they explain things and watch very carefully when new developers like you come into the chat to ask questions and how the developers respond.

Remember.. you can also read existing questions, most exist unless your problem is fairly unique.

There is so much more to learn and you could of possibly googled all of this but hopefully it can help a few people... I'm sorry it isn't up to the best standards but it should help a few newbies in the areas where I struggled when I started off.
 
Last edited:

Anglo

New Member
Jun 19, 2017
24
13
Great tutorial for people starting out, thought it'd be important to mention to have consistency with your code - stick with the way you're presenting your code, it'll be easier on your eyes and look much more professionally done.
PHP:
int jamInStock = 10;

if( jamInStock < 10 )
{
    jamInStock = 10; //Get more jam
}

int jamPlus23 = jamInStock + 23;
int jamPlus49 = jamInStock + 49;

if( jamPlus23 < 33 )
{
    jamPlus23 = 33; //No idea where I'm going with this in terms of jam stock
}
PHP:
int jamInStock = 10;
if( jamInStock < 10 )
{
    jamInStock = 10; //Get more jam
}

int jamPlus23 = jamInStock + 23, jamPlus49 = jamInStock + 49;

if( jamPlus23 < 33 )
    jamPlus23 = 33; //No idea where I'm going with this in terms of jam stock
 

Seriosk

Programmer;
Oct 29, 2016
256
105
This is a really good thread for newbies
Thanks.

Always help me with my coding, thank you!
You're now at the stage where you no longer need help, you have improved a lot recently...

Thanks xD

Great tutorial for people starting out, thought it'd be important to mention to have consistency with your code - stick with the way you're presenting your code, it'll be easier on your eyes and look much more professionally done.
What you just stated is personal preference (in my opinion).
 

Users who are viewing this thread

Top