Why is Testing Code so Important?

We’re approaching week four in the semester and getting into the processes of testing code. Prior to taking this course, I’ve tested code typically with random input, ad-hoc style. But I am now learning new testing methods as well, which are more systematic and cover larger ranges of potential case failures. That being said, I would like to talk about unit testing in general, and why it is so important.

We do unit testing because we want to ensure that our code works. Sometimes it can be frustrating when we can’t get our code to do what we want it to do. We need to do thorough testing to weed out these problems. For instance, perhaps our code works sometimes, but not always, and we have no idea why.

It can be disheartening when spending hours trying to fix something in your code which seems to magically work for some inputs, but then crashes on others. It seems that simply entering a finite and/or random number of test cases, or simply not running tests frequent enough, we may not ever find out why our code only works sometimes, but not always.

Now that I’ve discussed a few reasons why I feel that unit testing is important, I would like to share a blog that I found on the topic as well.

The Green Machine (TGM): 5 Reasons Why Unit Testing is fun–and Important

As the title suggests, TGM provides additional clarification as to why testing code is an essential part of programming. He also emphasizes that unit testing is fun as well, for a variety of reasons.

For instance, TGM states that unit testing can be rewarding in the sense that “we can execute our code right away and know that it works.” Since one of the most enjoyable aspects of programming is seeing the result of our work, having the capability to test our code at any given point is beneficial. And if for some reason it doesn’t work, we can likely figure out where it went wrong faster if we’re testing in a frequent and consistent manner.

Unit testing can also lead to an overall better understanding of how our code works. As TGM indicates, unit testing helps us figure out how our code will behave under a large range of circumstances. By running frequent tests, we can gather a better understanding of exactly what our code is doing, regardless if the tests pass or fail.

TGM’s blog was an interesting read for me, especially in regard to his insights of how unit testing can be rewarding. I’ve always known that testing code was important for functionality reasons, and now I feel that frequent testing can help make me a better programmer in general. This is due to what TGM indicated about how we can learn more about our code through its behavior during pass/fail tests.

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

Interfaces

URL: http://www.codingblocks.net/podcast/episode1
So for the second blog, I did end up sticking to the same website and people I had listened to last week. The reason for this was, I had found a couple other podcasts I had liked, but they were harder to hear, and I just felt like I wasn’t as interested in hearing just one person talk. I really like the setup that Coding Blocks has with three people. So the topic I chose for this week was interfaces, which I know doesn’t completely have to do with computer construction, design and architecture, but from working in Eclipse from last week, I felt like it was just a good idea to watch another kind of  “back to the basics” video. Also, interfaces was just another topic I have always had a hard time understanding and I felt like it just helped me a lot with the understanding, just like encapsulation.      Now, just like last week, the speakers started off with a simple definition of what an interface was, “A contract of what you have to adhere to in your program, if there is something in the interface, you have to make it do something”. Pretty much, how you should interact with that piece of data. A good way that one of the men put it was that it is like two different kinds of people, there is Joe who visits his grandma, and the joe who goes to the bar. They are still Joe, but just different portrayals at the appropriate times and places. After that, they went on to describe the differences between an abstract class and an interface.  In an abstract class, you want to provide some implementation as part of it, but you want to make sure some concrete information is defined and you want that user of the class to add on to that with their specific use cases and needs. Storage is assigned for members that the coder wants to have available public or private, while interfaces don’t have that and only have a declaration. Also, abstract classes have to be inherited.     What I found really interesting about this podcast though is that when they mentioned when implementing an interface, it will almost always be public, but there is that slight chance that it isn’t. This is the explicit interface case. The example that was given was that there were two different interfaces with the same method. The class needs to implement both interfaces, but when the class can’t define them both with the same method, one of them has to be defined by default will be private. I hadn’t ever heard of that before, and It was nice how in depth the podcast went on about that.      Overall, another really good podcast. The setup of CodingBlocks just makes it very user friendly, and I am able to understand what they are saying without getting too lost. With each podcast I listen to, I feel a little bit more confident in my computer science grammar knowledge and just feel more prepared for when I do have to write more complex code. 

