1 June 2016

R programming class week 4

Some skills about debugging.

The Sys.time() for get time and profiler that can help find out the time distribution for programs.

Working on the assignment 3 . and there are several useful method learned.

subset: get subset from a vector

min: min value for a vector

which: used in dataframe to get a logical vector, with expression.

 

 

try to start the the Visual Studio Code. that seems promising.

 

 

Misc,

the fried

30 May 2016

Finished the Week 3 of R programming.

Learned several split-and-combine functions

lapply : return a list;

sapply : simplified result of lapply

apply: apply functions on the matrix, directions (rows or columns) could be chosen.

tapply: subsetting the vectors and then apply functions on each sub group and get result.

mapply : apply funcitons on multiple inputs.

split: split a matrix according to subsetting index. combine with lapply or sapply it could achieve effects as tapply(but potentially more powerful)

Work:

Tried butterknife

Evening

finished the interface pattern

And read the composite design pattern.

The composite pattern suits for tree structure.

There are three classes:

Component : the base class for composite and leaf

Composite: a concrete component class that ‘contains’ multiple component classes which could be either composite or leaf.

leaf: just a concrete component class

There are also two ways implementing it:

transparent: all methods are in base class – Component

safe : some methods are in composite class, avoid accessed through leaf.

26 May 2016

Work

some practice of numberpicker, I could not find a way to programmatically change the font size of numberpicker. There is a way to do it fixed, that is create a custom numberpicker and assign the text size to the EditText. I have to say the “iterating children view” method is the first time come across me and I was really like “Ah! We could do that ?!”

Evening

Forget an access token for my instagram tutorial.

THat is the reason why the “grams” variable in index page keeps producing error “forEach() function on undefine” .

Practice the basic R concepts with Swirl().

Things goes fine, I just start wondering what the exact type language is R.

25 May 2016

Morning

The R control syntax,

if… else…

while…

for loop and several usage of for loop

repeat, next, break

Work

Some practice in ‘themes’ and ‘styles’.

Evening

design pattern- adapter.

Adapter is built to allow two different interfaces could communicate with each other without changing the interfaces.

R programming :

Function :

  • Arguments Matching
  • Arguments could be matched by position or name
  • lazy evaluation for arguments
  • ‘…’ arguments

Scoping:

  • From function defined environment to parent environments
  • Until to global environment
  • Continues to packages in order.
  • lexical scoping Vs. dynamic scoping

 

Misc

Introduced Gordon, because T is leaving.

24 May 2016

Morning

start the R programming of the Data scientist’s tool box.

Work tips

About changing the font for entire application,

There are some promising ways.

A stackoverflow answer introduced  a method implemented by reflection.

Calligrahpy is a library that could be imported from gradle directly.

Evening

End the design pattern about the factory.

Start the abstract factory. It seems that abstract factory is for factory with complex products.

20 May 2016

Morning

Data scientist toolbox Week3.

Basically just introduced the principles of experiment. And also some important terminologies.

Work

Change fonts of android turns out to be a tricky task.

Calligraphy turns out to be a workable library but it does not work with our one.

Some other tricks does not apply also. I need to investigate what is the reason for that.

Java Reflection is an interesting function. Maybe it is time to read the thinking in java.

Evening

Beside the simple factory pattern. there is also factory pattern

The simple factory pattern is constrained as that addition of new product need to modify the factory class.

So, an abstract factory class could be introduced and every new product would has its corresponding factory sub-class.

 

 

19 May 2016

Morning

Some follow up of the data scientist tool box.

Reviewed some git and markdown

Work

Spend some time on TST.

And installed ToDoList, StarUML. Such things seems being able to improve my efficiency.

I start feeling my old code is not abstract enough.

 

Evening

Simple factory pattern:

A factory class that receive a concrete product class identifier and return an object of that specific product sub-class.

18 May 2016

Morning

Start the data scientist tool box.

Just the overview starters. Not something very useful. take it as English practice.

 

Work

After reads some Design patterns, I really feels that there are a lot of flaws in my code and I really should improve the codes.

Evening

Single Responsibility principle,

a class should only work for only thing

open-closed principle.

Open for expanding, close for modification.

Liskov substitution principle (LSP).

All base class should be able to be replaced by its a sub-class.

 

 

 

17 May 2016

Morning Train

Watched first several videos from basic statistics of Coursera.

They introduced more variable types to me. Previously I only know there are “nominal” and “ordinal”. And they introduced “interval” and “ratio” which belongs to a “quantitative” category. other than that there is not some thing new.

Work

Android:

<Activity> in the Manifest defines the information related with a specific activity.

<meta-data> defines several meta- information about a specific attributes which could belongs to “Activity”.

How does startActivityforResult() get the result back in onActivityResult()?

Using setResult(Intent intent). where the intent could contain a bundle which contains the complex information.

Evening Train

Builder type. is  about building complex objects.

There are  “Product” class defines what variables should product have.

abstract “Builder” class defines what a concret builder should have.

concret “builder” class that could be used directly to populate several variables in “Product”

And there could be a “Controller” controls the flow of building  by calling the methods belongs to “Builder” class.

 

 

 

16 May 2016

 Morning Train

Reviewed the linear algebra part of deep learning.

Work

Looked at the android-wizard library and created two new custom “pages” – number picker page and time picker page.

Evening Train

Continues with the Design pattern

The decorator pattern is about adding new functions to specific component without introducing new complexities.

The basic idea is :

An decorator will get an original component as its initializer and then add more functions under the name of some “super method”.

Then this decorator is still being a “component” so that everything is “just like original and transparent.”

Or this decorator could be a “concrete decorator” which will allow client side use the “new add functions” specifically with the cost of “simplicity”.