Skip to content
This repository has been archived by the owner on Mar 5, 2023. It is now read-only.

Simplify FXML files #231 #356

Merged
merged 10 commits into from
Apr 3, 2017

Conversation

MightyCupcakes
Copy link
Contributor

@MightyCupcakes MightyCupcakes commented Mar 23, 2017

Closes #231

Propsed merge commit message:

The FXML files are deeply nested with unnecessary parent elements.
There are also multiple conflicting coding styles that exists within
the same file.

This makes the files hard to read and navigate. Furthermore, the
differing coding styles in the same file makes the whole file
inconsistent.

Let's modify the FXML files as follows:
    * Change indentations to 2 spaces in all FXML files as these files
      tends to have deep nesting
    * Remove all star imports and reorder the rest in alphabetical
      order in all FXML files
    * Remove unnecessary parent elements to reduce the nesting in
      all FXML files
    * Remove all unnecessary CSS style sheet imports except those
      in MainWindow.fxml
    * Wrap long attributes into multiple lines and add white spaces
      in MainWindow.fxml to improve readability
    * Remove unneeded minwidth attribute in StatusBarFooter.fxml
    * Remove unnecessary HBox element in PersonListCard.fxml
    * Standardize inset attributes order declarations in all FXML files
    * Add a space before closing slash in self-closing tags in all FXML files
    * Standardize height and width declarations in all FXML files to use
      only integer values 

@mention-bot
Copy link

@MightyCupcakes, thanks for your PR! By analyzing the history of the files in this pull request, we identified @yl-coder, @m133225 and @pyokagan to be potential reviewers.

@CanIHasReview-bot
Copy link

v1

@MightyCupcakes submitted v1 for review.

(📚 Archive)

Checkout this PR version locally
git fetch https://github.com/se-edu/addressbook-level4.git refs/pr/356/1/head:BRANCHNAME

where BRANCHNAME is the name of the local branch you want to fetch this PR to.

Copy link
Contributor

@chao1995 chao1995 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[v1 1/6]

FXML files tends to have rather deep nesting and arrowhead style code.
Having 4 spaces as indentation makes the code rather hard to read as
most elements are aligned to the right.

tends -> tend
rather hard -> harder

Copy link
Contributor

@chao1995 chao1995 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[v1 2/6]

The imports in the FXML files are arranged in a haphazard order and contains
star imports.

contains -> contain

Let's refactor the imports in all FXML files to follow the project's coding
standards

missing period in the end of sentence

Copy link
Contributor

@chao1995 chao1995 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[v1 3/6] commit title can be changed to remove unnecessary children tags

Copy link
Contributor

@chao1995 chao1995 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[v1 3/6]

The FXML file wraps all its children between a pair of children tags.
Some FXML files wrap the contents between a pair of children tags.

This is unnecessary in the JavaFX as all panes has a default property of
children.
in the JavaFx -> in JavaFx
all panes has -> all panes have

Let's remove the children tags and remove the unnecessary nesting in the files
Let's remove those unnecessary children tags.

</children>

<StatusBar styleClass="anchor-pane" fx:id="syncStatus" />
<StatusBar styleClass="anchor-pane" fx:id="saveLocationStatus" GridPane.columnIndex="1" nodeOrientation="RIGHT_TO_LEFT" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minWidth="0.0" is removed, but seems like it is not related to this commit.

Copy link
Contributor

@chao1995 chao1995 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[v1 4/6]

commit title can be changed to just:

PersonListCard.fxml: remove unnecessary nesting

PersonListCard.fxml contains deep nesting with unnecessary parent elements.

with -> due to

Let's refactor PersonListCard.fxml with the following changes:
* Remove unnecessary parent elements to reduce nesting
* Add white spaces between siblings to increase readability

Some white spaces are unnecessary imo. Maybe try not to do two things in one commit. Let's make this commit only remove unnecessary nesting. Do refactor in a separate commit if needed.

Copy link
Contributor

@chao1995 chao1995 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[v1 5/6]: Similar suggestions to [v1 4/6].
[v1 6/6] see below.

