Principles Of Software Design Types, Paradigms

2y ago
15 Views
3 Downloads
268.90 KB
27 Pages
Last View : 2d ago
Last Download : 3m ago
Upload by : Aiyana Dorn
Transcription

Types, ParadigmsPrinciples of Software DesignTypes, ParadigmsRobert Luko kalukotka@dcs.fmph.uniba.skwww.dcs.fmph.uniba.sk/ lukotkaM-255Robert Luko kaTypes, Paradigms

Types, ParadigmsTypesWhat is type system good for?kill(int, int)kill(SIGUSR1, pid)Compiles, runs. May cause an hard to track. Writing testsmay be hard.kill(Signal, ProcessId)kill(Signal SIGUSR1), ProcessId(pid))Compile-time error. Hard to make a bug.Robert Luko kaTypes, Paradigms

Types, ParadigmsTypesStrings encoding:a "lala\aa"a "lala\\aa", because "\"somewhere you should writesomewhere elseis a specialcharacter.We might want to make distinct types for these two to avoidbugs.One can also write unit tests to handle this, but if this issuespans multiple units, type checking is not only more reliablebut also more e cient way to handle this.Robert Luko kaTypes, Paradigms

Types, ParadigmsWhen to check typesWhen type correctness can be checkedWhile writing, your IDE may have this feature (requires statictyping)Compile time (static typing)Run time (dynamic typing) Strong vs weak typing, examples of weak typing may include 5 3C pointers . you cast(void *)to something all the time.many other shortcuts used in various programming languagesRobert Luko kaTypes, Paradigms

Types, ParadigmsType systemsThe types may be very complex. Some type systems areNP-complete.template int N struct Factorial{enum { val Factorial N-1 ::val * N };};template struct Factorial 0 {enum { val 1 };};std::array int, 6 andstd::array int, Factorial 3 ::val Thus typesRobert Luko kaare the same.Types, Paradigms

Types, ParadigmsDependent typesExamples from Python:AnyUnionTuple, List, Sequence, IterableOptionalCallable.You can de ne your own dependent types:Tuple[int, str, List[int]]Tuple[int, .]Robert Luko kaTypes, Paradigms

Types, ParadigmsType checksBene ts of type checks:Compile time type checking provides faster feedbackHelp document the code.Enables better IDE support (autocomplete, even fasterfeedback).Help to maintain cleaner design.Disadvantages:You have to write types.You have to create boundaries between typed and untypedcode (e.g. using external libraries).Robert Luko kaTypes, Paradigms

Types, ParadigmsMore info on typing in Python and on typing in generalIf you are interested check this.Robert Luko kaTypes, Paradigms

Types, ParadigmsProgramming paradigmA programming paradigm is a style, or way, of programming.Paradigm can also be termed as method to solve some problem ordo some task. Programming paradigm is an approach to solveproblem using some programming language or also we can say it isa method to solve a problem using tools and techniques that areavailable to us following some approach.Robert Luko kaTypes, Paradigms

Types, ParadigmsSelected ParadigmsFrom which elements we compose programs:ProceduralObject orientedFunctionalHow we write program:DeclarativeImperativeRobert Luko kaTypes, Paradigms

Types, ParadigmsProgramming ParadigmsNote that there are many other paradigms accounting for variousconcerns:Event-driven programmingAspect-oriented programmingGeneric programming.See e.g. Wikipedia for some random list.Robert Luko kaTypes, Paradigms

Types, ParadigmsProcedural programmingProcedure perform operations over data.Procedures call other procedures or functions to performpartial tasks.Robert Luko kaTypes, Paradigms

Types, ParadigmsObject oriented programmingPrinciples:Program is divided into classes. Classes contain both data bert Luko kaTypes, Paradigms

Types, ParadigmsFunctional programmingPrinciples:Based on composing pure functions.Same input gives the same output (no internal/global state).No side-e ects (throwing exceptions, i/o, . . . )Higher order functions (functions that take functions asparameters)Referential transparency - Immutable dataPure functional languages are often accompanied by verystrong and complex type systems.Robert Luko kaTypes, Paradigms

Types, ParadigmsExample - Relation on RProcedural (Python):def relation add(rel, el1, el2):if (el1, el2) in rel.elements:returnrel.elements.add((el1, el2))Robert Luko kaTypes, Paradigms

Types, ParadigmsExample - Relation on ROOP (Python)class Relation:.def add(self, el1, el2):if (el1, el2) in self.elementsreturnself.elements.add((el1, el2))Robert Luko kaTypes, Paradigms

