Patterns Simpl: Abstract Factory

This pattern describes the creation of new objects through the assembly of various interchangeable parts defined by interfaces.





ANOVA

ANOVA, short for "Analysis of Variance", is a set of mathematical models that can be used to analyze the differences among group means (ie. dispersal, or "distribution" of averages within a group).

You can easily calculate ANOVA in R as follows (when file.choose()  prompts you, you should open up a .csv dataset, in this case I used a file of crime statistics on the C:\ drive):





data = read.csv(file.choose()) #select your .csv
attach(data) #attach so you don't need to explicitly reference
data.aov = aov(district~crimedescr) #choose your x and y variables and get ANOVA
summary(data.aov) //ANOVA Summary stats
plot(data.aov)


For an (important/deeper) understanding of the numbers and formulas used to calculate an ANOVA Summary, just walk through one or all of the ANOVA reference links below.

It is relatively simple math- all you need is (1) the Hypothesis or question and (2) the data. Then using tools like R, Minitab, Mathematica, etc.- you can analyze the test results and draw conclusions and infer meaning from the data.


References:

http://www.graziano-raulin.com/tutorials/stat_comp/man1way.htm

http://www.mathandstatistics.com/learn-stats/hypothesis-testing/one-way-anova-by-hand

https://www.statmethods.net/stats/anova.html

Symmetric Encryption

Symmetric encryption is used in electronic communication as a means to:

(1): Take visible-to-humans data

(2): Scramble the plaintext data with a mathematical byte-rearranging cipher algorithm (unlockable only via a secure cryptographic key) to make it unreadable/invisible-to-humans while it’s being stored on a disk or transmitted over a network

(3): Unscramble the encrypted data with the required cryptographic key when it’s needed, making it visible-to-humans, but only for the key-holding recipient(s).

Encryption's Purpose: it enhances security by limiting data loss even if access controls are bypassed. For example, if the database host computer has vulnerabilities and a hacker obtains sensitive data, that stolen information might be useless if it is encrypted.




Reference: https://stackoverflow.com/questions/10168240/encrypting-decrypting-a-string-in-c-sharp

Patterns Simpl: Proxy

Provide a surrogate or placeholder for another object to control access to it.



The above example illustrates how a paper check is proxy for a transaction on your bank account. Another example is thumbnail images of videos on Fb or Twitter which, when you click on them, open up the more resource-hungry actual video content.

Reference: https://sourcemaking.com/design_patterns/proxy

Patterns Simpl: Iterator

Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation.

The essence of this pattern is that when implemented correctly, you can easily iterate through a collection of complex objects in a uniform manner (ie. IEnumerator, IEnumerable in .NET) without having to know the details of the type of object in the collection.





Reference: https://www.google.com/searchq=iterator+pattern+defined&oq=iterator+pattern+defined

Loan Origination

If you want a loan you should expect to wait for the origination process before approval
"Origination is the multi-step process every individual must go through when obtaining a mortgage or home loan, as well as other types of personal loans. During this process, borrowers must submit various types of financial information and documentation to a mortgage lender, including tax returns, payment history, credit card information and bank balances. Mortgage lenders use this information to determine the type of loan and the interest rate for which the borrower is eligible."-Investopedia
The loan process known as "origination" is a way for lenders to prove- to regulators and to other financial institutions (selling debt is a still a highly profitable and popular trade)- that their claim on the future interest revenue streams of a home loan or a business loan has been properly vetted and the risk has been documented and deemed acceptable and legal.

Below are the origination steps for a typical transaction. Each step must be completed before moving on to the subsequent step.

1). Pre-qualification - The first step in the loan origination process is pre-qualification. During this stage the potential borrower will receive a list of items they need to pull together to submit to the lender. This may include:
  • Employment information
  • Household income
  • Payment history
  • Bank statements
  • Tax returns
2). Loan Application - Submit an electronic or written application with loan request specifics such as amount, rate, payment schedule, etc. to the lender.

3). Application Processing - Lender reviews application and pre-screens to ensure no time is wasted on obviously unacceptable parameters.

4). Underwriting Process - Lender or a 3rd party perform rigorous manual and/or automatic review of the loan application looking such items as credit score, risk scores and other proprietary scoring criteria to ensure the loan is not only serviceable but profitable- "worth the risk" so to speak.

5). Credit Decision - Lender approves, denies or sends the application back to the potential borrower for adjustment of loan terms (a higher rate concession for instance) before reappraisal.

6). Quality Control - Last and important final check before funding goes through. This addresses the time gap between the beginning and end of loan origination which present new risks that were not known at the beginning of processing. Some lenders skip this step, unfortunately.

