Showing posts with label banks. Show all posts
Showing posts with label banks. Show all posts

Wednesday, 2 March 2016

Node JS - Project 2 - Bank Account

Hello! I'm back again!

In this project we want to be able to do the following things:

  1. Create new bank accounts
  2. Search for bank accounts
  3. Deposit and withdraw amounts
  4. Check account balances

In lesson 18 of The Complete Node JS Developer Course (check here for an update on my progress so far), the task was set out, and we had to go away and work through it independently. Lesson 19 is a step-by-step guide to a complete solution.

Getting Started


In lesson 18 we did the ground work for the project. This is the code we created to set the foundations:



We have created an empty array that will store all of the accounts, and there are some methods (or functions) that we can call on to make deposits, withdrawals, and check balances.

The Task


In the instructions we are told to create a new function called 'createAccount'. It's going to take an account object and store it in an array of accounts.

Each account object needs a 'balance', which should be a number, and a 'username', which should be a string.

The second function we're going to create is called 'getAccount' and takes one argument, which is 'username'.

The Solution


createAccount

We start with the 'createAccount' function. It accepts one argument, which is the object 'account'.


Basically, what we've done there is create a function, 'createAccount', that takes an account object and pushes it into the accounts array.

Now we can work on our 'getAccount' function.

getAccount


Within the function, we use forEach to iterate over the accounts and find any matching account.

We create a new variable called 'matchedAccount' within the function, which will store the account if a match is found.

Within the forEach, we want to check if the username of the account matches any of our accounts, so we create an if statement to do that. We then save the account to the matchedAccount variable that we created earlier.

We then return the matched account.

Re-cap


So, here's what we have so far:


Underneath that, we are going to create a new account.

New Account


We create a new account and save it to a variable. We then set that variable equal to createAccount, which is a function that expects an account object. The new object is created right within the function! Awesome! We give it a username and a balance. Yay!


Let's start as we mean to go on, and make a deposit into our account.

Deposit


We'll be using that function we created earlier on lines 19 to 21. Here's a quick reminder:


Here's how we make a deposit into our new account:


Lovely!

We use console.log to keep track of things, and we do this with the getBalance function (also created earlier on lines 27 to 29):


Withdrawal


Another old'un, but a good'un (on lines 23 to 25):


And here's how we use it:


getBalance makes another appearance :)

getAccount

The star of the show!

Create a new variable called existingAccount, and set it equal to getAccount, with the username passed in. It accepts one argument, a string.


It will return the balance of the my account!

We can test it out by creating another account for Pinky.


To make sure that everything is working as it should do, we can log out both of the accounts that we have created so far, by simply doing the following:


That will log them both out to the terminal, with their usernames and balances. Beautiful!

Finally, let's create a new variable for the Pinky's account (like we did with my account earlier):


Here's a re-cap of that code from line 31 onwards:


And it's all done! Until the next time :)

Tuesday, 24 November 2015

Hedge Funds Join the Clamour for Tech Talent. Old World, New Tricks. Can They Keep Up?


Software technology is developing at lightning speed, and everyone wants a piece.

Tech companies are doing whatever they can to entice and retain the best software engineers, but they are not the only ones vying for this specialist talent. Many non-tech companies have jumped on the bandwagon too. Rather than outsource their software projects to specialist software companies, they are bringing programmers in-house to create their own bespoke software systems.

The demand for programmers is growing faster than supply.

There's an interesting article by Robin Wigglesworth in the FT which highlights the interests of another party in this clamour for tech talent. Historically, engineers, physicists and mathematicians have been recruited by financial institutions, but they are now shifting their gaze to computer scientists.

Software engineers already make great money, and according to a survey of 10,000 programmers conducted by Stack Overflow, 90% of them would accept an offer that pays 10% less than their current salary if the new opportunity fit their other criteria. So, money alone will not attract computer scientists to the shiny skyscrapers of finance.


When the programmers were asked if they would ever decline an offer based on their perception of the office quality or management structure, 59.7% of them said yes! When the money is already good, people shift their expectations to more qualitative issues.

The working environment offered by the likes of Google or Uber (companies mentioned in the FT article) are so vastly different from those of financial institutions that they may as well be in different dimensions of space and time. For financial institutions to be able to attract and retain software engineers, the whole culture would have to change.

Amongst the other things cited in the Stack Overflow survey as being important to programmers, there was a clear emphasis on the team, management, autonomy, creativity, being aligned with the company's products and services, and the company's goals. The financial markets, when put in that context, are not so attractive. It's not an impossible task, however, and people often do different jobs at different points in their lives for different reasons.

The comments made on the FT article are fascinating! Many of the people commenting seem to come from a tech / programming background, and they have some great insights.


A theme that seems to emerge from the comments is about the worthiness of the cause. Programmers have a great talent, and they could be using it to further society in more meaningful ways, rather than the simple pursuit of money. Money is great, and I like it, but the pursuit of wealth can be all the more satisfying when it is the by-product of great ideas, as opposed to the end goal in and of itself.

We could all benefit from a more collaborative approach to technology and programming. Just think about the massive advances in medicine, farming, sustainable technology that could be possible! Things are moving so fast that businesses, schools and governments are still playing catch-up when it comes to software technology. It's doubtful that we will ever reach a plateau, but we can all jump aboard for the ride.

A whole new way of working is needed. Society will either shape those changes or respond to them, but traditional ways of doing things are becoming more alien to what is needed in today's world - or rather - tomorrow's world.

References:

Hedge funds poach computer scientists from Silicon Valley, by Robin Wigglesworth, Financial Times US markets editor (22/11/2015)

Joel Spolsky's Guide to Standing Out & Attracting Top Talent