Design Patterns: Iterator

I’ve been discussing AntiPatterns quite a bit lately, so I elected to switch it up and talk a bit about Anti-AntiPatterns, aka Design Patterns. As a quick recap: If AntiPatterns are common bad practice traps that developers/teams can fall into, then Design Patterns are good practices which help guide them to either avoid AntiPatterns, or to lean towards a more efficient solution.

One design pattern we’ve used many times in my Data Structures class is the iterator, and personally feel as though it was never fully explained to the class as to what an iterator even really is, let alone why we were writing one. This post from Sourcemaking.com helped a lot in terms of learning what the use of them is.

As covered in the article, there has been a push in recent programming towards something called “Generic Programming”, and the iterator is a core idea within it. An iterator is an attempt to abstract out the traversal of data items in a data structure into a separate thing. The usefulness of this is outlined by an example given in the article:

“As an example, if you wanted to support four data structures (array, binary tree, linked list, and hash table) and three algorithms (sort, find, and merge), a traditional approach would require four times three permutations to develop and maintain. Whereas, a generic programming approach would only require four plus three configuration items.”

– Sourcemaking.com

So essentially, your iterator is an object in itself that handles the job of traversing through the objects in a list. A real-world example of this may be the AM/FM radio controls in your car. The radio stations are the objects in a list, with their station name and frequency (or channel, I suppose) as their data. The iterator would be your “scan” button, which skips over the stations with fuzzy signals in order to reach the next one whose frequency is available to you, while all you did was press the one button. Each station is a data point in your list (your data structure) with a station name and a frequency. You, the driver, don’t need to know anything about the details of the stations you’re scanning over, because the iterator (the scan button) handles that for you when finding the next available station.

The article from Sourcemaking has several really great UML diagrams and other examples to pick apart which help elaborate on the subject even further. I highly suggest visiting their website to read more about it — they have detailed explanations on almost every type of AntiPattern and Design Pattern I’ve looked into so far.

From the blog CS@Worcester – James Blash by jwblash and used with permission of the author. All other rights reserved by the author.

Testing vs. Debugging

If you’ve been immersed in the tech industry for any amount of time, the difference between Testing and Debugging is probably pretty clear to you. The two concepts are interlocked and cannot exist without one another, even if they are very different. I recently found this article which outlines the differences between them, the purposes of each, and some tips to help with the debugging process. To start off, let’s examine a really great graphic they used to describe the differences: 

As shown above, testing is a process usually maintained by a dedicated team (or at least a few individuals who assist the development team). The job of the tester is to ensure that the product adheres to guidelines, and that it doesn’t execute in any way that it isn’t supposed to. Tests can be automated or manual (or a mix of both), and are intended to not only find an incorrect result, but also to find specifically where the failure happens and what may result from it. Given this information, the correction of the error becomes much easier.

So then what exactly is debugging? Once the testing team observes a failure, they bring that failure to the attention of the development team. It is then again the job of the development team to run through a few instances of the error and find out what exactly is going wrong, attempt to fix that issue in a way that still adheres to the project guidelines, and then resubmit it to the testers. If the testers find an issue, it is no longer their responsibility to ensure that a solution is found. It is the development team’s job to figure out what is going wrong and implement a good solution — and that is debugging.

A lot of this is probably common knowledge in the field, however “debugging” is a term that is haphazardly tossed around (kind of like “refactoring”) that I feel its’ meaning is easily lost. Especially for those breaking into the field or students just learning about what these concepts are, having loose definitions can be confusing. Essentially, if you’re fixing a known error, you’re debugging the code. If you’re trying to find errors, you’re testing your code.

From the blog CS@Worcester – James Blash by jwblash and used with permission of the author. All other rights reserved by the author.

Big Companies and Flaws

In software teasing and quality assurance, it is very important that issues be buffed out before release of a product. A lot of companies pour a ton of resources into this and inevitably things still do slip through space. One of the issues developers deal with a lot post launch are security issues. A lot of people may think that security issues are exclusive to smaller companies because they often think that “the bigger the company the better the security”, however, this has been proven wrong time and time again. Throughout Windows 10’s 2018 history, a lot of big updates were released. A lot of these updates actually needed up breaking a lot of things. Let’s go over some of the issues and look at what a little more software testing and quality assurance could have avoided.

Microsoft had been planning to release a massive Windows 10 update in April that added a ton of new features (including security) to their flagship operating system. However, a very bad bug that was causing Windows 10 to spam the blue screen of death was discovered. Microsoft could not release this big update with an issue such as this because it would leave the operating system even more unstable than it already is in its current state. After this issue was fixed, Microsoft was ready to finally ship out the update after a long delay. However, after the update was shipped out, there were over 600 million reports of Google chrome freezing and crashing after the update.

I think the reason that things like this happen is because of rushed deadlines. Sometimes while scheduling updates, there are a list of prioritized tasks that need to be finish in order to meet a deadline. However, in this rushed period bugs and glitches are bound to be overlooked because of the stressful development runs. In this case, Microsoft had to actually take the update offline and rollback the update because their user files were being deleted. From this, we learn that time management is important but also making sure rushed development doesn’t end up making the end users’ quality of products even worse.

From the blog CS@Worcester – Amir Adelinia's Computer Science Blog by aadelinia1 and used with permission of the author. All other rights reserved by the author.

Grey Box Testing

I am writing in response to the blog post at https://www.guru99.com/grey-box-testing.html titled “Grey Box Testing: Process, Techniques, Strategy, Challenges”.

Grey box testing, as the name suggests, is meant to be a combination of black box testing and white box testing. In white box testing, the internal structure of the code is known, and in black box testing, the structure of the code is unknown, and in grey box testing, it is partially known. Grey box testing combines the benefits of black box testing and white box testing, combining the input of developers while testing from the perspective of a user.

An example of grey box testing is given where a tester is testing a website and something is wrong with the HTML code, so the tester is able to look at and make changes to the code themselves to continue testing. A few other types of testing are listed as qualifying as being in the category of grey box testing: matrix testing, regression testing, orthogonal array testing, and pattern testing. These methods follow the strategy of black box testing while integrating some white box testing practices to focus more on what the test cases should be looking for.

A sequence of steps is provided for how to perform grey box testing. The first two steps, identifying inputs and outputs, do not seem to be directly related to black box testing or white box testing alone. In black box testing, there would be no need to explicitly identify the inputs and outputs; they would already be given in the test specification. The creation of the specification does require access to the code, which relates to white box testing, so grey box testing in this sense seems like a real-time testing approach where there is not necessarily a pre-developed specification and learning about the environment is a part of the testing process.

Challenges in grey box testing that are listed include when a test executes and the result is incorrect, and when something being tested encounters some failure. These do not really sound like challenges, they seem to just be examples of what testing is for.

From the blog cs-wsu – klapointe blog by klapointe2 and used with permission of the author. All other rights reserved by the author.

Choosing Testing Techniques

I recently landed upon this article, which is essentially an introduction into software testing. It gives a great overview of why different types of testing techniques are important, what different types aim to achieve, and the ins-and-outs of each.

The last section though is perhaps the most interesting, as I think it covers a topic that we haven’t discussed quite as much in our testing class (although my professor would probably beg to differ) — different reasons for choosing each type, and what may influence your choice.

In this article, the author mostly reflects on outside influences as opposed to outlining which technique to use to solve technical challenges best. I suspect this is because each technique has its pros and cons in each technical situation. Some influencing factors are:

  • The Type of System/Software App
  • Regulatory Standards
  • Customer Requirements
  • Type/Level of Risk
  • Test Objective
  • Tester’s Skill & Knowledge
  • Time and Budget
  • Development Life Cycle
  • Previous Testing Experience

By now, I’ve learned that different companies/teams will follow different testing paradigms (usually they’ll implement several of them, to be more accurate). There doesn’t seem to be an industry standard, and I’ve heard that even things like code reviews aren’t necessarily used everywhere. What I find interesting about the points listed above is that it gives some insight into the reasoning and motivation behind why teams may choose different techniques to implement for their particular scenarios.

For example, some software systems may work better with static vs dynamic testing as their primary methodology, and some (although probably most) would prefer a decent blend of each. Obviously the time and budget for the development cycle of the app will influence how rigorous the testing process is, which will influence what specific techniques teams implement as well.

Another interesting point I felt the article made was that the customer may actually have a preference for how they want their product to be tested. I think this was an interesting point because, while a customer probably wouldn’t say “I want you to use more white-box testing”, their requirements may actually require the team to modify the tests that they had intended to use in indirect ways.

I felt as though this article was an interesting overview of different ideas in software testing, from the different types of testing, to the advantages and disadvantages of each, to the reason behind choosing which one may be best. This website, Test Automation Resources, seems to have a lot of interesting and easy-to-read testing articles. I’ll likely be reading more from it in the future!

From the blog CS@Worcester – James Blash by jwblash and used with permission of the author. All other rights reserved by the author.

The Structure of Angular Structural Directives

As I mentioned in a previous blog post, we have been working on a final project in our Software Design, Construction, and Architecture class, where we are constructing a single-page website that connects front-end and back-end components. I’ve been working on front-end elements most recently, and I got up close and personal with Angular structural directives (after debugging my code for almost 2 days). This link was my main reference when trying to fix my code: https://angular.io/guide/structural-directives.

Structural directives, like the name suggests, alter the structure of the HTML layout by changing individual elements in the document. The directive is simply added to the tag of the element to be altered, called the host element. Any descendants of this element will also be affected by the directive. For example, a tag with an ngIf directive would look something like: <div *ngIf=”true”>Hello there! (I didn’t add the ending div tag because this makes the whole tag disappear upon publishing this post)

There are three common directives used in HTML: ngIf, ngFor, and ngSwitch. ngIf takes in a Boolean expression as a string and displays the host element if the expression is true. For example, if the example tag from above was present in a document, the element would still display, and “Hello there!” would be visible.

ngFor is used as a repeater directive, where items in a list or array can be displayed by iteration, or a statement can be shown a certain number of times depending on however many iterations. The loop takes on Python syntax when expressed as a String for the ngFor directive. An example of ngFor would be: <p *ngFor = “let name of names”> This is a name.</p> The loop would iterate the same number of times as the number of names present in the list, and the statement would be displayed that many times as well.

Finally, ngSwitch operates like the switch statement in Java, where one variable’s value is checked, and depending on the value of that variable, one case will be executed, which is an element defined with that variable’s desired value. For example, if you’re trying to look up profiles for different users of a social media website, ngSwitch would work along the following lines: a profile variable would be set to whichever profile name you’d like to look at, and depending on the value you chose, that appropriate profile page would display.

This article was incredibly helpful for me to figure out how to conditionally display some of the elements on my webpage, and I am certain that I will use it later on for further reference!

From the blog CS@Worcester – Hi, I&#039;m Kat. by Kat Law and used with permission of the author. All other rights reserved by the author.

Importance of Quality Assurance

For this week’s software quality assurance Blog, I would like to revisit software testing as a career, because it is something that I am interested in pursuing. I found an article, “Software testing is big business,” from a South African website, “itweb.co.za”.
In the article, it stresses the importance of quality assurance in software. I think I have said here in this blog how fickle customers can be with software that is buggy and jump ship at the first chance if the code causes them even a slight inconvenience. If I have not said it here, I know I have read something similar before. The article repeats this sentiment, and it is probably something worth repeating. 
The article continues and says that developers often rush to add new features, while leaving quality assurance as an afterthought. The article claims that when companies allocate resources properly, about one third of IT budgets are allocated to software quality assurance and testing.
The article says that often software testers are seen as “second-rate,” which should not be the case. I was talking to my dad about entering the field as a software tester. He is a software developer, and he said something interesting that a colleague told him. He asked a coworker of his why he decided to stay a QE (Quality Engineer) when he had a lot of opportunities to be a developer. The answer surprised him, and I thought it was a good mindset that I might think about when I enter the field.
The QE said that a developer will usually work on one project at a time, and won’t be able to influence what other developers working on other projects are doing. A QE, on the other hand, will be able to influence everyone’s work. He has his finger in many, many pies.
I am more resolved to get into quality assurance the more that I learn about it. It doesn’t necessarily have to be something I do forever if I find I don’t enjoy it. I’m sure it would be easy enough to switch tracks.
I once heard some advice that when you don’t know where you want to go, a step in any direction is a step in the right direction. It is better that than being so paralyzed to make no choice. I felt this way when I had to declare my concentration, and again before that when I had to declare my major. In the same way, if an opportunity presents itself to start a career in quality assurance, I would like to jump at the chance.
https://www.itweb.co.za/content/KrxP3jqBkXkvA2ye

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

Differences between the different levels of tests

In these 443 blogs post I am going to write about the differences between the different levels of tests. There are four basic levels of tests which are unit/component testing, integration testing, system testing, and acceptance testing. Unit testing when you separate each part of the program and test them individually and confirm that they perform what they were design to do. This is usually done in the beginning of the development and usually done by the developer first than hand over to the testing team. Integration testing is when you break the program into combinations and test if they actually work together. This exposes any flaws that show if the components don’t work together or not. There are many ways this can be tested, bottom up or top bottom. System testing is one of the higher levels of testing. It’s when you test the whole program to ensure that it all work properly and meets the requirements. This is one of the most important steps before deploying the product and it confirm that the product is almost ready to ship. This can be tested in an area where user can test the product. This usually done when a special testing team to see if the product fulfills its requirements for the business. Acceptance testing is involving a lot of user end. Acceptance testing test whether the system complies with the user end. This step is to find out many different problems that can occur like bugs that can harm the product in anyway. During this step you can find out if the program will be installed or not into the user’s system. Every single of these testing levels is important and testing early to avoid error in the future and testing for often is well worth it. This important because finding and fixing errors near the finishing stage which be more difficult and more time consuming than finding them early. All in all, these four levels of tests are important, and I learned more about those four after reading this article. It changes the way I work because I know the importance of the levels and what to do in those levels.

https://reqtest.com/testing-blog/differences-between-the-different-levels-of-tests/

From the blog CS@Worcester – Phan&#039;s CS by phancs and used with permission of the author. All other rights reserved by the author.

Code Smells

Today I am doing another smells blog post but this one is going to about code instead of design. This article that I am doing it on contains many of the code smells and I will be being writing about some of the things I learned from them. First, code smells within codes:

Comments – I learned to remember that comments should be written for people, not the machines. I will also try to refactor my code as possible to avoid to comments for example better method names and cleaner code, so it would be easier to understand and follow.

Long Method – I learned that shorter method is better than longer method because it is easier to read, understand, and maintain. I will always try to minimize the size of my method as small as possible to be more efficient.

Long parameter list – I learned a great to limit the number of parameters by using a object to combine it if I actually need the values of the parameters because the more parameters there is, the more complex it is.

Duplicated Code – never have code that duplicated.

Conditional complexity – don’t have large conditional logic block, use design patterns to avoid this problem.

Combinatorial explosion – I learned that this is when we have lots of code perform the same operation but have a little difference. I think the best way to avoid this is to make a method for the operation.

Large class – if a class seem too large than you can break it into smaller class, so it can be easier to understand.

Large class – if a class seem too large than you can break it into smaller class, so it can be easier to understand.

Also, Code smells between classes:

Data class – I learned to avoid class that only data because a class should have data but should have method to manipulate the data.

Lazy class – this just means that every class should be important enough to be a class.

Shotgun surgery – this means that you should avoid making a class that effect other classed when making an update.

Solution Sprawl – this is when you have need multiple class to do one thing, it’s better off to simplify the code.

All in all, this article has All in all, this article has code smells and I learned a lot from them. I now know how to avoid these smells and how to deal with them after reading this.

https://blog.codinghorror.com/code-smells/

From the blog CS@Worcester – Phan&#039;s CS by phancs and used with permission of the author. All other rights reserved by the author.

What Causes Design Smells?

Hello, every and welcome to another blog post by Phan CS. Today topic is about to be about design smells. According to this article “design smells are certain structures in the design that indicate violation of fundamental design principles and negatively impact design quality”.  Design smells affect the software quality and the organization in a negatively way. The organization will be affected because the presence of the smells in the framework will be used by clients and depending of the feed back which is usually going to be negative, the whole community is going to feel the same and it’s also hard to fix design in the API when the API is already in use. There are many causes of design smells. First, when a class has multiple responsibilities this would consider a violation of design principles which they named multifaceted abstraction smell because abstraction should be unique. They had an example of this problem in the article which explains that calendar class in the java.util package support date-related functionality which it is supposed to but also supports time-related functionality as well which is a violation of design principles. Second, inappropriate use of design patterns which is when programmers try to apply design pattern because they are pressure into using them by don’t fully understand how use them and this result of too many classes. Next, is language limitations, this when two methods that support different primitive types belong to the same class and its java does support primitive types which result in it’s impossible to remove duplicate code. Also, when programmers mistakenly think classes are doing things instead of being things, this can cause problems that can result in design smells. Finally, design smell is usually created when a programmer is in a rush and is hacking the code because it requires less time and effort to do it this way. When the environment is following practice usually other programmers will so the same. All in all, design smell should be avoided because it bad for product. I thought this was interesting in many ways. This change the way I code because I will be thinking about what I am doing more.

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

From the blog CS@Worcester – Phan&#039;s CS by phancs and used with permission of the author. All other rights reserved by the author.