Structured Text File: 6 Exercises

After we learned the classes and methods related to the File I/O, we did 6 exercises to test our understanding. In this blog post, I will focus on these six exercises and my reflection about them.

Questions and Answers

Q1

Write a program that reads a file that contains only one line; output all the characters, one character per line.1

Here is the result of the program. I used the method from Scanner Class, useDelimiter(), to separate every character. Since the question asks me to print all the characters line by line, I used the delimiter “”.

Q2

Write a program that reads a file and counts how many lines it contains.

2

I think this problem is simpler than the previous one, since what I need to do is construct a while loop using “inputStream.hasNextLine()”, while using a integer variable to record the time of looping.

Q3

Write a program that reads a text file that contains a grade (for instance, 87) on each line. Calculate and print the average of the grades.

  1. 3

This problem requires a similar algorithm as the previous one, as we need to use

inputStream.hasNextLine()

Then, we put the each line in a variable, and add them together. However, there is a problem because the data type of the lines is String. Therefore, we can use wrapper class, Integer, to convert the String into integer data type. This is what I used:

item = Integer.parseInt(line);

Also, we need a try catch block to handle the error “InputMismatchException.”

Q4

Design a class that checks if the contents of two text files are identical and, if not, determines how many lines are different. //Lines are different if they differ in one or more characters.//Test your class with a client program, which contains main() method

4

To deal with this seeming difficult problem, I first create a Scanner for the two InputStreams, which are the two files. Then, I use the a while loop to count the same lines. I wrote three conditions: The first has next line; the second has next line; they are equal (represented by a boolean variable declared in advance). Here are the codes for this part:

int number = 0;
int a = 0;
int b = 0;
boolean equal = true;
while (input1.hasNextLine() && input2.hasNextLine() && equal){
    String garbage1 = input1.nextLine();
    String garbage2 = input2.nextLine();
    if(garbage1.equals(garbage2)){
        number ++;
    } else {
        a += 1;
        b += 1;
        equal = false;
    }
}

To read the text line by line, I used garbage variables to accept the data in each line while counting the number of lines. After finding the number of same lines, I used two while loops to count lines that are left out, which gives me the number of different lines.

Q5

In Internet programming, programmers receive parameters via a query string, which looks like a String with fields separated by the “&” character. Each field typically has a metadata part and a data part separated by the equal sign. An example of a query string is: “first=Mike&last=Jones&id=mike1&password=hello”

Using Scanner at least once, parse a query string and output each field on a different line after replacing the equal sign with a colon followed by a space. For example, for the preceding sample query string, the output should be: first: Mikelast: Jonesid: mike1password: hello

5

The aim is to re-format the line. So I must use delimiter to separate the line with “&” and then “=”. I chose to use ArrayList to gather all the lines, since it is easy for me to go through each item it the list. Firstly, I use the delimiter “&” and put each item in an ArrayList named “info.” Then, here is what I got for the second delimiter:

int i = 0;
for (String item: info){
    Scanner parse2 = new Scanner(item);
    parse2.useDelimiter("=");
    info.set(i,"" + parse2.next() + ": " + parse2.next());
    i++;
}

I initialise an integer i control the number of the loop. Also, it provides me index so that I can use the method “.set(index,argument)” this for each loop. In the argument, I formatted the line in my own way.

Q6

Design a class that attempts to determine the relative frequency of each letter by reading a file and keeping track of the number of times each of the 26 English alphabet characters appears.Also provide methods, such as highestFrequencyCharacter and lowestFrequencyCharacter.Test your class with a client program.

6

This program is a little tricky. Firstly, to separate all the characters, I used delimiter “” again. I create a method which takes the file name and a character as arguments. Inside the method, I use while loop and an integer variable to record the number of times that the character appears. When I get the character, I use charAt(0) for each line I separated using delimiter.

 

Real Life Implication

There are many real life implications of these exercises. The first program can be improved to be able to count characters. The second one is useful because it can count line in a file. The third can be used by teachers to calculate the average grade out of a file that records all the grades. The fifth one can be used when we need to unpack some messages that have particular pattern. It’s very useful for changing the format of some documents. The six one can be used in cryptography, since determining the frequency of characters can help us discover the plain code of a cypher.

Conclusion

By doing these exercises, we solidified our knowledge about File I/O. Also, I am inspired by these programs so that I can create some similar programs to solve my daily-life problems. It’s so much fun to create programs that do complicated jobs!

File I/O

Last week, we began to learn about the input and output of file. Before this topic, the information stored temporarily in the program will disappear as we close the program. However, now we can read from and write to files to get or store information. In this blog, I will explain classes and methods related to File I/O topic, and I will share a mini project I made using what I have learned about file I/O.

Stream Objects

