Testing in OO

--Originally published at Hackerman's house

Testing takes a big part in software development. It is important to know how to do the testing so that you can solve the problems presented and spend less time in this stage.  Object-Oriented testing is different from traditional testing. The root of this differences is that traditional programming consists of procedures operating on data, while OO testing treats with objects that are instances of classes.

Resultado de imagen para object oriented

Testing levels

There are several testing levels when you are doing OO testing.

Algorithmic level

Each module or method of every class should be tested in isolation.

Class level

Every class should be tested as an individual entity.

Cluster level

As classes are collaborated or integrated to form a small subsystem or cluster. Testing each cluster individually becomes a necessity.

System level

At this level, interaction among the clusters is tested.

Test Cases

Methods to design OO test cases are based on the conventional methods, but the should encompass some special features to that they can be used in the object-oriented environment.

  1. It should be explicitly specified with each test case which class it should test.
  2. Purpose of each test case should be mentioned.
  3. External conditions that should exist while conducting a test should be clearly stated with each test case.
  4. All the states of object that is to be tested should be specified.
  5. Instructions to understand and conduct the test cases should be provided with each test case.

Resultado de imagen para testing

Testing Methods

State based testing is used to verify if the methods of a class are interacting properly with each other. The basic idea of this method is that an object is created, and several methods are invoked to see if the object is changing states the way it should.

Scenario-based testing is used to detect errors that are caused due to incorrect specifications Continue reading "Testing in OO"

UML Part 2

--Originally published at Hackerman's house

As I already discuss in another posts, UML is a common language used to draw diagrams that can express software processes or even business models. In this post I will be talking more about this amazing resource.

State Machine Diagrams

These diagrams are used to describe the states of a component within a system. The name of this type of diagram is state machine because it is a machine that describes multiple states of an object and how it changes due to internal and external events of the system.

UML State machine Diagram

Package Diagrams

A package diagram is a container of multiple UML diagrams. They organize diagrams and components into groups, this according to the relation between them. In more complex systems, package diagrams can be constructed by several package diagrams. The purpose of this type of diagrams is to show the relations between large components of the system, bringing an easier understanding of it.

Component diagrams

Component diagrams can help break down the system into smaller components. These components usually work very different than the others.

lambda architecture

MVC

The model view controller is a style of software architecture that separates the system into three main components. The first one is the model, which is a representation of the data. The view contains the information that the client sees, also contains all the ways the client can interact with the system. The last part is the controller that is an intermediary between the first two, its function is to modify the data according to the interaction given with the client; if the data changes the client must be able to see this in the view.

Reference:

https://tallyfy.com/uml-diagram/#component-diagram

UML Part 1

--Originally published at Hackerman's house

UML stands for Unified Modeling Language. It is one of the most popular process modeling techniques. It represents software components utilizing a diagrammatic representation. It is mainly used because of the easy understanding of the representation. One advantage of UML is that in can be used to represent different types of processes; it is standardized, this means that everyone that learns UML can understand the design of other people, besides this, this language provides with a wide range of features that can improve the readability and efficacy of your project.

UML diagrams can be divided in many categories. I’ll be listing 3 of the more important.

Sequence Diagram

These are probably the most important UML diagrams, and can be used in business application development as well as in computer science. They describe the sequence of messages and interactions between actors and objects, it is characterized because they are represented in a chronological manner. It is used to understand how the system works from start to finish, and how the actors take part in the process.

Sequence UML Diagram

Class diagrams

It is a common diagram because most of the software is Object Oriented. Class diagrams contain classes, attributes and behaviors, this means each class is divided in these 3 fields. The relation between the classes is represented as well in this diagram, inheritance is also depicted in this diagram.

Class UML Diagram

Object diagrams

These diagrams are used to check whether the generic structure of the class diagram works. It is based on the class diagram, but depicts specific objects of the classes created earlier; all the values for the attributes of the object are assigned.

Object UML Diagram

Reference:

https://tallyfy.com/uml-diagram/

Design Patterns

--Originally published at Hackerman's house

Design patterns in programming are like recipes in cooking. They are not the final product, but instructions to obtain your final product in an easier and adequate way. Design patterns are repeatable solutions to common problems that occur in software design. They provide proven development paradigms that can help you prevent issues while developing. One of the advantages of design patterns is that they are so common that they are improved over time, making them more robust and more useful overall.

