Posts by Chang Park

Testing Methods

test

These are currently popular methods to test software.

Fuzz Testing

  • Input massive invalid, unexpected, or random data(Fuzz) to find errors or vulnerabilities in the software.
  • Effective on blackbox testing

 

Stochastic Testing

  • Input random sequence of datas 

 

Model-based Testing

  • Generates meaningful test case models which can detect errors on the desired behavior.

 

Symbolic Testing

  • Replace inputs of program with symbolic variables.
  • Find the feasibility of all paths in the program.
  • Quite expensive for finding feasibility of path.
x = read();
if (x > 3) {
  y = 1;
  if (x < 0)
    y = 2;
} else y = 3;

After changing with symbolic variables, it checks the feasibility of paths. On above example, the expression (y = 2; on line #5) will not be reached.

 

Concolic Testing (Concrete + Symbolic)

  • Input actual concrete value to the program, then generate new input by changing the path condition.
  • Less expensive then Symbolic testing.

What does the symbol ‘&’ mean in C and C++?

ampersand

‘&’ symbol has two meanings in C and C++.

  • Address of Operator: returns address of a variable.
    • int a = 3;
    • printf(“%d”, a);
      • will return value of a: 3
    • printf(“%d”, &a);
      • will return address of variable a.

 

  • Bit-wise Operator &: operates on bitlevel
    • Example:table_bitwise_operator
    • int a = 13&4;
      • 13 = 1101
      • 4  =0100
      • 13&4 = 0100
      • a = 4

compileSdkVersion, minSdkVersion, and targetSdkVersion

Screen Shot 2017-11-15 at 12.37.43 AM

compileSdkVersion

  • can choose which version of Android SDK to compile the app with
  • strongly recommended to compile with latest SDK (the app can use latest API)
  • this compile SDK will not be included in the app.
  • If using support library, the version should be matched with this compileSdkVersion.

 

minSdkVersion

  • lower bound of your app (minimum version of user devices the app can be installed).
  • Google Play Store uses to determine which devices the app can be installed on.
  • If using support libraries, it should be higher than the version of the support libraries.
    • On July 2017, minSdkVersion of all support libraries were increased to 14.
  • Check DashBoard to see current distribution of all Android versions.

 

targetSdkVersion

  • Indicates which Android version the app designed for.
  • Informs that developer tested the app against target SDK version.
  • If target SDK version is lower than running API version, system enables compatible behaviors to maintain the app’s forward compatibility.

 

Tips

compileSdkVersion = targetSdkVersion = latest Android Version

  • so that the app can work on latest Android version devices.

Recommend to check latest SDK and update the app

  • Set targetSdkversion and compileSdkVersion to latest version.
  • In that way, you can check if there will be any error when running the app on newer version.
  • You don’t need to use any new features of newer versions.

Euclid’s Algorithm

Screen Shot 2017-10-02 at 10.32.14 PM

Euclid’s(Euclidean) Algorithm

  • Algorithm to find GCD of two large numbers

GCD(N1, N2), suppose that N1 is larger than N2

N1 = N2 * q1 + r1   <– Larger number divide by Small number

N2 = r1 * q2 + r2   <– Small number divide by remainder of previous

r1 = r2 * q3 + r3

…….

N = r * q + 0    <– When remainder becomes zero, then r is the GCD

 

example

  • GCD(1701,3768)
    • 3768 = 1701*2 + 366
    • 1701 = 366*4 + 237
    • 366 = 237*1 + 129
    • 237 = 129*1 + 108
    • 129 = 108*1 + 21
    • 108 = 21*5  + 3
    • 21 = 3*7 + 0       <– 3 is the GCD of 1701, 3768

 

Deprecated APIs

3678.deprecated

Deprecated

  • As Android Versions keep being updated, many APIs and their methods are being revised.
  • Even though those API’s methods get deprecated, developers can still use the methods. (but they will see compiler’s warning)
  • However, developers are discouraged to keep using these methods because it is dangerous or there is better alternatives.

 

Example

deprecated

 

Multi Core vs. Hyper-threading

multicore

Multi Core

  • Provides multiple cores in CPU.
  • Dual-core can run two different processes at a time. (quad-core = 4 cores = 4 processes at a time)

hyperthreading

Hyper-threading

  • Make one physical processing unit to two logical processing units.
  • Little bit of cheat to make it looks like two different processing unit.
  • Keep switching between two tasks, but actually one at a time.
  • Even though divided logically, CPU with hyper-threading performs better than CPU without hyper-threading.

 

Comparison

  • i5: 4 cores without hyper-threading => 4 processing units
  • i7: 4 cores with hyper-threading => 8 processing units(logically)

 

 

 

Diagrams are from UB CSE421 lecture slides (Professor: Karthik Dantu)

FDMA, TDMA, and CDMA

fdma

FDMA (Frequency Division Multiple Access)

  • Vary frequencies for each user.
  • If number of users increases, it becomes complicated.

TDMA (Time Division Multiple Access)

  • Using same frequency, divide into many time slots.
  • Allocating different time slot for each user.
  • They can speak only when their turns.

CDMA (Code Division Multiple Access)

  • Each pair communicates in different languages.
  • The mobile and base station are able to distinguish between signals transmitted simultaneously over the same frequency allocation.

Bandwidth and Frequency

bandwidth

Bandwidth (bps – bits per second)

  • Amount of data that can be transmitted in per unit time.
  • Difference between highest frequency and lowest frequency (bandwidth = high – low)

Frequency (Hertz)

  • Number of complete cycles per second.
    • ex) 60Hz = 60 cycles per second

bandwidth_frequency

  • Low Frequency Wave
    • There are many frequencies already being used by other appliances such as microwave ovens(causes interferences).
    • Small bandwidth: There is no much space not being used around it.
    • Too crowded these days.
    • Covers farther distance
    • Low speed
    • ex) Wifi (2.4GHz or 5 GHz)
  • High Frequency Wave
    • Large bandwidth: There is a lot of space not being used around it.
    • Covers short distance
    • High speed
    • ex) Millimeter Wave (60GHz)

 

Latency vs. Jitter

Screen Shot 2017-09-26 at 11.18.26 PM

Latency

  • Amount of time it takes for a packet to travel from point A to point B(or round-trip).
    • ex) Data Latency: time between a query and the result displaying on the screen.

Jitter

  • Variance in latency over time
  • If every packet takes exactly the same amout of time to travle from A to B, there is no jitter.

4 ways to handle button click

128

1. New OnClickListener in  setOnClickListener’s parameter

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Button b = (Button) findViewById(R.id.button);
        b.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Log.d("BG","1st way handling button click");
            }
        });

    }
}

2. Inner class OnClickListener

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Button b = (Button) findViewById(R.id.button);
        b.setOnClickListener(buttonListener);

    }

    private View.OnClickListener buttonListener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Log.d("BG","2nd way handling button click");
        }
    };
}

3. Implements OnClickListener interface & override onClick()

public class MainActivity extends Activity implements View.OnClickListener {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Button b = (Button) findViewById(R.id.button);
        b.setOnClickListener(this);

    }
    @Override
    public void onClick(View view) {
        switch(view.getId()){
            case R.id.button:
                Log.d("BG","3rd way handling button click");
                break;
        }
    }
}

4. Assign method at onClick attribute in layout file.

Activity class

public class MainActivity extends Activity implements View.OnClickListener {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }
    public void buttonClick(View view) {
        Log.d("BG","4th way handling button click");
    }
}

layout file

<Button
    android:text="Button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/button"
    android:onClick="buttonClick" />