A stream is an object that enables data to flow from the program to file or to I/O devices. When the data flow from the program to the file, the stream object is an output stream, as we write to the file. Contrasty, as data flow from the file to the program, the stream is an input stream.

Actually, we have already made use of input and output stream, when we use the following codes:

System.out.print("PrintToTheScreen");
Scanner input = new Scanner(System.in);

Text Files

Since we are reading and editing files, we should clarify that what we called “files” are usually text files. Different from binary files, which can be understand by computers, data in text files are encoded with ASCII coding scheme.

Dealing with text files, we need to import classes from java.io. As these codes show:

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.PrintWriter;
import java.io.FileNotFoundException;

Not only do we need the input and output stream classes, but also we need PrintWriter class to write to files.

The last line is used to deal with possible errors. We can use try catch to catch the error and send an error message.

try{
    inputStream = new Scanner(new FileInputStream("../example.txt"));
} catch(FileNotFoundException e){
    System.out.println("Failed to find the file.");
    System.exit(0);
}

This process is necessary for the program to run. The picture below shows what will happen if we do not deal with this possible error.

Picture1.png

Input Stream and Scanner

As this picture shows, we need to put the Scanner method in the try catch block. I have learned Scanner before, but we only used System.in, which is to get data from the keyboard. This time, we use the inputStream as the argument of the creation of the Scanner object. In side the parenthesis next to “Scanner,” we create a new file input stream. We put the name of the file there. The “../” means that the “example.txt” is located in the parent folder. If we use only “example.txt”, it will be in the same folder as the program.

Similar to what we have learned about Scanner, we can use methods like “.hasNext(), inputStream.next(), inputStream.nextLine(), inputStream.nextInt()”, etc. Every time we use .next…(), the Scanner will keep on searching, like a pointer, and it will never come back.

PrintWriter

For writing to files, we use FileOutputStream class as well as PrintWriter class which is used to write transmit data to the outputStream and to the file.

If we want to write to a txt file named “example” in the same folder of the program, we can use the following codes:

outputStream = new PrintWriter(new FileOutputStream("example.txt"));

This line is in the try catch block, before it, we need to declared the variable Output stream:

PrintWriter outputStream = null;

Then, we can write text to the file. Here is an example:

Picture3

This is quite similar to the System.out.print() method. We just need to change the former part to the PrintWriter object.

However, there might be a problem using the previous codes. If there is already a file named “example.txt,” this program will create a new file and replace the existing one, so the data in the original file will be deleted. If we want to append to a file, we can add a boolean argument into the parenthesis after “FileOutputStream”. Here’s the code:

Picture4

We put a another argument, “true,” after the file name, we can append to the file.

It’s important to note that after we finished using the input or output stream, we should close them, in another word, we clear the data stored temporarily in the streams. We use these codes (the two objects are created before):

 outputStream.close();
 inputStream.close();

Mini Project – Popular Names

After we learned file I/O topic, we did a mini project. That is, to write a program that can show the inputted name’s rank (according to popularity) and the number of people who are using the name. We are provided two files: One includes the boy names in the order of popularity and the number of people using them; the other is for girl names.

To create this program, I started using array, scanner, and input stream to store all the information in these two files.

4

Also, I used while loop and a int to access all the lines in the two files and write them to the array.

Then, I let the user to input the name, and then I used toLowerCase() method to make the problem more usable. I used subString() method to differentiate the names and the numbers. Then, I output them in a way that make sense. Also, I used a boolean variable to check if the name is found.

5

Here is the result:

3

This project shows my understanding and skill about file I/O. As what I said in the last post, I will continue on the Library project and implement file I/O. I believe the library project will be more easy to use after I used file I/O.

Smart Library Project

As mentioned in the last blog post, I finished this little project! This blog post will explain the features as well as some of the core ideas in this program.

The Class Diagram

Picture1.png

Here is the class diagram of my Smart Library Project. This time I finished both the Student class and Book class, as well as the main menu created in the Library class.

To interact in with the users, I used a main method in Library Class. I will talk through the menus and functions in the rest of my blog.

Terminal Window

5

As we call the main method, this window appears, and the main menu shows up. I did not write this menu in the main method, in fact, my main menu is very short. I did this by creating the menus in the library class.

This slideshow requires JavaScript.

Here is the class card of the three classes. For some methods, I made them private, since they are only going to be called with the class. For example, private methods that return student object and book object are very useful. Since the parameter is ID, you can input an ID and then the methods will return the actual objects. Then, we can use dot notation to call the methods of the Student class and Book class.

6

Here is the student menu. In this menu, we can add student, remove student, search students, which are functions that I discussed in my previous blog post.

7

