Translate

Thursday, September 16, 2021

Algorithmic and Data Structure Techniques - A Newbies Perspective.

Programming languages have made life so much easier over the last ten years. What had to be done at home on a computer can now be done with a device that can fit in your hand or on your wrist. But none of those new devices would be able to perform any of your favorite tasks without implementing algorithms and data structures.

So how would we apply algorithms and data structures? First, we need to have a unique problem that needs to be solved without there already being an answer to it. Many programming languages have built-in libraries that contain algorithms to help with the coding process, but what if there are no libraries? This is where data structures and algorithms come into play. 

Let's take a look at data structures first. In Java, the most common data structures are:

  • Arrays
  • Stacks
  • Linked List

These data structures can be designed to be a certain size or can be the maximum size allowed by Java. Within these data structures, multiple variables can be stored in a unique order, known as elements.  Here is an example using an Array that can contain strings and integers:

import java.util.Arrays;

class test {

public static void main(String[] args) {

Object[] myArray = new Object[10]; //Implement an array with 10 element max.
myArray[0] = "Hot dogs";
myArray[1] = 23;
System.out.println(Arrays.toString(myArray));
}
}

The array would print out as [Hot dogs, 23]. We can also implement it as:

import java.util.Arrays;

class test {

public static void main(String[] args) {

Object[] myArray = new Object[]{"Hot dogs", 23, 18, 100.23, "soda",
"fries", "$50", 2,"Italian beef", "Summer"};
System.out.println(Arrays.toString(myArray));
}
}

This array would print out as [Hot dogs, 23, 18, 100.23, soda, fries, $50, 2, Italian beef, Summer]

Now that we understand what a data structure is, we can now come up with an algorithm. Let's take the array above, remove the numbers, and put caps on the first letter of the strings. We can create an algorithm to find a string within the array. Let's look for the string "Soda":

import java.util.Arrays;

class test {

public static String findString(Object[] testArray, String check) {

for (Object o : testArray) {
if (o == check) {
return "String '" + check + "' is in the array.";
}
}
return "The string '" + check + "' was not found in the array.";
}

public static void main(String[] args) {

Object[] myArray = new Object[]{"Hot dogs", "Soda", "Fries", "$50", "Italian beef", "Summer"};
System.out.println("My array is: \n\n" + Arrays.toString(myArray) + "\n\n" +
"Searching for the string 'Soda' in the array: \n");
System.out.println(findString(myArray, "Soda"));
}
}

The output will be:

----------------------------------------------------------------

My array is: 

[Hot dogs, Soda, Fries, $50, Italian beef, Summer]

Searching for the string 'Soda' in the array: 

String 'Soda' is in the array.

----------------------------------------------------------------

Now the question lies: Are some data structure designs and algorithms better than others? The answer is yes because some data structures are modified differently depending on the need to modify the stored elements. Also, because some algorithms are slower than others. The above algorithm has to go through all the array elements to find the string and could be redesigned to split the array to search a smaller portion of it (see binary search).

As you learn more about data structures and algorithms, you will see just how important they are and how much more they can increase your productivity while maintaining the same amount of effort.

  


Thursday, August 19, 2021

To the Joys of Object Oriented Programing!

Hello, future software developers!

In the early days of computers, programmers were developing applications using machine language, like Assembly, to achieve their goals with computers. Before then, programmers were using binary. Can you imaging writing a program using only 1's and 0's? If the idea of doing that makes your head spin, you're in luck! Java is one of the top programming languages in the world, and it uses object-oriented programing (OOP) concepts to allow users to be more efficient when writing their code. OOP focuses on the use of objects and classes. So what are these things? Let me explain:

Classes are procedures that you design to make something work. They can be used over and over again to increase your productivity. Objects are the items that you see in the class. Variables, arguments, and functions are all objects. Here is an example using pseudo-code:

class SayHello(arguments):  //SayHello is the class

    function Hello(string myName): //Hello and myName are Objects

        print "Hello " + myName;

In this example, you can call to the class and its function to perform a task. Something like this:

SayHello.Hello("Jaime")

returns

"Hello Jaime"

It's important to highlight that there are four principles to OOP:

Inheritance: The ability of an object to inherit data and behaviors from another.

Encapsulation: Any data in an object that exposes only the selected data, preventing unwanted modifications.

Abstraction: Fetching, add, or removing data from an object. This is done a lot in classes.

Polymorphism: Many methods can do the same task but do not mix types. More than one function can be created within an class to do more than just one thing. The object can then be used multiple times for different behaviors.

Let's take what we made in the pseudo code and run it in a Java application:

class SayHello {

    //inherits whatever is passed into "myName"

