10/2/2017 – Blog Assignment 3 – CS 443

http://testerstories.com/2014/06/path-testing-the-coverage/
This week we turn to path coverage. Path coverage refers to test cases with linearly independent paths, in which a given program will execute at least once. A linearly independent path maps out the control flow of an application, which visually describes the execution path of a program in a sequence. Control flow graphs are numbered in sequence through all parts of a program. Each numbered segments serves as nodes in the execution path.
The article introduces the following coverages and their paths:
Node coverage has test cases that goes to every node in the graph.
Link coverage has test cases that goes to every link or line in the graph.
Loop coverage has tests that explores the interactions between sub-paths within a loop.

Node Coverage
1 2
1 3 4 7 6 8
1 3 4 5 6 8

Link Coverage
1 3 4 3 4 5 3 4 5 6 8

Loop Coverage
1 3 |4 3| 5 7 8
1 3 |4 3| 7 6 8
1 3 4 |5 3| 4 5 6 8
…
Through the different coverages, the example above shows the different paths that can be taken in the example program. What this example shows is that path testing maps out the control flow of an application and its execution paths to test out its coverages.

The coverage that I thought was interesting was statement coverage. Statement coverage is the lowest level testing coverage. It tests whether the flow of control has reached every executable statement at least once. The goal is to map out each executable code at least once.
The following example was given:
public class compute {
public static void main(String[] args) {
(1) float x = Float.valueOf(args[0]);
float y = Float.valueOf(args[1]);
(2) if (x != 0)
(3) y += 10;
(4) y = y / x;
(5) System.out.println(x + ” ” + y);
}
}
This maps out the path
3
1 -> 2 —>4 -> 5
Statement 2 divides into 2 conditionals, whether x is equal to 0, corresponding to condition 4, or not, corresponding to condition 3.
Statement coverage is defined by a percentage of number of statements executed over the total number of statements in the source code*100.
In this case the total number of statements in the source code is 5. If x = 0, then the number of statements executed is 4, providing 80% coverage. If x != 0, then this provides 100% coverage.
I first chose this article to learn more about path testing and coverage. I did not thoroughly understand the concept introduced in class until I went through this article. Though short, it provides a brief overview of the different coverages. However, the examples given in the article for the different types of coverages are inadequate. I particularly liked the examples provided for statement coverage. What I had learned is that statement coverage is simply a measure of how many execution paths are needed for 100% coverage. This demonstrates what path testing is all about, which is modeling the execution flow and testing its different paths for coverages.

From the blog CS@Worcester – Site Title by myxuanonline and used with permission of the author. All other rights reserved by the author.

Post #2

I’ve been a longtime listener of podcasts but I’ve never really put any effort into finding a podcast that was relevant to software development.  Until now, I never considered the convenience and benefits of being able to learn about my field of study through my headphones while I perform other tasks.  In particular, I have been binge-listening Software Engineering radio because it is technical, topical, and informative while remaining pleasant to listen to.  Today, I am going to review and give commentary on Episode 51 of the show.

The topic of this episode is the Design By Contract (DbC) software correctness methodology.  One of the hosts of the show, Arno, defines DbC as a way of thinking about and designing interfaces that contain “contracts”.  The contract is a metaphor; the idea is that you as the caller must meet the preconditions expected by the method, and the method must meet the postconditions expected by the caller.  Arno gives the example of a square-root function:

– As the caller, you must meet the precondition of passing in a value that is zero or greater because of the inability to take square-roots of negative numbers.
– As the method, you must produce the value that, if multiplied by itself, is equal to the value passed in; this is expected by the caller.

Arno goes on to explain that, programatically, these preconditions and postconditions are boolean expressions that are listed in each method and must evaluate to true in order to perform their function.  One benefit of designing software in this way is that you provide more provide a more precise specification of what a method does.  Another benefit is that this prevents incorrect information from being displayed to the user; DbC evangelists believe that it is worse for the user to receive incorrect output than to not receive any output at all.  There are downsides to DbC as well, Arno claims.  He states that DbC runs into problems when implemented in a polymorphic system – subtypes of a supertype will inherit all of the contracts agreed upon by that supertype.  Arno advises that if somebody wishes to begin designing their code in this way, the first step is to just begin thinking with a contract-oriented mindset.  DbC functionality tools are not native to many languages so, if you wish to begin designing in this way in a language like Java, you must acquire them via a third party or start of by using assertions.  Arno insists that assertions are not enough to truly implement DbC because you have to manually maintain the checks on postconditions as they will often change based on input.

I selected this episode to be the subject of a blog post because I think that it prescribes a pretty good method of designing quality software.  By preventing incorrect input and output at a developer level, you reduce the workload of testers, allowing them to perform more rigorous and extensive testing of input.  I have recently been doing a lot of research on various software development and design paradigms and one of the ones that I have dived into extensively is Agile.  I feel that DbC is similar to an Agile approach because it entails a process of developers testing as they work, which generally produces a more sustainable and higher quality product.  In my next blog post, I will elaborate further on developer testing and how it contributes to the production of high quality software.

This blog post(1/9) is part of an assignment for the Fall 2017 session of CS343 @ Worcester State University.

From the blog CS@Worcester – RM by Ryan Marcelonis and used with permission of the author. All other rights reserved by the author.

When Time and Testing do not Play Nice (Which is Almost Always)

The more I continue to browse the various blogs on testing, the more I find myself gravitating to a certain kind of blog. There are many blogs on different kinds of testing, new types of testing, etc., but I find myself often going to help/tips type blogs. I find them to be quite useful, because they are easy to apply to my job. One I found this week was “What To Do When There Isn’t Enough Time To Test?”. Well, that is a very good question, isn’t it? Testing is very important and time is almost always limited. There are deadlines to meet, people to see, and places to go. Time crunches are common for testing and seeing as the course for this blog is about testing, I felt this might be some good “real world” advice.

There are lots of reasons why time be tight when testing. They talk about several reasons why this might happen, all of which I have seen before. The three big ones discussed are a poor time estimating to being with, technical problems, and disagreements between teams. Generally, it is not a good idea to have an aggressive timeline for testing. It often backfires as it is never going to go exactly as expect. I agree that technical problems are often a cause for delays, especially if the product is new and some exploratory trouble shooting is needed. This relates back to making sure you’ve allow for enough time. I’d rather be done early than stuck working nights and weekends to meet a deadline for testing. The third, disagreements, is not very common. And when I do see it, it is often due to a miscommunication more than anything. If there is a disagreement, I’d like to think it would be worked out swiftly and in a professional manner.

The article then goes into how to make sure your team does have enough time to test. The first one mentioned, is making sure you have estimated enough time. This crucial to having a successful testing experience. Now, time estimating relates a lot to what they mentioned following this: know how long the testing has taken in the past, know what the team is capable of, keep track of your progress, etc. Do you know that there is a high probability that a certain aspect of the product is going is going to break? If so, that should be factored it. To me the easiest way to make sure there is enough time to test is to think of the worst-case scenario and make sure you have allotted enough time to complete testing should that situation take place. Granted, often teams do not have the luxury of that much time, so making sure there is enough time to test goes back to having an efficient overall operation with realistic goals and deadlines. Be ambitious, but so ambitious that it comes back to bite you.

This article provided some great advice on how properly schedule testing and is something I will be sure to reference back to time and time again.

Link:

http://www.softwaretestinghelp.com/what-if-there-isnt-enough-time-for-thorough-testing/

From the blog CS@Worcester – README by Matthew Foley and used with permission of the author. All other rights reserved by the author.

B3: Teacher Evaluation Model

A Soft Computing Model for Evaluating Teachers’Overall Performance using Fuzzy Logic

          This week, I chose an article that talked about the soft computing model for teacher evaluations using fuzzy logic. The author starts by explaining the major two points of teacher evaluations which were to identify problems and adjust their practice along with accountability for performance. He then goes to talk about soft computing explaining that through this field many different technologies have been made using the same logic and reasoning to solve complex real world problems. He then gets into how they created this model using fuzzy logic by naming two modules M1 and M2 that both held the overall performance. He then makes M1 calculate the teaching performance while M2 calculates the academic and administrative performance. He explains that through these two modules you can then gain the total overall performance. Those modules are then used by the Fuzzy Interface System which takes in the raw data and organizes it. There are tables within the article that help visualize how they are going to get the raw data. They have organized questions, different subjects, and even responsibilities so that they can analyze every aspect of the teacher.

          I chose this article because I really wanted to know more about fuzzy logic and how it worked in the real world. It really interested me how the modules were structured and the different tables that were shown to describe the data. As I read on in the article, I saw how they analyzed the data using different graphs which were a bit confusing at first. After some quick googling the general idea was starting to make more sense. My favorite part of the article was when they compared the conventional system used today to their fuzzy system and realized that their overall performance data was more realistic. This was because the fuzzy system also highlighted a large number of other factors that affected the teacher’s performance that the conventional system did not. I found that this article was important because it shows how algorithms and logic work in the real world. I also learned how to read fuzzy logic rules that the author made for the specific problem. It surprised me how much it looked exactly like an if, then statement that also used and, or operators as well. The entire article used the data and graphs to explain its points well, but it did use some complicated language and didn’t completely explain complicated ideas. However, it did a great job of explaining fuzzy logic’s role within the entire computing model with the module examples. This material can also be important to show the structure of explaining logic controller models and how certain things can interact with each other like the Knowledge Base and it’s input to the Interface.

From the blog CS@Worcester – Student To Scholar by kumarcomputerscience and used with permission of the author. All other rights reserved by the author.

CS 343 Blog – 10 Java Coding Tips – 10/2/17

http://blog.stoneriverelearning.com/10-java-coding-tips-every-programmer-should-know/

This blog details 10 tips aimed at beginning Java programmers.

  1. Get the basics right – Learning Java can be frustrating if you try to learn too many things in too little time. It is better to have a solid understanding of the basics before you try more advanced techniques
  2. Don’t just read – The only way to get better at programming is to actually code. Reading books is useful but that alone will not turn you into an expert programmer
  3. Understand your code and algorithm – Before you start coding, realize it on a piece of paper. The best way to solve a problem is to break it down into sub-parts and devise a solution for each sub part.
  4. Do not forget to allocate memory – Memory allocation in Java using the ‘new’ keyword is a necessity. Not using it will create a null pointer exception
  5. Avoid creating useless objects – Creating an object uses up memory and processor speed. It is good practice to not create an object until it is needed
  6. Interface is better than abstract class – There is no multiple inheritance in Java, but you can use an interface if you want to implement something similar. Usually it is more useful to use an interface rather than an abstract class
  7. Standard library is a bliss – Java has a rich set of standard library methods that make programming easier and more efficient
  8. Prefer primitive classes over wrapper classes – Wrapper classes are often slower than primitive classes and comparing wrapper classes does not give desired results as it compares objects instead of the values
  9. Dealing with strings – It is always better to instantiate a String object directly without using the constructor
  10. Code, Code, Code – The only way to get better is to keep learning and coding

I chose this blog because most people in this class are beginner Java programmers and it is interesting to learn about tips that you might otherwise not know about.

I thought that most of these tips were too basic and it seems like this blog post was more aimed at people that are just starting to learn Java. However, there were a couple interesting code examples.

public class vehicles {
    public List getvehicles(){
        if(null == vehicles){ // this ensures that the object is initialised only when its required
            countries = new ArrayList();
        }
        return vehicles;
    }
}
In this example, the object is initialized only when it is required. This is similar to the singleton example we did in class where the Singleton object was instantiated in an if statement in the getInstance() method.
String slow = newString ("This string is making the system slow"); //slow instantiation
String fast = "This string is better"; //fast instantiation
This example taught me something that I didn’t know before: that the second line is a faster way to instantiate a String.
I thought this was a good blog post but I wish that it had more examples of code as the ones in this blog were interesting.

From the blog CS@Worcester – Computer Science Blog by rydercsblog and used with permission of the author. All other rights reserved by the author.

The Importance of Clean Code