This is also discussed in my previous blog post. Actually, the student class resembles the Book class. The difference is that there is an ArrayList in the Student class, which contains the books that one student borrows.

8

This is the Borrow/Return Menu, which I added a last. This is more difficult than the previous menus since it include borrow and return methods.

11.png

This is the most difficult method in this program. It firstly asks for the student ID to find the student. Then it brings the student’s book collection back to the book system. Since each book has an Unique ID, as the book object is returned, its ID will not change. The key of successfully creating this return method is that I created a return method also in the student class.

12.png

This method is in Student class. The difficulty of returning book is to remove the book from student’s collection and add the book back to the book system. Here, I pass a argument, which is the ArrayList textbook (the book system), into this method. Therefore, I can simply remove the book by “collection.remove(i).” The same method is applied to adding the book back to the book collection of the library.

Continue reading “Smart Library Project”

Track Class and Iterator

After we learned ArrayList class, we firstly reviewed while loop. Then we learned to improve our ArrayList by designing our own class as the type of the elements in the ArrayList, as the example of “Track Class” shown in the Textbook. Then, we learned Iterator, which will be explained later.

While Loop Exercises

Here are the exercises we have done to review while loop. After recalling the syntax of while loop, I found them easy. It’s also because we have created the program that print prime numbers last semester.

Picture1.png

Here are my codes.

1

While loop is different from for loop since the variable that stores the index is declared outside the loop. Also, “i++” is required to make the loop progress.

2

Also, sometimes we need to add addition variable to store the results coming from every time the loop runs.

3

4
4.33

 

The exercise is more complex, since it has a return type, boolean. In this exercise, there are two conditions, both of which determine if the input number is a prime number. At last, there is a return statement that returns the value stored in a boolean variable.

Library Project

The library program is a simulation of the program that the librarian uses to manage the books in a library. Now I have not complete the full program yet. Now, this program has the functions of adding, removing, and searching books. Here is the class diagram for the library program.

11

We can see that the class are connected by arrows. This means that classes use other classes’ objects or methods. I have finished the book class and library class, and here is a screenshot of the book class.

12

In this class, I created three fields. They are the name of the book object, as well as the ID. By using a static variable, I create a integer field that only belongs to the class. Therefore, if I use “bookUniqueID++,” every time an instance of the class is created, the ID changes. At the same time, since this variable is inherent to the class, I need to create a new field that belongs to each object created, which is the bookID variable. In this class, I created two accessor methods, which return the book’s name and ID respectively.

Before talking about the library class which is the centre of this program, I want to introduce the “Track Class” first.

Track Class

Here, the “Track Class” does not refer to a class inherent to the java utility package. Instead, it is a technique we can implement on ArrayList.

Here an example in the textbook:

26.png
Objects First with Java a Practical Introduction Using BlueJ (5th Edition);

Generally, using the “Track Class” is to firstly design our own class, and then use it as the type of the ArrayList. Therefore, the elements in the ArrayList is no longer String, but a series of objects, which can contain more information as well as more methods.

Here is how I implement it in my library project.

14

As I mentioned earlier, book is class I created for the actual books in a library. So how can we put them in a list and access their names and IDs? The answer is to use Book class type to declare a new ArrayList.

Continuing on Library …

22

In the library class, to make use of the Book class, I create a most basic method called “add book.” When it is called, it pass the argument to the parameter of the book object to create a new book object.

23
Remove book by ID

Here, I use a boolean “indicator” for a searching method. This means that the loop is trying to check if, in a loop, something meets a certain condition. If the bookID is found using “contain” method, the boolean indicator “contain” will become true, which is initially false. If anything is found, the program will not print our “No book matched.”

24

This is the beginning of the main method I used. I by printing of the menu and using Scanner, I can interact with users.

25

To let users choose the functions, I used switch loop. This is more efficient than write a lot of “ifs” and “else ifs.”

Iterator

We have learned that to scan through each item in an ArrayList, we have two methods. One is for-each loop, the other is while loop. However, there is another technique to go through an ArrayList – the Iterator. Comparing to while loop, the Iterator Object will replace the index of the while loop. By using the “.iterator” method of ArrayList (but we have to import the “java.util.Iterator” at first), we can create a more efficient loop.

27.png

This is an example of using Iterator. The method “.hasNext()” of Iterator class is similar to  the “hasNextLine()” method of Scanner class. The method “.next()” of the ArrayList will return the next item in the ArrayList. Iterator is like going through the ArrayList one by one, and it will not go back.

If we want to remove an object in the ArrayList, we can simply use –

books.remove();
//or IteratorObject.remove();

Remember there is not index in the parenthesis, since Iterator goes through the list by checking the only items themselves.

