• Post Reply Bookmark Topic Watch Topic
  • New Topic

My design for a core Java Banking Application  RSS feed

 
Ravi Desigan
Ranch Hand
Posts: 37
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

This application is for pure Java, without JDBC access, etc.

I have several objects to meet with the scenario of simulating a bank, which allows to add account, delete account, view account, perform individual account operations (deposit, withdraw, money transfer, balance inquiry), etc.

The objects include -
                BANK
                CUSTOMER
                ACCOUNT

Since the Bank has many customers and each customer can have accounts in several banks, there is a M:M scenario. So I am going to have the Customer Object store the Bank references in an arraylist and have the Bank store the customers it has in an arrayList.

Why I chose to post a question here is because of the following reason :

I do not like the Customer object having internal private instance variables for multiple accounts. This is because when a customer visits the bank and performs any of deposit, withdraw, money transfer or balance inquiry, then I have to provide for these function calls at Bank level, then again implement them at Customer level.

Therefore, I am going to implement my Bank object have an arraylist of customers to be each 'associated with' an array of accounts. The account array will be 2 in size and will each be capable of holding 0 to 2 elements (Saving, Checking accounts).

Therefore, the following private variable will be declared in my Bank object:



Now, when the customer (an object) comes to the Bank to deposit, he will have a string value represent the Bank, the account name and a double value containing amount.

Then, the BankImpl, the service class, will get a reference to the Bank stored within the customer object via the String bank name value, and then, on this Bank reference, will 'get' the account[] associated with the customer from the internal arraylist.



The following is the custBank.deposit function:




And so also for the other methods - withdraw, money transfer, etc....

The purpose is to avoid coding a redirect from Bank to Customer object for the above functions, which the bank can handle itself, without the customer needing to know it.

My questions:
------------------


1. Is my above design correct/good/feasible for large scale application?
2. Does the Customer object strictly need to be aware of its accounts, which I am trying to avoid in the above scenario?
3. Are there better, alternative design solutions?
4. Is there provision for declaring abstract classes, interfaces, etc in the above design?

Thank you.
 
Campbell Ritchie
Marshal
Posts: 56553
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ravi Desigan wrote:. . . is a M:M scenario. So I am going to have the Customer Object store the Bank references in an arraylist and have the Bank store the customers it has in an arrayList. . . . I do not like the Customer object having internal private instance variables for multiple accounts. . . .
That suggests you are not designing your application. You are trying to code it before you have finished the design.
1. Is my above design correct/good/feasible for large scale application?
No
2. Does the Customer object strictly need to be aware of its accounts, which I am trying to avoid in the above scenario?
That sounds like, “Is it all right for the customers not to know how many accounts they have and how much money is in each?”

3. Are there better, alternative design solutions?
Yes.

4. Is there provision for declaring abstract classes, interfaces, etc in the above design? . . .
At this stage that is a meaningless question. Finish the design and it should become obvious whether you can use interfaces and abstract classes.
 
Junilu Lacar
Sheriff
Posts: 11493
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ravi Desigan wrote:
1. Is my above design correct/good/feasible for large scale application?
...
3. Are there better, alternative design solutions?

I agree with Campbell, no, this is not a good design for a large scale application.  A large-scale application would involve layering and distribution of components on multiple hosts with capabilities to accept transactions from multiple sources and thousands of transactions occurring concurrently. Your ideas are designed to run as one process with a single user. Plus the classes you planned out and the relationships and interactions are trying too hard to model the real world. That's a trap and it never ends well.

There are alternative design solutions but it depends on how much time you have to devote to the work. I suggest you curb your enthusiasm and either pare down the scope of your project and requirements or look for something else that's more manageable by a single person. Large-scale applications aren't built overnight or in a month even. In fact, real-world large-scale banking applications could have thousands of people working them over several years and are so large and complex that it's impossible for any single person to know everything about the system.
 
Junilu Lacar
Sheriff
Posts: 11493
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As an alternative, you could write a program that simulates an ATM.
 
Ravi Desigan
Ranch Hand
Posts: 37
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell and Junilu,

Thank you very much for your helpful replies.

Yes, there is an alternative ATM project with good amount of documentation on the requirements. As Junilu said, I am going to invest my time on that.

Thank you very much again.
 
Campbell Ritchie
Marshal
Posts: 56553
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's a pleasure
 
Carey Brown
Saloon Keeper
Posts: 3323
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The objects include -
                BANK
                CUSTOMER
                ACCOUNT

Since the Bank has many customers and each customer can have accounts in several banks, there is a M:M scenario.

I think you are over thinking what it means to be a "customer". I am a customer of bank "A" and also bank "B" but as far as bank "A" is concerned I am customer "12345" and at bank "B" I'm customer "5551212". So "customer" in your model should be from the bank's perspective thus eliminating the M:M issue.

If you wanted to take it to the next extreme you'd need something like a Person who has a list of establishments that they have accounts at. The key to this list would be an establishment ID and that establishment's customer ID. This would still not be an M:M problem.
 
Ravi Desigan
Ranch Hand
Posts: 37
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Carey Brown wrote:
The objects include -
                BANK
                CUSTOMER
                ACCOUNT

Since the Bank has many customers and each customer can have accounts in several banks, there is a M:M scenario.

I think you are over thinking what it means to be a "customer". I am a customer of bank "A" and also bank "B" but as far as bank "A" is concerned I am customer "12345" and at bank "B" I'm customer "5551212". So "customer" in your model should be from the bank's perspective thus eliminating the M:M issue.

If you wanted to take it to the next extreme you'd need something like a Person who has a list of establishments that they have accounts at. The key to this list would be an establishment ID and that establishment's customer ID. This would still not be an M:M problem.


Ha.. ha... I enjoyed this answer! Made me rethink my OP very much! Certainly, you are right! If I think the more comprehensive scenario would be to include all Banks that someone is a customer of, then surely, as you say, such as situation could be extended to every institution that he/she is a member of! Such as schools/colleges/hospitals and what not!

Therefore, when I code this bank application, I will limit my choice to just 1 bank. Thank you for the insight.
 
Ravi Desigan
Ranch Hand
Posts: 37
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also I want to appreciate the true and correct design flaw, as per my design in the OP.

That is, same customer object cannot be reused for locating his presence amongst various banks. (yes, the only way to lookup the customer ideally is through his ID which cannot be the same between various banks.)

Thanks for this!
 
Ravi Desigan
Ranch Hand
Posts: 37
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry about my English in the above post, I posted reply in a hurry.
 
Carey Brown
Saloon Keeper
Posts: 3323
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ravi Desigan wrote:Sorry about my English in the above post, I posted reply in a hurry.

Not a problem. Glad I could help.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!