Principles of Software Programming:Structured and OOP paradigmsSvitlana Vakulenko, MSc.WS 2017Acknowledgement: slides adopted from Dr. Jürgen Umbrich GZP SS 2014 lecture slides
This Episode 13:00-15:45 Structured programming in Python Branching (if-else) Iteration (for, while) Object Oriented Programming (OOP): Classes Objects Methods Inheritance UML
Programming paradigms Structured programming: all programs are seen ascomposed of control structures Object-oriented programming (OOP): Java, C , C#, Python Functional programming: Clojure, Haskell Logic programming based on formal logic: Prolog, Answer set programming (ASP), Dataloghttps://en.wikipedia.org/wiki/Comparison of programming .htmlhttps://dl.acm.org/citation.cfm?id 278289
Control flow Algorithm - sequence of commands (computation steps)https://python.swaroopch.com/control flow.html
/python-if-elif-else-statement/
Data Types Boolean: True and False Numeric Types — int, float, long .html
Operators Comparison: , , , ! , , Arithmetic: , -, *, /, %, **, // Assignment: , , - ,* ,/ , % , ** , // Logical: and, or, nothttp://www.tutorialspoint.com/python/python basic operators.htm
Warm up: Hello, World!
Ex.1: ATM hdraw-cash-1524869/
Data Structure: uildings/standard/shopping/?item list
Data Structure: uildings/standard/shopping/?item list
List w/buildings/standard/shopping/?item ys-and-tuples-in-python/
List www/buildings/standard/shopping/?item ist
Warm up: Hello, World!
Loopsfor x in shopping list:print (“I need ” x)http://www.icrar.org/ data/assets/pdf file/0008/1436615/challenge09b-notes3.pdf
Create int list range(10)[0, 1, 2, 3, 4, 5, 6, 7, 8, 9] range(5, 10)[5, 6, 7, 8, 9] range(0, 10, 3)[0, 3, 6, .html
Counting Loop for loopfor x in range(9):print 'The count is:', xprint "Good bye!” while loophttp://www.tutorialspoint.com/python/python while s://wiki.python.org/moin/ForLoop
Ex.1: ATM hdraw-cash-1524869/
Ex.2: Hey-You"Write a program that prints the numbers from 1 to 100. Butfor multiples of three print “Hey” instead of the number andfor the multiples of five print “You”. For numbers which aremultiples of both three and five print t
Ex.2: Fizz-Buzz"Write a program that prints the numbers from 1 to 100. Butfor multiples of three print “Fizz” instead of the number andfor the multiples of five print “Buzz”. For numbers which aremultiples of both three and five print t
Program for success1.problem solved False2.think() # about the problem and how to start3.if do not know where to start or do not understand: say() # tell me or ask your fellow student4.while not problem solved: try figure out solution() # do not give up! if got stuck: say() # tell me or ask your fellow student5. say(“I AM AWESOME!”)
Object Oriented Programming (OOP) Classes attributes methods Objects - instances of book/object oriented programming.html
Constructor Initialisation method Classes act as factories for new instances of themselves Class is a callable object (like a function), with the call being the constructor Calling the class returns an instance of that classhttps://en.wikipedia.org/wiki/Constructor %28object-oriented g-in-python-part-3/?relatedposts exclude 1352
UML: Class diagramClass ki/Class diagram
OOP principles Abstraction Encapsulation Inheritance nciples/
Abstractionhttp://commons.wikimedia.org/wiki/Main title greekology
Encapsulation restrict access to methods and variables (visibility) to prevent the data frombeing modified by accident public accessible from anywhere private can be accessed only from the same class: prefixclass Car:def init (self):self. updateSoftware()def drive(self):print 'driving'def updateSoftware(self):print 'updating software'redcar Car()redcar.drive()#redcar. updateSoftware()not accesible from object.https://pythonspot.com/en/encapsulation/
Inheritance Class utorial-uml-notation
Inheritanceclass Animal:class Dog(Animal):def init (self):print("Animal created")def init (self):super(). init ()def whoAmI(self):print("Animal")def eat(self):print(“Eating")print("Dog created")def whoAmI(self):print("Dog")def bark(self):print("Woof!")d ang/python/oop/
Abstract classclass Animal:def init (self, name):# Constructor of the classself.name namedef talk(self):# Abstract method, defined by convention onlyraise NotImplementedError("Subclass must implement abstract method”)class Dog(Animal):def talk(self):return .net/posts/abstract classes in python/
Polymorphism if class B inherits from class A, it doesn't have to inheriteverything about class A; it can do some of the things that classA does differently using function/operator in different ways for different typesclass Animal:def init (self, name):# Constructor of the classself.name namedef talk(self):# Abstract method, defined by convention onlyraise NotImplementedError("Subclass must implement abstract method")class Cat(Animal):def talk(self):return 'Meow!'class Dog(Animal):def talk(self):return ple-of-polymorphism
Ex.3: e-to-polling-in-the-classroom/
Next Episode Monday 6 November 13:00-15:45 D2.0.031 Data structures & operations: list: Stack & Queue string set tuple dictionary (hash table)
Programming paradigms Structured programming: all programs are seen as composed of control structures Object-oriented programming (OOP): Java, C , C#, Python Functional programming: Clojure, Haskell Logic programming based on formal logic: Prolog, Answer set programming (ASP), Datalog
Workbook 1: Use flowchart symbols for structured programming . Purpose of the Terminal Symbol . The terminal symbol in structured programming flowcharts indicates a starting or ending point in the . If a software developer plans to use flowcharts to visualize complex logical processes, he or she should .
Key takeaway: After being educated on the difference between a lump-sum and a structured settlement, 73 percent of Americans would choose a structured settlement payout when they received their settlement in a personal injury case. Chose structured settlement Chose lump sum CHART 4 - REASONS FOR CHOOSING A STRUCTURED SETTLEMENT
Abstract - A Programming Paradigm is the silent intelligence in any software design. Although many Programming Paradigms have evolved, only a few programming paradigms are actively used by the software industry. In addition, many hundreds of programming languages have been developed, but only a few are established and beneficial.
Object Oriented Programming 7 Purpose of the CoursePurpose of the Course To introduce several programming paradigms including Object-Oriented Programming, Generic Programming, Design Patterns To show how to use these programming schemes with the C programming language to build “good” programs.
Functional programming paradigm History Features and concepts Examples: Lisp ML 3 UMBC Functional Programming The Functional Programming Paradigm is one of the major programming paradigms. FP is a type of declarative programming paradigm Also known as applicative programming and value-oriented
1 1 Programming Paradigms ØImperative Programming – Fortran, C, Pascal ØFunctional Programming – Lisp ØObject Oriented Programming – Simula, C , Smalltalk ØLogic Programming - Prolog 2 Parallel Programming A misconception occurs that parallel
About this Programming Manual The PT Programming Manual is designed to serve as a reference to programming the Panasonic Hybrid IP-PBX using a Panasonic proprietary telephone (PT) with display. The PT Programming Manual is divided into the following sections: Section 1, Overview Provides an overview of programming the PBX. Section 2, PT Programming
Automotive is ready to inform and assist government in promoting the country’s competitiveness around the world; global trade is complex and it needs the knowledge and insight industry experts can offer. Looking globally, there are challenges enough without Brexit - even superpowers aren’t immune from the effects of trade tensions, unsettling business and consumer confidence. Furthermore .