From the blog mrogers4836 by mrogers4836 and used with permission of the author. All other rights reserved by the author.

9/25/2017 — Blog Assignment 2 — CS 343

https://sandit27.wordpress.com/2008/03/24/what-are-anti-patterns/
This week’s post focuses on Anti-patterns. Patterns defines a common solution to a problem that occurs through different settings. It is a general solution that can be specialized for a given context. In software design, it helps to capture the best practices that can be reused and applied in the development of different types of software.
In CS, anti-patterns are repetitive practices that appears beneficial, but will most likely result in bad consequences that will outweigh the advantages. It is called anti-pattern because the use will produce negative implementations. Two key elements are used to distinguish an anti-pattern:
A repetitive pattern that appears beneficial but ultimately produces negative results that outweighs its advantages.
A refactored solution that has been documented, proven in practice, and repeatable.
Anti-patterns should be diagnosed early. The following are some of the classic Anti-Patterns:
Organizational anti-patterns:
The “I told you so” the ignored warning from an expert is justified.
Mushroom management is when employees are kept uninformed or misinformed.
Project management anti-patterns:
The smoke and mirrors shows how unimplemented functions will appear.
Finally, software bloat is for allowing successive versions of a system to demand more resources.
I chose this topic because I thought a blog post on anti-pattern of function as child component was interesting. The post can be found following this link, http://americanexpress.io/faccs-are-an-antipattern/. The article argued that Function as child component, FACC is an anti-pattern. FACC is a pattern that allows users to pass a render function to a component as child prop. It allows users to pass as children to a component/function.
FACC was argued to be an anti-pattern. The example was a summation function of 2 numbers and returns the result. Clean code practices recommends descriptive names for properties, variables, and functions. So, in this case the best practice is to name it as add or sum, but not children. The function passes render callback functions through a prop named children. The main issue here is that the FACC function uses the prop children to pass in render callbacks. This pattern goes against what is considered best practice, so it is an anti-pattern.
I chose this article because it introduces an anti-pattern in a reactjs function and reactjs articles are always an interesting read. It argues that naming props as children in the FACC function was not the best practice. It goes against what is considered to be the “Clean Code” standards. I thought that this article was worth a blog post because it was an interesting read.

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

9/25/2017 — Blog Assignment 2 – CS 443

Equivalence Class Testing
This week we turn to equivalence class testing. Equivalence class testing is a black box software testing technique that divides function variable ranges into classes/subsets that are disjoint. It is beneficial for two cases:
When exhaustive testing is required.
When there is a strong need to avoid redundancy.
Equivalence class testing selects test cases one element from each equivalence class. This helps to reduce redundancy.
There are 4 types of equivalence class testing:
Weak normal equivalence class testing: The term weak refers to single fault assumption. This is accomplished by using one variable from each equivalence class in the test case.
Strong normal equivalence class testing: The term strong refers to multiple fault assumption. This method uses test cases from each element of the cartesian product of the equivalence classes. The cartesian product guarantees the notion of completeness in that all of the equivalent classes are covered and there is one of each possible combination of inputs.
Weak robust equivalence class testing: This term combines weak with robust, meaning single fault assumption with invalid values.
Strong robust equivalence class testing: This term combines strong with robust, meaning multiple fault assumption with invalid values. The test cases are the cartesian product of all the equivalence classes.
This article talks about redundancy in equivalence class testing. It introduces the following problem: Suppose a there is a UI for creating user accounts. The Username is between 1 and 25 characters, spaces are not allowed. The gender can be Male or Female. It would be impossible to test all combinations of inputs instead we turn to equivalence class testing.

Breaking the conditions down EC reduces the test cases into 5 equivalence classes.

Field
Description
3. User Name
Empty
4. User Name
Length > 25 (no spaces)
5. User Name
Length > 25 (containing a space)
6. User Name
Length >1 and = with >.