@@ -1,15 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import java.net.URL?>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this removal be done in [v1 2/6] or is this caused by removing stylesheet tag? As I saw `personlistcard.fxml" actually gets rid of this import before removing the stylesheet tag in [v1 5/6]

Copy link
Contributor

@PierceAndy PierceAndy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[v1 3/6] Commit message:
Missing period at end of last sentence.

Copy link
Contributor

@PierceAndy PierceAndy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[v1 4/6]
It makes more sense to get rid of the unnecessary tags in the previous commit. This commit can focus on improving readability using whitespace.

Copy link
Contributor

@PierceAndy PierceAndy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[v1 5/6]
Same as previous.

Copy link
Contributor

@PierceAndy PierceAndy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[v1 6/6] Commit message:

  • The various UiParts FXML files import the same DarkTheme and extension CSS files.
  • at runtime

<padding>
<Insets top="5.0" bottom="5.0" left="10.0" right="10.0"/>
<Insets top="10" bottom="10" left="10" right="10" />
Copy link
Contributor

@PierceAndy PierceAndy Mar 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change unrelated to [v1 5/6] commit.

Copy link
Contributor

@PierceAndy PierceAndy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[v1 2/6] Commit message:
Coding style could be in list form (short, easier to read)
This is not compliant with the coding style used in the rest of the project:
* Imports should be arranged in alphabetical order.
* Avoid using star imports as they load more modules than necessary.

@MightyCupcakes MightyCupcakes force-pushed the 231-simplify-fxml-files branch 6 times, most recently from 580e9e5 to ffd64bd Compare March 25, 2017 05:07
@CanIHasReview-bot
Copy link

v2

@MightyCupcakes submitted v2 for review.

(📚 Archive) (📈 Interdiff between v1 and v2)

Checkout this PR version locally
git fetch https://github.com/se-edu/addressbook-level4.git refs/pr/356/2/head:BRANCHNAME

where BRANCHNAME is the name of the local branch you want to fetch this PR to.

@damithc
Copy link
Contributor

damithc commented Apr 1, 2017

@yl-coder any inputs?

@damithc
Copy link
Contributor

damithc commented Apr 1, 2017

@MightyCupcakes can you propose a merge commit message too?

Copy link
Contributor

@yl-coder yl-coder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. No objection on the extra space.

Copy link
Contributor

@damithc damithc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. A few minor nits only.

<AnchorPane VBox.vgrow="NEVER" fx:id="resultDisplayPlaceholder" styleClass="anchor-pane-with-border" minHeight="100" prefHeight="100" maxHeight="100">

<AnchorPane VBox.vgrow="NEVER" fx:id="resultDisplayPlaceholder" styleClass="anchor-pane-with-border"
minHeight="100" prefHeight="100" maxHeight="100">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When line wrapping, indentation should be twice the normal? e.g. Java uses 8 spaces when line wrapping.

@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commit 2 message:

Let's refactor the imports in all FXML files to follow the project's
coding standards.

This statement promises too much. How about this?

Let's refactor ... to fix the two problems given above.

@@ -9,7 +9,6 @@
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
<StatusBar styleClass="anchor-pane" fx:id="syncStatus" minWidth="0.0"/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commit 6 message:
Both StatusBar -> Both StatusBar elements?
both status bar will > both status bars will

@MightyCupcakes MightyCupcakes force-pushed the 231-simplify-fxml-files branch 5 times, most recently from 9cea693 to 8380bc8 Compare April 2, 2017 07:56
@CanIHasReview-bot
Copy link

v6

@MightyCupcakes submitted v6 for review.

(📚 Archive) (📈 Interdiff between v5 and v6)

Checkout this PR version locally
git fetch https://github.com/se-edu/addressbook-level4.git refs/pr/356/6/head:BRANCHNAME

where BRANCHNAME is the name of the local branch you want to fetch this PR to.

<AnchorPane fx:id="mainPane">
<TextArea fx:id="resultDisplay" editable="false" styleClass="result-display"/>
</AnchorPane>
xmlns:fx="http://javafx.com/fxml/1">
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double indentation for line wrapping here too

FXML files tend to have rather deep nesting and arrowhead style code.
Having 4 spaces as indentation makes the code harder to read as
most elements are aligned to the right.

Let's modify the FXML files to use 2 spaces instead.
The imports in the FXML files are arranged in a haphazard order and
contain star imports.

This is not compliant with the coding style used in the rest of the
project that states:
    * Imports should be arranged in alphabetical order.
    * Avoid using star imports as they load more modules than necessary.

Let's refactor the imports in all FXML files to fix the two problems
given above.
Some FXML files wrap the contents between a pair of children tags.

This is unnecessary in JavaFX as all panes has a default property of
children.

Let's remove these unnecessary children tags.
The various UiParts FXML files import the same DarkTheme and
extension CSS files.

This is not necessary as MainWindow loads all UiParts by adding their
various components as a child of the AnchorPane placeholders. Since
the AnchorPane placeholder is part of MainWindow, all its children
will also be styled by the stylesheets declared in MainWindow.

Let's remove the stylesheets declarations from the various UiParts FXML
files.
MainWindow consists of multiple placeholders contained in a VBox all
clumped together. Furthermore, some elements have multiple attributes,
causing it to exceed the character limit for a line.

This makes the file very hard to read.

Lets refactor MainWindow.fxml as follows:
    * Add white spaces between sibling elements to improve
      readability.
    * Wrap long elements to a new line.
Both StatusBar elements sets their minimum width to zero.

This is unnecessary as both status bars will have some content in
runtime.

Let's remove this unneeded attribute.
The id and name label in PersonListCard is wrapped around two parent
HBoxes.

This is not necessary.

Let's remove the unneeded child HBox.
The various FXML files use insets declarations in order to add
inner padding within elements. The declaration is not consistent as
some elements declare the padding size using integer values
while others use declare using double values.

Let's standardize all insets declarations as follows:
    * Insets should declare paddings using the CSS convention
      (i.e top right bottom left)
    * All padding sizes are declared in integer values.
The various FXML files contains self closing tags that are closed by
appending a slash at the end of the element. Some of these tags prepend
a space before the slash while others do not.

Let's standardize all self closing tags to prepend a space before the
closing slash.
The various FXML elements declares their height and width using
both integer and double values.

Let's standardize all height and width declarations to use integer
values
@CanIHasReview-bot
Copy link

v7

@MightyCupcakes submitted v7 for review.

(📚 Archive) (📈 Interdiff between v6 and v7)

Checkout this PR version locally
git fetch https://github.com/se-edu/addressbook-level4.git refs/pr/356/7/head:BRANCHNAME

where BRANCHNAME is the name of the local branch you want to fetch this PR to.

@damithc
Copy link
Contributor

damithc commented Apr 3, 2017

@MightyCupcakes

Regarding the proposed commit message:

  • This statement is too general Re-factor the codes to follow a consistent coding style
  • Given the nature of this PR, may be the merge commit message can be an itemized list of the 10 refactorings done, somewhat similar to the CIHR commit summary, but with a tiny bit more details.

@MightyCupcakes
Copy link
Contributor Author

@damithc update proposed merge commit message

@damithc damithc merged commit 22397f3 into se-edu:master Apr 3, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants