Skip to main content
Code Review

Return to Answer

Commonmark migration
Source Link

Good on you for taking on a project to learn, and even more for posting it here! Keep it up, you'll go far.

Make use of methods

#Make use of methods LikelyLikely what you mean when you say modular, you should be using more methods. Right now pretty much all your logic is in your start method. Not only would using methods increase both maintainability and readability it would also make adding features more streamlined thus making your entire program both more flexible and extensible.

Here's a small example of where you can do this: This if series where you currently check whether a deleted character is an operator:

if(charToDelete == '+' || charToDelete == '-'
 || charToDelete == '*' || charToDelete == '/'){
 operatorAlreadyPressed = false;
}

You can extract this into the following:

private boolean isOperator(char potentialOperator) {
 return potentialOperator == '+' || potentialOperator == '-' ||
 potentialOperator == '*' || potentialOperator == '/';
}

This way you reduce your if condition to isOperator(charToDelete), You could even have a method that calls this one and alters operatorAlreadyPressed as a result. Try to see where else you can add more methods to your code!

Use Lambda expressions

#Use Lambda expressions UnlessUnless you're explicitly constrained in which runtime you may use, consider replacing your anonymous inner classes with lambda expressions.

e.g. Everywhere you use the setOnAction method, like the following:

numberButtons.get(counter).setOnAction(new EventHandler<ActionEvent>(){
 public void handle(ActionEvent e){
 // logic
 }
 }

You can write it simply:

numberButtons.get(counter).setOnAction(e -> {
 // logic
});

Read more about Lambda Expressions, from Oracle, here & for a general rundown of Java 8 features I recommend this.

Interface Intuitiveness

##Interface Intuitiveness TheThe 'C' button typically acts as a clear option on calculator. Yours currently acts as a backspace and you actually lack a clear option altogether. In addition, after any result is displayed any proceeding input appends to the end of the previous result. Lastly, I would organize things to be more like a natural calculator. It's fairly horizontal and there's quite a lot of space that just doesn't do anything. Good work on the flexible sizing however.

Remove commented code.

###Remove commented code. CommentedCommented is dead code. 'Nuff said.

On XML & CSS

###On XML & CSS AA large appeal of JavaFX is the possibility to use CSS stylings and the ability to use XML to separate your model / view from your application logic. There is even software, like Scene Builder, that feature GUI whose use generates the desired XML for an interface. Here's a simple example using both CSS and XML facilitated by Scene Builder to design an interface.

Good on you for taking on a project to learn, and even more for posting it here! Keep it up, you'll go far.

#Make use of methods Likely what you mean when you say modular, you should be using more methods. Right now pretty much all your logic is in your start method. Not only would using methods increase both maintainability and readability it would also make adding features more streamlined thus making your entire program both more flexible and extensible.

Here's a small example of where you can do this: This if series where you currently check whether a deleted character is an operator:

if(charToDelete == '+' || charToDelete == '-'
 || charToDelete == '*' || charToDelete == '/'){
 operatorAlreadyPressed = false;
}

You can extract this into the following:

private boolean isOperator(char potentialOperator) {
 return potentialOperator == '+' || potentialOperator == '-' ||
 potentialOperator == '*' || potentialOperator == '/';
}

This way you reduce your if condition to isOperator(charToDelete), You could even have a method that calls this one and alters operatorAlreadyPressed as a result. Try to see where else you can add more methods to your code!

#Use Lambda expressions Unless you're explicitly constrained in which runtime you may use, consider replacing your anonymous inner classes with lambda expressions.

e.g. Everywhere you use the setOnAction method, like the following:

numberButtons.get(counter).setOnAction(new EventHandler<ActionEvent>(){
 public void handle(ActionEvent e){
 // logic
 }
 }

You can write it simply:

numberButtons.get(counter).setOnAction(e -> {
 // logic
});

Read more about Lambda Expressions, from Oracle, here & for a general rundown of Java 8 features I recommend this.

##Interface Intuitiveness The 'C' button typically acts as a clear option on calculator. Yours currently acts as a backspace and you actually lack a clear option altogether. In addition, after any result is displayed any proceeding input appends to the end of the previous result. Lastly, I would organize things to be more like a natural calculator. It's fairly horizontal and there's quite a lot of space that just doesn't do anything. Good work on the flexible sizing however.

###Remove commented code. Commented is dead code. 'Nuff said.

###On XML & CSS A large appeal of JavaFX is the possibility to use CSS stylings and the ability to use XML to separate your model / view from your application logic. There is even software, like Scene Builder, that feature GUI whose use generates the desired XML for an interface. Here's a simple example using both CSS and XML facilitated by Scene Builder to design an interface.

Good on you for taking on a project to learn, and even more for posting it here! Keep it up, you'll go far.

Make use of methods

Likely what you mean when you say modular, you should be using more methods. Right now pretty much all your logic is in your start method. Not only would using methods increase both maintainability and readability it would also make adding features more streamlined thus making your entire program both more flexible and extensible.

Here's a small example of where you can do this: This if series where you currently check whether a deleted character is an operator:

if(charToDelete == '+' || charToDelete == '-'
 || charToDelete == '*' || charToDelete == '/'){
 operatorAlreadyPressed = false;
}

You can extract this into the following:

private boolean isOperator(char potentialOperator) {
 return potentialOperator == '+' || potentialOperator == '-' ||
 potentialOperator == '*' || potentialOperator == '/';
}

This way you reduce your if condition to isOperator(charToDelete), You could even have a method that calls this one and alters operatorAlreadyPressed as a result. Try to see where else you can add more methods to your code!

Use Lambda expressions

Unless you're explicitly constrained in which runtime you may use, consider replacing your anonymous inner classes with lambda expressions.

e.g. Everywhere you use the setOnAction method, like the following:

numberButtons.get(counter).setOnAction(new EventHandler<ActionEvent>(){
 public void handle(ActionEvent e){
 // logic
 }
 }

You can write it simply:

numberButtons.get(counter).setOnAction(e -> {
 // logic
});

Read more about Lambda Expressions, from Oracle, here & for a general rundown of Java 8 features I recommend this.

Interface Intuitiveness

The 'C' button typically acts as a clear option on calculator. Yours currently acts as a backspace and you actually lack a clear option altogether. In addition, after any result is displayed any proceeding input appends to the end of the previous result. Lastly, I would organize things to be more like a natural calculator. It's fairly horizontal and there's quite a lot of space that just doesn't do anything. Good work on the flexible sizing however.

Remove commented code.

Commented is dead code. 'Nuff said.

On XML & CSS

A large appeal of JavaFX is the possibility to use CSS stylings and the ability to use XML to separate your model / view from your application logic. There is even software, like Scene Builder, that feature GUI whose use generates the desired XML for an interface. Here's a simple example using both CSS and XML facilitated by Scene Builder to design an interface.

replaced http://codereview.stackexchange.com/ with https://codereview.stackexchange.com/
Source Link

Good on you for taking on a project to learn, and even more for posting it here! Keep it up, you'll go far.

#Make use of methods Likely what you mean when you say modular, you should be using more methods. Right now pretty much all your logic is in your start method. Not only would using methods increase both maintainability and readability it would also make adding features more streamlined thus making your entire program both more flexible and extensible.

Here's a small example of where you can do this: This if series where you currently check whether a deleted character is an operator:

if(charToDelete == '+' || charToDelete == '-'
 || charToDelete == '*' || charToDelete == '/'){
 operatorAlreadyPressed = false;
}

You can extract this into the following:

private boolean isOperator(char potentialOperator) {
 return potentialOperator == '+' || potentialOperator == '-' ||
 potentialOperator == '*' || potentialOperator == '/';
}

This way you reduce your if condition to isOperator(charToDelete), You could even have a method that calls this one and alters operatorAlreadyPressed as a result. Try to see where else you can add more methods to your code!

#Use Lambda expressions Unless you're explicitly constrained in which runtime you may use, consider replacing your anonymous inner classes with lambda expressions.

e.g. Everywhere you use the setOnAction method, like the following:

numberButtons.get(counter).setOnAction(new EventHandler<ActionEvent>(){
 public void handle(ActionEvent e){
 // logic
 }
 }

You can write it simply:

numberButtons.get(counter).setOnAction(e -> {
 // logic
});

Read more about Lambda Expressions, from Oracle, here & for a general rundown of Java 8 features I recommend this.

##Interface Intuitiveness The 'C' button typically acts as a clear option on calculator. Yours currently acts as a backspace and you actually lack a clear option altogether. In addition, after any result is displayed any proceeding input appends to the end of the previous result. Lastly, I would organize things to be more like a natural calculator. It's fairly horizontal and there's quite a lot of space that just doesn't do anything. Good work on the flexible sizing however.

###Remove commented code. Commented is dead code. 'Nuff said.

###On XML & CSS A large appeal of JavaFX is the possibility to use CSS stylings and the ability to use XML to separate your model / view from your application logic. There is even software, like Scene Builder, that feature GUI whose use generates the desired XML for an interface. Here's a simple example example using both CSS and XML facilitated by Scene Builder to design an interface.

Good on you for taking on a project to learn, and even more for posting it here! Keep it up, you'll go far.

#Make use of methods Likely what you mean when you say modular, you should be using more methods. Right now pretty much all your logic is in your start method. Not only would using methods increase both maintainability and readability it would also make adding features more streamlined thus making your entire program both more flexible and extensible.

Here's a small example of where you can do this: This if series where you currently check whether a deleted character is an operator:

if(charToDelete == '+' || charToDelete == '-'
 || charToDelete == '*' || charToDelete == '/'){
 operatorAlreadyPressed = false;
}

You can extract this into the following:

private boolean isOperator(char potentialOperator) {
 return potentialOperator == '+' || potentialOperator == '-' ||
 potentialOperator == '*' || potentialOperator == '/';
}

This way you reduce your if condition to isOperator(charToDelete), You could even have a method that calls this one and alters operatorAlreadyPressed as a result. Try to see where else you can add more methods to your code!

#Use Lambda expressions Unless you're explicitly constrained in which runtime you may use, consider replacing your anonymous inner classes with lambda expressions.

e.g. Everywhere you use the setOnAction method, like the following:

numberButtons.get(counter).setOnAction(new EventHandler<ActionEvent>(){
 public void handle(ActionEvent e){
 // logic
 }
 }

You can write it simply:

numberButtons.get(counter).setOnAction(e -> {
 // logic
});

Read more about Lambda Expressions, from Oracle, here & for a general rundown of Java 8 features I recommend this.

##Interface Intuitiveness The 'C' button typically acts as a clear option on calculator. Yours currently acts as a backspace and you actually lack a clear option altogether. In addition, after any result is displayed any proceeding input appends to the end of the previous result. Lastly, I would organize things to be more like a natural calculator. It's fairly horizontal and there's quite a lot of space that just doesn't do anything. Good work on the flexible sizing however.

###Remove commented code. Commented is dead code. 'Nuff said.

###On XML & CSS A large appeal of JavaFX is the possibility to use CSS stylings and the ability to use XML to separate your model / view from your application logic. There is even software, like Scene Builder, that feature GUI whose use generates the desired XML for an interface. Here's a simple example using both CSS and XML facilitated by Scene Builder to design an interface.

Good on you for taking on a project to learn, and even more for posting it here! Keep it up, you'll go far.

#Make use of methods Likely what you mean when you say modular, you should be using more methods. Right now pretty much all your logic is in your start method. Not only would using methods increase both maintainability and readability it would also make adding features more streamlined thus making your entire program both more flexible and extensible.

Here's a small example of where you can do this: This if series where you currently check whether a deleted character is an operator:

if(charToDelete == '+' || charToDelete == '-'
 || charToDelete == '*' || charToDelete == '/'){
 operatorAlreadyPressed = false;
}

You can extract this into the following:

private boolean isOperator(char potentialOperator) {
 return potentialOperator == '+' || potentialOperator == '-' ||
 potentialOperator == '*' || potentialOperator == '/';
}

This way you reduce your if condition to isOperator(charToDelete), You could even have a method that calls this one and alters operatorAlreadyPressed as a result. Try to see where else you can add more methods to your code!

#Use Lambda expressions Unless you're explicitly constrained in which runtime you may use, consider replacing your anonymous inner classes with lambda expressions.

e.g. Everywhere you use the setOnAction method, like the following:

numberButtons.get(counter).setOnAction(new EventHandler<ActionEvent>(){
 public void handle(ActionEvent e){
 // logic
 }
 }

You can write it simply:

numberButtons.get(counter).setOnAction(e -> {
 // logic
});

Read more about Lambda Expressions, from Oracle, here & for a general rundown of Java 8 features I recommend this.

##Interface Intuitiveness The 'C' button typically acts as a clear option on calculator. Yours currently acts as a backspace and you actually lack a clear option altogether. In addition, after any result is displayed any proceeding input appends to the end of the previous result. Lastly, I would organize things to be more like a natural calculator. It's fairly horizontal and there's quite a lot of space that just doesn't do anything. Good work on the flexible sizing however.

###Remove commented code. Commented is dead code. 'Nuff said.

###On XML & CSS A large appeal of JavaFX is the possibility to use CSS stylings and the ability to use XML to separate your model / view from your application logic. There is even software, like Scene Builder, that feature GUI whose use generates the desired XML for an interface. Here's a simple example using both CSS and XML facilitated by Scene Builder to design an interface.

added 1130 characters in body
Source Link
Legato
  • 9.9k
  • 4
  • 50
  • 118

Good on you for taking on a project to learn, and even more for posting it here! Keep it up, you'll go far.

#Make use of methods Likely what you mean when you say modular, you should be using more methods. Right now pretty much all your logic is in your start method. Not only would using methods increase both maintainability and readability it would also make adding features more streamlined thus making your entire program both more flexible and extensible.

Here's a small example of where you can do this: This if series where you currently check whether a deleted character is an operator:

if(charToDelete == '+' || charToDelete == '-'
 || charToDelete == '*' || charToDelete == '/'){
 operatorAlreadyPressed = false;
}

You can extract this into the following:

private boolean isOperator(char potentialOperator) {
 return potentialOperator == '+' || potentialOperator == '-' ||
 potentialOperator == '*' || potentialOperator == '/';
}

This way you reduce your if condition to isOperator(charToDelete), You could even have a method that calls this one and alters operatorAlreadyPressed as a result. Try to see where else you can add more methods to your code!

#Use Lambda expressions Unless you're explicitly constrained in which runtime you may use, consider replacing your anonymous inner classes with lambda expressions.

e.g. Everywhere you use the setOnAction method, like the following:

numberButtons.get(counter).setOnAction(new EventHandler<ActionEvent>(){
 public void handle(ActionEvent e){
 // logic
 }
 }

You can write it simply:

numberButtons.get(counter).setOnAction(e -> {
 // logic
});

Read more about Lambda Expressions, from Oracle, here & for a general rundown of Java 8 features I recommend this.

##Interface Intuitiveness The 'C' button typically acts as a clear option on calculator. Yours currently acts as a backspace and you actually lack a clear option altogether. In addition, after any result is displayed any proceeding input appends to the end of the previous result. Lastly, I would organize things to be more like a natural calculator. It's fairly horizontal and there's quite a lot of space that just doesn't do anything. Good work on the flexible sizing however.

###Remove commented code. Commented is dead code. 'Nuff said.

###On XML & CSS A large appeal of JavaFX is the possibility to use CSS stylings and the ability to use XML to separate your model / view from your application logic. There is even software, like Scene Builder, that feature GUI whose use generates the desired XML for an interface. Here's a simple example using both CSS and XML facilitated by Scene Builder to design an interface.

Good on you for taking on a project to learn, and even more for posting it here! Keep it up, you'll go far.

#Use Lambda expressions Unless you're explicitly constrained in which runtime you may use, consider replacing your anonymous inner classes with lambda expressions.

e.g. Everywhere you use the setOnAction method, like the following:

numberButtons.get(counter).setOnAction(new EventHandler<ActionEvent>(){
 public void handle(ActionEvent e){
 // logic
 }
 }

You can write it simply:

numberButtons.get(counter).setOnAction(e -> {
 // logic
}

Read more about Lambda Expressions, from Oracle, here & for a general rundown of Java 8 features I recommend this.

##Interface Intuitiveness The 'C' button typically acts as a clear option on calculator. Yours currently acts as a backspace and you actually lack a clear option altogether. In addition, after any result is displayed any proceeding input appends to the end of the previous result. Lastly, I would organize things to be more like a natural calculator. It's fairly horizontal and there's quite a lot of space that just doesn't do anything. Good work on the flexible sizing however.

###Remove commented code. Commented is dead code. 'Nuff said.

###On XML & CSS A large appeal of JavaFX is the possibility to use CSS stylings and the ability to use XML to separate your model / view from your application logic. There is even software, like Scene Builder, that feature GUI whose use generates the desired XML for an interface. Here's a simple example using both CSS and XML facilitated by Scene Builder to design an interface.

Good on you for taking on a project to learn, and even more for posting it here! Keep it up, you'll go far.

#Make use of methods Likely what you mean when you say modular, you should be using more methods. Right now pretty much all your logic is in your start method. Not only would using methods increase both maintainability and readability it would also make adding features more streamlined thus making your entire program both more flexible and extensible.

Here's a small example of where you can do this: This if series where you currently check whether a deleted character is an operator:

if(charToDelete == '+' || charToDelete == '-'
 || charToDelete == '*' || charToDelete == '/'){
 operatorAlreadyPressed = false;
}

You can extract this into the following:

private boolean isOperator(char potentialOperator) {
 return potentialOperator == '+' || potentialOperator == '-' ||
 potentialOperator == '*' || potentialOperator == '/';
}

This way you reduce your if condition to isOperator(charToDelete), You could even have a method that calls this one and alters operatorAlreadyPressed as a result. Try to see where else you can add more methods to your code!

#Use Lambda expressions Unless you're explicitly constrained in which runtime you may use, consider replacing your anonymous inner classes with lambda expressions.

e.g. Everywhere you use the setOnAction method, like the following:

numberButtons.get(counter).setOnAction(new EventHandler<ActionEvent>(){
 public void handle(ActionEvent e){
 // logic
 }
 }

You can write it simply:

numberButtons.get(counter).setOnAction(e -> {
 // logic
});

Read more about Lambda Expressions, from Oracle, here & for a general rundown of Java 8 features I recommend this.

##Interface Intuitiveness The 'C' button typically acts as a clear option on calculator. Yours currently acts as a backspace and you actually lack a clear option altogether. In addition, after any result is displayed any proceeding input appends to the end of the previous result. Lastly, I would organize things to be more like a natural calculator. It's fairly horizontal and there's quite a lot of space that just doesn't do anything. Good work on the flexible sizing however.

###Remove commented code. Commented is dead code. 'Nuff said.

###On XML & CSS A large appeal of JavaFX is the possibility to use CSS stylings and the ability to use XML to separate your model / view from your application logic. There is even software, like Scene Builder, that feature GUI whose use generates the desired XML for an interface. Here's a simple example using both CSS and XML facilitated by Scene Builder to design an interface.

added 289 characters in body
Source Link
Legato
  • 9.9k
  • 4
  • 50
  • 118
Loading
added 289 characters in body
Source Link
Legato
  • 9.9k
  • 4
  • 50
  • 118
Loading
deleted 1 character in body
Source Link
Legato
  • 9.9k
  • 4
  • 50
  • 118
Loading
Source Link
Legato
  • 9.9k
  • 4
  • 50
  • 118
Loading
lang-java

AltStyle によって変換されたページ (->オリジナル) /