In software, there is nothing more frustrating than looking at someone else’s code for whatever reason, and having no clue what is going on. There no comments, no classes, no indentations, and ambiguous variables. If I had to bet, I’d say if the original developer had to go back and look at it they would have no idea that is going on, so how can one be expected to use that code for whatever they might need if for or are being asked to do with it. In my opinion, clean code is perhaps the most important aspect of developing software. It is vital if someone ever hopes to use the code for something else again, that the code is written in manner that is easy to read and easy to understand.

I found this blog by Bill Spooner called “10 Ways to Write Cleaner Code”. I found what he had to say to be quite useful and hope to use some of his suggests when writing code myself. Since I have a word limit, I will only discuss the ones I felt I learned the most from and or felt they were important to reiterate. The first one was about naming conventions. Naming conventions can vary from language to language are sometimes simply made up by the developer. Because of this, simply put a comment above the first time you use that type of variable. For example, for constant variables Spooner says, “constant values are in all caps and separated with underscores, not camel-case”. By adding this simple statement, it has been made clear to the user what a constant variable should look like and may have prevent confusion later. It something that only takes and extra second to do, so why not make someone’s life a bit easier. I know I am going to try and do this in the future.

The next couple are ones I just felt should be reiterated. Comments are extremely important. They allow both the original author and a new reader to know what is going on. No matter how clear you feel your code is, include comments explaining what is going on. You’ll regret it if you don’t. Another one he mentions is adding white space. Breaking up your code into logical portions makes it far easier to read than one giant continuous block. Lastly on the reiteration front is to make variable names are clear and descriptive. For example, if you were adding things together, don’t simple call the sum “total”. The total of what? It needs to be clear so it can be refence later.

The last time he mentions I wanted to talk about is a rule of thumb. He suggests automating an action if you find yourself doing that action three or more times. I think that is a pretty good rule to follow. If repetitive code can be prevented, do so as it will save time and be easier to read.

Link:

https://www.codeschool.com/blog/2015/09/29/10-ways-to-write-cleaner-code/

From the blog CS@Worcester – README by Matthew Foley and used with permission of the author. All other rights reserved by the author.

When Time and Testing do not Make (Which is Almost Always)

The more I continue to browse the various blogs on testing, the more I find myself gravitating to a certain kind of blog. There are many blogs on different kinds of testing, new types of testing, etc., but I find myself often going to help/tips type blogs. I find them to be quite useful, because they are easy to apply to my job. One I found this week was “What To Do When There Isn’t Enough Time To Test?”. Well, that is a very good question, isn’t it? Testing is very important and time is almost always limited. There are deadlines to meet, people to see, and places to go. Time crunches are common for testing and seeing as the course for this blog is about testing, I felt this might be some good “real world” advice.

There are lots of reasons why time be tight when testing. They talk about several reasons why this might happen, all of which I have seen before. The three big ones discussed are a poor time estimating to being with, technical problems, and disagreements between teams. Generally, it is not a good idea to have an aggressive timeline for testing. It often backfires as it is never going to go exactly as expect. I agree that technical problems are often a cause for delays, especially if the product is new and some exploratory trouble shooting is needed. This relates back to making sure you’ve allow for enough time. I’d rather be done early than stuck working nights and weekends to meet a deadline for testing. The third, disagreements, is not very common. And when I do see it, it is often due to a miscommunication more than anything. If there is a disagreement, I’d like to think it would be worked out swiftly and in a professional manner.

The article then goes into how to make sure your team does have enough time to test. The first one mentioned, is making sure you have estimated enough time. This crucial to having a successful testing experience. Now, time estimating relates a lot to what they mentioned following this: know how long the testing has taken in the past, know what the team is capable of, keep track of your progress, etc. Do you know that there is a high probability that a certain aspect of the product is going is going to break? If so, that should be factored it. To me the easiest way to make sure there is enough time to test is to think of the worst-case scenario and make sure you have allotted enough time to complete testing should that situation take place. Granted, often teams do not have the luxury of that much time, so making sure there is enough time to test goes back to having an efficient overall operation with realistic goals and deadlines. Be ambitious, but so ambitious that it comes back to bite you.