7). Loan Funding - Most consumer loans get their funding disbursed shortly after the loan documents are signed while second mortgage loans and business lines of credit are typically scrutinized a bit more before the borrower is issued funds.


Reference: https://www.decisivedge.com/blog/7-stages-in-loan-origination/

Patterns Simpl: Observer

The Observer defines a one-to-many relationship so that when one object changes state, the others are notified and updated automatically.



Referencehttps://sourcemaking.com/design_patterns/observer

Patterns Simpl: Adapter


Adapter pattern works as a bridge between two incompatible interfaces.




SSRS URL Access Query String Parameters


If you want to hide the parameter UI, skip to a certain page or, as in my case, need to force the "target=_blank  |_self | _parent | _top" attribute of Action URLs in your report, simply add the appropriate SSRS Qs param to the URL of your target report.

http://myrshost/reportserver?/Sales&rc:FindString=Mountain-400

http://myrshost/ReportServer?/myreport&rs:Format=PDF

http://myrshost/ReportServer?/myreport&rs:LinkTarget=_top

In my case, I was running into a scenario where my report link targets were being suppressed in FireFox and IE due to server restrictions on the content surrounding my report view. Simply applying rs:LinkTarget=_top to the report URL query string forced the necessary target=_top to override the undesired behavior. Because this took me longer than I'd think it should take to find the resolution, I have shared this tidbit in the hopes it helps save time for another developer at some point.


Reference:

https://www.w3schools.com/tags/att_a_target.asp

https://docs.microsoft.com/en-us/sql/reporting-services/url-access-parameter-reference

Check SQL Server Version from T-SQL

Windowing in SQL

When something is already very clearly explained in a concise manner, there is no need for me to take a stab at explaining it. While researching the concept of windowing (running counts, SUM ... OVER ... AS), I identified the following quote which sums up this useful SQL feature very neatly:

" A window function performs a calculation across a set of table rows that are somehow related to the current row. This is comparable to the type of calculation that can be done with an aggregate function. But unlike regular aggregate functions, use of a window function does not cause rows to become grouped into a single output rowthe rows retain their separate identities. Behind the scenes, the window function is able to access more than just the current row of the query result. "



Running count request on some of your data? No problem- just use something like this, repurposed for your own requirements:

SELECT xact_amt,
     SUM(xact_amt) OVER (ORDER BY xact_datetime) AS running_total
FROM SOME_DB.dbo.SOME_TABLE

References: 

https://community.modeanalytics.com/sql/tutorial/sql-window-functions/

https://www.postgresql.org/docs/9.1/static/tutorial-window.html

Patterns Simpl: Singleton

It is imperative to ensure atomicity (indivisible-ness) for certain "master" objects in your applications.

Singleton ensures the existence of 1 and only 1 object instance (or version/representation) of an application entity- at all times.


Some examples of Singleton:

If your program somehow winds up with 2 globally-scoped objects of a class that handles bank deposits, let's hope our account gets updated by the one with a larger dollar amount!

In Java, there is a single instance of java.lang.Runtime. If there were more than 1 language instance to interface with the Java application environment, you can see how problems would unfold.

In .NET applications, an application .config file serves as a single source of configuration values.

Log Managers should have 1 and only 1 instance, lest our log files become far too complex to sift through when we are tracking down an application issue.




Reference: https://stackoverflow.com/questions/3192095/where-exactly-the-singleton-pattern-is-used-in-real-application

C# switch case, for/foreach loops and enum

Often in the earlier years of my software development career (esp. after working solely on SQL code for a long stretch of time), I would forget the exact syntax of some commonly used C# logic routines.

I've long since memorized the exact syntax for all of these, but I'd like to help someone else out there who may need a reminder in the future.

So here is a one-stop handy reference for these 3 commonly used C# constructs:

using System;
// enum
public enum Color { Red, Green, Blue }

public class Example
{   // switch
   public static void Main()
   {
      Color c = (Color) (new Random()).Next(0, 3);
      switch (c)
      {
         case Color.Red:
            Console.WriteLine("The color is red");
            break;
         case Color.Green:
            Console.WriteLine("The color is green");
            break;
         case Color.Blue:
            Console.WriteLine("The color is blue");   
            break;
         default:
            Console.WriteLine("The color is unknown.");
            break;   
      }
   }
}

// for loop
for (int i = 1; i <= 5; i++)
{
 Console.WriteLine(i);
}

 // foreach loop
int[] fibarray = new int[] { 0, 1, 1, 2, 3, 5, 8, 13 };
foreach (int element in fibarray)
{
    System.Console.WriteLine(element);
}