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.

180 lines
4.9 KiB

  1. ## Programming Paradigms
  2. ### Exercise 2
  3. **Java**
  4. - Programming paradigm: Imperative, object-oriented and functional
  5. - Portability: Platform-independent
  6. - Readability: Clear syntax
  7. - Security: Highly secure
  8. - Popularity: Widely used
  9. - Advantages:
  10. - Platform independence
  11. - Object-orientation
  12. - Security
  13. - Typing
  14. - Large ecosystem of libraries and frameworks
  15. - Disadvantages:
  16. - Compilation can be slow
  17. - Memory management can be complex
  18. - Application areas:
  19. - Applications that need to run on multiple platforms
  20. - Applications that require a high level of security
  21. - Applications that require object-orientation
  22. **C**
  23. - Programming paradigm: Imperative, procedural
  24. - Portability: Platform-independent
  25. - Efficiency: Highly efficient
  26. - Readability: Clear syntax
  27. - Security: Less secure than Java
  28. - Popularity: Widely used
  29. - Advantages:
  30. - High efficiency
  31. - Hardware proximity
  32. - Simple syntax
  33. - Disadvantages:
  34. - Less secure than Java
  35. - Complexity
  36. - Application areas:
  37. - Operating systems
  38. -Embedded systems
  39. - Game development
  40. **Python**
  41. - Programming paradigm: Imperative, object-oriented, functional
  42. - Portability: Platform-independent
  43. - Efficiency: Relatively efficient
  44. - Readability: Very good syntax
  45. - Security: Less secure than Java
  46. - Popularity: Widely used
  47. - Advantages:
  48. - Simple syntax
  49. - High readability
  50. - Large ecosystem of libraries and frameworks
  51. - Disadvantages:
  52. - Less secure than Java
  53. - Typeless programming can lead to errors
  54. - Application areas:
  55. - Web development
  56. - Data science
  57. - Machine learning
  58. **Go**
  59. - Programming paradigm: Imperative, object-oriented
  60. - Portability: Platform-independent
  61. - Efficiency: Very efficient
  62. - Readability: Clear syntax
  63. - Security: Less secure than Java
  64. - Popularity: Growing
  65. - Advantages:
  66. - High efficiency
  67. - Simple syntax
  68. - Good support for parallelism
  69. - Disadvantages:
  70. - Less secure than Java
  71. - Not as widely used as Java, Python, or JavaScript
  72. - Application areas:
  73. - Backend development
  74. - Cloud computing
  75. - System administration
  76. **JavaScript**
  77. - Programming paradigm: Imperative, object-oriented, functional
  78. - Portability: Platform-independent
  79. - Efficiency: Moderately efficient
  80. - Readability: Clear syntax
  81. - Security: Less secure than Java
  82. - Popularity: Widely used
  83. - Advantages:
  84. - Simple syntax
  85. - Good support for web development
  86. - Disadvantages:
  87. - Less secure than Java
  88. - Typeless programming can lead to errors
  89. - Application areas:
  90. - Web development
  91. - Mobile applications
  92. - Game development
  93. **TypeScript**
  94. - Programming paradigm: Imperative, object-oriented
  95. - Portability: Platform-independent
  96. - Efficiency: Relatively efficient
  97. - Readability: Clear syntax
  98. - Security: Less secure than Java
  99. - Popularity: Growing
  100. - Advantages:
  101. - Typing
  102. - Good support for web development
  103. - Disadvantages:
  104. - Less secure than Java
  105. - Compilation can be slow
  106. - Application areas:
  107. - Web development
  108. - Mobile applications
  109. - Game development
  110. ---
  111. ## Exercise 3
  112. **Least astonishment principle (LAP)**
  113. 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.
  114. Useful tips for following the LAP:
  115. - Use consistent naming conventions for variables, functions, and classes.
  116. - Avoid using clever or obscure code constructs.
  117. - Write clear and concise comments.
  118. - Document your code thoroughly.
  119. **Law of Demeter (LoD)**
  120. 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.
  121. Useful tips for following the LoD:
  122. - Avoid using global variables.
  123. - Pass objects to functions as parameters, instead of returning them from functions.
  124. - Use interfaces to decouple objects from each other.
  125. **Command-query separation (CQS)**
  126. 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.
  127. Useful tips for following the CQS:
  128. - Use separate commands and queries to read and write data.
  129. - Use a mediator to handle the routing of commands and queries.
  130. - Use a data mapper to map between the domain model and the database.
  131. **Testability**
  132. 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.
  133. Useful tips:
  134. - Write small, modular units of code.
  135. - Use interfaces to decouple your code.
  136. - Write unit tests for your code.
  137. **Immutability**
  138. 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.
  139. Useful tips:
  140. - Create immutable objects whenever possible.
  141. - Use immutable data structures, such as lists, maps, and sets.
  142. - Use pure functions to transform immutable objects.