Author Archives: myxuanonline

10/16/2017 -Blog Assignment Week 5 CS 343

https://airbrake.io/blog/design-patterns/factory
The post this week hinges on factory pattern method. Similar to simple factory, factory method revolves around the concept of a factory. An important difference is that factory methods provides a simpler way to further abstract the underlying class. As further explained in the article, like factories, the code should make use of an intermediary factory class, which provides for an easier way to rapidly produce objects for the client. The main benefit as explained is that the factory should “take care of the work for us”, meaning that we do not have to care about what happens behind the scene, we can just want to use the codes.

In order to explore a real world example of implementing a factory method, the article explores the relationship between authors and publishers. As we all know, there are many different types of authors. For example, those that specializes in fiction or nonfiction. Similarly, different publishers prefer authors that specializes in certain fields and styles of writing. An example of a publisher is a newspaper. A newspaper is a type of publisher that focuses on publishing nonfiction authors.

In the example, the publisher acts as a factory method, where it always have some tasks that remains the same. The baseline concept is that it acts as a factory to abstract and separate the different types of publishers from the different types of authors. The main goal is to separate the process of hiring the type of author from the particular type of publisher. The code starts off with a basic IAuthor interface, which contains the Write() method. From there two unique types of authors are used FictionAuthor and NonfictionAuthor. Both contains the Write() method. The publisher class contains the core component of the factory method pattern that is it contains a HireAuthor() method and a Publish() method.
The convenience of the factory pattern method in this case is that implementations of the Blog.HireAuthor() and Newspaper.HireAuthor() methods can be different. All in all, the client can freely create a blog and newspaper by issuing the Publish() command without knowing the internal workings of the factory method. The result is automatic instantiations of the appropriate types of IAuthors, which implies that it instantiates the correct type of author for what the type of publication had expected. The Publisher class furthermore adheres to the open/closed principle so that it can be easily expanded without affecting the other internal codes. The main idea here is that any inherited classes from Publisher can be referenced without having knowledge of how the authorship or the writing process works behind the scenes.
I chose this article because the example outlines the advantages and disadvantages of factory pattern methods. One advantage based on the example is that it encourages consistency in code that whenever an object is created it uses Factory instead of different constructors at different client side. Another advantage is that it enables subclasses to to have extended versions of an object. Therefore, creating objects inside factory is more flexible than creating one directly in the client. Finally, factory design makes it easier to debug and troubleshoot the code since it centralizes object creation and every client is receiving the object from the same place. The main disadvantage that I see from the example is that it can complicate the code when it is unnecessary. That is why I chose this topic this week in order to analyze the advantages and disadvantages of factory pattern.

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

10/16/2017 – blog Assignment Week 5 CS 443

http://reqtest.com/testing-blog/white-box-testing-example/
This week we generalize to whitebox testing. Whitebox testing or code based testing as the name implies works at the code based level. This technique does not rely on the specifications but instead provides the programmer with the actual code. Armed with such technical details, programmers can create test cases to test for the success of the system. The key principles to successful testing are the following:

Statement coverage – the simplest type of coverage ensures that every statement is executed.
Branch coverage which ensures that every branch is covered.
Finally, path coverage which ensures that all paths are tested.

Statement and branch coverage does not guarantee full edge coverage. So, above all path coverage is favoured for its comprehensiveness.
For code testing, I have always asked if white-box testing is enough to create a successful, working product when the tester already has the code. What are the advantages of black box testing when whitebox testing should be sufficient?
This article is all about whitebox testing. It poses the question of which is better white box or black box testing, but does to formulate any favoritism for either. Both has advantages/disadvantages depending on the scenario, so neither can be ruled out over the other. As stated in the article, black box testing allows the system to be tested from a user’s point of view. White box testing on the other hand allows the system to be tested from a developer’s point of view.
Black box testing allows the tester to have more perspective on the intended customer/users and tests for the expected results. For new insights, the author seems to favor it during the early stages of product development and the first few sprints in the release. It allows for further progress and development after eliminating “show stopper” bugs. However, from what I have seen black box testing is redundant and consumes too much time. One disadvantage is that test cases are extremely difficult to design when the specifications are unclear and not concise. One advantage is that it can test for boundary conditions.
White Box testing on the other hand, allows the tester to see the code. Therefore, it helps to bring out bugs that would otherwise be missed with black box testing. White box testing as stated helps to fix journeys and scenarios that would have otherwise been considered as exceptions, but that can be damaging in real life in terms of reputational, regulatory, and monetary damages. It allows for code optimizations by revealing hidden bugs. The emphasis on it is that it allows engineering teams to conduct thorough testing of the application by allowing for all possible paths to be covered. So, in my opinion whitebox testing should be given higher weights

I chose this article for generalization and out of interest to learn more about whitebox testing. Although the article does not show favoritism, I am in favor of most of the techniques over black box testing.

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

10/9/2017 — blog assignment Week-4

http://truptijethva.blogspot.com/2010/05/how-to-perform-decision-table-testing.html
This week we focus on decision table testing. Decision table testing is a black box testing technique, which, contrary to boundary value testing and EC class testing which tests for individual input conditions, tests for combinations of conditions. A more formal definition is that it is a table, which displays combinations of inputs and/or causes along with the associated outputs or actions. It is helpful for designing test cases. The advantage is that it ensures full coverage.
This blog post provides an example of decision table testing which takes us away from the common approach of using true or false as conditions. So, it gives a different perspective, demonstrating the versatility of the method compared to the other test methods mentioned before, which was boundary value testing and EC testing. The example is that with stub for flyer member and whether they are traveling in the business class or the economics class. The table rules uses yes and no, which is equivalent to true and false for the flyer member conditions, but business or economics class for the class condition. This shows that the conditions of whether the member is in the business or economics class can be collapsed into one condition, which is the class condition, instead of in two which would have been for example the business class and the economics class. This shows that the conditions from the assignments in class can be collapsed as well instead of creating equivalent classes which would make the rule counts more accurate and it would lessen the counts significantly as well.

For the stubs column the conditions are: for conditions we have flyer member and class. For actions we have upgrade to first and upgrade to business.

The rules are the following:
1. flyer member yes, class business, upgrade to first yes, and upgrade to business irrelevant.
2. flyer member yes, class economics, upgrade to first no, and upgrade to business yes.
3. flyer member no, class business, upgrade to first no, and upgrade to business irrelevant.
4. flyer member no, class economics, upgrade to first no, and upgrade to business no.

The question to ask is which rules follows these two test cases.
testcase1: Frequent flyer member, traveling in business class
testcase2: non-member, traveling in economics class

Matching the test conditions with the conditions and actions for the rules column, we have rules 1 and 4. This states that for testcase1 the following actions should apply: upgrade to first yes, upgrade to business irrelevant.
For testcase2 the following actions should apply: upgrade to first no, and upgrade to business no.

I chose this blog post because it is coming from a test lead in the software engineering field. So, this is an example of a real world application of decision table testing in software development. It gives an interesting perspective that decision tables can have conditions outside of the normal norm of yes or no and true or false and still provides to conditions of business and economics. This raises the question of whether or not a condition can have more than 2 variables in testing or is it more convenient to break up the solution into multiple conditions. In the latter case, this would increase the rule count. In the first case, it is using more than 2 variables in a single condition. The answer to this question probably depends on experiences with testing. But, it raises an interesting blog post topic of the advantages and disadvantages of breaking up conditions away from its normal norm of true and false. I chose this post because it gives a different perspective on decision table testing and raises some interesting questions on the topic about breaking up the conditions or not.

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

10/9/2017 –Blog post Week 4

http://javarevisited.blogspot.com/2011/03/10-interview-questions-on-singleton.html
The topic for this week is on singleton patterns, but specifically for real world applications, on common interview questions that could catch any undergraduate students.
Let’s start with an introduction. Singleton pattern is a software design pattern that restricts class instantiations to one object, which implies that it restricts the class to global variables that can be accessed and changed anywhere in the code. Thus, the critics calls it an anti-pattern. Critics argues that it is overused in too many places where it is not beneficial. It introduces unnecessary restrictions where one single instantiation is not required, and it introduces global variables into the application. Thus, singleton patterns complicates the code. So, why is it useful? In Java, singleton design patterns are the most common patterns a software developer will see. It is heavily used in core Java libraries.
The article introduces 10 common interview questions and answers on singleton patterns in Java. I chose it because doing well on technical interviews is one of the most crucial aspect to landing a great career in this industry. This blog post is a learning step that any undergraduate students can reflect upon. We will only list 5 here, however.
The 1st question is the obvious: What is Singleton class? Have you used Singleton before?
The answer is the following: As stated above, Singleton is a class with only one instance. It provides global variables that are instantiated only once and can be accessed through the getInstance() method. The advantage is that it saves memory from having to instantiate the objects every time. Have I used singleton before? My background is mostly data analytics for the sciences. So, no.
The next question is: Which classes are candidates of Singleton? Which kind of class do you make Singleton in Java?
The author of this blog post commented that this is used to check whether or not the candidate has enough experiences with singleton usage or not. Are the candidates familiar with the advantages and disadvantages of singleton in Java?
The answer is the following: Any classes that would be available to the whole application and hold only one instance. An example is the Runtime class, since only one runtime environment is possible. Another is the utility classes like Popup.
The final question is, can you write code for getInstance() method of a Singleton class in Java? This tests the programmer’s ability to understand the code as well as the concept, since there can be many follow-up questions about the code that the candidate had written.
The answer is to not write the code with double checked locking until asked, since it is more complicated. Therefore, the chances of errors are greater. However, for more experienced programmers with deeper knowledge of double checked locking, volatile variable, and lazy loading, why not?
I chose this post as a reflection on interview questions that I could come across in the workplace. One of the most interesting questions I have been asked is what happens to a particle whose speed exceeds or reaches the speed of light. However, even in technical interviews for software development, I have never been asked questions about singleton patterns. So, this blog post was out of curiosity of the different interview questions that I could come across on singleton patterns in the workplace.

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

10/2/2017 — Blog assignment 3 CS 343

http://blog.synopse.info/post/2015/05/03/SOLID-Design-Principles
The topic for this week is on SOLID. SOLID stands for:
Single responsibility principle: when objects only have only 1 responsibility.
Open/closed principle: when software is opened for extension, but closed for modification.
Liskov substitution principle: when objects in a program are replaceable with instances of subtypes without significantly altering the program behavior
Interface segregation principle: when many client specific interfaces are better than one general purpose interface.
Dependency inversion principle: when one should depend on abstractions.

SOLID provides the best-practice guidelines and can help fight against 3 main code weaknesses:
Rigidity: Changes are hard since system parts are dependent upon many other parts.
Fragility: Making changes may break parts of the system.
Immobility: part of system cannot be reused in another application because it cannot be disentangled from the current application.

What I thought was interesting was the open/closed principle. Accordingly, when a class or unit is defined at the same time, it is either open for extension or closed for modification. This behavior allows existing code to be extended without breaking its initial behavior. Conformance to this policy allows for code reusability, code maintainability, and code extendibility without breaking the initial behavior of the program. An example that does not abide by this rule is a rectangle class for calculating the area of a rectangle. Say we want to extend it to calculate the area of a triangle. Then, extend it to calculate for the area of a circle. The class requires 3 different modifications. This implies that the area calculator class is not closed for modification as it needs to be changed in order to be extended, so it is not opened for extension. In large scale software development, these modifications are impractical. Instead, what would abide by this rule is a general area and shape class. This will allows for extension for the program, but its initial behaviors are closed for modifications.
The last topic that I thought was interesting was the Liskov substitution principle. The Liskov substitution principle states that if an object of type for example TChild is a subtype of another object of type TParent, then the TChild can substitute for the TParent without making major modifications to the desired properties of a program. The example presented was that of stacks and queues. If both have push and pop methods, since the storage behavior of stacks and queues are the opposite of one another they cannot inherit from a single parent type. Switching the behaviors of the stack with a queue for example will result in unexpected behavior during execution.
To adhere to this principle, the following should apply:
Class or interface definition should be properly named or commented. “behavior ” design patterns should be used when defining object hierarchy. Tests should use abstract local variables. Finally, class hierarchy should be separated.
I chose this article because it introduces one of the best practice guidelines in software engineering. For example, conformance to the open/closed policy allows for code reusability, code maintainability, and code extendibility. So, I chose it for learning purposes in order to improve coding practices for my own programs. Programming concepts for me is based on scope and visibility. Some of these programming guidelines helps create organizations in the code.

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

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.

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.

9/18/2017 — 1st Blog Post CS 343

http://creately.com/blog/diagrams/class-diagram-relationships/
I thought class diagrams were complex when first introduced, but this blog post breaks it down into simple concepts that are easier to understand. This article has helped me a lot in learning the current course materials on class diagrams. It has helped me to determining and distinguishing the different components in class diagrams and their relationships, which are applicable in object-oriented modeling.
As stated in the article class diagrams are the main building blocks in object-oriented modeling. Their main function is to show the relationship between different objects in the system. This includes their attributes, operations, and relationships among them. Classes in a class diagram are represented as boxes partitioned in three. An example of a class is the loan account with three partitions. The first is the class name, which in this case is loan account. The middle is the class attributes which are the type, accountName, dateReleased, and loanAmount. The last is the method or possible operations associated with the class. The example shows all of the relevant data of a particular object in a systematic and clear way. A class diagram is simply a collection of classes.
Relationships between classes are interrelated through different types of logical connections. The following are the different types:
Association – encompasses just about any logical connection or relationships between classes.
Directed Association – shows directionality with an arrowhead, arrowhead depicts a container-contained directional flow
Reflexive Association – occurs when classes may have multiple functions or responsibilities.
Multiplicity – active logical connection when cardinality of class in relation to another is depicted.
Aggregation – formation of particular class as result of one class being aggregated or built as a connection, directionality is a diamond shape near the parent class to the child class.
Composition – similar to aggregation, difference being emphasizing dependence of contained class to life cycle of container class, directionality line is a diamond shape adjacent to the container class and directionality arrow to the contained class.
Inheritance/Generalization one associated class is a child of another by virtue of assuming same functionality, to show relation a solid single arrowhead is drawn from the child class to the parent class, with the arrowhead unfilled
Realization – shows implementation of functionality defined in one class by another class, relationship is indicated by broken lines.
This article was a overview of class diagrams. I chose it for its simplicity in explaining design concepts. It is worth reading for someone looking for a review and it has helped me a lot in understanding the course materials.

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

9/18/2017 — 1st Assignment Blog Post

http://urosv.blogspot.com/2008/03/boundary-value-analysis-bva.html
Staying current with the current course topic and keeping things as simple as possible, this blog post gives some interesting examples of boundary value testing that I believe are helpful for understanding the course material on boundary value testing.
Boundary value testing is a simple concept of error checking range functions at the boundary. As stated in the article, it is one of the most important techniques for test case designs that every software developer will come across. It is basically a black box testing technique where knowledge of the source code is not required.
Boundary value testing checks for off-by-one error, a common mistake in computer programming. The most common off-by-one error are the following:
misplacing < with with >=.
Under indexing or exceeding the limit of the storage space of an array
incrementing and decrementing variables that are not needed or failing to do so when needed.
loop conditionals
The simplest example given is that of N apples assembled in a straight line. Each apple is a assigned a number corresponding to its position. Taking all apple from p to q, including the two variables, q-p apples will be off by one, whereas q-p+1 will include all of the apples needed in counting.
Another example given is a function which colors rectangles with coordinates of the upper left and bottom right points. The code given are as follows:

if (points > 90) grade = ‘A’;
if (points > 80 && points 70 && points 60 && points 50 && points < 60) grade = 'E';
if (points < 50) grade = 'F';

This a a typical off-by-one error. The error that needs correction is the < sign which has to be <=. The error is that the last column and row of the rectangle is not colored in.
The final example are simply boundary ranges, say from 1-10. Some good test cases are 1 and 10 or 0 and 11, or perhaps 2 and 9. This is a typical example that is much like the exercises done in class or on the hw assignments.
This blog post gives a variety of interesting examples of a simple concept in boundary value testing that is off-by one error that was not shown in the examples in class or on the hw assignment that I think are worth noting for any entry level programmer. It gives a brief overview of different test cases that any programmer should try to avoid. It gives a decent overview of boundary value testing which is a simple concept of testing boundary values of functions that takes in ranges of independent variables. Those are the reasons why I choose this post for last week’s blog post assignments.

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