






Prepara tus exámenes y mejora tus resultados gracias a la gran cantidad de recursos disponibles en Docsity
Gana puntos ayudando a otros estudiantes o consíguelos activando un Plan Premium
Prepara tus exámenes
Prepara tus exámenes y mejora tus resultados gracias a la gran cantidad de recursos disponibles en Docsity
Prepara tus exámenes con los documentos que comparten otros estudiantes como tú en Docsity
Encuentra los documentos específicos para los exámenes de tu universidad
Estudia con lecciones y exámenes resueltos basados en los programas académicos de las mejores universidades
Responde a preguntas de exámenes reales y pon a prueba tu preparación
Consigue puntos base para descargar
Gana puntos ayudando a otros estudiantes o consíguelos activando un Plan Premium
Comunidad
Pide ayuda a la comunidad y resuelve tus dudas de estudio
Ebooks gratuitos
Descarga nuestras guías gratuitas sobre técnicas de estudio, métodos para controlar la ansiedad y consejos para la tesis preparadas por los tutores de Docsity
´nhtrbefjsdkanmS´PEFRETPHRU8IQEW4oñielsot gjfbjdhstj 34wep
Tipo: Esquemas y mapas conceptuales
1 / 11
Esta página no es visible en la vista previa
¡No te pierdas las partes importantes!







funcions=[mult,suma,parell] for i in range(10): print(list(map(lambda x: x(i), funcions))) filter (funcio_que_retorna_boolea, llista_elements) list(filter(lambda x: x%2 == 0, l)) map + filter + lambda exemple: list(map(lambda x: x*.5, filter(lambda x: x>=0,l))) list comprehension = [expressió for variable in llista if condició] l2 = [x5 for x in [x+2 for x in l if x>10] if x%2==1] #primer fa l’if x>10 i després x%2== list comprehension if-else ["mango" if i%3==0 else "orange" for i in range(10)] CONJUNTS ➢ Pertinença (in) ➢ Diferència (-) Elements es troben en un conjunt i no en l’altre. ➢ Or (|) Elements presents en un conjunt o l’altre. La unió en sentit matemàtic. ➢ And (&) Elements presents en un conjunt i l’altre. La intersecció en sentit matemàtic. ➢ Xor (^) Elements presents en un conjunt o l’altre, però no en els dos. ➢ conjunt.add(element) ➢ conjunt1.update(conjunt2) ➢ conjunt.remove(element)
distància euclidània
Docstrings help(Classe) Unittest import unittest class testNomClasse(unittest.TestCase): self.assertXXXX(“resultat esperat”, str(valor calculat)) GRASP PATTERS ➢ GRASP: General Responsibility Assignment Software Patterns ➢ GRASP patterns: how to assign responsibilities to classes. What class should do what ➢ Two types of responsibilities: doing or knowing o Doing responsibilities of an object include: ▪ Creating an object or doing a calculation ▪ Initiating action in other objects ▪ Controlling and coordinating activities in other objects o Knowing responsibilities of an object include:
▪ Knowing about private encapsulated data ▪ Knowing about related objects ▪ Knowing about things it can derive or calculate ➢ There are 9 GRASP patterns: ▪ Expert : Assign responsibility to the information expert, the class that has the information necessary to fulfil the responsibility. ▪ Creator: Assign class B the responsibility to create instances of class A if: ▪ Class B aggregates or contains objects of class A ▪ Class B closely uses objects of class A ▪ Class B has the initializing data to be passed to the A constructor. B is the expert with respect to creating A If more than one option applies, usually prefer a class B which aggregates or contains class A. Ex. Classe Tauler té info de Casella i Jugador ▪ Low Coupling : minimitzar l’impacte de canvis futurs i les dependències entre classes. measures how strongly a class is connected, depends, relies on or has knowledge of objects of other classes. Assign responsibilities so that coupling remains low. Try to avoid one class to have to know about many others.
➢ Bloc condicional en un diagrama de seqüència: [condició] acció sobre la línia PRINCIPIS DE DISSENY ORIENTAT A OBJECTES Technique or advice to be applied when designing or writing code to make software more maintainable, flexible, or extensible under the inevitable changes. 6 design principles: ▪ Information hiding: Minimize the accessibility of classes and members. Classes should not expose their internal implementation details (we set private attributes). A class should provide all and only the information (by setter i getters) clients need to effectively use it. ▪ Don’t talk to estrangers: ▪ An object A can request a service (call a method) of an object instance B, but object A should not "reach through" object B to access yet another object C to request its services. ▪ It is another name for low coupling A no pot accedir a C, però sí per B ▪ DRY: Don’t Repeat Yourself: Avoid duplicate code by abstracting out things that are common and placing those things in a single location. And put each piece of information and behavior in a unique, sensible place.
▪ SRP (Single Responsibility Principle): Every object in your system should have a single responsibility, and all the object's services should be focused on carrying out that single responsibility. One class should have only one reason to change. --> HIGH COHESION ▪ LSP (Liskov Substitution Principle): Objects of a superclass shall be replaceable with objects of its subclasses without breaking the application. Where an object of the base class is expected, it can be substituted by an object of the derived class. subclasses should behave in the same way as the objects of their superclass un mètode present a les subclasses tmb ha de ser-hi a la superclasse amb els mateixos paràmetres i així no haver de distingir entre els tipus de classes derivades ▪ Favor composition over inheritance: No fent herència d’una classe es fa que es pugui canviar més fàcilment el tipus, ja que una classe no es pot canviar. Amb la composició es blinda la informació interna, només dins la classe es pot veure els seus dos tipus i la informació de cada una. Ex: joc de dames, fent herència hi ha dos tipus de fitxes i fent composició hi ha una classe moviment i dins d’ella MovimentNormal i MovimentDama.