Pages for Test One from LPI-Learning-Material-030-100-en.pdf
Document Details
Uploaded by Deleted User
Tags
Full Transcript
Web Development Essentials (030) (Version 1.0) | Topic 031: Software Development and Web Technologies 031.1 Software Development Basic Reference to LPI objectives Web Development Essentials version 1.0, Exam 030, Objective 031.1 Weight 1 Key knowledge areas Understand what sourc...
Web Development Essentials (030) (Version 1.0) | Topic 031: Software Development and Web Technologies 031.1 Software Development Basic Reference to LPI objectives Web Development Essentials version 1.0, Exam 030, Objective 031.1 Weight 1 Key knowledge areas Understand what source code is Understand the principles of compilers and interpreters Understand the concept of libraries Understand the concepts of functional, procedural and object-oriented programming Awareness of common features of source code editors and integrated development environments (IDE) Awareness of version control systems Awareness of software testing Awareness of important programming languages (C, C++, C#, Java, JavaScript, Python, PHP) 2 | learning.lpi.org | Licensed under CC BY-NC-ND 4.0. | Version: 2022-10-14 Web Development Essentials (030) (Version 1.0) | 031.1 Software Development Basic 031.1 Lesson 1 Certificate: Web Development Essentials Version: 1.0 Topic: 031 Software Development and Web Technologies Objective: 031.1 Software Development Basics Lesson: 1 of 1 Introduction The very first computers were programmed through the grueling process of plugging cables into sockets. Computer scientists soon started a never-ending search for easy ways to tell the computer what to do. This chapter introduces the tools of programming. It discusses the key ways that text instructions—programming languages—represent the tasks a programmer wants to accomplish, and the tools that change the program into a form called machine language that a computer can run. NOTE In this text, the terms program and application are used interchangeably. Source Code A programmer normally develops an application by writing a textual description, called source code, of the desired task. The source code is in a carefully defined programming language that represents what the computer can do in a high-level abstraction humans can understand. Tools have also been developed to let programmers as well as non-programmers express their thoughts visually, but writing source code is still the predominant way to program. Version: 2022-10-14 | Licensed under CC BY-NC-ND 4.0. | learning.lpi.org | 3 Web Development Essentials (030) (Version 1.0) | Topic 031: Software Development and Web Technologies In the same way that a natural language has nouns, verbs, and constructions to express ideas in a structured way, the words and punctuation in a programming language are symbolic representations of operations that will be performed on the machine. In this sense, source code is not very different from any other text in which the author employs the well-established rules of a natural language to communicate with the reader. In the case of source code, the “reader” is the machine, so the text cannot contain ambiguities or inconsistencies—even subtle ones. And like any text that discusses some topic in depth, the source code also needs to be well structured and logically organized when developing complex applications. Very simple programs and didactic examples can be stored in the few lines of a single text file, which contains all the program’s source code. More complex programs can be subdivided into thousands of files, each with thousands of lines. The source code of professional applications should be organized into different folders, usually associated with a particular purpose. A chat program, for example, can be organized into two folders: one that contains the code files that handle the transmission and reception of messages over the network, and another folder that contains the files that build the interface and react to user actions. Indeed, it is common to have many folders and subfolders with source code files dedicated to very specific tasks within the application. Moreover, the source code is not always isolated in its own files, with everything written in a single language. In web applications, for example, an HTML document can embed JavaScript code to supplement the document with extra functionality. Code Editors and IDE The variety of ways in which source code can be written can be intimidating. Therefore, many developers take advantage of tools that help with writing and testing the program. The source code file is just a plain text file. As such, it can be edited by any text editor, no matter how simple. To make it easier to distinguish between source code and plain text, each language adopts a self-explanatory filename extension:.c for the C language,.py for Python,.js for JavaScript, etc. General-purpose editors often understand the source code of popular languages well enough to add italics, colors, and indentation to make the code understandable. Not every developer chooses to edit source code in a general-purpose editor. An integrated development environment (IDE) provides a text editor along with tools to help the programmer avoid syntactic errors and obvious inconsistencies. These editors are particularly recommended for less experienced programmers, but experienced programmers use them as well. 4 | learning.lpi.org | Licensed under CC BY-NC-ND 4.0. | Version: 2022-10-14 Web Development Essentials (030) (Version 1.0) | 031.1 Software Development Basic Popular IDEs such Visual Studio, Eclipse, and Xcode intelligently watch what the programmer types, frequently suggesting words to use (autocompletion) and verifying code in real-time. The IDEs can even offer automated debugging and testing to identify issues whenever the source code changes. Some more experienced programmers opt for less intuitive editors such as Vim, which offer greater flexibility and do not require installation of additional packages. These programmers use external, standalone tools to add the features that are built-in when you use an IDE. Code Maintenance Whether in an IDE or using standalone tools, it’s important to employ some kind of version control system (VCS). Source code is constantly evolving because unforeseen flaws need to be fixed and enhancements need to be incorporated. An inevitable consequence of this evolution is that fixes and enhancements can interfere with other parts of applications in a large code base. Version control tools such as Git, Subversion, and Mercurial record all changes made to the code and who made the change, allowing you to trace and eventually recover from an unsuccessful modification. Furthermore, version control tools allow each developer on the team to work on a copy of the source code files without interfering with the work of other programmers. Once the new versions of source code are ready and tested, corrections or improvements made to one copy can be incorporated by other team members. Git, the most popular version control system nowadays, allows many independent copies of a repository to be maintained by different people, who share their changes as they desire. However, whether using a decentralized or centralized version control system, most teams maintain one trusted repository whose source code and resources can be relied on. Several online services offer storage for repositories of source code. The most popular of these services are GitHub and GitLab, but the GNU project’s Savannah is also worth mentioning. Programming Languages A wide variety of programming languages exist; each decade sees the invention of new ones. Each programming language has its own rules and is recommended for particular purposes. Although the languages show superficial differences in syntax and keywords, what really distinguishes the languages are the deep conceptual approaches they represent, known as paradigms. Paradigms Paradigms define the premises on which a programming language is based, especially concerning Version: 2022-10-14 | Licensed under CC BY-NC-ND 4.0. | learning.lpi.org | 5 Web Development Essentials (030) (Version 1.0) | Topic 031: Software Development and Web Technologies how the source code should be structured. The developer starts from the language paradigm to formulate the tasks to be performed by the machine. These tasks, in turn, are symbolically expressed with the words and syntactic constructions offered by the language. The programming language is procedural when the instructions presented in the source code are executed in sequential order, like a movie script. If the source code is segmented into functions or subroutines, a main routine takes care of calling the functions in sequence. The following code is an example of a procedural language. Written in C, it defines variables to represent the side, area and volume of geographical shapes. The value of the side variable is assigned in main(), which is the function invoked when the program is executed. The area and volume variables are calculated in the square() and cube() subroutines that precede the main function: #include float side; float area; float volume; void square(){ area = side * side; } void cube(){ volume = area * side; } int main(){ side = 2; square(); cube(); printf("Volume: %f\n", volume); return 0; } The order of actions defined in main() determines the sequence of program states, characterized by the value of the side, area, and volume variables. The example ends after displaying the value of volume with the printf statement. On the other hand, the paradigm of object-oriented programming (OOP) has as its main characteristic the separation of the program state into independent sub-states. These sub-states and associated operations are the objects, so called because they have a more or less independent existence within the program and because they have specific purposes. 6 | learning.lpi.org | Licensed under CC BY-NC-ND 4.0. | Version: 2022-10-14 Web Development Essentials (030) (Version 1.0) | 031.1 Software Development Basic Distinct paradigms do not necessarily restrict the type of task that can be performed by a program. The code from the previous example can be rewritten according to the OOP paradigm using the C++ language: #include class Cube { float side; public: Cube(float s){ side = s; } float volume() { return side * side * side; } }; int main(){ float side = 2; Cube cube(side); std::cout