I chose this post for its simplicity and example of the UI for creating user accounts. The example helps to connect the concept of EC to test cases that can be validated. So, it helps to break down the problem into different ECs and its product into different test cases. It also demonstrates the advantages of EC in helping to reduce redundancy and test time. I chose this post because it gives a good example of EC testing.

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

Anti Patterns that can be the Death of a Project

A course named “Software Construction, Design, and Architecture” can certainly hit upon an endless number of topics. Due to this problem, I referred to concept map Prof. Wurst created at the beginning of the semester. Of the various topics to choose from I ended up going with anti-patterns for this week. I’ve found learning what not to do can sometimes be more useful than learning what to do. A lot of times you can infer what to do by simply being told what not do to. In a nutshell, anti patters are common patterns that occur that are known to cause problems and make life more difficult. So, I stumbled upon a blog post written by Emile Swarts in which he discusses some of the most common anti patters he has seen. I found Emile’s thoughts to be quite useful and relatable and I will be sure to factor in these common situations when developing software.

Emile discusses five of them: accidental complexity, dependency hell, catch me if you can (he made up the name for this one), blind faith, and abstractions of deceit. With the experience I have gained from my internship, accidental complexity, blind faith, and dependency hell are the three that stood out the most to me and have encountered personally. I find people are very good at making things more complicated than it needs to be under any circumstances, not just software. Complexity is often the root of all problems and can ruin projects. If it works it should probably be left alone. The biggest thing I took from what he wrote about this is that accidental complexity can basically be blanket over all anti patterns. Don’t reinvent the wheel if you don’t have to. Work with what is already given to you. The next anti-pattern I mentioned I liked was dependencies. Dependencies break things and make things more complicated. In an ideal world each piece of software and everything each piece software does would be totally non-reliant on anything else. Obviously that won’t be happening anytime soon, but I feel it something all developers should strive for. I always think of operating system specific software as an annoying overarching dependency. Granted this often on purpose, but the point is it certainly would be easier if different software wasn’t needed for different operating systems. Blind faith is the last one I wanted to discuss. He brings up valid points on how damaging an update or new piece of software can be if it doesn’t work correctly. Depending on the size of the operation, it could cost companies thousands of dollars each minute the software is still broken. This is why no one should ever assume something works. No matter how confident you are, test it, and if it works, test it again. You don’t want your software to be source of a major problem.

Link:

https://www.madetech.com/blog/5-software-anti-patterns-i-love-to-hate

 

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

Qualities of a Great Software Tester

As I was perusing the various blogs about testing on softwaretestinghelp.com I stumbled across a blog titled “7 Qualities of Highly Effective Testers”. Seeing as I am currently taking a course on software testing I figured it might provide some useful information. The blog followed suit with what I expected; with talking point about meticulous attention to detail and whatnot, but that is not to say the article wasn’t useful. In fact, I found it to be quite useful because it justified why these seven qualities are needed.

The seven qualities discussed were: curiosity, attention to detail, imagination, logical thinking, ability to focus, discipline, and constructive communication. Having some experience testing software at my internship, a couple of these really stood out to me. Curiosity/imagination (I feel that these go hand in hand) were the first ones. Under these topics they discuss how a good tester will think of every possible scenario. This includes things like behavior that you normally wouldn’t expect a user to perform or potential flaws in the deepest, darkest corners of your code that you would never expect to be exploited. If you don’t expect it to happen, it probably will. One example they gave is “what will happen if I click on the ‘submit’ key and then hit the ‘escape’ key?”. When testing you must make sure you cover everything across the board even if you think the chances of the scenario playing out are less than zero. I can tell you a lot of the problems we have found with the product we are building at work have come from a “let just try this for the fun of it” comment while testing.

Attention to detail is the next one that stood out. To me this means that a good tester will take note of even the smallest flaws. If the tester feels that it due to his/her own mistake or some external circumstance that normally wouldn’t be there, the issue still needs to be noted. Because what if it is not? What if it has been a recurring issue, but because it is so minor other people running tests have chalked it up to the reason you think it is? Everything, no matter how minor it seems, need to be tested and recorded.

The last one that really stood out was constructive communication. Nobody wants to hear that their product doesn’t work as it should. In the case that someone other than the developer is running the test, the tester needs to be able to communicate with the proper sources to explain the issue without making seems like they are trashing the product. There needs to be a good relationship between the testers and engineers/developers.

After reading this I feel a lot of what was discussed it true and these skills are critical if you are going to be a highly effective tester.

Link:

http://www.softwaretestinghelp.com/7-qualities-of-highly-effective-testers/

 

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

The Future of Testing Taking An Interesting Turn

So, I was reading a blog called Awesome Testing the other day, (really clever name, I know, it’s what caught my attention) and I saw a whole section of pages titled “TestOps”. Intrigued, I ventured further by reading the posts, which led me to the initial blog post that coined the term, by Seth Elliot. The short and sweet of it is that originally testing can be represented by this diagram:

software_testing_model

The tests are created, they are run on the system, the results are obtained, the results are checked against the ‘oracle’, and an assessment is completed. However, the interesting thing is the current trend in software products. The most popular products now a days are not simple programs, but are actually services. Facebook, Amazon, Twitter, etc. With this new change, testing becomes a bit more different. Big Data concepts are used, new features are tested with exposure control and monitors. This becomes the new model:

model

The testing system becomes a whole architecture testers are serviced with maintaining and using. This whole post was incredibly interesting to me. As someone new to Software Testing, my experience up until now has been discrete test cases and suites. With TestOps however, testing becomes a whole new beast. Using Big Data techniques to test how well a service is doing, not just if it runs correctly was a definite surprise. As someone who is currently dipping their toes into Big Data as I take a Software Quality Assurance course, I didn’t expect the areas to meet like this.

The final paragraphs of the post describing how this development is also blurring the lines between tester and developer is exciting. There was the worry in the back of my head, that software testing and development were two divided areas. That one had to choose one or the other. But knowing how much they will intermingle in the present and future helps alleviate this to a great extent.

It also makes a large amount of sense. As the software being tested becomes much more dynamic, testing must as well. Not just testing if software is working, but working well is quite the interesting distinction that requires more complicated solutions. These tests will require a process similar to software development to create. Choosing the right kind of Architecture, using tools similar to software process management tools to cut down on the time QA requires to make new tests or change existing ones, and the continuous updates and integration.

The incredibly interesting blog post can be found here: https://dojo.ministryoftesting.com/lessons/the-future-of-software-testing-part-two

The original blog post that sent me to it: http://www.awesome-testing.com/2016/07/testops-missing-piece-of-puzzle.html

From the blog CS@Worcester – Fu's Faulty Functions by fymeri and used with permission of the author. All other rights reserved by the author.

B1: Dangers Of The IoT

Gregory Falco: Protecting Urban Infrastructure Against Cyberterrorism

         This article from MIT shows the story of Gregory Falco who is a PhD student that works with urban planning and computer science. The article talks about the IoT (Internet of Things) where everyday objects are embedded with the basic functions of communications to other devices through the internet. Falco works with getting this project off the ground and around the world to other countries so that everyone can have the positive effects of this technology. He says it will help solve their problems with sustainability issues and social problems. However, there were concerns with security of this new system as it is possible for new technology to be susceptible to hacking. Falco continues to explain in the article that IoT devices usually have little to no real security software as they only have small amounts of memory and low-power processors. This can become a “gate” for hackers to exploit bigger systems as they may all be linked on one network. Falco is working on the industrial controls and embedded systems within the IoT such as automatic switches. He goes into detail of all the dangers this hack could create for a variety of people. IoT devices can control anything from subway switches to insulin pumps which puts a large number of people at risk.

            I chose this specific article because it was really interesting that as technology gets to be smaller, we are running into roadblocks like this. This is a very important roadblock because it shows that we need to develop technology to meet these needs faster or many people could lose lives. I found it was interesting how hackers can exploit the smallest flaw in a system to extract dangerous information. I think that the resource was quite interesting and made me more aware to the dangers of having little no security on devices. I feel that technology needs to have some sort of real security behind it as we are constantly relying on for our life functions such as water grids and electric grids. I learned quite a bit on this material from how much technology is taking over our lives to how insecure and manipulated it can get. This helped show me the side of hacking where even small flaws within a system can be used to hack into a much bigger system. It can be important to learn this sort of material because it really shows you to be careful when designing programs and working with networks to make sure that you know what data to keep private vs public. If you give the user access to public data, they can use it to break the system and cause a lot of damage to the program.

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

