heldentodd / xray-diffraction

This repository contains the code for one simulation, but eventually three are planned: bragg-law, Single Crystal Diffraction, and Powder Diffraction.
GNU General Public License v3.0
2 stars 1 forks source link

PhET code style #10

Closed pixelzoom closed 4 years ago

pixelzoom commented 4 years ago

Related to #1 (code review).

Since this is your own repository, this is somewhat irrelevant. But I thought I'd provide more info, in case you're interested.

PhET's code style is codified in phet-idea-codestyle.xml, which is a configuration file for use with IntelliJ IDEA or WebStorm. If you're using either one of those IDEs, then you can set up a "Code Style" by importing phet-idea-codestyle.xml, and the IDE will format code using that style. If you're using Sublime, there might be some other process that I'm not familiar with, and I'd refer you to one of the other PhET developers (a couple of them us Sublime). If you're using some other IDE, then you're sort of on your own.

If you want to do nothing, that's of course OK too.

heldentodd commented 4 years ago

To be honest, I've been using MS Visual Studio Code because it was free and easy to install when I was getting started. I think it's time I switch to IntelliJ IDEA or WebStorm. I'm researching them now. Any recommendation between the two?

pixelzoom commented 4 years ago

WebStorm is a subset of IDEA, and their user interfaces are almost identical. The typical advice is: Use IDEA if you're working with Java and JavaScript. Use WebStorm is you're working with JavaScript exclusively.

On the other hand, IDEA Community Edition is free for use by open-source projects. WebStorm has no such free version, and you'll need to purchase a license. So you might consider starting with IDEA Community Edition.

Regardless of which product you choose, PhET has useful information in https://github.com/phetsims/phet-info/tree/master/ide/idea, including how to set up both IDEA and WebStorm for doing PhET sim development.

heldentodd commented 4 years ago

Thank you. I was just figuring that out. It turns out all the jetBrains products are free to me since I'm an educator! I'm installing WebStorm for now since it seems a bit simpler and should meet all my current needs. I will read the PhET information first.

heldentodd commented 4 years ago

OK, I've installed imported the PhET codestyle into webstorm. I did put the hardwrap a little past 120 with a guide at 120. Other than that, I don't see the difference yet. Hopefully my code will be prettier.

pixelzoom commented 4 years ago

FYI... Code formatting is not (by default) entirely automatic in WebStorm or IDEA.

If you haven't already, you'll need to ask WebStorm to reformat your existing code. Select your xray-diffraction repository in the Project View, then choose "Code > Reformat Code" from the menu bar. You should see a dialog like this (you might want to check "Organize Imports" too):

screenshot_378

If you're using WebStorm to commit and push changes to GitHub, you can automatically format code by checking "Reformat Code" in the Commit Changes dialog, see screenshot below. Otherwise you'll need to use the "Code > Reformat Code" menu item.

screenshot_379
heldentodd commented 4 years ago

Great. I just reformatted all the code. It still looks recognizable to me. Yes, Webstorm is handling all my github pushes. I don't think I could manage it otherwise.