    public static void Hello(String myName) {

        String hi = "Hello"    //The object "hi" is encapsulated, unchangable.

        System.out.println(hi + " " + myName);

    }

}


class NameGame {

    //Create an instance of a class

    public static void main(String[] args) {

        SayHello object = new SayHello();

        SayHello.Hello("Jaime");

        //passing "Jaime" into the class SayHello and its function.

    }

}


In the above code, the console will output "Hello Jaime" as it would in the pseudo-code. Any name can be passed to the function, and you can add more than just your name. You can give this a shot yourself by downloading the free Java JDK at:


https://www.oracle.com/java/technologies/javase-downloads.html


It is highly recommended that you use an IDE (integrated development environment) to help you with syntax and provide a nice interface. Some highly favored IDEs include:


Eclipse

Visual Studio Code

IntelliJ


Happy coding!









Monday, August 16, 2021

Operating System Theory and Design Final

Operating System Theory and Design Final 

            CPT304 has been a very interesting and thought-provoking call. It has allowed me to share what I have learned over the years from my experiences with computers with my classmates and has granted me more knowledge of how operating systems work. For our final project, we are tasked with summarizing the primary goal of an Operating System, and I am happy to share what I have learned in this post. Here we go.

Saturday, October 10, 2020

Tech Topic Connection

Before starting this course, I was already heavily involved with computers and information technology (IT) for over 30 years. During this time, I got involved with coding and, more recently, began creating applications using the Python programming language. Since I am already versed in languages such as C++, JAVA, and Python, I chose programming language as my tech topic.

Without programming language, there would be no forms of information technology. The earliest computer applications started with programming on punch cards for a loom created by Joseph Marie Jacquard (Vahid and Lysecky). The punch cards allowed the loom to weave different patterns, thus negating the need to change the machine's mechanics. As time progressed, programming languages became more verbose and easier to understand. Almost all computer programs are written in some form of programing language, and without it, there would be no computers at all.

Although computers rely on programming languages to operate, there would be no programming languages without computers. The loom was built and was capable of weaving patterns without the need for punch cards, but it needed to have certain mechanical parts organized to operate. The organization of the components, in essence, is the programmed language. Contemporary computers run on a central processing unit, also known as a CPU, and, hypothetically, the CPU of the loom was whatever made the machine move. The CPU would not function without the programming language, and modern computer systems do not function without an operating system. Operating systems have been written in various programming languages throughout time. The Unix operating system, created in 1973 by Ken Thompson and Dennis Ritchie, is written in the C programing language, and it runs on many computers worldwide (University of Colorado Boulder). Operating systems manipulate the CPU, memory modules, hard disk drive, and input/output (IO) devices to get the computer to function. If not for programming languages, no operating systems would exist, and as stated earlier, no computers would either.

Application software and programming languages go hand-in-hand. For an application to work, it needs to be programmed with instructions via a programming language. Using Python as an example, a programmer can create a simple application that sends a greeting to its user by using the following code:

            name = input("Please type in your name:\t")
            print(f"\nHello {name}!")

This application will first ask for the user's input and then display text with the input onto a window, typically a command based prompt. Many applications have been written in multiple programming languages, and they have contributed to the betterment of everyone's lives.

Programming languages also go together with databases and their management. Several languages work specifically to operate a database, and the most common is the Structured Query Language, more commonly known as SQL. SQL works by using a set of commands to organize, manipulate, and retrieve data stored on a database (Brooks). Various database engines use SQL, including Amazon's Aurora, Postgre SQL, MySQL, MariaDB, and Microsoft SQL Server (aws.amazon.com).

Network architecture, management, and security partially influence my choice of programming languages as my tech topic mainly because of the work I currently perform for my job. Managing servers remotely requires a basic knowledge of networking and the securities involved with its operation. Programming languages have helped me connect to the servers I work with to submit commands, retrieve data, and change settings without the need to be in front of the server physically. Parts of the code I wrote required security tokens before the server can be accessed, and I would love to learn more about implementing more robust security features.

Over the years, I have had a lot of exposure to programming languages and have only recently begun to take more interest in it, due primarily to automation. I have come to enjoy writing programs, and it has opened my mind to new and exciting ways to view computers, and it's may processes. I hope to become a competent software developer eventually and possibly work in a research and development department.

References

Amazon AWS (N.D.) Amazon Relational Database Service (RDS)

    Retrieved October 8, 2020 form:

    https://aws.amazon.com/rds

Brooks, C (January 2014) What is SQL?

    Retrieved October 8, 2020 form:

    https://www.businessnewsdaily.com/5804-what-is-sql.html