Design patterns are divided into 3 categories, creational patterns, structural patterns and behavioral patterns.

Creational Design Patterns

Resultado de imagen para creation

These design patterns are about class instantiation.

Abstract factory creates an instance of several families of classes. It provides an interface for creating families of related objects without specifying their concrete class.

Builder separates object construction from its representation. This can be used in a way that the same construction processes can create different representations.

Factory Method creates an instance of several derived classes. It is basically an interface that the subclasses adapt to do their own specific tasks.

Prototype is a fully initialized instance that can be copied or cloned. It is used when direct creation of an object is costly, creates new objects by copying this prototypical instance.

Singleton is a class of which only a single instance can exist.

Structural Design Patterns

Resultado de imagen para structure

These design patterns are about Class and object composition. These patterns are divided into class creation patterns that use inheritance to compose interfaces, object patterns define ways to compose objects to obtain new functionality.

Adapter converts the interface of a class into another interface. This allows a class to work with another one even if it had an incompatible interface.

Bridge separates an object’s interface from its implementation.

Composite; composes object intro tree structures to represent hierarchies.

Resultado de imagen para behavior
Continue reading "Design Patterns"

HFOOAD Chapter 6

--Originally published at Hackerman's house

Chapter 6 is called My Name is Art Vandelay…I am an Architect, it shows how to use the tools we already know to build bigger programs and handle big problems. To solve these big problems, you must remember the steps, we already learned, making sure that the software does what the customer wants, apply basic object-oriented principles and create maintainable software. Using this knowledge, you can approach the big problem as a group of smaller problems that you can attack individually.
Ball

Photo by Kay Ramslay

In the case that you are working in a big system of software, the analysis becomes even more important. There are more elements in the software, this means the cohesion between all its parts become essential in the creation of good software. A good advice given by the book is that first you have to analyze the individual pieces, and after that you analyze the way the interact with each other.

Just like in the previous chapter the interaction with the client is very important to determine the requirements of the system, and what is the purpose of the software. A new term is introduced Feature, a feature is something big that a system does, usually you must do a series of requirements to complete a feature. This means it is basically a more complex requirement.

Get features from the customer, and then figure out the requirements you need to implement those features

