13.07.2015 Views

Analysis of Structures - Baustatik-Info-Server

Analysis of Structures - Baustatik-Info-Server

Analysis of Structures - Baustatik-Info-Server

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

2.14. OOP WITH CLASSES Page 412.13.3 Close a FileAfter the usage <strong>of</strong> a file, the file should be closed.f.close()...... example ......f.open("log.txt","a")f.write("Write a little log line\n")f.close()2.14 OOP with ClassesPython is an object orientated programing language 13 . Everything within Python is implemented as anobject, even a simple integer number. So what is the concept <strong>of</strong> a class? A class or an object combinesdata, called attributes, with functions, called methods. This can be described by so called UML 14An instance <strong>of</strong> a class, that is the realization <strong>of</strong> the class in memory, is created simply by assigning theclass’s name followed by the constructors parameter list to a symbolic name, which than is the pointer orthe reference to this instance. Within the class the self pointer to the actual instance is called self. Toaccess member attributes or methods <strong>of</strong> a class the dot notation is used, i.e. ..We can remove an instance <strong>of</strong> a class by calling the del operator (del example). The referencesto an instance are handled by the python runtime system. If an instance has lost all it’s references, theinstance is removed from the memory. 152.14.1 Some UML DiagramsUML structure diagrams <strong>of</strong> the emphasize the things that must be present in the system being modeled.Since structure diagrams represent the structure they are used extensively in documenting the architecture<strong>of</strong> s<strong>of</strong>tware systems. In our description <strong>of</strong> the examples we want to implement we use the ClassDiagram which describes the structure <strong>of</strong> a system by showing the system’s classes, their attributes, andthe relationships among the classes.A UML class diagram (see figure 2.7) consists <strong>of</strong> a rectangular box, which is dividedinto three sections. The fist section contents the class’s name. This nameis written centered in bold letters. The second section contents the attribute’snames <strong>of</strong> the class and the third section contents the method’s names.Class Nameattribute 1attribute 2method 1method 2Figure 2.7: A UMLClass Diagram13 Object orientated Programming is <strong>of</strong>ten used with the abbreviation OOP.14 The Unified Modeling Language includes a set <strong>of</strong> graphic notation techniques to create visual models <strong>of</strong> s<strong>of</strong>tware-intensivesystems. The Unified Modeling Language is an international standard see [4], UML 2.3 was formally released in May 2010.15 This is also called Garbage Collector. In contrast to this in poor C or C++ an once allocated object has to be removedexplicitly from the memory to avoid so called memory leaks, this are blocked parts <strong>of</strong> the applications memory, which remainunaccessible until the application is closed.2.12.2011

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!