This article provided some great advice on how properly schedule testing and is something I will be sure to reference back to time and time again.

Link:

http://www.softwaretestinghelp.com/what-if-there-isnt-enough-time-for-thorough-testing/

From the blog CS@Worcester – README by Matthew Foley and used with permission of the author. All other rights reserved by the author.

Static vs. Dynamic Testing

Image result for static vs dynamic testing blog

http://www.360logica.com/blog/difference-between-static-testing-and-dynamic-testing/

Static testing and dynamic testing are two types of processes when testing software. Software testing is a process of analyzing and operating software to reveal bugs.  Static testing is a white box system of testing where developers check the code to find a fault. Dynamic testing is a process of operating a real application with valid entries to verify expected results.

Other main difference between the two types include:

  • Static testing is about prevention whereas dynamic testing is about cure.
  • Static testing is more cost-effective than dynamic testing.
  • Static testing tools provide greater marginal benefits as compare to dynamic testing.
  • Static testing gives comprehensive diagnostics for code than dynamic testing.
  • Dynamic testing finds fewer bugs as compare to static testing.
  • Dynamic testing usually takes longer time as compare to static testing as it test each case separately.
  • Static testing covers more areas than dynamic testing in shorter time.
  • Static testing is done before the code deployment whereas dynamic testing is after the code deployment.
  • Static testing is done in verification stage whereas dynamic testing is done in validation stage.
  • In static testing code is being examined without being executed whereas In dynamic testing, code is being executed and tested without necessarily being examined.

I chose this blog because I didn’t know anything about dynamic or static testing. I knew that software had to be tested, but I didn’t know there were two processes. Finding about these two processes made me think that one process probably works much better than the other depending on the type of software that is being created. If I were to make an assumption of what type of testing I would most likely use, it would be static testing because I am the type of person that often checks code to find faults. However, after briefly learning about these types, it would all matter on the type of application in the end that would determine which test process would be most efficient to find bugs. I also think that if I were to test software, I could use both because why not.

Overall, this blog outlined the most important aspects of static and dynamic testing. Understanding these two types is important because when I go and develop gaming software, there would be different types of games, which contain different code layers that I’d need to analyze and find bugs. A lot of games nowadays have updates and bug fixes, so it is necessary for me as a future game developer to find all the bugs or at most of them before releasing the game for the public to enjoy.

From the blog CS@Worcester – Ricky Phan by Ricky Phan CS Worcester and used with permission of the author. All other rights reserved by the author.

Elements That Cause Design Smells

http://www.codeops.tech/blog/linkedin/what-causes-design-smells/

In this blog presented by CodeOps, he explains what causes design smells. From the image displayed above, some of the causes include violation of design principles, inappropriate use of design patterns, language limitations, procedural thinking in OO (Object-Oriented Environment), viscosity, and non-adherence to best practices and processes. 

CodeOps gives an example for the violation of design principles by considering the Calendar class in java. He makes a valid point that the Calendar class that is part of the java.util package has a Multifaceted Abstraction Smell because the class itself is overloaded with multiple responsibilities and tasks, which violates the Single Responsibility Principle.

To provide an explanation of inappropriate use of design patterns, CodeOps explains that software designers sometimes apply methods that solve problems but often do not know the full understanding of the effects of their solutions. There needs to be a balance of design patterns, which is why designers need to know which patterns would be needed to efficiently implement the function of the software.

There are many kinds of programming languages out there such as C, C++, java, python, and perl. These languages can differ from one another in a sense that some generic features in these languages may not support certain primitive types. This is called language limitations because there are limits to what each programming language can do as CodeOps states for example “since the generics feature in java does not support primitive types, it is not possible to eliminate such code duplication when programming in java.”

Procedural thinking in OO refers to programmers implementing procedural thinking into their code. These programmers make the mistake of thinking that classes are “doing things” than “being things.”

Viscosity means resistance and is in the form of two types: Software Viscosity and Environment Viscosity. Software viscosity is the resistance that must be encountered when the correct solution is being applied to a problem. Environment viscosity is the resistance offered by the software development environment that must be overcome to develop good practices.

