Jump to content

What do you guys think of code?

babadoctor
Go to solution Solved by Nuluvius,

oh shit dude

so if i use 20 tags instead of one to define them all, will the code be bad?

because i just do anything that works...

 

Judging by the line numbers present in that picture I don't think that at this point you should worry too much. Such is the process of learning...

 

Generally though you should try to understand and learn good software engineering and design principles as soon as possible. It's not all about hammering out line after line of code and crunching that next problem as fast a possible. These principles are arguably far more important and valuable.

Be mindful of Code SmellsAntipatterns and increasing Cyclomatic complexity i.e. lots of branching logic such as those if elses... get rid of them and employ a design pattern.

5d27d53a4ec51b6a37df424767235a8a.png

what could be changed

i know this is a very limited picture and code, but...

i want your opinion with code given

is it horrid?

OFF TOPIC: I suggest every poll from now on to have "**CK EA" option instead of "Other"

Link to comment
Share on other sites

Link to post
Share on other sites

It looks good, and I mean that in the most literal sense :)

 

Not sure what it's supposed to do or even the language, so can't comment on functionality, but it looks good, and it also looks like it should work, I think

 

You wouldn't believe the number of people who have absolutely no idea how to just format their code, in terms of indentation, etc. never mind the actual writing...

Solve your own audio issues  |  First Steps with RPi 3  |  Humidity & Condensation  |  Sleep & Hibernation  |  Overclocking RAM  |  Making Backups  |  Displays  |  4K / 8K / 16K / etc.  |  Do I need 80+ Platinum?

If you can read this you're using the wrong theme.  You can change it at the bottom.

Link to comment
Share on other sites

Link to post
Share on other sites

It doesnt, thanks for pointing that out!

OFF TOPIC: I suggest every poll from now on to have "**CK EA" option instead of "Other"

Link to comment
Share on other sites

Link to post
Share on other sites

You could replace the while loop with a for loop, or move the incrementation of ID into the assignment statement.

Other than that (and the mention of switch statements above), it looks good. I mean, I guess you could make it more object oriented, but whether or not that's worth it is up to you.

15" MBP TB

AMD 5800X | Gigabyte Aorus Master | EVGA 2060 KO Ultra | Define 7 || Blade Server: Intel 3570k | GD65 | Corsair C70 | 13TB

Link to comment
Share on other sites

Link to post
Share on other sites

You could replace the while loop with a for loop, or move the incrementation of ID into the assignment statement.

Other than that (and the mention of switch statements above), it looks good. I mean, I guess you could make it more object oriented, but whether or not that's worth it is up to you.

right now im not focused on making it air tight...

its not like the users ever gonna go through and criticize my code... right?

also since your here WHAT HAVE YOU DONE WITH THE WHOS VIEWING MY TOPIC BAR!!!!!!

OFF TOPIC: I suggest every poll from now on to have "**CK EA" option instead of "Other"

Link to comment
Share on other sites

Link to post
Share on other sites

right now im not focused on making it air tight...

its not like the users ever gonna go through and criticize my code... right?

also since your here WHAT HAVE YOU DONE WITH THE WHOS VIEWING MY TOPIC BAR!!!!!!

We're just testing some stuff out.

15" MBP TB

AMD 5800X | Gigabyte Aorus Master | EVGA 2060 KO Ultra | Define 7 || Blade Server: Intel 3570k | GD65 | Corsair C70 | 13TB

Link to comment
Share on other sites

Link to post
Share on other sites

First of all use code tags not images. Secondly get rid of all of those magic numbers. They should be behind clearly defined constants... if they even really need to exist at all. Often needing so many as is the case here is a bad code smell which is indicative of a problem with the design.

The single biggest problem in communication is the illusion that it has taken place.

Link to comment
Share on other sites

Link to post
Share on other sites

right now im not focused on making it air tight...

its not like the users ever gonna go through and criticize my code... right?

Well if this is javascript, the users would be able to see it I think. But who does that... ^_^

Link to comment
Share on other sites

Link to post
Share on other sites

Well if this is javascript, the users would be able to see it I think. But who does that... ^_^

I suspect UnityScript personally :)

The single biggest problem in communication is the illusion that it has taken place.

Link to comment
Share on other sites

Link to post
Share on other sites

You should define schoolwear as an enum so you can say 

switch schoolwear{  case Uniform: stuff  case Gym: stuff}

Makes it more readable.

 

I'd also pass all the assignments you're making to a function that takes 3 arguments looking like

function(arg1, arg2, arg3){  MyRenderer.materials[0].mainTexture = arg1;  MyRenderer.materials[1].mainTexture = arg2;  MyRenderer.materials[2].mainTexture = arg3;}

Then you just call that function instead of writing it out 3+ times.

Link to comment
Share on other sites

Link to post
Share on other sites

You should define schoolwear as an enum so you can say 

switch schoolwear{  case Uniform: stuff  case Gym: stuff}

Makes it more readable.

 

I'd also pass all the assignments you're making to a function that takes 3 arguments looking like

function(arg1, arg2, arg3){  MyRenderer.materials[0].mainTexture = arg1;  MyRenderer.materials[1].mainTexture = arg2;  MyRenderer.materials[2].mainTexture = arg3;}

Then you just call that function instead of writing it out 3+ times.

This is good advice.

I don't know if ECMAScript supports enums, but a (still better than the current solution) alternative if it doesn't is to just use named constants.

 

i.e.

var NUDE = 0;var UNIFORM = 1;var SWIMSUIT = 2;var GYM = 3;...if(schoolwear == NUDE){    Nude();}...
Link to comment
Share on other sites

Link to post
Share on other sites

First of all use code tags not images. Secondly get rid of all of those magic numbers. They should be behind clearly defined constants... if they even really need to exist at all. Often needing so many as is the case here is a bad code smell which is indicative of a problem with the design.

oh shit dude

so if i use 20 tags instead of one to define them all, will the code be bad?

because i just do anything that works...

OFF TOPIC: I suggest every poll from now on to have "**CK EA" option instead of "Other"

Link to comment
Share on other sites

Link to post
Share on other sites

oh shit dude

so if i use 20 tags instead of one to define them all, will the code be bad?

because i just do anything that works...

 

Judging by the line numbers present in that picture I don't think that at this point you should worry too much. Such is the process of learning...

 

Generally though you should try to understand and learn good software engineering and design principles as soon as possible. It's not all about hammering out line after line of code and crunching that next problem as fast a possible. These principles are arguably far more important and valuable.

Be mindful of Code SmellsAntipatterns and increasing Cyclomatic complexity i.e. lots of branching logic such as those if elses... get rid of them and employ a design pattern.

The single biggest problem in communication is the illusion that it has taken place.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×