-
Recent Posts
Recent Comments
- R.P. Churchill on TWSL Series 07: Discovery and Data Collection
- R.P. Churchill on A Simulationist’s Framework for Business Analysis: Round Two
- LN on A Simulationist’s Framework for Business Analysis: Round Two
- R.P. Churchill on Starting to Learn About the Java Memory Model
- R.P. Churchill on Multidimensional Arrays in Javascript
Categories
Meta
April 2024 M T W T F S S 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
Category Archives: Software
Post University CIS Advisory Board Meeting 2018
Today I participated in the annual meeting of the advisory committee for the undergraduate CIS department at Post University in Waterbury, CT (as I have on previous occasions). Most of the students participate in the program remotely, which is a … Continue reading
A Simple Discrete-Event Simulation: Part 91
I started thinking about the design of processes that require resources and realized there are a lot of ways I could go with this, so I thought I’d back up and think it through in writing. Let’s begin with a … Continue reading
A Simple Discrete-Event Simulation: Part 90
This evening I attended the DC IIBA Meetup on the subject of process mapping, which is obviously an area in which I have some experience. Since I’ve reached a natural break in writing about pure business analysis subjects I’m going … Continue reading
Cross-Browser Compatibility: My Website Animation, Part 2
Digging into yesterday’s problem more I found references to a procedure called font boosting, and a number of ways to potentially control it or turn it off. Font boosting has to do with making the text larger by default on … Continue reading
Cross-Browser Compatibility: My Website Animation, Part 1
The introductory animation on my website has been a source of annoyance for me for some time. It never scaled properly on Android devices. It worked fine on every other browser I was able to test (IE, Edge, Firefox, Chrome, … Continue reading
Generic Sensor API
On Wednesday I attended a Meetup hosted by Pittsburgh Code & Supply. This particular event was hosted by Brian Kardell (see also here) and was formally titled with the prefix “[Chapters Web Standards]:” I think to indicate that the talk … Continue reading
Posted in Software
Tagged Generic Sensor API, instrumentation, sensors, Web API, Web standards
Leave a comment
fredfredfred
Example code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
package main.com.bankapp; /** * Created by rpchurchill on 9/3/2015. */ public class bankAccountClass { //HashSet<Object> accountList; String firstName, lastName; double balance; private EmailNotifier emailNotifier; private daoBankAcctDatabase bankDB; public bankAccountClass() { setBalance(0.0); setFirstName(""); setLastName(""); } public bankAccountClass(String first, String last, double initbal) { setFirstName(first); setLastName(last); setBalance(initbal); } public bankAccountClass(String first, String last, double initbal, EmailNotifier emailNotify) { setFirstName(first); setLastName(last); setBalance(initbal); emailNotifier = emailNotify; } public bankAccountClass(String first, String last, double initbal, daoBankAcctDatabase acctDB) { setFirstName(first); setLastName(last); setBalance(initbal); bankDB = acctDB; } public String getFirstName() { return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } public void setLastName(String lastName) { this.lastName = lastName; } public void setBalance(double balance) { this.balance = balance; } public String getLastName() { return lastName; } public double getBalance() { return balance; } public void deposit(double depamount) { setBalance(getBalance() + depamount); } //TODO figure out hoow to throw and test for excepptions public void withdrawal(double wdamount) { //throws acctOverdraftException { if (wdamount > getBalance()) { // throw new acctOverdraftException() emailNotifier.sendMessage("fred", "barney", "wilma", "betty"); } else deposit(-wdamount); } public double sumDeposits(int days) { double[] deposits; double sum = 0.0; deposits = bankDB.getDepositsFromDatabase(days); for (double d : deposits) { sum += d; } return sum; } } |
Example tests for above:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
package test.unit.com.bankapp; import junit.framework.Assert; import main.com.bankapp.EmailNotifier; import main.com.bankapp.bankAccountClass; import main.com.bankapp.daoBankAcctDatabase; import org.junit.Test; import static org.mockito.Mockito.*; /** * Created by rpchurchill on 9/3/2015. */ public class bankAccountClassTest { @Test //does account exist public void acctExists() { bankAccountClass account = new bankAccountClass("Fred","Flintstone",0.0); Assert.assertNotNull(account); Assert.assertEquals(0.0, account.getBalance(), 0.00000001); Assert.assertEquals("Fred", account.getFirstName()); Assert.assertEquals("Flintstone",account.getLastName()); } @Test public void acctDepositSimple() { bankAccountClass account = new bankAccountClass("Fred","Flintstone",0.0); account.deposit(100.0); Assert.assertEquals(account.getBalance(), 100.0, 0.00000001); } @Test public void acctDepositCents() { bankAccountClass account = new bankAccountClass("Fred","Flintstone",0.0); account.deposit(43.42); Assert.assertEquals(account.getBalance(), 43.42, 0.00000001); } @Test public void acctDepositModifyExisting() { bankAccountClass account = new bankAccountClass("Fred","Flintstone",0.0); account.deposit(250.24); account.deposit(100.0); Assert.assertEquals(account.getBalance(), 350.24, 0.00000001); } @Test public void acctDepositModifyExisting1() { bankAccountClass account = new bankAccountClass("Fred","Flintstone",100.0); account.deposit(25); Assert.assertEquals(account.getBalance(), 125.0, 0.00000001); account = new bankAccountClass("Fred","Flintstone",23.42); account.deposit(100); Assert.assertEquals(account.getBalance(), 123.42, 0.00000001); account = new bankAccountClass("Fred","Flintstone",12.41); account.deposit(55.00); Assert.assertEquals(account.getBalance(), 67.41, 0.00000001); account = new bankAccountClass("Fred","Flintstone",67.89); account.deposit(10.25); Assert.assertEquals(account.getBalance(), 78.14, 0.00000001); } @Test public void acctDepositModifyMultiple() { bankAccountClass account = new bankAccountClass("Fred","Flintstone",0.0); account.deposit(45.45); account.deposit(50.00); account.deposit(12.73); Assert.assertEquals(account.getBalance(), 108.18, 0.00000001); } @Test public void acctWithdrawal() { bankAccountClass account = new bankAccountClass("Fred","Flintstone",100.0); //try { account.withdrawal(50.00); //} //catch (acctOverdraftException e) {} Assert.assertEquals(account.getBalance(), 50.0, 0.00000001); } @Test public void acctWithdrawalMultiple() { bankAccountClass account = new bankAccountClass("Fred","Flintstone",45.45); //try { account.withdrawal(25.00); //} //catch (acctOverdraftException e) {} account.deposit(50.00); //try { account.withdrawal(10.25); //} //catch (acctOverdraftException e) {} account.deposit(12.73); Assert.assertEquals(account.getBalance(), 72.93, 0.00000001); } /* @Test //(expected = acctOverdraftException.class) public void acctWithdrawalOverdraft() { bankAccountClass account = new bankAccountClass("Fred","Flintstone",25.00); //try { account.withdrawal(50.00); //} //catch (acctOverdraftException e) {} } */ @Test public void acctEmailSentOnOverdraft() { EmailNotifier mockEmailNotifier = mock(EmailNotifier.class); bankAccountClass account = new bankAccountClass("Fred","Flintstone",25.00,mockEmailNotifier); account.withdrawal(50.00); verify(mockEmailNotifier).sendMessage("fred", "barney", "wilma", "betty"); Assert.assertEquals(account.getBalance(), 25.00, 0.0000001); } @Test public void acctDepositsFromDatabase() { daoBankAcctDatabase mockDB = mock(daoBankAcctDatabase.class); //List<Double> deposits = new ArrayList<Double>(); //deposits.add(11.12); //deposits.add(22.23); //deposits.add(33.34); double [] deposits = new double[3]; deposits[0] = 11.12; deposits[1] = 22.23; deposits[2] = 33.34; doReturn(deposits).when(mockDB).getDepositsFromDatabase(30); bankAccountClass account = new bankAccountClass("Fred","Flintstone",0.00,mockDB); //verify(mockDB.getDepositsFromDatabase(30)); Assert.assertEquals(account.sumDeposits(30),66.69,0.0000001); } } |
“What is a Mutex?”
This was the first question I was asked in an interview sometime around 2006. I didn’t know the answer, which is exceptionally annoying because I’d been using them for years without knowing what they were called. This is a danger … Continue reading
Posted in Software
Tagged inter-process communication, internal architecture, real-time computing
Leave a comment
Course Wrap-up: JavaScript: Understanding the Weird Parts
I finished plowing though Anthony Alicea’s Udemy course, JavaScript: Understanding the Weird Parts, and found it to be quite satisfying. To answer the question left hanging yesterday, yes, the course did describe more details of prototype inheritance, and it did … Continue reading
JavaScript Inheritance: A Form of Composition
Lectures 53 through 56 of JavaScript: Understanding the Weird Parts discuss more about the creation and manipulation of objects under the hood. I’d seen different aspects of this material previously, which gave me a different take on how to build … Continue reading
Posted in Software
Tagged composition, discrete-event sim project, inheritance, JavaScript, memory management, OOP in JS, Underscore.js
Leave a comment