Vahid, F., Lysecky, S. (July 2015) INT 100: Fundamentals of Information Technology &

    Literacy. Retrieved September 9, 2020 from:

    https://learn.zybooks.com/zybook/ASHFORDINT100AcademicYear2018

University of Colorado Boulder (N.D) History of Unix

    Retrieved October 7, 2020 from:

    http://ibgwww.colorado.edu/~lessem/psyc5112/usail/concepts/hx-of-unix/unixhx.html

Tuesday, October 6, 2020

Network Security

The assignment of week 4 for INT100 asks to look into network security.

The internet has become more than a fascinating tool for people to find information, entertainment, work, and many other useful things throughout the past three decades. Still, unfortunately, many individuals choose to use it for nefarious purposes. Most people who use pinging to contact sites for connectivity purposes do not realize that although it seems harmless, pinging a site with enough packets can cause the site to crash. The most commonly known ping interruption is a Denial of Service (DoS) attack in which a single person or group flood a web site server with packets to overload its bandwidth (Vahid and Lysecky). Other types of ping attacks include MAC flooding, evasive UDP land attacks, and “Ping of Death” (Sankar). To mitigate these attacks, network administrators need to detect illegitimate traffic at the routing level, manage the bandwidth of their services, and be mindful of the site architecture so that it can handle a high amount of traffic (Sankar).

Other than DoS attacks, there are several different forms of malicious computer security breaches, including computer viruses and email spam. Computer systems are vulnerable to these types of attacks because they can inadvertently install damaging software or malware that can corrupt a person’s computer or company’s computer network (Vahid and Lysecky). Some computer virus symptoms include the computer not functioning properly, slow processing, or complete OS failure. Symptoms of email spam include virus installation and mass emails sent from your email address, causing the email service provider to lock your account (Vahid and Lysecky). The best way to prevent computer viruses is to install anti-virus software and to update the computer’s software with the latest updates (nortonsecurityonline.com). To avoid spam email, users should carefully evaluate emails that contain attachments. Users should make sure that they know exactly what the attachment file is and if they know the sender, ask them if they are aware of an email they sent with an attachment. Emails that seem suspicious should be converted to plain text instead of HTML format to avoid possible infections (University of Wisconsin Milwaukee). Lastly, users should not post their personal email online on social media or a website, and they should not attempt to reply to a spammer (Stucken).

Conclusion

As wonderful as the internet and computers are, it is necessary to know the possible dangers of attacks from would-be hackers. Attacks become more sophisticated every year, and a lack of prevention becomes more costly. With good information, awareness, and tech-savvy, anyone can protect themselves from becoming victims from those of ill-intention.

References

Norton Security Online (N.D.) Computer Viruses and Their Spread Prevention.

    Retrieved October 1, 2020 from:

    https://www.nortonsecurityonline.com/security-center/computer-viruses.html

Sankar, K (December 2013) Type of Attacks

    Retrieved October 1, 2020 from:

    https://community.cisco.com/t5/security-documents/type-of-attacks/ta-p/3154808

Stucken, A (September 2010) How can I stop getting spam emails?

    Retrieved October 1, 2020 from:

    http://www.bbc.co.uk/webwise/guides/stopping-spam-emails

Vahid, F., Lysecky, S. (July 2015) INT 100: Fundamentals of Information Technology &

    Literacy. Retrieved September 9, 2020 from:

    https://learn.zybooks.com/zybook/ASHFORDINT100AcademicYear2018

University of Wisconsin Milwaukee (N.D) Tips for Avoiding Computer Viruses

    Retrieved October 1, 2020 from:

    https://uwm.edu/itsecurity/tips-for-avoiding-computer-viruses/

Computers in the Workplace

For week four of INT100, the first discussion touches on computers in the workplace. We were to choose an industry and talk about the functions of computers within them. I thought the best industry to speak on would be the health care industry.

From its inception, the health care industry has been recording patient data to keep records about their health, historical visits, and personal information. Record-keeping was primarily done on paper and filed in large cabinets for future access upon a patient's next visit. As the years go by, doctors, dentist, and other health care professionals had to create archives which either took up office space or required them to rent space to store patient data. The need to archive data then becomes expensive and can pose a threat to personal information should the archived data be lost or stolen. With the increase of technological power and processing, the health care industry is now moving slowly towards logging patient information into a digital format.

I have been seeing the same dentist for over 13 years, and she continues to improve her customer relations using technology. Her patient data is now registered in a proprietary application on a local network and backed up to cloud storage, eliminating the need to have physical archives and added security. She has also incorporated an email and text-based messaging system that sends alerts to patients on when their next scheduled appointment is, which is great because myself and others tend to forget about the appointment, especially since they are typically scheduled every six months. With all the new technologies that have been implemented to her business, her employees must have a fair amount of computer literacy to enter patient data, create future scheduled visits, and process payments. Procedures that my dentist took can be applied by primary physicians, chiropractors, and other professionals as well.

