Week 6 CST 338: Multithreading

What experience do you have with UML diagrams?

I use a simplified version of UML diagramming with my AP Computer Science A students, so I am familiar with the concept of representing has-a and is-a relationships with a UML diagram.

Are they used at your workplace?

Yes, I use them with my students. I am curious to see if, when I begin my internship with Qualcomm, if they use UML diagrams or something similar.

Have you done multithreading in any language before?

I guess I have with physical computing (Arduino) without realizing it was multithreading. This is the first time I used multithreading with the full understanding of what I was actually doing. I really enjoyed learning about this concept.

Did you find Patterns to be helpful? 

Yes, I found the MVC (Model-View-Controller) pattern helpful, although I had to figure out which features of the timer to integrate in which component. Ultimately, I decided the Timer class (which extends Thread) should be declared as an inner class within the Controller class since the multithreading should occur at the Controller level.

Update your learning journal from what you experienced this week with class. 

I had a lot of fun learning about multithreading and different patterns (although the focus what just on one pattern–MVC). I felt like my approach to this week’s group assignment was much more effective. Being in charge of integrating a timer that uses its own independent thread, I decided to create a simple timer using the MVC pattern that at first only displayed to the console. Then, I worked up to using Swing to make a GUI timer with a START button. After I got this working, I worked towards integrating it with the base project that one of my partners laid out. It went pretty smoothly!

Week 5 CST 338: Java GUI with Swing

GUI is learned late in the game with Java.  Do you think this is helpful or harmful and why? I don’t think GUI necessarily has to be learned late in the game with Java. In fact, in some ways it is harmful to hold off on programming GUIs because many students want to make a “real” program like the ones that they use in their daily lives, which usually have GUIs. I feel like many young students are turned off by introductory programming classes because they do not get the sense of achievement of creating what looks like a “real” program right away. However, I do see the merits of establishing a good background of the fundamentals before approaching GUI programming.

Why do think that coding the Swing elements in Java would be more difficult compared to some other languages? I think the biggest drawback of coding Swing elements is the fact that it is quickly becoming outdated by the newer JavaFX.

Update your learning journal from what you experienced this week with class. This week our group started using Trello to better divide up and prioritize tasks. This made our teamwork stronger and the project easier to manage.

This week was also exciting because I attended HackXX at UCSD–a women-centric hackathon that took place within a 24 hour period. I arrived without a team, met some amazing people to team up with, and our project won first place!

In other news, this past week I had the opportunity to interview with Qualcomm. I went through three 30-minute back-to-back phone interviews with people from their Enterprise Project Management Office (EPMO) and then I was invited to meet with them for coffee on site. It was an amazing and welcoming experience, and I am proud to announced that I will be interning with this team over the summer for 14 weeks!

CST 338 Week 4: Polymorphism

Give an example of polymorphism and what will be inherited between classes. Polymorphism literally means many forms. In an object oriented programming language, we can make methods take different forms through dynamic or late binding. For example, we may want to represent geometric shapes in our program, such as circles, rectangles, and triangles. We could simply code these classes independently. However, we might find there are some commonalities between each of the shapes and what information we want to encode about them. For example, it may be important to find the area of each of these shapes. We can declare all these common functions into an abstract class named Shape.

Shape would declare but not define the method int calculateArea(). We would create subclasses–Circle, Rectangle, and Triangle–that extend Shape. When these subclasses extend Shape, we are making a promise that we will define calculateArea in each of these classes. However, how we calculate the area for each of these geometric shapes is going to differ based on the individual formulae for each geometric shape. Although we have the same method defined in each of our three subclasses, they take different forms. This is the notion of polymorphism.

After the learning this week, can you identify the difference between Abstract classes and Interfaces?  Be specific.

Abstract classesAbstract classes AND InterfacesInterfaces
CAN contain instance variablesCANNOT instantiate an objectCANNOT contain instance variables
Subclasses can extend ONE class (can be abstract)Subclasses can implement more than one interface
Can provide implementations for some of its methods in addition to declaring abstract methods.Declares abstract methods to be defined in subclassesInterfaces don’t provide implementations for its methods (*as of Java 8, interfaces can define default methods)

Update your learning journal from what you experienced this week with class. I enjoyed this week’s project in creating an implementation of a barcode scanner. There was a lot of information to digest in the specifications and, after doing the UML (see below), I found it particularly helpful to draw out the various pieces and how they interact, especially when it came to implementing the DataMatrix class.

Below, you can find illustrations of my approach to most of the DataMatrix class implementation:

Week 3 CST 338: Inheritance & Arrays

What is the largest multi-dimensional array that you have used? For the scope of my previous classwork, I have only used 2D arrays (matrices).

What is the largest that you think would be unwieldy and why? I would imagine that anything above a 3D array would be hard to conceptualize as we live in a three-dimensional world.  

What does inheritance do for your classes?  Have you used it in the past? How? Inheritance allows us to generalize behaviors (methods) and characteristics (instance variables) from superclasses to subclasses. Overriding methods specified in superclasses allows us to redefine the behavior more specific to a subclass. For instance, you can create a general Bird class with a speak method that returns a String “chirp”. You could extend this Bird class in a subclass called LoudBird that returns the uppercase version of this String (super.talk().toUpper()).

Update your learning journal from what you experienced this week with class. This week was my first experience using an enum. I discovered that comparing two enum types via the class’ equals method really just utilizes the == operator so comparing with the method and comparing with the operator are essentially equivalent.

Week 2 CST 338: OOP

OOP is not in all languages.  Have you used one that does not?
Previously, I have the LISP language (more specifically Common LISP or CLISP) in a course in Artificial Intelligence.

What was your experience? My experience with functional programming was fun. I learned functional programming before OOP, but I see the merits of both depending on whether or not one wishes to isolate data (classes/objects) from behaviors (methods/functions).

How extensively have you used OOP outside of the classroom? Besides my own personal projects, not a whole lot. I am currently seeking opportunities to exercise this skill more through internships.

Are you experienced with UML diagrams and do they help? I am familiar with creating UML diagrams and I believe they do help me visualize and plan out a program with many different classes and methods.

Update your learning journal from what you experienced this week with class. So far this week has been more review for me since I am familiar with OOP using Java.

CST 338 – Week 1

Have you used Eclipse before?  While I have used Eclipse before, I am more proficient with and used to Jet Brains’ IntelliJ. Therefore, I will be sticking with IntelliJ, as permitted by the professor.

What languages are you proficient in at this point? I am most proficient in Java and Python. I have some experience with C, but I would like to continue to developing my experience with it. I’d also like to spend some time with C# working with the Unity Game Engine this summer. For web development, I have experience working with JavaScript, HTML, and CSS. After having recently completed the databases course, I feel pretty proficient with MySQL as well.

What is your desired field of Computer Science at this point? Software engineering. I’d also like to maintain a presence in CS education as well.

What have you learned this week? This week primarily focused on String manipulation. Having taught AP Computer Science A for the past three years at the high school level, in which the language of study is Java, this was a review for me. However, it was necessary to adhere to the professor’s programming guidelines, so I did have to review his guidelines as well. They are not dissimilar to what I expect my current students to follow.

Weeks 7 & 8 CST 363: Map-Shuffle-Reduce and the FINAL

During Week 7, we learned about MapReduce (or Map-Shuffle-Reduce), which is used in processing large amounts of data over distributed systems.

During the mapping stage, relevant data is selected from tables on each worker node. Then, during the shuffle stage, this data is redistributed and sorted into temporary tables on each node. These two stages may be repeated any number of times, depending on the number of joins is necessary to get the desired results. Finally, we enter the reduce stage, which combines the results from every worker node sent to the controller.

While the concept of MapReduce is easy to understand, it took a while for me to wrap my head around how it should be implemented in our Python model.

However, I ultimately realized that every temporary table created in the map-shuffle stages were equivalent to SELECT subqueries in the FROM clause in MySQL. The reduce stage is equivalent to the main query that uses these subqueries and JOINs to get a desired result. Once I understood this, crafting programs that would return result tables using MapReduce became incredibly easy.

I look forward to learning more about utilizing cluster computing in the future.

Entering week 8, I only have the final to worry about and I feel extremely prepared. I have read over the questions and I have no doubt that I will do well. I have learned much during this class and I look forward to integrating my knowledge of MySQL to Web Programming this summer.

Week 6 CST 363: ACID Properties

This week we focused on the importance of maintaining the ACID properties of databases.