It’s advantage is that it can directly return the items in the ArrayList without index. Also, it can stop in the process, comparing to “for each” loop. However, sometimes it’s more convenient to store the index and use them later.

Continue reading “Track Class and Iterator”

ArrayList Intro

library
Retrieved from the NSPCC

Collection

In Java, abstraction is often used to manipulate date. Collection is an abstraction in which data are grouped together for us to arrange and manage. The collection can be huge, or it can be empty. We can add, remove, or get items in the collection. In a programmer’s perspective, collection can be regarded as a class, and the items in it can be objects. As we make changes to the collection, we are calling methods. As an example of collection, the names of all students in the school may form a collection.

Library Class & ArrayList

In java, there are many classes that are proven to be useful for developer, which are stored in the class libraries. The instances of library classes are constructed using new.

ArrayList is a class imported from a library class in java.

图片 1
Importing the ArrayList from the package “java.util.”

The line above should be written in the beginning of the program. The “java.util” is called a package. By importing the ArrayList class, we can use it in the following program.

Generic Classes

ArrayList is a type of collection, which is static and very simple. To instantiate a new variable that has the class type “ArrayList,” we add this line to our program:

3.png

Here, the new ArrayList is stored in the field “files.” The word “String” means that this ArrayList is a collection of Strings. We use the diamond notation “<>” to specify the type of elements stored in the ArrayList.

Classes like ArrayList are called generic classes. These classes need parameters that have a second type. For example, the elements in the ArrayList may be String, integer, etc. Not limited to primitive data type, we can use class type to instantiate the objects in the ArrayList.

ArrayList

Specifically for ArrayList class, there are many methods that are under this class. In our course, we only learned four types of them, which are add, size, get, and remove. We use dot notation to use these methods. For example, if we want to use these methods, we use these codes:

files.remove(index);

files.add(item);

int number = files.size();

return files.get(index);

Since the the ArrayList is static, it has a temporarily fixed size (if not changed by other methods). The size of an ArrayList is the total number of items in the ArrayList. Moreover, each item has an Index. It has to noted that the first item has the index “zero.” Therefore, the last item’s index is “size-1.” Therefore, when we use the remove or get method, we should be careful about this. Here is an example:

2
Here, I make sure that the index is not out of range.

In this example, if we use a index that is not in the range, there will be an error called “IndexOutOfBoundsException“. This error is a called an index-out-of-bounds error.

It’s also important to know that the add method automatically add the new item to the end of the ArrayList.

Exercises

The exercise 4.17 asked us to try to play around with the music player.

5

This class diagram shows that the Music Organizer uses the object instantiated from the class MusicPlay.

Firstly, I created an object called MusicOrg1. Then I used the method addFile(String filename).

4
I entered the file’s location as the argument.

Then I called the startPlaying(int index) method.

6
The code of startPlaying Method, which is actually from the MusicPlayer class.

After that, It works! I heard the music start playing. Then I tried stop playing and the music stops. How amazing this program is!

Continue reading “ArrayList Intro”

Usability and Ethics

product-usability-testing
Retrieved from Far research.

Components of Usability

Here are 8 components of usability:

  • Complexity/simplicity – the amount of effort required to find a solution to a problem. A simple product will save a lot of time and effort for the devices and users.
  • Effectiveness – how does the system achieves the predefined level of performance. The product should be effective enough to meet the users’ needs.
  • Efficiency – the time required for the system to perform certain tasks. product with high efficiency can certainly improves the readers experience.
  • Error – the amount and type of error, and the time required to recover from the error. Once there is a error, there need to be some recovery plan or guidance to help the users to fix it.
  • Learnability – time taken for the user to successfully use the system for the first time. Therefore, step by step user guide should be included in the product. Also the design should be clear.
  • Memorability – time and steps used by the user as they have not use the system for a period of time. To make the product more memorable, the icons and symbols should be reasonable and straightforward.
  • Readability/comprehensibility – the speed that the users process the information provided by the system. It is usually related to the design of the presentation of the information (for example, the selection of font size).
  • Satisfaction – the extent to which users like the product (aka. the users’ attitude towards the product). 

Real-life Usability Problems

For different products, their might be different types of problems.

For PCs, the visual design is not aesthetically good so that some users do not like it (satisfaction). There are a lot of bugs, which may interrupt the user’s action (error). Sometimes, changing a small setting means to go to so many options which makes the system too complex (complexity/simplicity).

Digital cameras: Sometimes there are too many buttons that the user do not know the symbols on them. It’s might require a lot of time to learn it (learnability). And, as users turn back after a long time for not using them, they might forget the meaning of the icons (memorability).

Cell phones: Some times the font is too small to see it clearly (readability).

MP3 players: The buttons on the MP3 player are too close that users are prone to errors as they push them (error). Sometimes, to change a setting requires too many steps, which is not quite efficient (efficiency).