The technology that the health care industry will need to assist with patient care will continue to expand and make patient interaction more streamline. The technology over the next ten years will see health care professionals move all processes to cloud-based servers that will eventually make schedules, send alerts to patients via call, email, or text messages, and automate billing processes. Patients may also interact with computer interfaces to make scheduling fast and more accessible. There is no doubt that new technology will have a lasting impact on the health care industry, and in the end, both health care professionals and their patients stand to benefit immensely.

Traveling Through a Network

For week 3 of INT100, we were assigned to interact with websites via ping and traceroute commands. On this assignment, I was able to utilize the knowledge I have about ping and traceroute from what I already learned years ago. Using the ping command is a good way to determine if your connectivity to a particular site is active or down. It can also be used to see if your internet connection is poor by pinging several sites and seeing how long a packet took to reach its destination or how often the ping times out. Traceroute is a good way to see how your site request travels throughout a network. Both of these commands are not just for use on websites, they can be utilized on devices on a private network as well. As long as a device has an IP address or a secured DNS (Domain Name System) name, a name given to a device or website that is easy for a person to memorize, anyone can use these commands to access network traffic to those devices (cloudflare.com).  

Packets travel through a network via a wrapper that contains a header and a footer. Within the wrapper, there is information about the origin of the packet, the kind of data in the packet, and its final destination. When data is sent out, that data is split into different packets that do not have to follow the same path, and thus makes the networks, such as the Internet, fast. Once the packets reach their destination, the receiver reassembles the data and recreates the originally transmitted data (Strickland). 

Other than Google.com, I chose Nintendo's Japanese site at nintendo.co.jp and DHL's German site at dhl.de. The ping request had no issues with time outs or dropped packets. What I did notice is that the sites outside of the country took longer for the packets to reach their destination. Packets sent to Google averaged around 13.6 milliseconds (ms) to reach their server, Nintendo averaged 15.7ms, and DHL averaged 128.1ms. The results tell me that the servers used by Google and Nintendo are more robust and have better bandwidth paths that DHL has.

The traceroute results were a real eye-opener for me. I have run traceroutes before, but I had some mixed results from Nintendo and DHL. When I ran a traceroute to Google, I had no issue getting the full path to their site, but with Nintendo and DHL, traces were being rerouted to a content delivery network (CDN) called Akamai. Once the trace reached a certain point for Nintendo and DHL, it would time out. If I were to use my best guess, I think Nintendos trace reached a server near O'Hare International Airport in Chicago, due to the partial DNS name segment "ord01"; ORD is the city code for O'Hare Airport. The trace for DHL went to London England and then to Paris France where it reached an Akamai server before timing out. It looks like Nintendo and DHL decided to host their content on Akamai's servers to minimize delays in loading their web page content (akamai.com). 

I mentioned how ping and traceroute commands can be used to troubleshoot Internet connection problems, but if a user is curious if their internet connection is out completely, you can find out by pinging or tracerouting multiple sites. If all pings time out or you receive a message of "Destination Host Unreachable," and your traceroutes do not go past the first hop, chances are your internet is down. On occasion, connectivity to servers either drops or lags, and when running ping/traceroute commands, there will be time outs or errors. There are various reasons why ping and traceroute commands time out or return an error response, which includes server or network router failures, excess traffic to destinations, not enough bandwidth from an internet service provider, and a possible Denial of Service attack on a website.

I use ping and traceroute commands often for work to see if connectivity is down for a remote server. I also use traceroute to find names of switches/routers that servers are connected to. Some time ago, my team had a connectivity issue with a server in Rushford MN, and we were getting dropped packets to the server. The fix was a reboot of the modem that the firewall connects to. Another reason why errors might occur in a ping/traceroute is that the server you are trying to access is disconnected from the network or is powered off. In some cases, the IP or DNS name is wrong.

Resources

akamai.com(N.D.) What does a CDN stand for? CDN Definition

   Retrieved 9/23/2020 from:

   https://www.akamai.com/us/en/cdn/what-is-a-cdn.jsp

cloudflare.com(N.D.) What is DNS | How DNS Works

    Retrieved 9/23/2020 from:

    https://www.cloudflare.com/learning/dns/what-is-dns/

Strickland, J (N.D.) How IP COnvergence Works

    Retrieved 9/23/2020 from:

    https://computer.howstuffworks.com/ip-convergence2.htm