Software Engineering
Software Engineering
ANSWER
Example:
area1 = calculate_area(10, 5)
area2 = calculate_area(8, 3)
# Complex way:
if not (user is None and len(user.name) == 0):
print("Valid User")
# Simple way:
print("Valid User")
3. SOLID Principles
These are a set of five principles for object-oriented design:
A class should have only one reason to change. Each class should
handle only one specific task or functionality.
Subtypes must be substitutable for their base types without affecting the
behavior of the program.
4. Encapsulation
Example:
class Person:
self.__age = age
def get_name(self):
return self.__name
5. Modularity
# Violation of LoD:
person.get_address().get_city().get_zipcode()
# Better:
person.get_zipcode()
10. Reusability
11. Scalability
Summary
The principles of software design—DRY, KISS, SOLID, and
others—promote clean, maintainable, and efficient software
development. By following these principles, developers can build
systems that are easier to understand, test, and scale.