Accessibility Solutions

We have talked a lot about the problems of accessibility. Since accessibility means to make the product used by a wide range of people, the special needs of some groups of people must be needed. Therefore, we need to consider people with these impairments:

  1. Visual impairment
  2. Hearing and speech impairments
  3. Cognitive problems and learning disabilities
  4. Mobility impairments

So, what are the solutions to those problems?

Here is my presentation about the solutions to the 3rd and 4th problem.

 

Also, for the first two impairments, my classmate has made a presentation about it. Here is the link: https://docs.zoho.com/show/publish/1vl9609db73b5105e471eaf83d63174b344c9

Human and Machine

human-intelligence-825x510
Intelligent Machines and Foolish Humans. Retrieved from AI Research

As technology develops in an unprecedented speed, machines are growing more and more intelligent, thus blurring the border between human and machine. Therefore, moral, ethical, social, economic, and environmental problems rise due to the more advanced machine.

Before talking about these problems, I would like to clarify the difference between moral and ethical issue:

幻灯片02

Regarding this these issues, I will narrow my topic to one technology: Visual Reality. Here is my presentation (click to see bigger picture):

To conclude this blog post, I would like to add one TOK question. Is VR an ethical technology? In my perspective, there is no exact answer. I think that VR is kind of neutral. It depends on how human will use it. I believe that it will bring us to unimaginable future.

 

Reflection on IA and Usability

Internal Assessment (IA)

These weeks, we are learning about the internal assessment of IBDP. The CS IA generally requires us to be a developer of a software and to create a product eventually. The whole process is assessed according to the criteria from IBCS.

Criterion A: Planning (5-6)

There are three parts in the planning stage.

  • Defining the problem or unanswered question
  • Justification for the proposed product
  • success criteria

     

Firstly, we should depicts the scenario of the problem, which includes the consultation with the client. The second part is rationale for solution, which is a brief outline of how my product will solve the problem as well as the reason why I choose the specific programming language. The success criteria guides me to evaluate my product, which includes 5-7 bullets points.

It must be noted that the first two parts are between 175 and 200 words each, and the success criteria are listed as bullet points, which is not included in the word count.

Before the planning stage, we should give Mr. Pete our IA proposal. The proposal should specify the problems of the old system as well as the solutions for them and the requirements of the new system.

Criterion B: Solution Overview

The solution overview actually belongs the design stage of the system development. It includes:

  • Record of tasks
  • Design overview

    data-flow-diagram
    A data flow diagram may be included in this stage. Retrieved from smartdraw.

The record of tasks (ROT) file, which includes some significant steps of developing some criteria. The design overview includes the test plan, the brief summary of methods, and the design of the solution (through flowcharts and other graphical visualization).

Criterion C: Development

In this stage, the different techniques and algorithms used should be appropriate and should be identified and presented. Also, we should show the reason why we use certain techniques, using screenshot to illustrate our thinking. It is also very important to cite sources correctly using MLA format. This development document should be approximately 1000 words.

Criterion D: Functionality and extensibility of Product

Criterion D involves two parts:

  • Evidence of functionality
  • Extensibility

To make sure that the product is functioning, the product needs to be tested using the success criteria. Also, the product needs to be tested in several locations, meaning that it  should be tested on a DVD or USB. As long as the product functions well, a video should be recorded to show how well the product functions.

Moreover, the ways that the product can be further improved should be included. Also, we should specify how a third party would maintain the product.

Criterion E: Evaluation

The evaluation section should involves:

  • Evaluation of the product
  • Recommendations for further development

feedback
Feedback from the client and advisor. Retrieved from Nepalipaisa.

As developers, we need to collect the client’s and advisor’s feedback, and link them to the cover page. Also, the product should be evaluated based on the success criteria in stage A as well as the feedback we obtained.

Furthermore, specific and realistic student recommendations for the improvement of the product should be included.

Usability

As a crucial part in user experience design, usability is the potential of a product, app or website to accomplish user’s goal. Generally, a program of high usability is easy to use and is self-explanatory. The three main elements of usability are effectiveness, efficiency, satisfaction. To improve a product’s usability, one must consider the users’ needs, wants, and abilities from the perspective of actual persons.

Here is a video for you to understand the concept better.

Ergonomics & Accessibilities

Ergonomics and Accessibility are two components of usability.

From Merriam-Webster, the definition of Ergonomics is:

An applied science concerned with designing and arranging things people use so that the people and things interact most efficiently and safely —called also biotechnology, human engineering, human factors.

The goal of ergonomics is to optimize human well-being and performance of the system when human uses it. For example, the angle between the Macbook’s screen and the keyboard can be adjusted so that people can see the screen clearly in different body positions. This is a design related to ergonomics.

