+ 10
How to learn to write code beautifull?
3 years I worked on one game engine, where I have a different programming language! There you haf to write the cofe closely. That wad the syntax! So I'm used to write the code closrly, and this is very harmful to the beauty of the code. For example: 1) Closely: int x; cout << "PIN Lock One \n\n"; do {cout << " Enter PIN code: ";cin >> x; if (x != 31254 ) {cout << "False! \n";} while (x != 31254); cout << "True!"; return 0; 2) Beauty: int x; cout << "PIN Lock One \n\n"; do { cout << " Enter PIN code: "; cin >> x; if (x != 31254 ) { cout << "False! \n"; } } while (x != 31254); return 0;
19 Réponses
+ 10
The source code is only that - a source. From there it gets compiled and becomes the actual executable machine code, that hardly anyone (no one?) would be able to read.
It doesn't matter how the source code looks, it's got nothing to do with the program anyway. So you can do with it what you want.
However, what if you want to change the code months later, after you have forgotten many details of what you wrote there?
What if you want to add new functionality, improve an algorithm, find a bug?
What would make this most easy for you? And what would make it harder?
There are different styles how you can format code. But if you don't care about formatting at all, not only will it be hard for yourself to understand your own code (weeks or months later), but also it will be even harder for other people, for example when you're working on a team.
And yeah, some parts are confusing even if you format them well. In these cases, comments will help.
+ 10
Find your own style.
There is no absolute truth.
It is ok if you think it is ok.
But your opinion will change during the years.
add comments if you become too compact.
+ 5
I really like the compactness of the code! But then it becomes unreadable to others(
+ 4
If you like compactness that much, then you can learn Python to embrace the beauty of oneliners 👍
+ 4
Good indentation, adequate whitespace, methods/functions for repeating code blocks, not cramming too many statements in one line, relevant and succinct comments are a start.
+ 3
Read carefully what HonFu wrote!!
+ 3
That's right, you can play some serious golf with Python. 😉
+ 3
You can learn it by experience and using OOP for writing a clean code and also u can use some extension in ur Editor for help you organized ur code I think that's help u and good luck
+ 3
For Python code, make it Pythonic.
+ 2
Host: localhost:3001
Accept: text/html
Accept-Language: en-US,en;q=0.5
Connection: keep-alive
Content-Type: multipart/form-data; boundary=-1233445
Content-Length
+ 1
HonFu
Maybe not, but no one can deny the compactness of oneliners. Everything comes with a price tag, but compactness speaking, oneliners -> unbeatable 😁
+ 1
Abderrahmane Ahmam, thank you!)
0
It is really explainable about the coding.I want to add on that I am unable to take screenshot from my mac book for a couple of days.I have tried out the manual configurations as instructed by the support team to figure out this consequences regarding the https://applemacsupportnumbers.com/blog/imessage-not-working-on-mac/
Suggest what to include to resolve this issue permanently.
0
I know Python)))
0
It's all on hands-on experience. Or that's the case with me at least. 3 months ago, I had trouble creating tables in HTML. Now, I just fished creating my first website.
You can learn all you want, but I believe that the way to actually get used to it is by just starting new projects and creating codes. Experiment to what you like and how things are more comfortable for you.
For example, I like inserting my CSS right into my HTML instead of creating a .css file.
0
HonFu, thanks! It's good idea)
0
Ipang, I studied python about a year ago. There I didn't bother with this question)
I used the standard IDE. It's easy to work with syntax.
- 1
Does anyone know how to cout and cin char variables to cout all the variables together?