Non-adherence to best practices and processes can cause design smells because a process in a design that is not properly practiced or tested can definitely result in problems within the entirety of the software itself.

I chose this blog about design smells because I wanted to take into account what causes design smells. Part of what I learned about it was that you needed to right “clean code” and not “bad code” in order to have a high quality design. However, I had a feeling there was more to it than just writing a properly written code. Taking in all of these elements helped me understand how to avoid design smells. Elements such as these helped me understand how to work and process a design outside of the realm of programming.

 

From the blog CS@Worcester – Ricky Phan by Ricky Phan CS Worcester and used with permission of the author. All other rights reserved by the author.

Lab 3: Obstacle avoidance and Multi-process systems

Before I would like to start, I would like to speak openly here for the intelligent Dr. Wurst, my professor, to ask him something really quick.
Would this blog post count as acceptable for a lab notebook entry? It would be a pleasure and a great convenience if you will accept this!

I will answer all of your questions in the following paragraphs and write about me, Urooj, and Braxtons time working on Lab 3 for Robotics.

Let us begin.
Today, I am working on finishing up our multi-process c program that will have the robot adjust its direction and speed at the same time, thus two processes working in a multi-process system can be observed.

If we had approximately four or so hours straight to spend on this lab, we would have completed it all in one day in my opinion.

But that is fine, now I am back and now I am more than ready to solve some problems!

There begs a question: What will I do first? Well, right here and right now is a start. Keeping steady lab notes and tracking everything I do will be most beneficial for us all in the long run, as we all can learn easily about anything — we must simply have a passion for whatever it may be!

I apologize. I am writing much like a Philosopher. One could say I am a philosopher of technology. With this out of the way however, I would like to actually get down to business. I will now begin [:chuckling:]

I am going to produce a program to read the Sonar Sensor attached to the 0th analog position in the Botball device. After I do this I will begin to track the sensor readings for the following materials and light levels.
If my hypothesis is correct then light levels will not affect the Sonar sensor, as it uses echolocation to sense its surroundings. What a smart device truly!

However if I were to attach light sensors and IR sensors, I could create even more functionality to the robot.  Heck, imagine if I put a camera on the front of the robot to stream to my phone! And a bluetooth keyboard to have the user gain full control of the robot itself.
Goodness, technology endlessly brings me so much interesting new stuff to work with! Okay, I am going to stop writing here now so that I can accomplish the programming for the Botball.


Attempt Number 1: Robot keeps moving forward, stops to check IR readings (sensing left value vs right value.) but fails to adjust course in second function. Layout of functions: First function is the IR reading function, then comes the DRIVE function. The IR reading (and, well, writing as well) function keeps track of the devices input readings and adjusts variables so that the drive function performs as we want it to — to avoid obstacles or turn around if there is no way forward.

Changed motorValue from changing using is equals ( == sign) with = sign. Maybe program will work now. Attempt number 2 will be detailed in the paragraph/s below.

Attempt Number 2:
Attempt 2 was a success!! The robot followed the instructions perfectly this time after setting each analog state (0 and 1 as floating points) and used multiple functions in rapid succession. Time to implement C multi-process capabilities and if this works the robot is all set. Its behavior is to like stimuli and approach it (when it senses more from one IR to the other, it goes towards the stimuli closest.)

Attempt Number 3:

Pre-program test: Using multi-process function in KIPR C programming environment means I might not be able to use the defer method. Initially I would have used this in between processes to defer the need of one process to the need of the other process. Let us try to see how it works.

Post-program test:

Robot functionality lost while using start_process and kill_process. Maybe I should use kill_process in while loop? Next attempt will be below.

Attempt Number 4:
Put the start processes and kill processes before and after with while loop. Did not work. Now attempting to change kill_process(0 and 1) to kill_process(1 and 2). Maybe this will finally work?

Attempt Number 5:
Everything is balls [:tears forever:]

From the blog CS@Worcester – Sean Raleigh's CS Blog by sraleigh62 and used with permission of the author. All other rights reserved by the author.