Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implment a userfactory, Iuser interface, 1.0 #19

Conversation

Yuhan-Ut
Copy link
Contributor

userfactory entity and add a shared interface of user and dummyuser

@Yuhan-Ut Yuhan-Ut requested a review from ScottCTD October 31, 2022 23:29

return user;
}
return null;
Copy link
Contributor

Choose a reason for hiding this comment

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

An error raise could be more appropriate here..?

Copy link
Collaborator

Choose a reason for hiding this comment

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

That is correct, but as I have mentioned earlier, if we will stick to the factory design pattern, we shouldn't have too much places to raise an error in the UserFactory class.

Copy link
Collaborator

@Lei-Tin Lei-Tin left a comment

Choose a reason for hiding this comment

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

General review

First of all, nice start and attempt to create a pull request! I think you are trying to contribute, but it might be better if we can settle a general direction before we do anything that implements new features!

Also, note that the pull request did not follow our naming convention, please use the following prefixes in both the Pull Requests and the commit messages:
[+], to denote any NEW features that are added
[*], to denote any MODIFIED features
[-], to denote any REMOVED features and/or files

Also, try to provide more details when you are submitting a pull request, try to mention what you're trying to achieve so that other members can easily follow along. The more description, the better, as the other team members can also try to understand and help.

Detailed comments

  • Convention issues
  • Not clear direction of modification
  • No purpose seen on IUser.java type
  • Not clearly following the factory method (Or maybe I am misinterpretting here)
  • Useless comment
  • Redundant code (Through copy pasting)

@ScottCTD, decide on whether we should close this pull request or not.
I personally prefer discussing on the GUI implmentation details first, so that we can write the use case based from the GUI. 👍

package billgates.entities;

public class UserFactory {
//use getShape method to get object of type shape
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure what this "getShape" is supposed to mean in the comment here

@@ -0,0 +1,5 @@
package billgates.entities;

public interface IUser {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm, what does this Interface user contain?

Usually, an interface should probably have methods that should be overridden by the classes that tries to implment it, in this case, User.java. Maybe try declaring some methods for User to implement?


public class UserFactory {
//use getShape method to get object of type shape
public IUser getUser(int id, String name, String UserType) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe the factory method doesn't work like this?

We should have a way to store the information, then call multiple generation methods to return the User types we are interested in.
E.g.

private int id = -1;
private String name = "";
private String password = "";
private int billId = -1;

public void setId(int id) { this.id = id; }
public void setName(String name) { this.name = name; }
public void setPassword(String password) { this.password = password; }

public DummyUser generateDummyUser() { return DummyUser(id, name); }
public User generateUser() { return User(id, name, password, billId); }


return user;
}
return null;
Copy link
Collaborator

Choose a reason for hiding this comment

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

That is correct, but as I have mentioned earlier, if we will stick to the factory design pattern, we shouldn't have too much places to raise an error in the UserFactory class.

return null;
}

public IUser getUser(int id, String name,String password,int billID,String UserType) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm, this looks pretty much like a "Code smell" that we are creating redundant lines by copy pasting from the above, maybe my suggestion could adhere to the factory method better.

…se those instance to generate User/dummyuser in getuser function

[*]Modify Iuser, so this interface include abstract functions supposed to return instance of user and dummyuser,(may add more function later)

[+]Add constructor for Userfactory

[+]Add quickGetUser in Userfactory, using default value stored to create desired type User

[*]cleaning up some Redundant code in UserFactory
@Yuhan-Ut
Copy link
Contributor Author

Yuhan-Ut commented Nov 6, 2022

[*]modify UserFactory so it can set or store temporary instance and use those instance to generate User/dummyuser in getuser function

[*]Modify Iuser, so this interface include abstract functions supposed to return instance of user and dummyuser,(may add more function later)

[+]Add constructor for Userfactory

[+]Add quickGetUser in Userfactory, using default value stored to create desired type User

[*]cleaning up some Redundant code in UserFactory

ps. this is modified from a history version of your branch, I am not sure if this will cover your changes, sorry for the inconvenient and this uncertainty.

@Yuhan-Ut Yuhan-Ut closed this Nov 6, 2022
@Yuhan-Ut Yuhan-Ut deleted the Brandon's_B_r branch November 19, 2022 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants