Author Archives: phancs

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'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's CS by phancs and used with permission of the author. All other rights reserved by the author.

Why you need to know these 9 automated testing tools for Java

Hi everyone and welcome to my sixth 443 cs blog post. Today I’m going to go over this article that I am certainly reading which is titled “why you need to know these 9 automated testing tools for java”. This article explains how do selenium, junit, grinder and other automated testing tools work and how to use them. Testing java applications is important because you must ensure that your program is supposed to do what it is doing. There are many automated testing tools for java, but this article goes over the most common and useful of them. First, there are different types of tools for different kinds of situations. For example, unit testing is for newly written code before its incorporated into the base of the code. Next, integration testing prevents the application from crashing from newly written code. Also, to test the performance of the application you would use performance and user experience testing. Finally, to test the vulnerabilities of the application to would use security testing. These are some the testing methods and there’s many more and some of these methods are used for multiple purposed. This article listed what the best automated testing tools for java and there are:

  1. Junit which is the most popular and is usually for unit testing
  2. Testingng which is a versatile tool because it can be used for unit test, integration test and many others.
  3. Jtest which is good for security testing.
  4. The grinder is for performance testing.
  5. Gatling which is also a performance testing.
  6. Selenium which is for interface and experience testing.
  7. Mockito which is good because it makes it fast and easy to write automated java test.
  8. Powermock which is a unit testing framework.
  9. Arquillian which allows you to write tests that execute in real runtime environments.

 

All in all, this article is very helpful and change the way I think about this subject because I did not know there was so many testing tools out there and the purpose of each testing tools. I now know what and when to use the automated tools depending on the situation.

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

solid, grasp, and other basic principles of object-oriented design

Today’s topic for blog 6 is solid, grasp, and other basic principles of object-oriented design. This article teaches you about basic about solid and grasp languages. First, code should have the following qualities maintainability, extensibility, and modularity. These qualities are usually in code that are easy to maintain, extend, and modularize over its lifetime. This article has many examples written in java and c#. These are the principle that the article goes through:

Single responsibility principle which states that a class should have only one responsibility and a class a fulfills its responsibilities by using its functions.

Open-closed principle which states a software module (class or method) should be open for extension but for modification.

Liskov substitution principle which states derived classes must be substitutable for their base classes. What this basically means is that abstraction should be enough for a client.

Interface segregation principle which states clients should not be forced to depend upon the interfaces that they do not use.

Dependency inversion principle which states program to an interface, not to an implementation.

Hollywood principle which helps prevent dependency rot. It states that a high-level component can dictate low-level components in a manner so that neither one is dependent upon the other.

Polymorphism which they say it is a design principle.

Information expert which helps you to give responsibilities to classes.

Creator which is a grasp principle that helps decide which class should be responsible for instantiating a class.

Pure fabrication which reduces the cohesiveness of the domain classes.

Controller which is a design principle that helps minimizing the dependency between gui components and the domain model classes.

And favor composition over inheritance and indirection.

All these topics were provided examples and it was very easy to understand. I thought this article was very informative. I think it provides the basic main idea of these principles. After reading this article I changed the way I work because I now know how to apply these principles to improve my code. I agree with everything in this article but if I would to improve it, I would say to break up grasp and solid to separate articles. All In all, this article was  very useful in learning the basic about different principles and how to apply them.

https://dzone.com/articles/solid-grasp-and-other-basic-principles-of-object-o

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

Equivalence partitioning and boundary value analysis

Hello everyone, and welcome back to my 443 blogs where I post many interesting topics that I am currently learning. Today blog post topic is about boundary value analysis and equivalence partitioning. Boundary value analysis is a testing technique where you test between valid and invalid inputs. Boundary values are also known as lower/upper values and errors are often observed in those ends. It’s considered a black box testing technique. Equivalence partitioning and boundary value analysis can co-exist and used together to test many more areas of the test. Boundary value analysis test is proficient because it can test most of the test product. Equivalence partitioning is when we categorize the values into ranges and test one input from each of category. This is also a black box test design technique and can be applied to several different test like unit, integration, etc. Equivalence partitioning would have numerous amounts of test cases that we cannot test all. All in all, this blog post is about Boundary value analysis and equivalence partitioning. The resources that I gather my information was from https://reqtest.com/testing-blog/what-is-boundary-value-analysis-and-equivalence-partitioning/. I thought this blog was good but didn’t provide much information about this topic other than basic. The examples that this blog provide wasn’t descriptive enough for me to truly grasp on the idea of equivalence partitioning and boundary value analysis. After reading this blog, it didn’t change the way I think about the subject because I already knew most of the content, but I was looking for more details. I thought the blog should of include more visual examples with actual test inputs. I learn some useful tips on this subject like for example that we can’t test all possible cases in equivalence partitioning because the test cases would be too large. Also, even though this resource was simple it’s was easy to understand the material and the example wasn’t complex, so it was easy to follow. I agree with everything in the article and like the way it explains the topic. In conclusion, this was my 443-blog post and I learned many interesting things from this recourse that I used.

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

JAVA OOPS

Hey everyone, welcome back to phan’s cs where I discuss my recent 343 CS course related topics that I’m currently learning. Today I’m using Edureka blog about object-oriented programming for my resource which can be found on https://www.edureka.co/blog/object-oriented-programming/. Java OOPS concepts which stands for object-oriented programming is a programming style that includes concepts like class, abstraction, object etc. The core of oriented-oriented programming involves these four concepts inheritance, encapsulation, abstraction, and polymorphism. First, the concept of inheritance is where the properties of one class can be inherited by the other. A great analogy is a parent and child, where the child inherited properties from the parent. In programming, this would be called a parent class which is a super class and a child class which is known as a sub class a sub class. There are classified into 4 types single, multilevel, hierarchical, and hybrid. Second, encapsulation, this means to hide your data to prevent any modifications. This can be done by two ways, first, declare the variables of a class as private and constructing public setter and getter methods to get or change the variable. Next, abstraction which is basically hiding the details and providing the vital things. A good example cell phone that they provide in this blog is a cell phone which a user can make calls, take pictures, etc. and there’s a lot of code that runs in the background that the users doesn’t have to worry about. Finally, there is polymorphism, which many forms. This when you can have multiple implementations for an interface or method. All in all, object-oriented programming is a programming style which involves these four concepts inheritance, encapsulation, abstraction, and polymorphism. The reason why I choose this topic is because I wanted to review the main objective of OOPS. I think this article is very informative and provides many analogy and examples of the concepts which made it easier for me to understand the material. I agree with many of materials that it provides and think it was very accurate. After reading this blog, I think it change the way I work because I now have a better understanding of Java OOPS.

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

Decision Table Testing

Today blog is about Decision Table Testing. “Decision table testing is a testing technique used to test system behavior for different input combinations” and known as cause and effect table. The table consist of rules, cases, and test conditions. This tutorial has a good and easy to understand example. It created a decision table for a login screen where the output is true if both conditions, username and password are true else the output would be false. There were four rules because there were two variables. There was also another example that was similar which had eight cases because there were three variables. The test would only pass if and only if three of the conditions were true else it would return an error message. This test method is important because it allows us to test several combinations of tests which allows us to have more coverage of on the tests. There are many advantages of decision table testing:

  1. “When system behavior is different for different input and not the same for a range of inputs”
  2. It provides better coverage for testing because it has many combinations.
  3. Any complex conditions can be converted into a decision table.
  4. Great for low input combinations, will cover all testes.

But there is one big problem with decision table testing and that is when there are many inputs the table gets complex and complicate things. This article was very helpful to me. Because I have a better understanding of decision table testing now. This tutorial had many good examples and even a video on decision table testing. The formula for possible combinations is 2 ^ n, where n is the number of inputs which is shown in this article which I remember during class. I think after reading this article I change the way I think about decision table testing because I now know what it’s best used for. I found this article very interesting because of the clever examples that it uses its. All in all, the decision table testing is one of many important testing methods out there.

https://www.guru99.com/software-testing-techniques-1.html

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

Angular

Today blog is about a brief introduction on angular. This article starts off explaining what a scope is. This was not new to me because I have a little background in programming but I assuming this part of the blog is for people who is just started programming and pursued angular as the focused. The definition of angular in this article “a structural framework for dynamic web applications, made in pure JavaScript.” What does structural framework mean? I didn’t know at first, but this article explains well, it’s states that “angular is a structural framework because it allows us to use HTML as a template language and extend its syntax to express the components of the applications in a cleaner and simpler way.” Basically, I think its take complex syntax like HTML and converts it to a simpler format. AngularJS uses MVC where whatever is changed in the controller is updated in the view. It’s appropriate to use AngularJS when the it is a large application, when you need a good structure, when you need a robustness, and when the application is complex. The controller is a tool that Angular provides. A controller acts as the middleman between various views and models. The web view or mobile view is the user interface, it’s what the user sees, and the model is the database. A module is a gives structure to an application because it acts as “a container for controllers, services, filters, directives.” I learned that it reusable and doesn’t require to run in any specific order because it can slow down the execution time and it great for unit testing. There are also two types of service, Factory and Service. They both services are ways to create an object. After reading this blog I learned a little more about Angular. This article was helpful but didn’t have much example of the topic which I would like because some topics I wanted to know what its visual look like. All in all, this article was helpful, and it changed the way I look about this topic Angular because it seems more complex which I will research further but for now this is all.

https://www.belatrixsf.com/blog/an-introduction-to-angularjs/

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

INTEGRATION TESTING

This blog post is about second of level of software testing. Integration testing is when individual units are merged and tested as a group. The purpose of integration testing is discovering errors in the interaction between integrated cases. A good example of integration testing is a basketball hoop, the rim, the pole, and the net. They are created and tested separately in the same facility but when two unit or more are ready they are tested together which is integration testing. Black box testing, white box testing and gray box testing can all apply to this method. There are many approaches to integration testing:

 

  1. Big Bang – when every or most of the units are merged together and tested at the same time.
  2. Top Down – when lower level units are tested after top level units.
  3. Bottom up – when top level units are tested after lower level.
  4. Sandwich/Hybrid – combination of both top down and bottom down testing method.

 

Integration testing is important level of software testing because for example if you have a two separately created and tested units like a door and door knob, even though both door and door knob were tested you don’t know if they would fit because they weren’t tested together. There could be many faults for example like the door was inch in width smaller or the door knob was didn’t fit with the door. With integration testing the door and door knob would be tested together after each of the unit is ready so if there any error that makes the door and the door knob to be non-compatible then the test cases will fail which shows that there’s an error and you can fix it.

 

After reading this article I have a better understanding of integration testing. This article changes the way I think about software testing because I more knowledge about one of the levels of software testing. I now know why integration testing is so important. I find this method useful in many ways in testing in general outside of software testing. All in all, integration testing is important level of software testing.

http://softwaretestingfundamentals.com/integration-testing/

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

Flyweight Design Pattern

Today blog is about Flyweight Design Pattern. Flyweight design pattern a structural design pattern like the adapter pattern that we learned in class and decorator pattern in home work two. Flyweight design pattern is applied in a situation when we need to instantiate a large number of objects of a class. It reduces the amount of memory consumed and execution time by sharing objects that similar in some way. Flyweight objects can’t be modified once they have been constructed which means in short, it’s immutable. HashMap is used in flyweight pattern to reference of the created objects. The Object property are also divided into two properties intrinsic and extrinsic. “Intrinsic properties make the object unique whereas extrinsic properties are set by client code and used to perform different operations.”. An example of Intrinsic state is that if there a Shape object that already created we don’t have to create another color feature because every shape has a color related instead we can just use the already created object. The extrinsic state is the size of the shape which is different for many objects. To return the shared objects we have to create a flyweight factory which is used by the client programs to create the object. All in all, this design pattern is used to speed up the speed of the program by sharing objects instead of creating new ones. I think this design pattern is complex. I don’t see this pattern used often unless the program is creating insanely number of objects. During this tutorial, I learned a lot about this design pattern, they used a shape example which shows the result of flyweight design pattern. I thought this was interesting, but I couldn’t think of many other situations that this design pattern can applied to. The tutorial was straight forward so I didn’t disagree with everything. This design pattern is complex so the I had trouble understanding it but when I actually implemented and ran the code I had a better understanding of this design pattern. This content did change the way I think because I now know there is many ways to increase the performance of my code.

 

https://javapapers.com/design-patterns/flyweight-design-pattern/

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