Sometimes you need to know what a system does, but don’t want to get into all the detail that use cases require. This is where you can utilize use case diagrams to see the bigger picture. The diagram consists on the actor that is related to the system, the system, and the use cases inside the system (the use cases are

Resultado de imagen para use case diagram
Continue reading "HFOOAD Chapter 6"

Semestre I, Parte Técnica

--Originally published at Hackerman's house

En este semestre I teníamos la tarea de proponer un modelo de luminaria pública inteligente, en el cual se solucionarán problemas relacionados al municipio de Zapopan, como la contaminación, el bajo índice de luminarias funcionales, las altas tasas de criminalidad ocasionados por la luminaria deficiente.

IOT

La propuesta implementada por la mayoría de los equipos en este semestre I fue utilizar 2 fotorresistencias, 1 sirve para medir la luz solar que llega a la posición de la lampara y con esto implementar la automatización de la lampara, la segunda fotorresistencia tiene la función de medir la luz que esta emitiendo la lampara. Los resultados de estas 2 variables se pueden comparar para así determinar si la lampara está comportándose de la manera adecuada ante la luz natural presente, en caso de que esta no haga lo adecuado, la base de datos se actualiza para que los administradores estén al tanto de las fallas en el sistema, de esta manera pueden ejecutar su mantenimiento de mejor manera.

Para realizar este proyecto requerimos desarrollar competencias referentes a bases de datos, principalmente referentes al diseño de tablas y las relaciones entre ellas, esto lo aprendimos en el salón de clases, mientras que el manejo de estas mediante la utilización de un lenguaje de programación lo realizamos por nuestra cuenta, con un manejo bastante básico de los datos mediante la utilización de PHP.

php

Por otra parte, la competencia más complicada de aprender, en parte porque soy Ingeniero Computacional y la materia es de electrónica, fue microcontroladores, requerimos de esta para la implementación de las fotorresistencias, además de para enviar datos coherentes mediante la utilización de un módulo wi-fi. Parte de la funcionalidad del microcontrolador es permitir la automatización de la lampara. Este sistema funciona gracias a la utilización de interrupciones que permiten que se hagan

teamwork-background-design_1284-1008
Continue reading "Semestre I, Parte Técnica"

Semestre I, gran idea de ejecución mediocre

--Originally published at Hackerman's house

giphy-8

En este blog hablaré de mis opiniones y recepción al semestre I que estoy cursando actualmente. Primero que nada, el semestre I es un nuevo programa de enseñanza que se está llevando a cabo desde hace un par de años en mi universidad, el Tecnológico de Monterrey, este busca desarrollar competencias que les serán útiles a los estudiantes a lo largo de su carrera profesional. Todas las materias acreditadas a lo largo del semestre están enfocadas a un solo proyecto a realizar, este modelo crea equipos que se mantienen juntos a lo largo de todo el semestre y en todas las materias. En mi opinión personal este modelo tiene bastante futuro, ya que se experimentan cosas mas reales que en el semestre regular no experimentas.

Este semestre tuvo sus problemas incluso antes de comenzar, no se nos comunicó que participaríamos en el semestre I, los alumnos nos dimos cuenta debido a lo poco común que eran nuestros horarios, además de que es poco usual que muchos alumnos lleven exactamente las mismas materias en este semestre, especialmente en nuestro caso en el que alumnos de 2 carreras diferentes tenían las mismas materias. Después de que varios alumnos presentaron su inconformidad en relación a la situación que se estaba dando, se logro que hubiera una junta informativa, en esta nos pintaron el semestre I como una maravilla donde tendríamos una libertad de horario que nunca habíamos experimentado, después nos daríamos cuenta que esto no sería así, además nos mencionaron que el socio formador (el cual nos debe de ayudar a desarrollar estas competencias) todavía no había sido confirmado, esto a escasas semanas del inicio del semestre.

El comienzo del semestre se dio de manera muy similar a un semestre regular, cada clase veíamos temas que también se ven en el plan regular,

giphy (1)
Continue reading "Semestre I, gran idea de ejecución mediocre"

My own dictionary

--Originally published at Welcome to the Heaven

The dictionaries in Python are very similar to a list. The dictionaries can be directly defined or can start in blank and over time you add some values and words or delete some.

The dictionaries write inside keys {} and the values and words with two points:

Example = {"my":12,"first":24,"dictionary":36}

So now with this variable you have already a dictionary and you can call one, two, three or any number of items that you want or change, delete or add one.

down = {“example”:picture}

screen-shot-2016-11-28-at-12-42-56-pmIn the picture you can see how I create a dictionary in white and after I add some values to it.

We can have access to specific items in the dictionary, as you can see in the second print we do it.

If you don’t want to have a KeyError in some key that you do not know if has a value you can use .get that returns None(if the key does not have it), the example of this is the last two prints.

More information? and you want my source?

If you want another different post of the same topic. Is from the blog of one friend.


Writing and reading

--Originally published at Welcome to the Heaven

Writing and reading comments is pretty easy, we only need create a text file, open and select the mode that we will use.

Open()

First we need to create a variable with the code: example:

text = open(file_name,mode)

Mode

Exist four kinds of modes: “r”, “w”, “a” and “r+”.

“r”->Only for reading

“w”->Writing(if you  have already a file with the same name will be erased)

“a”->Open the file to append any type of data

“r+”->Reading and Writing

Example

Writing

I am going to use “shot”
as a name, and if you see the picture I don’t have any file with this name. So if you write the code of the next picture, your program is going to create a new file with the name that you want and with the
text that you write. screen-shot-2016-11-26-at-11-29-46-pmscreen-shot-2016-11-26-at-11-34-37-pm

When you run your program in the terminal nothing is going to change, but if you search the file you will find it. Remember, if you have already a file with the same name will be erased.screen-shot-2016-11-26-at-11-39-21-pm

Reading

I am going to use the file shot for the example.screen-shot-2016-11-26-at-11-45-26-pm

If you don’t write “()” at the final of file.read, when you run the program will print you the same as the first time.

More information and the source.