Another hot tip is make the class partial so your editor script can be in a different file.
// in file named Foo.cs
public partial class Foo : MonoBehaviour
{
private int bar;
}
// in a different file name Foo.Editor.cs
public partial class Foo
{
[CustomEditor(typeof(Foo))]
public class FooEditor: Editor
{
public override void OnInspectorGUI()
{
var script = (Foo)target;
script.bar = EditorGUILayout.IntField("Bar:", script.bar);
}
}
}