Trying to create OO based bank app
posted 11 years ago
Yes it is
Yes we did but i put this check on another methods instead of setActivate() method itself.
Thanks for motivating and sharing the links. I read java ranch style guide and update my code accordingly. I have update setActivate method as below
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Campbell...Really? It is what you wrote earlier minus the == true bit. Well, as near as I could remember it, anyway.
Yes it is
Campbell....I thought we had discussed reopening a closed account, in which case that method should throw an Exception.
Yes we did but i put this check on another methods instead of setActivate() method itself.
Junilu
Don't get down on yourself or apologize for not knowing any better.....................Here's a search that brings up a few, including JavaRanch's own style
Thanks for motivating and sharing the links. I read java ranch style guide and update my code accordingly. I have update setActivate method as below
Tushar Goel
Ranch Hand
Posts: 954
4
posted 11 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
I tried to make a penalty system:
Penalty will be applicable for 2 cases:
1) If minimum balance is not maintained and this checked on Quarterly basis. I will do this later.
2) If over withdraw happened.
PenaltyRule:
Penalty will be applicable for 2 cases:
1) If minimum balance is not maintained and this checked on Quarterly basis. I will do this later.
2) If over withdraw happened.
PenaltyRule:
posted 11 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Surely the method should take the amount as an argument and be called on the Account object.
Would you have a static penalty amount in the Account class; different subclasses can have different penalties? That would make the penalty the same for all instance of a particular type of account.
Would you have a static penalty amount in the Account class; different subclasses can have different penalties? That would make the penalty the same for all instance of a particular type of account.
Tushar Goel
Ranch Hand
Posts: 954
4
posted 11 years ago
I tried to have that implemented but in this case i always getting penalty value from parent class.
I tried to have simple example as well but result is same:
It always print 5. So i can not use but i think i need to define static methods and have tooverride them
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
ould you have a static penalty amount in the Account class; different subclasses can have different penalties?
I tried to have that implemented but in this case i always getting penalty value from parent class.
I tried to have simple example as well but result is same:
It always print 5. So i can not use but i think i need to define static methods and have to
Campbell Ritchie
Marshal
Posts: 81607
593
posted 11 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
The static method is declared in class A so it uses the field in class A. Remember things static are not polymorphic. Their values are statically linked before run‑time. Things polymorphic (=instance methods) are linked dynamically at run‑time. I think it is because of static linking that they chose the keyword static.
Tushar Goel
Ranch Hand
Posts: 954
4
posted 11 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
then we cannot have static penalty amount in the Account class so that different subclasses can have different penalties because we defining all methods (deposit, withdraw etc)
or call (penalty or interest etc) from account class itself so it always uses value from the parent not subclasses.
or call (penalty or interest etc) from account class itself so it always uses value from the parent not subclasses.
Campbell Ritchie
Marshal
Posts: 81607
593
posted 11 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Have you tried a Map<Class<?>, Penalty> ?
Tushar Goel
Ranch Hand
Posts: 954
4
posted 11 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Thanks Campbell... I made below changes:
Account class I have removed other variables from the account constructor to check if implementation of penalty is correct. If its correct then other will be implemented in same way
SavingAccount One of the type of account
Account class I have removed other variables from the account constructor to check if implementation of penalty is correct. If its correct then other will be implemented in same way
SavingAccount One of the type of account
Campbell Ritchie
Marshal
Posts: 81607
593
posted 11 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
What is the access of getPenaltyMap...? Is it package‑private? I presume only the Account classes are in that package.
Tushar Goel
Ranch Hand
Posts: 954
4
posted 11 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Yes, it is package private. the package name is 'onlinebanking' and all classes except utility and test classes in it.
So should i initialize all other things like minimum balance , interest rate etc like this ?
So should i initialize all other things like minimum balance , interest rate etc like this ?
Campbell Ritchie
Marshal
Posts: 81607
593
posted 11 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
I still don't understand why minimum balance can't be a class attribute.
Tushar Goel
Ranch Hand
Posts: 954
4
posted 11 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
because like Penalty , minimum balance is also variable. Each type of account having different minimum balance. Say Saving type of account have 504 minimum
but the Salary account have 0 minimum balance etc. (Actually in real life i am having both type of accounts and they have same amount of minimum balance)
but the Salary account have 0 minimum balance etc. (Actually in real life i am having both type of accounts and they have same amount of minimum balance)
Campbell Ritchie
Marshal
Posts: 81607
593
posted 11 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
And why can't those be static fields of the individual account classes?
posted 11 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Have a look at Martin Fowler's analysis patterns for accounting: http://martinfowler.com/apsupp/accounting.pdf
It might help you see the different possibilities for organizing your code and concepts if you read through this article and Fowler's examples. One of the more interesting things about these patterns is that some things that you may think should be implemented as attributes of an object can actually be treated as "rules". For example, a minimum balance rule can be applied to some types of accounts, applied differently for others, and perhaps not at all for some.
It might help you see the different possibilities for organizing your code and concepts if you read through this article and Fowler's examples. One of the more interesting things about these patterns is that some things that you may think should be implemented as attributes of an object can actually be treated as "rules". For example, a minimum balance rule can be applied to some types of accounts, applied differently for others, and perhaps not at all for some.
Tushar Goel
Ranch Hand
Posts: 954
4
posted 11 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Campbell Do you mean this?
Thanks for sharing the link Junilu, Yes, i am checking the same and get back to the post...
Have a look at Martin Fowler's analysis patterns
Thanks for sharing the link Junilu, Yes, i am checking the same and get back to the post...
Campbell Ritchie
Marshal
Posts: 81607
593
posted 11 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
I haven't had the time to read that Martin Fowler link, but I never knew about it before.
Might be worth reading the Martin Fowler link and digesting it before doing anything else.
Might be worth reading the Martin Fowler link and digesting it before doing anything else.
Tushar Goel
Ranch Hand
Posts: 954
4
posted 11 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
I found it to be little bit difficult to understand but i am still trying to understand what Martin wanted to convey, it will take some more time.. So, please be with me...
Tushar Goel
Ranch Hand
Posts: 954
4
posted 11 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Hi, Sorry for delay. I am quite busy with personal and official commitment so could not able to spare much time.
Thanks Junilu, for the link it is very good. As per doc, i have re-modified my application... This looks like as per screenshot. Please suggest.
Thanks Junilu, for the link it is very good. As per doc, i have re-modified my application... This looks like as per screenshot. Please suggest.
FlowDiagram.PNG
General
| Destiny's powerful hand has made the bed of my future. And this tiny ad: Paul Wheaton's 16th Kickstarter: Gardening playing cards for gardeners and homesteaders https://coderanch.com/t/889615/Paul-Wheaton-Kickstarter-Gardening-playing |










