You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
## Programming Paradigms
### Exercise 2
**Java**
- Programming paradigm: Imperative, object-oriented and functional - Portability: Platform-independent - Readability: Clear syntax - Security: Highly secure - Popularity: Widely used - Advantages: - Platform independence - Object-orientation - Security - Typing - Large ecosystem of libraries and frameworks - Disadvantages: - Compilation can be slow - Memory management can be complex - Application areas: - Applications that need to run on multiple platforms - Applications that require a high level of security - Applications that require object-orientation
**C**
- Programming paradigm: Imperative, procedural - Portability: Platform-independent - Efficiency: Highly efficient - Readability: Clear syntax - Security: Less secure than Java - Popularity: Widely used - Advantages: - High efficiency - Hardware proximity - Simple syntax - Disadvantages: - Less secure than Java - Complexity - Application areas: - Operating systems -Embedded systems - Game development
**Python**
- Programming paradigm: Imperative, object-oriented, functional - Portability: Platform-independent - Efficiency: Relatively efficient - Readability: Very good syntax - Security: Less secure than Java - Popularity: Widely used - Advantages: - Simple syntax - High readability - Large ecosystem of libraries and frameworks - Disadvantages: - Less secure than Java - Typeless programming can lead to errors - Application areas: - Web development - Data science - Machine learning
**Go**
- Programming paradigm: Imperative, object-oriented - Portability: Platform-independent - Efficiency: Very efficient - Readability: Clear syntax - Security: Less secure than Java - Popularity: Growing - Advantages: - High efficiency - Simple syntax - Good support for parallelism - Disadvantages: - Less secure than Java - Not as widely used as Java, Python, or JavaScript - Application areas: - Backend development - Cloud computing - System administration
**JavaScript**
- Programming paradigm: Imperative, object-oriented, functional - Portability: Platform-independent - Efficiency: Moderately efficient - Readability: Clear syntax - Security: Less secure than Java - Popularity: Widely used - Advantages: - Simple syntax - Good support for web development - Disadvantages: - Less secure than Java - Typeless programming can lead to errors - Application areas: - Web development - Mobile applications - Game development
**TypeScript**
- Programming paradigm: Imperative, object-oriented - Portability: Platform-independent - Efficiency: Relatively efficient - Readability: Clear syntax - Security: Less secure than Java - Popularity: Growing - Advantages: - Typing - Good support for web development - Disadvantages: - Less secure than Java - Compilation can be slow - Application areas: - Web development - Mobile applications - Game development
--- ## Exercise 3
**Least astonishment principle (LAP)**
The least astonishment principle (LAP) states that the code should be written in such a way that it is easy to understand and use. This means that the code should be consistent, predictable, and well-documented.
Useful tips for following the LAP:
- Use consistent naming conventions for variables, functions, and classes. - Avoid using clever or obscure code constructs. - Write clear and concise comments. - Document your code thoroughly.
**Law of Demeter (LoD)**
The Law of Demeter (LoD) states that each object should only communicate with its immediate neighbors. This means that an object should only call methods on its own fields, parameters, and return values.
Useful tips for following the LoD:
- Avoid using global variables. - Pass objects to functions as parameters, instead of returning them from functions. - Use interfaces to decouple objects from each other.
**Command-query separation (CQS)**
CQS is a design pattern that separates the code that reads data from the code that writes data. This can make the code more robust and easier to test.
Useful tips for following the CQS:
- Use separate commands and queries to read and write data. - Use a mediator to handle the routing of commands and queries. - Use a data mapper to map between the domain model and the database.
**Testability**
Testability is the principle that code should be written in such a way that it is easy to test. This means that the code should be modular, decoupled, and well-documented.
Useful tips:
- Write small, modular units of code. - Use interfaces to decouple your code. - Write unit tests for your code.
**Immutability**
Immutability is the principle that objects should not be changed once they are created. This can make the code more thread-safe and easier to test.
Useful tips:
- Create immutable objects whenever possible. - Use immutable data structures, such as lists, maps, and sets. - Use pure functions to transform immutable objects.
|