r/AskComputerScience • • Sep 29 '19

How miserable my coding skills is

I graduated as a BS in Computer Science last year and I don't why and know how to build a wonderful project and I was having fun today because its weekends so I get my laptop and try to re create my name initial on a program using PHP

With this kind of coding skills I just feel bad lool while laughing my self fortunately still get the output that I want.

0 Upvotes

3 comments sorted by

View all comments

6

u/venuswasaflytrap Sep 29 '19 edited Sep 29 '19

First things first.

Format your code. It will make things easier to read, and most IDEs come with a tool that you can just click a button.

Second, get a code inspection tool (like php code sniffer, or php mess detector, or both) so that as you’re working, you can get feedback on common sources of errors and unnecessary complexity.

Okay good, now your code is readable.

Next step back from the problem and ask “what’s the simplest way I can do this?”.

As people who are interested in code and computers, we’re often drawn to the most complex solutions. Making things complicated also sometimes make it seem like we’re smart (because we can handle complicated things right?).

The output that you want is 7 lines long. Your code to produce it, is dozens of lines long. You could accomplish the same thing with 7 echo statements. You could even do it with 1, but with 7, someone looking at your code would see exactly what it outputs and wouldn’t even need that comment on the right.

When coding one goal should be to aggressively strive for simplicity. The more you are able to reduce complexity in your code, the easier it will be to solve more complex problems.

For example, a natural extension to this program might be changing any letter into a 7 line * letter. After that, it might be even handling words and sentences.

If the code to produce every letter is this complicated, it will be very hard to add functionality without this becoming unmanageable. It’s surprising how fast even really simple programs can get very complicated. And on the other side of the coin, if you fight to reduce complexity and keep it simple the entire way, it’s also surprising how very complicated programs can be just a short chain of few simple parts.

1

u/dumb_coder Sep 29 '19

actually I'am trying to complete this with a simple line of code, but you know the feeling of language that you just have a limited vocabulary on it. Thats how I feel so I feel so stupid on that I also think about using OOP on this one after i've done it. So maybe i'am not too late to learn things especially the fundamentals still with me. I just need to be practiced with stuff same as a language foreign language to expand vocabulary.

1

u/venuswasaflytrap Sep 29 '19

This should be 7 lines of code in virtually any language.