Types, ParadigmsExample - Relation on RFunctional (Python):class Relation:.def add(self, el1, el2):if (el1, el2) in self.elementsreturn selfreturn Relation(self.elements (el1, el2))Robert Luko kaTypes, Paradigms

Types, ParadigmsExample - non-pure functionEventually, you need a state. It can be done, but you should becareful with it in FP:def give counter():j 0def function to return():nonlocal jj 1return jreturn function to returncounter give counter()a counter() %1b counter() %2Robert Luko kaTypes, Paradigms

Types, ParadigmsExample - server performs stu on databaseProcedural:You can perform a set of changes in several proceduresO-O:You read data, build object structure, then you do somethingand update what needs to be updated.Functional:Read data, evaluate pure function, write data.You can return a procedure that changes the state as required.Robert Luko kaTypes, Paradigms

Types, ParadigmsSome stu to be found in functional languagesfib - n { (n 0 n 1) ? n :fib[n - 1] fib[n - 2] }s(x) (1 to x) filter (x x % 2 0) map (x x * 2)my map and filter filter(x x % 2 0). map (x x * 2)Robert Luko kaTypes, Paradigms

Types, ParadigmsSome stu to be found in functional languagesCheck this (or if it is too abstract, just move on):Maybe MonadRobert Luko kaTypes, Paradigms

Types, ParadigmsImperative vs declarativeImperative - you describe how to do somethingDeclarative - you de ne what you want to get doneThe boundary is fuzzy.Robert Luko kaTypes, Paradigms

Types, ParadigmsExamples: declarative approachSQL - you do not say how to join tablesHTML - you do not say how to render stu Regular expressionsConstraint programming.Robert Luko kaTypes, Paradigms

Types, ParadigmsDeclarative programmingYou need something that translates what how.It is really important that this something is very reliable.If you manage to do it, you will have a code that is mucheasier to read and write.Hard to do in general, however, it might be reasonable to dothis if the scope is small.Robert Luko kaTypes, Paradigms

Types, ParadigmsDomain speci c languagesWatch this:M. Fowler: Introduction to Domain Speci c LanguagesRobert Luko kaTypes, Paradigms

Types, ParadigmsResources IWikipedia: Procedural programming (includes shortdescription of OO and functional programming)M. Fowler: Introduction to Domain Speci c LanguagesRobert Luko kaTypes, Paradigms

Types, ParadigmsReferences IRay Toal: Programming ParadigmsRobert Luko kaTypes, Paradigms

Programming paradigm A programming paradigm is a style, or w, ay of programming. Paradigm can also be termed as method to solve some problem or do some task. Programming paradigm is an approach to solve problem using some programming language or also we can say it is a meth

Related Documents:

Project Outcomes: -Understand the principles of design. -Label design principles in a specific work of art, craft, graphic design or interior design. Project Indicator: Complete the project exercises in activity including identifying principles of design in various pieces. The elements & principles of

tres tipos principales de software: software de sistemas, software de aplicación y software de programación. 1.2 Tipos de software El software se clasifica en tres tipos: Software de sistema. Software de aplicación. Software de programación.

Seven Basic Principles vs Other Software Principles Other software principles l-manage to plan 2-continuous validation 3-product control 4-MPP 5-accountability 6-people 7-improve process Other Do a complete preliminary design * Involve the customer and user * Current, complete documentation * .

of surfaces, there is a need to modify these principles. The principles of green tribology will be formulated in the following section. 2. Twelve principles of green tribology Below, we formulate the principles of green tribology, which belong to the three areas, suggested in the preceding section. Some principles are related to the design

2.1 Design principles in traditional logistics Several principles, which apply to supply chain (or parts of it) design, are referred to in bibliographies (e.g. Ralph Sims, 1991). A quite comprehensive list of such principles, which appears in (Gattorna, 1997) is described below. Where appropriate, we added the interpretation of these principles .

2. To understand how design principles are used to communicate with an audience. 3. To use design principles to communicate a message to an audience. 4. To be able to embed your understanding into your design intentions and show your understanding in sketchbook work. Outcomes: you will experiment with design principles and create a number of

The IC Dedicated Support Software is described in Section 1.4.3.2. 1.3.1.2 Security Software The IC Dedicated Software provides Security Software that can be used by the Security IC Embedded Software. The Security Software is composed of Services Software and Crypto Library. The Services Software consists of Flash Services Software, Services .

SDD Software Design Document SDP Software Development Plan SEL Software Engineering Laboratory SIDD Software Interface Design Document SLOC Source Lines of Code SRS Software Requirement Specification WBS Work Breakdown Structure YİE Software Process Group in ASELSAN Inc. YMM