Before understanding what these processes entail, one must understand that a database management system’s (DBMS) transactions are comprised of a group of tasks and that a task is the minimum processing unit that cannot be further broken down.

ACID

A: Atomicity

Each transaction must be treated as an atomic unit. That is, either ALL of its tasks are executed and committed or NONE.

C: Consistency

The database must remain in a consistent state after any transaction.

I: Isolation

Concurrent transactions (e.g. in the case of multiple users accessing the database at once) should be executed as if they are the ONLY transaction in the system. Transactions should not affect one another.

D: Durabilty

The database should maintain its latest updates even if the system fails/restarts. The system should hold commits or finish updating data once the system comes back online.

I feel pretty good about solving these past two assignments. They were challenging, but doable and enjoyable. On a lighter note, here is a picture of me drawn by one of my high school computer science students:

Week 5 CST 363 – B Trees

This week we learned about B-Trees and B+ Trees as a way of more efficiently reading and writing data from a hard disk drive (HDD).

In order to understand B Trees, it is important to understand a HDD’s structure and how data is read and written to it. A HDD is split up into tracks and sectors, two vital pieces of information utilized in block addresses. In addition to track and sector, we also need to know the offset (from byte 0) on which to read/write. In order to change sector, a HDD spins; in order to change tracks a HDD’s head shifts.

Once we understand a HDD’s structure, we can understand how data is stored on it, e.g. in terms of a database. Database records are rows within a table. The amount of space a row takes up on the HDD depends on how many bytes each column has been allocated. We can then use that information to determine how many records (rows) we can store per block. Block size is usually 512 bytes, but it depends on the HDD manufacturer. For example, if we create a database that has 5 columns: eid (10 bytes), name (50 bytes), dept (10 bytes), section (8 bytes), address (50 bytes), each record in that database would have a size of 128 bytes. We could then calculate that we could store up to 4 records per block (of 512 bytes). Furthermore, we would need 25 blocks to store a database with 100 rows in it.

Considering a database of this size, in the worst case scenario, we would have to access all 25 blocks on the HDD to return the results of a query. To make this process more efficient, we use indexing. An index is used to store a key (a column from the database) and a pointer to the record on the HDD. This reduces the number of blocks to access during search because the size of the index (key and pointer) will be smaller than the size of an entire record. Smaller size, means less blocks of storage and less blocks to search through. If our indexes, for instance, only take up 16 bytes, we would only need 4 blocks to store the indices for 100 records. This means, at maximum, we would only need to access 5 blocks (all 4 index blocks and the block to which the pointer points to).

But simple indexing is not the most efficient. Sparse indexing builds upon simple dense indexing by adding higher level layers of indexing on the lower level index table previously mentioned. These higher level indexes point to index blocks in the lower level table. Therefore, a single index could point to a block of 32 indexes. This is the notion of multilayer indexing.

Once we understand multilevel indexing, we can understand M-Way Trees. The m  stands for the degree and represents the maximum number of children a node can have. The number of keys a parent node can have is m – 1. To use M-Way Trees/Search, our data should be sorted from smallest to largest. A Binary tree is an example of an m-way Tree with a degree of 2. M-way search trees have child pointers associated with each of their keys. In multidimensional indexes, they also have record pointers. This is the node structure of a B-Tree.

B-Trees are M-Way trees with rules. These rules include:

  1. Each node should have m/2 children before filling the next node.
  2. Root can have minimum 2 children
  3. All lead nodes must be at the same level
  4. Creation process is bottom-up

The difference between a B-Tree and a B+ Tree is that B+ Trees do not have record pointers from every node — just the lead modes. Therefore, each key in a node is also copied on to one of the leaves. Leaves are linked together like a linked list. The leaf level is a dense index. The upper node levels are spare indices. For an illustration of how B+ trees work, use the B+ Tree Simulator!

Week 4 CST 363

This has been a busy week! We had a midterm and the final iteration of our DB/WI project due. I have learned quite a bit about the utility of data warehouses to create simple and understandable systems for end users to query a database. I have gained insight for how to continue with my Staff Directory System at my school site and how to structure different relational databases to the extract data into a central data warehouse to create different applications for different user purposes.

There are so many needs that my school has — teacher location, monitoring student success, preventing teacher burnout, ensuring equity — and I am beginning to see how an OLAP system can be applied to the decision making processes that make a school successful.