Here is a poster made by my classmate that demonstrate what is ergonomics:

David's Ergonomics Poster

For accessibility, the main goal is to meet the needs of as many individuals as possible (i.e. handicapped people or people with specific needs). For example, there is a setting in iPhone called Accessibility under the General setting. There are settings about reading the text so that people who cannot see clearly can access the information in this iPhone.

Here is a poster I made about accessibility:

Justin's Accessibility Poster

 

 

System Design and Prototype

The system design stage

The design stage is usually regarded as the second stage of the system development life cycle. In this stage, how the system is created and how the system operates will be designed. Below are several ways to illustrate the system graphically.

System Flowchart, DFD and Structure Chart

These three are three types of illustrations of the design of a system. The words that are bold are key features of each illustration that distinguish them apart.

System flowchart

Modelling_System_Flowchart_1
From SDD-HSC-Online
  • The system flowchart shows how the system generally work. It illustrates the relationship and connection between different parts of the system, as well as how the data flow between these parts. The data storage type is also shown. However, details are excluded from the flowchart.

Data flow diagram (DFD)

data-flow-diagram
From SmartDraw Software
  • It shows the route and direction of data flow with a system. It focuses on inputs and outputs to the system. It is used to describe the problem to be solved. It seems similar to the system flowchart, however, it focuses more on how data flow from process to process.
  • 
It doesn’t specify the type of data

Structure chart

describing-structure-chart
Retrieved from zimmer.csufresno.edu
  • Hierarchical order structure
  • Functions and sub-functions; Relationship between the modules
  • No arrow
  • Relationship of the modules
  • Break large problem, make it easier for the system analyst

Types of Processing (presentation)

The followings are the types of processing. The pictures are from the presentation addressed by David and Justin.

Online Processing (interactive)

A process in which the user directly interacts with the system.

WX20170308-100655@2x

Real-Time Processing

A subset of online processing since there is no delay between the input and the change in the system.

WX20170308-100746@2x

Batch processing

A series of non-interactive jobs all at once

WX20170308-100804@2x

Prototype

Prototypes represents the system abstractly by focusing only one or two key aspects of the system. For example, a prototype can be the “ghost” user interface which does not include any central complex algorithms.

By having prototype, we can test the system before implementation. Also, prototypes help the developer to show to the client what the product will be like. Therefore, customers are usually attracted by the prototype and continue to invest more into the project.

Here is a real life example of the use of prototype.

Robots-working-in-Restaurants-in-China4.jpg
Robot waitress. From Wonderful Engineering

Let’s assume we are designing a robotic system. The robot is going to be used in a automatic restaurant. Now the restaurant really wants to see the product as soon as possible, since the restaurant wants to make sure that the robot is suitable for the service system in the restaurant. The robot is easy to produce, and it can be mass produced.

In this case, a prototype is necessary.

However, sometimes we might not need prototype. Also for a robotic system, if the robot is going to work in very dangerous environment, it’s very hard to replicate the environment for testing the prototype. Then, it might be better to produce the product directly. Also, if some products can be tested through simulation, making a prototype is not necessary.

SDLC and System Analysis Reflection

System Development Life Cycle

System development includes the phases that a system developers must go through when they develop a hardware or software system.

pict-circular-arrows-diagram-systems-development-life-cycle
Retrieved from conceptdraw.com

The System Development Life Cycle (SDLC) generally includes five phases:

Analysis
Design
Implementation
Testing
Evaluation

 

This five phases are called a cycle because there might not be a final product at the end of one cycle. Then I will discuss these stages in detail.

Analysis

Before developing a new and better system, we should first learn about systems that are already exists. We should firstly know “what is wrong about the current system.”

Then, how to get information about the current system?

Methods of Gathering Information from Existing System

 

First, we can do interviews. It’s a direct way of getting the raw data from the stakeholders of the current system. By interviewing operators, supervisors, or managers of the current system, we can know what the problems are, what they require from a new system.

To specify how the interview works, there are two types of interviews: Structured Interview and Unstructured Interview. For structured interview, the questions are predefined and are presented in the same manner to all interviewees. In contrast, unstructured interview allow interviewees to freely express their thoughts and personal feelings.

unknown
Retrieved from Pixabay.com

However, interview is a way of getting the first feeling of the problems of the current system, and it is very time consuming. Also, some details might be skipped in the processing of getting information from interviewing.

So we can do direct observation. In this way, professional system analysts may walk around the organization and try to see how the staff work as well as their working practices. How can the efficiency of the system be improved? From observation, we can get the first hand and unbiased information about the current system. Also, we may notice many details which may point out the bottle neck that the current system has. However, it is also very time consuming to directly observe, and people may not work like they normally do if there are people observing.

