CSC 408F/CSC2105F Lecture NotesThese lecture notes are provided for the personal use ofstudents taking CSC 408H/CSC 2105H in the Fall term2004/2005 at the University of Toronto.Copying for purposes other than this use and all forms ofdistribution are expressly prohibited.cDavid B. Wortman, 1999,2000,2001,2002,2003,2004cKersti Wain-Bantin, 2001cYijun Yu, 20040Designing Portable SoftwarePortability - the ability to easily transfer a piece of software from one hardwareor software environment to anothercompare: Interoperatability - the ability to easily transfer a piece of informationfrom one software or hardware to anotherThere are many examples of good portable/interoperatable software, e.g.GNU C compiler, vi editor, many X applications, SQL queries, Javaapplet/applications, XML/SOAP, Web Services/WSDL, etc.Portability increases the market for a piece of software at a much lower costthan creating multiple independent versionsDesign for portability is generally compatible with the good design practicesdiscussed previouslyPortability generally enhances reusability Portability has to be designedinto the software (c.f. build for reuse), retrofitting portability is expensive1Portability TechniquesIsolation: Isolate all hardware/environment dependenciesParameterization via unique defining declarationsUse named constants and typesUnique declaration allows single point modificationConditional compilation and macro substitutionSubstitution at the module levelStandarization[Java: Write once, run everywhere] [XML: Write once, exchange everywhere][Web Services: Write once, call everywhere]Avoid embedded and distributed dependencies Magic numbers in thecode, Machine or system dependent programming2Portability Issues - SoftwareVariability in programming languages and compilers [Java/.NET story ... abattle behind the giants]– Manufacturer specific language extensions– Differences in run-time support libraries– Failure of compiler to adhere to language standard– Different implementation limits and system supplied defaultsPortability techniques– Program strictly according to language standard– Avoid manufacturer-dependent programming constructs– Avoid system supplied defaults– Use software tools (e.g. lint) to verify compliance with the standard– Use conditional compilation and macro expansion to isolate unavoidabledifferences3Portability Issues - SoftwareDifferences in Interface to Environment– Operating System, e.g. Unix(almost Unix, Linux, FreeBSD),DOS/Windows(3.1/95/98/NT/2000/XP/2003/Longhorn), MAC OS . . .– Input & Output, e.g. Unix, DOS/Windows, MAC, [Path separator], . . .– Database packages, e.g. dbm, Empress, SQL, . . .– Graphics, e.g. X11R?, SunView, DOS, Windows, curses, . . .– Browsers, e.g. Netscape, IE, Opera, Mozilla, Safari, Firefox . . .Portability techniques– Isolate all interfaces to external environment– Use standard internal data representations, convert on input/output– Parameterize all attributes (constants, types) affecting interface to environment– Use tables to encapsulate environment dependent information– Use conditional compilation and macro expansion to deal with unavoidabledifferences4Portability Issues - HardwareData representation– Numeric - integers, reals, IEEE vs. DEC vs IBM– Character - ASCII vs. EBCDIC, signed/unsigned, collating sequence– String - explicit length vs. null term, max length– Pointers - range & representations– Type size equivalence assumptionssizeOf(int) = sizeOf(address), sizeOf(int) = sizeOf(real)Portability techniques– Isolate all machine dependent code in separable modules– Parameterize data representation and machine specific information– Program to avoid hardware dependent constructs– Use conditional compilation and macro expansion– Use templates and application generators: e.g., generative programming,automated configuration5Portability Issues - Operating SystemsWide variety of Operating SystemsUnix-like: SunOs, System V, Ultrix, HPUNIX, AIX, IRIX, SEQUNIX, BSDOther: DOS, Windows, Next, MAC OS, OS/2, VMS, MVS,. . .File System Issues– File naming conventions– Directory structure, naming, traversing– Protection mechanisms, file attributes– Limits on concurrently open files– Physical structure of files, fixed vs. variable records– File access methods: sequential, random, byte, blockPortability techniques– Isolate all OS-specific code in separable modulesUse module level substitution– Use conditional compilation and macro expansion6Building Portable SoftwareDocument rules for customizing softwaree.g. table of optionsIsolate customization to a small number of separate files that may controlcustomization of other filese.g. Makefile, config.hTry to provide a customization tool (shell script)Make configconfigure VMS DECMIPSTry to make documentation track customization using conditional textTest customization thoroughly7Legal Issues for Software EngineersabContracts - software acquisition or custom developmentLiability and Negligence, WarrantiesIntellectual Property - Copyright, Trade Secrets & PatentsWorld Wide Web Legal IssuesaAn informed civilian’s comments on legal matters affecting software engineers.If you need real legal advice, consult a real lawyerbB. Sookman, Computer Law, CCH Publishers, 1989+annual updates8Software ContractsAgreement by customer to purchase specified piece of software from vendorNeed to precisely set out– Nature of the software being produced, requirements or detailed specifications– Other goals affecting the software, e.g. performance, reliability, compatibility, etc.– Acceptance conditions, when is software complete?– Exception handling - breaches of the agreement by customer or vendor, changesin requirements or specification, cost or schedule overruns– Warranties and guarantees provided by the vendorMethods of payment– Fixed Price– Cost plus, vendors expenses + profit– Per diem perhaps with an upper bound– Progress payments at major milestones9Contracting IssuesBuyer and vendor cooperate on developing requirementsDevelop system specifications. A complete, correct and unambiguousspecification is in the best interest of both partiesContract sets out rights and obligations of buyer and vendorContract lists deliverables and settles ownership of the software, especiallythe source code and internal
View Full Document