Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Entrega Actividad 3 #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Actividad 4-iic2113

### Integrantes

Nombre | GitHub
-------------- | -------
Agustin Gomez | agomez4
Diego Sinay | TheDG
Maria Fernada Sepulveda | mf22


### Code Smells

1. Switch statements
* Línea 21 `customers.rb`
* Se tiene un switch complejo.
* Solución: Controlar la condición booleana de los case en solo una, en vez de comparar uno por uno, se puede añadir directamente.

2. Data Class
* Class Rental `rental.rb`, Class Movie `movie.rb*`
* Solo se definen atributos, no contienen comportamiento.
* Solución: Dado que Ruby es un lenguaje orientado a objetos, cada una de sus clases podría tener los métodos para acceder a sus clases y modificar el modelo.

3. Shotgun Surgey
* Class Rental
* Comportamiento segmentado en varios lados, o en este caso, se le quito el comportamiento y se asigno en otra clase.
* Solución: Darle comportamiento a Rental, y no asignar todo a Costumer.

4. Long Method
* Linea 14 `customers.rb` : statement
* Statement tiene más de 10 lineas de código.
* Solución: Particionar el comportamiento de `statement`.

5. Large Class
* Class Customer
* Excesivos metodos--> Statement pertenece a algun otro objecto caja o boleta, al cliente no cliente.
* Solución: Crear una nueva clase que encapsule esta funcionalidad.








9 changes: 8 additions & 1 deletion customer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,28 @@ def statement
this_amount = 0
# determine amounts for each line
case element.movie.price_code

when Movie::REGULAR
this_amount += 2
this_amount += (element.days_rented - 2) * 1.5 if element.days_rented > 2
return this_amount
when Movie::NEW_RELEASE
this_amount += element.days_rented * 3
return this_amount
when Movie::CHILDRENS
this_amount += 1.5
this_amount += (element.days_rented - 3) * 1.5 if element.days_rented > 3
return this_amount
end

#Arreglo
this_amount+=element.get_price()

# add frequent renter points
frequent_renter_points += 1

# add bonus for a two day new release rental
if element.movie.price_code == Movie::NEW_RELEASE && element.days_rented > 1
if element.movie.price_code == Movie::NEW_RELEASE && element.element.days_rented > 1
frequent_renter_points += 1
end

Expand Down
2 changes: 1 addition & 1 deletion movie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ class Movie

def initialize(title, price_code)
@title, @price_code = title, price_code
end
end
end
1 change: 1 addition & 0 deletions rental.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ class Rental
def initialize(movie, days_rented)
@movie, @days_rented = movie, days_rented
end

end