To get a wider view, we need quantitative data. Questionnaires is a very good way of getting a huge amount of data. Questionnaires or surveys are cost-efficient and time-saving, comparing to the the previous methods. However, it also has its limitations, since it is hard to ask the right question, and the information is limited by the content of the questionnaires. Additionally, people who fill in the questionnaires may not take it seriously.

There are also two types of questionnaires:

Closed or restricted questionnaires only allow “yes” or “no” answers.It is good for statistical analysis. Open or unrestricted questionnaires includes free response questions. It allows people to express their deeper thoughts, but the answers are difficult to interpret.

The final method is the examination of documentation. Systems analysts will look in the documents in the archive of the organization and find out how the current system operates. The documentation includes reports, guidelines, or planning documents used by the organization. The advantage of this method is that, we can get very detailed information about the current system. Therefore, it is usually used in the process of system analysis.

Design

Analysis is all about the current system, while design is about the new system.

The process of designing determines how to create the new system and how it will operate. The design should not be like a “screenshot” of the real program. Instead, the design should be a general layout of the program.

The process of design involves three or four parts. The first one is user interface. The second part is the process of developing the program. The third part is about the data storage requirements of the program. If there is a fourth part, it should be test design, which designs the how the test will operate.

Here is an example of test design. which should be filled out at the design stage (except for the actual outcome, which will be filled during the test).

#number Short Description Input data Expected outcome Actual outcome (leave it blank) F.     #.
F.     1.2

Implementation

Implementation is the process of really getting to create the program. It might involve creating or installing the hardware, but it is not required for IB IA.

In the implementation stage, software and maybe hardware is installed. Also, data files are prepared and users are trained. Also, it involves writing the system documentation, which is the documents that specifies how the system works.

And at the same time, system developers should make sure that the system that they build fits in with what they designed.

Testing

In general, there are three types of testing.

Black box testing: Only look at the input and output without testing the inside of the program

White box testing: Not only do we look at the input and output, but also we look at the inside of the program.

Dry run testing: looking at each instruction step by step.

The dry run testing is the most tedious and time-consuming one. However, it is usually used because of its strictness – no error should be skipped.

Evaluation

Evaluation is the process of reflecting on how successful the operational system is. We can ask questions like:

Does the new system meet its original system objectives and requirements?

How effective is the new system in solving the original problem?

If the answers are negative, the system should be analyzed and improve. Even if the system meets the standard or requirement, there should always be a recommendation of further improvement.

Group work: Development Models

 

 

Here is a poster that we made that demonstrates the three development models.

sdlc-models

Stakeholders & End-Users

Stakeholder are people who have an interest or concern in a project or something about the project, or they are individuals, teams, groups or organizations who might be affected by the outcome of a project.

Stakeholders can generally be divided into two types:

Internal

  • Employees
  • Manager
  • Owners

External:

  • Suppliers
  • Society(community)
  • Government
  • Creditors (like ibo)

End users are people who will use the product of the project. Therefore, a stakeholder might be an end-user at the same time.

The role of the end-user must be considered when planning a new system

This sentence stresses the importance of considering the role of the end-user so that the program will meet their needs.

When developers develop a product, there are 3 important questions:

  • Who will the end-user be?

  • What are their needs?

  • Any other stakeholders?

 

Answering these questions will help the developer create programs that most of the important people like.

stakeholders
Retrieved from linkedin.com

Besides, there are some parties that are usually involved in a System:

System analyst

End user

Software manufacture

Client company

Actually these parties are all stakeholders of the product. When we do the Internal Assessment, we should definitely consider these parties and communicate with them.

The Secret Rules Of Modern Living: Algorithms

From ancient to present, algorithms has been a indispensable part of our lives.

euclid_gcd1.gif
Retrieved from dynamicgeometry.com

The oldest algorithm is Euclidean Algorithm, which is used to calculated the greatest common divisor of two integers. Here is a picture illustrating how it works, which I will talk more about later.

The Secret Rules of Modern Living: Algorithms is a documentary produced by BBC, which introduces algorithm from past to now.

In this documentary, there are many more complex and interesting algorithms. Here, I chose seven of them to introduce algorithm in detail.

Euclidean Algorithm

As explained in the introduction, the Euclidean Algorithm is used to calculate the greatest common divisor of two integers. To visualize the mechanism behind the algorithm, we should look at the picture shown above. The two sides of the rectangle are the two integers that we are going to use to find the greatest common divisor. To begin, we use the shorter side as the side of a square in the rectangle. Then we took out the square, and do the same thing to the remaining rectangle. Eventually, the remaining rectangle can be perfectly divided to several squares, and the side of the square will be the greatest common divisor. This looks magical, but the basic principle is that the common divisor of the smaller number and the difference of two numbers is the same with the initial common divisor.

Through the lens of this old algorithm, let’s learn more about modern algorithms which are more complex and interesting.

Google Page Rank Algorithm

The google page rank algorithm is the first incarnation of the Google search engine, which is also the algorithm that made Google stood out.

The basic idea of this algorithm is that pages are ranked according to the inbound links that one has. Suppose that page C has its link on page T. The benefit that C can get from being linked by T depends on the rank of T and the total number of the links on T. (Reference: efactory) Also, there are also other factors that affect the ranking, which are just little complex.

This algorithm make it possible for users to find the most related and highly rated sites that may save a lot of time and efforts. With the development in computer technology, this algorithm can reduce human work as well as improve the efficiency of information searching.

Sorting Algorithm

Sorting algorithms are primarily used to line up a list of values from small to large (or from large to small.) The three basic algorithms that I am going to talk about are bubble sort,  select sort, and insert sort.

WX20170307-211614@2x
Bubble Sort. Pic from visualgo.net

Bubble Sort

Bubble sort is the simplest method of sorting. However, it is usually considered as the slowest for a large amount of value. Suppose that there is a series of values, bubble sort compares the first two values and switch them if the second value is less than the first one. Then, we do the same thing to the second and third value, so on and so forth.

Select Sort

In this sorting method, the data set is scanned, and the smallest value is found at first, and this value switched with the first value of the set. Then, in the second scan, the first value is fixed. The smallest value of the remaining values is then selected and switched with the second value of the whole set. This required time for this sorting method is usually predictable, but it is not very efficient.

Insert Sort

This sorting algorithm selects each value one by one, while comparing it with the all values before it. Then, the value selected is inserted in the right place – between a smaller one and a larger one.

Stable Marriage Algorithm

The stable marriage algorithm is a matching algorithm which match people who like each other. Now, over one-third of marriages are started online.

Suppose there are four girls and four boys each has his or her best choice to the fourth choice. Firstly, we just put the put the girls next to their first choice. Then, if there are more than one girls choosing one boy, the girl who has the highest ranking in the boy’s viewpoint is reserved, and others are then put next to their second choice. Eventually, they are all paired up.

I think this algorithm is extremely beautiful since it basically creates the most stable relationships. Moreover, it can also be used in other fields, such as organ donation matching.

Shortest Route Algorithm

In many real life situations, people need to find the shortest route to go though several places. For example, a postman wants to deliver all the mails to different places in the shortest time, but when there are too many places, it is very hard to find the shortest route.

To create an algorithm to achieve this goal, people tried hard but failed. Clay mathematics institute once offers 1 million dollar for whoever can find an efficient algorithm to solve this problem, or prove that none exist. The result was, mathematicians proved that the algorithm for this shortest route problem do not exist.

WX20170307-211743@2x
Using radar to record bumble bee’s routes. Retrieved from the documentary.

However, although we cannot find the most efficient way, there are some ways we can just find an adequate method. For example, some researcher found that when bees collect honey, their routes are quite efficient. They made models for the bees routing rule.

From this example, we can see that there is not always a solution for every problem. Algorithm is not the perfect tool, but it is useful enough and it indeed improves efficiency.

Heathrow Sequencing Algorithm

WX20170307-211317@2x
Retrieved from the documentary.

This sequencing algorithm is named after the Heathrow airport. It controls the departing time and route of all aircrafts in the airport. Since medium aircraft cannot depart next to a large aircraft because of the strong wind caused by the large turbine. Also, there is the problem of efficiency. Therefore, controlling the departure of airplanes is an extremely difficult task for human as there are too many factors. But machines can do calculations easily, as long as we tell them the rules.

This algorithm not only improves efficiency, but also save lives by preventing human mistakes. The high reliability of machines enable people to do something that seem dangerous or impossible in the past.

Machine Learning

WX20170307-211437@2x
Retrieved from the documentary.

Machine learning algorithms can develop themselves and learn from data.

For example, an algorithm can display people’s body movement in pixels of colors in real time. Different body parts are marked to different colors respectively. This algorithm is called decision tree, which ask twenty questions that help judge what body part it observed. The more examples it observe, the more accurate it is, the more questions it will ask – it writes questions by itself and make itself more accurate.

Machine learning algorithms are more flexible, having potentials to improve, even to a extent that people cannot predict. They relieve human from analyzing tons of data and looking for the clue.


To conclude, algorithms are steadily improving from past to now, from making human work easier to transcending the ability of human. I believe the algorithm, especially artificial intelligence which is based on machine learning, will bring human to great, unimaginable possibilities in the future.

Website Built with WordPress.com.

Up ↑