The Importance of Patterns in DDD

In this post, Jan Stenberg describes a conference in Amsterdam lead by Cyrille Martraire, Founder of the Paris Software. Martraire stresses the importance of knowing and evolving design patterns. Noting a few examples,

“…Exceptional Value which makes it possible to write code as a business domain statement by removing all need for special case handling like dealing with illegal or zero values. Another pattern that he has found particularly interesting is Diagnostic Query, a pattern which suggests that an object should be able to describe how it reached its current state, a diagnostic ability that replaces the need for logging and debugging. A Money object with a value of 100 EUR could then describe that the amount came from adding a certain amount of GBP with an amount of USD.”

In reference to modeling domain concepts and their relationships, Martraire found these patterns to be very useful:

Composite for composing objects into tree structures and letting a client treat individual objects and compositions uniformly.
Interpreter for evaluating sentences in a language.
Flyweight that uses sharing to support large numbers of fine-grained objects.
Strategy for separating algorithms themselves from their usage.

Martraire says that learning and implementing new and sometimes more simple design patterns will help you apply them in new domains.

The post The Importance of Patterns in DDD appeared first on code friendly.

From the blog CS@Worcester – code friendly by erik and used with permission of the author. All other rights reserved by the author.

Unified Modeling Language (UML)

We’ve been discussing this in class for the past couple of weeks so I thought this would be a good topic to reflect upon. Unified Modeling Language, or UML, can be described as the graphical representation of a program’s structure. This is useful for documenting relationships of, for instance, objects and classes in a given structure. Furthermore, UML diagrams can provide general descriptions of the intended behavior and purpose of these classes and objects.

I felt it would be useful to learn more about how to make the “ideal” UML diagram, and Bellekens has a good blog in regards to this topic.

GeertBellekens: UML Best Practice: 5 Rules for Better UML Diagrams

The blog is a good read on the subject because it emphasizes the importance of consistency as well as simplicity when designing UML diagrams. Five general “rules” were discussed in Bellekens’ blog. I will summarize these below while simultaneously providing my personal takeaways from each of them.

Less is more.

When designing UML diagrams, it is important to provide the user with information that is clean, easy to follow, and straight to the point. If a diagram has too much going on, it is bound to confuse and overwhelm the user with excessive information.

No crossings.

Bellekens explains that when designing a UML diagram, there is no need for lines to cross when pointing to the various objects within the structure. Instead, enough space should be allocated to prevent this line crossing from happening. If one is unable to find the space to prevent crossing, this is often a good indication that there’s too much going on in the diagram in the first place.

Orthogonality.

While it is possible to make diagonal lines when pointing from one object to another, I feel it does not nearly look as clean as straight lines and right angles. Other than a few minor exceptions, such as pointing to notes, Bellekens suggests to avoid making diagonal lines in UML diagram at all costs.

Parents Up.

In regards to inheritance and other hierarchies, “parents/superclasses” should always be above their “child/subclass” counterparts. This makes sense to me because whenever I think of something such as a UML diagram, I think of a family tree; oldest on top, youngest on bottom.

Tidy Up.

A great closing argument to Bellekens’ five rules of UML diagrams. Maintaining the validity of UML diagrams and keeping them up to date is just as important as designing a solid graphical representation of our programs in the first place. A UML diagram that is outdated and cluttered with unnecessary information can be frustrating to say the least. Furthermore, keeping objects aligned in an orderly way makes UML diagrams easier to follow and pleasing to the eye.

I look forward to learning more about Unified Modeling Language Design in the upcoming weeks – I am sure I will use Bellekens’ tips on creating solid UML diagrams in the near future!

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